Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Jul 10, 2024
1 parent 8600db6 commit e2c2645
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
18 changes: 4 additions & 14 deletions internal/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ func Read(absPath string) (manifest *Manifest, err error) {
return nil, err
}
defer r.Close()
jsonwallDB, err := jsonwall.ReadDB(r)
db, err := jsonwall.ReadDB(r)
if err != nil {
return nil, err
}

manifest = &Manifest{db: jsonwallDB}
manifest = &Manifest{db: db}
return manifest, nil
}

Expand Down Expand Up @@ -105,7 +104,7 @@ func (manifest *Manifest) IteratePath(pathPrefix string, f func(Path) error) (er
return nil
}

func (manifest *Manifest) IteratePkgs(f func(Package) error) (err error) {
func (manifest *Manifest) IteratePackages(f func(Package) error) (err error) {
defer func() {
if err != nil {
err = fmt.Errorf("cannot read manifest: %s", err)
Expand Down Expand Up @@ -168,7 +167,7 @@ func (manifest *Manifest) IterateSlices(pkgName string, f func(Slice) error) (er
func Validate(manifest *Manifest) (err error) {
defer func() {
if err != nil {
err = fmt.Errorf(`invalid manifest: %s`, err)
err = fmt.Errorf("invalid manifest: %s", err)
}
}()

Expand All @@ -183,9 +182,6 @@ func Validate(manifest *Manifest) (err error) {
if err != nil {
return err
}
if pkg.Kind != "package" {
return fmt.Errorf(`in packages expected kind "package", got %q`, pkg.Kind)
}
pkgExist[pkg.Name] = true
}

Expand Down Expand Up @@ -221,9 +217,6 @@ func Validate(manifest *Manifest) (err error) {
if err != nil {
return err
}
if content.Kind != "content" {
return fmt.Errorf(`in contents expected kind "content", got "%s"`, content.Kind)
}
if !sliceExist[content.Slice] {
return fmt.Errorf(`slice %s not found in slices`, content.Slice)
}
Expand All @@ -240,9 +233,6 @@ func Validate(manifest *Manifest) (err error) {
if err != nil {
return err
}
if path.Kind != "path" {
return fmt.Errorf(`in paths expected kind "path", got "%s"`, path.Kind)
}
if pathSlices, ok := pathToSlices[path.Path]; !ok {
return fmt.Errorf(`path %s has no matching entry in contents`, path.Path)
} else if !slices.Equal(pathSlices, path.Slices) {
Expand Down
2 changes: 1 addition & 1 deletion internal/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func dumpManifestContents(c *C, mfest *manifest.Manifest) manifestContents {
c.Assert(err, IsNil)

var pkgs []manifest.Package
err = mfest.IteratePkgs(func(pkg manifest.Package) error {
err = mfest.IteratePackages(func(pkg manifest.Package) error {
pkgs = append(pkgs, pkg)
return nil
})
Expand Down

0 comments on commit e2c2645

Please sign in to comment.