Skip to content

Commit 1d6db88

Browse files
authored
Make FromSlice and ToSlice methods private to the deploy package (#3089)
## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> Keeping methods private to the package makes the code easier to comprehend - private methods are used only inside the package where they are defined ## Tests <!-- How have you tested the changes? --> Existing tests <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent a79bc3d commit 1d6db88

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

bundle/deploy/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (e *entry) Info() (fs.FileInfo, error) {
101101
return e.info, nil
102102
}
103103

104-
func FromSlice(files []fileset.File) (Filelist, error) {
104+
func fromSlice(files []fileset.File) (Filelist, error) {
105105
var f Filelist
106106
for k := range files {
107107
file := &files[k]
@@ -117,7 +117,7 @@ func FromSlice(files []fileset.File) (Filelist, error) {
117117
return f, nil
118118
}
119119

120-
func (f Filelist) ToSlice(root vfs.Path) []fileset.File {
120+
func (f Filelist) toSlice(root vfs.Path) []fileset.File {
121121
var files []fileset.File
122122
for _, file := range f {
123123
entry := newEntry(root, filepath.ToSlash(file.LocalPath))

bundle/deploy/state_pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (s *statePull) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostic
9191
}
9292

9393
log.Infof(ctx, "Creating new snapshot")
94-
snapshot, err := sync.NewSnapshot(state.Files.ToSlice(b.SyncRoot), opts)
94+
snapshot, err := sync.NewSnapshot(state.Files.toSlice(b.SyncRoot), opts)
9595
if err != nil {
9696
return diag.FromErr(err)
9797
}

bundle/deploy/state_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestFromSlice(t *testing.T) {
2121
files, err := fileset.Files()
2222
require.NoError(t, err)
2323

24-
f, err := FromSlice(files)
24+
f, err := fromSlice(files)
2525
require.NoError(t, err)
2626
require.Len(t, f, 3)
2727

@@ -41,11 +41,11 @@ func TestToSlice(t *testing.T) {
4141
files, err := fileset.Files()
4242
require.NoError(t, err)
4343

44-
f, err := FromSlice(files)
44+
f, err := fromSlice(files)
4545
require.NoError(t, err)
4646
require.Len(t, f, 3)
4747

48-
s := f.ToSlice(root)
48+
s := f.toSlice(root)
4949
require.Len(t, s, 3)
5050

5151
for _, file := range s {

bundle/deploy/state_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (s *stateUpdate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnost
4040
state.Version = DeploymentStateVersion
4141

4242
// Update the state with the current list of synced files.
43-
fl, err := FromSlice(b.Files)
43+
fl, err := fromSlice(b.Files)
4444
if err != nil {
4545
return diag.FromErr(err)
4646
}

0 commit comments

Comments
 (0)