internal/archive: make archiveItem.add private

This commit is contained in:
Clayton Craft
2023-02-17 21:54:49 -08:00
parent fb52066d8f
commit 6fdc8937b5
3 changed files with 14 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ type archiveItems struct {
// Adds the given item to the archiveItems, only if it doesn't already exist in
// the list. The items are kept sorted in ascending order.
func (a *archiveItems) Add(item archiveItem) {
func (a *archiveItems) add(item archiveItem) {
a.Lock()
defer a.Unlock()
@@ -170,7 +170,7 @@ func (archive *Archive) addFile(source string, dest string) error {
destFilename := strings.TrimPrefix(dest, "/")
archive.items.Add(archiveItem{
archive.items.add(archiveItem{
sourcePath: source,
header: &cpio.Header{
Name: destFilename,
@@ -200,7 +200,7 @@ func (archive *Archive) addFile(source string, dest string) error {
destFilename := strings.TrimPrefix(dest, "/")
archive.items.Add(archiveItem{
archive.items.add(archiveItem{
sourcePath: source,
header: &cpio.Header{
Name: destFilename,
@@ -295,7 +295,7 @@ func (archive *Archive) addDir(dir string) error {
subdirs := strings.Split(strings.TrimPrefix(dir, "/"), "/")
for i, subdir := range subdirs {
path := filepath.Join(strings.Join(subdirs[:i], "/"), subdir)
archive.items.Add(archiveItem{
archive.items.add(archiveItem{
sourcePath: path,
header: &cpio.Header{
Name: path,

View File

@@ -180,7 +180,7 @@ func TestArchiveItemsAdd(t *testing.T) {
for _, st := range subtests {
t.Run(st.name, func(t *testing.T) {
a := archiveItems{items: st.inItems}
a.Add(st.inItem)
a.add(st.inItem)
if !reflect.DeepEqual(st.expected, a.items) {
t.Fatal("expected:", st.expected, " got: ", a.items)
}