From 4be3e6db9f4c2fc850a148466452abe845ca3f41 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Sun, 19 Jan 2025 05:26:43 -0700 Subject: [PATCH] Linting fixes called-out by vscode A few linting issues that were called out by vscode. Signed-off-by: Jonathon Anderson --- internal/pkg/node/fields_test.go | 4 ++-- internal/pkg/node/ignition.go | 4 ++-- internal/pkg/overlay/config.go | 18 ++++++++-------- internal/pkg/overlay/overlay.go | 32 ++++++++++++++-------------- internal/pkg/overlay/overlay_test.go | 4 ++-- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/internal/pkg/node/fields_test.go b/internal/pkg/node/fields_test.go index 8010d7a9..f93d162e 100644 --- a/internal/pkg/node/fields_test.go +++ b/internal/pkg/node/fields_test.go @@ -97,7 +97,7 @@ func Test_listFields(t *testing.T) { "tag": "value", }, NetDevs: map[string]*NetDev{ - "default": &NetDev{ + "default": { Tags: map[string]string{ "nettag": "netvalue", }, @@ -154,7 +154,7 @@ func Test_listFields(t *testing.T) { "tag": "value", }, NetDevs: map[string]*NetDev{ - "default": &NetDev{ + "default": { Tags: map[string]string{ "nettag": "netvalue", }, diff --git a/internal/pkg/node/ignition.go b/internal/pkg/node/ignition.go index c3ac4e96..b4d84742 100644 --- a/internal/pkg/node/ignition.go +++ b/internal/pkg/node/ignition.go @@ -13,7 +13,7 @@ import ( /* Create a ignition struct class for ignition */ -func (node *Node) GetStorage() (stor types_3_4.Storage, err error, rep string) { +func (node *Node) GetStorage() (stor types_3_4.Storage, rep string, err error) { var fileSystems []types_3_4.Filesystem for fsdevice, fs := range node.FileSystems { var mountOptions []types_3_4.MountOption @@ -142,7 +142,7 @@ type SimpleIgnitionConfig struct { Get a simple config which can be marshalled to json */ func (node *Node) GetConfig() (conf SimpleIgnitionConfig, rep string, err error) { - conf.Storage, err, rep = node.GetStorage() + conf.Storage, rep, err = node.GetStorage() conf.Ignition.Version = "3.1.0" return } diff --git a/internal/pkg/overlay/config.go b/internal/pkg/overlay/config.go index 5d15b43e..520a91e5 100644 --- a/internal/pkg/overlay/config.go +++ b/internal/pkg/overlay/config.go @@ -49,25 +49,25 @@ func getOverlay(overlaydir, name string) (overlay Overlay) { // Create creates a new overlay directory for the given overlay // // Returns an error if the overlay already exists or if directory creation fails. -func (this Overlay) Create() error { - if util.IsDir(this.Path()) { - return fmt.Errorf("overlay already exists: %s", this) +func (overlay Overlay) Create() error { + if util.IsDir(overlay.Path()) { + return fmt.Errorf("overlay already exists: %s", overlay) } - return os.MkdirAll(this.Rootfs(), 0755) + return os.MkdirAll(overlay.Rootfs(), 0755) } // Creates a site overlay from an existing distribution overlay. // // If the distribution overlay doesn't exist, return an error. -func (this Overlay) CloneSiteOverlay() (siteOverlay Overlay, err error) { - siteOverlay = GetSiteOverlay(this.Name()) - if !util.IsDir(this.Path()) { - return siteOverlay, fmt.Errorf("source overlay does not exist: %s", this.Name()) +func (overlay Overlay) CloneSiteOverlay() (siteOverlay Overlay, err error) { + siteOverlay = GetSiteOverlay(overlay.Name()) + if !util.IsDir(overlay.Path()) { + return siteOverlay, fmt.Errorf("source overlay does not exist: %s", overlay.Name()) } if siteOverlay.Exists() { return siteOverlay, fmt.Errorf("site overlay already exists: %s", siteOverlay.Name()) } - err = copy.DirCopy(this.Path(), siteOverlay.Path(), copy.Content, true) + err = copy.DirCopy(overlay.Path(), siteOverlay.Path(), copy.Content, true) return siteOverlay, err } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index e0eba792..628b4254 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -31,16 +31,16 @@ type Overlay string // Name returns the base name of the overlay directory. // // This is derived from the full path of the overlay. -func (this Overlay) Name() string { - return path.Base(this.Path()) +func (overlay Overlay) Name() string { + return path.Base(overlay.Path()) } // Path returns the string representation of the overlay path. // // This method allows the Overlay type to be easily converted back to its // underlying string representation. -func (this Overlay) Path() string { - return string(this) +func (overlay Overlay) Path() string { + return string(overlay) } // Rootfs returns the path to the root filesystem (rootfs) within the overlay. @@ -49,12 +49,12 @@ func (this Overlay) Path() string { // path to the "rootfs" directory. Otherwise, it checks if the overlay path // itself is a directory and returns that. If neither exists, it defaults to // returning the "rootfs" path. -func (this Overlay) Rootfs() string { - rootfs := path.Join(this.Path(), "rootfs") +func (overlay Overlay) Rootfs() string { + rootfs := path.Join(overlay.Path(), "rootfs") if util.IsDir(rootfs) { return rootfs - } else if util.IsDir(this.Path()) { - return this.Path() + } else if util.IsDir(overlay.Path()) { + return overlay.Path() } else { return rootfs } @@ -67,16 +67,16 @@ func (this Overlay) Rootfs() string { // // Returns: // - The full path to the specified file in the overlay's rootfs. -func (this Overlay) File(filePath string) string { - return path.Join(this.Rootfs(), filePath) +func (overlay Overlay) File(filePath string) string { + return path.Join(overlay.Rootfs(), filePath) } // Exists checks whether the overlay path exists and is a directory. // // Returns: // - true if the overlay path exists and is a directory; false otherwise. -func (this Overlay) Exists() bool { - return util.IsDir(this.Path()) +func (overlay Overlay) Exists() bool { + return util.IsDir(overlay.Path()) } // IsSiteOverlay determines whether the overlay is a site overlay. @@ -86,8 +86,8 @@ func (this Overlay) Exists() bool { // // Returns: // - true if the overlay is a site overlay; false otherwise. -func (this Overlay) IsSiteOverlay() bool { - return path.Dir(this.Path()) == config.Get().Paths.SiteOverlaydir() +func (overlay Overlay) IsSiteOverlay() bool { + return path.Dir(overlay.Path()) == config.Get().Paths.SiteOverlaydir() } // IsDistributionOverlay determines whether the overlay is a distribution overlay. @@ -97,8 +97,8 @@ func (this Overlay) IsSiteOverlay() bool { // // Returns: // - true if the overlay is a distribution overlay; false otherwise. -func (this Overlay) IsDistributionOverlay() bool { - return path.Dir(this.Path()) == config.Get().Paths.DistributionOverlaydir() +func (overlay Overlay) IsDistributionOverlay() bool { + return path.Dir(overlay.Path()) == config.Get().Paths.DistributionOverlaydir() } func BuildAllOverlays(nodes []node.Node, allNodes []node.Node, workerCount int) error { diff --git a/internal/pkg/overlay/overlay_test.go b/internal/pkg/overlay/overlay_test.go index 845ba11f..2742fb74 100644 --- a/internal/pkg/overlay/overlay_test.go +++ b/internal/pkg/overlay/overlay_test.go @@ -231,10 +231,10 @@ T3 assert.NoError(t, BuildOverlayIndir(tt.node, []node.Node{tt.node}, tt.overlays, env.GetPath(tt.outputDir))) dirFiles := tt.outputDirs - for outputFile, _ := range tt.outputFiles { + for outputFile := range tt.outputFiles { dirFiles = append(dirFiles, outputFile) } - for outputFile, _ := range tt.outputSymlinks { + for outputFile := range tt.outputSymlinks { dirFiles = append(dirFiles, outputFile) } sort.Strings(dirFiles)