Merge pull request #1644 from anderbubble/vscode-recommendations

Linting fixes called-out by vscode
This commit is contained in:
Xu YANG
2025-01-24 08:55:47 +09:00
committed by GitHub
5 changed files with 31 additions and 31 deletions

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -253,10 +253,10 @@ Tags:map[]
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)