Skip to content

Commit

Permalink
Fixup: ManifestName rename and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
martintomazic committed Jan 14, 2025
1 parent 5a1b1a1 commit d245a26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
14 changes: 7 additions & 7 deletions go/runtime/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (bnd *Bundle) Validate() error {
// Ignore the manifest not having a digest entry, though
// it having one and being valid (while quite a feat) is
// also ok.
if fn == ManifestName {
if fn == ManifestPath {
continue
}
return fmt.Errorf("runtime/bundle: missing digest: '%s'", fn)
Expand Down Expand Up @@ -321,7 +321,7 @@ func (bnd *Bundle) verifySgxSignature(comp *Component) error {
//
// This needs to be used after doing modifications to bundles.
func (bnd *Bundle) ResetManifest() {
delete(bnd.Data, ManifestName)
delete(bnd.Data, ManifestPath)
}

// Write serializes a runtime bundle to the on-disk representation.
Expand All @@ -336,7 +336,7 @@ func (bnd *Bundle) Write(fn string) error {
if err != nil {
return fmt.Errorf("runtime/bundle: failed to serialize manifest: %w", err)
}
if bnd.Data[ManifestName] != nil {
if bnd.Data[ManifestPath] != nil {
// While this is "ok", instead of trying to figure out if the
// deserialized manifest matches the serialied one, just bail.
return fmt.Errorf("runtime/bundle: data contains manifest entry")
Expand All @@ -352,7 +352,7 @@ func (bnd *Bundle) Write(fn string) error {
}
writeFiles := []writeFile{
{
fn: ManifestName,
fn: ManifestPath,
d: NewBytesData(rawManifest),
},
}
Expand Down Expand Up @@ -474,7 +474,7 @@ func (bnd *Bundle) WriteExploded(dataDir string) (string, error) {

for _, v := range []string{
subDir,
bnd.ExplodedPath(dataDir, manifestPath),
bnd.ExplodedPath(dataDir, manifestMetadataSubdir),
} {
if err = os.MkdirAll(v, 0o700); err != nil {
return "", fmt.Errorf("runtime/bundle: failed to create asset sub-dir '%s': %w", v, err)
Expand Down Expand Up @@ -558,7 +558,7 @@ func Open(fn string, opts ...OpenOption) (_ *Bundle, err error) {
switch i {
case 0:
// Much like the JAR files, the manifest MUST come first.
if v.Name != ManifestName {
if v.Name != ManifestPath {
return nil, fmt.Errorf("runtime/bundle: invalid manifest file name: '%s'", v.Name)
}
default:
Expand All @@ -572,7 +572,7 @@ func Open(fn string, opts ...OpenOption) (_ *Bundle, err error) {

// Decode the manifest.
var manifest Manifest
d, ok := data[ManifestName]
d, ok := data[ManifestPath]
if !ok {
return nil, fmt.Errorf("runtime/bundle: missing manifest")
}
Expand Down
8 changes: 4 additions & 4 deletions go/runtime/bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestBundle(t *testing.T) {

// Ignore the manifest, the bundle we used to create the file
// will not have it.
delete(bundle2.Manifest.Digests, ManifestName)
delete(bundle2.Data, ManifestName)
delete(bundle2.Manifest.Digests, ManifestPath)
delete(bundle2.Data, ManifestPath)

ensureBundlesEqual(t, bundle, bundle2, "opened bundle mismatch")

Expand Down Expand Up @@ -171,8 +171,8 @@ func TestDetachedBundle(t *testing.T) {

// Ignore the manifest, the bundle we used to create the file
// will not have it.
delete(bundle2.Manifest.Digests, ManifestName)
delete(bundle2.Data, ManifestName)
delete(bundle2.Manifest.Digests, ManifestPath)
delete(bundle2.Data, ManifestPath)

ensureBundlesEqual(t, bundle, bundle2, "opened bundle mismatch")
})
Expand Down
2 changes: 1 addition & 1 deletion go/runtime/bundle/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ func (d *Discovery) cleanStaleExplodedBundles() {
if len(manifestHash) != 2*hash.Size {
continue
}
manifestPath := filepath.Join(bundlesDir, manifestHash, ManifestName)
manifestPath := filepath.Join(bundlesDir, manifestHash, ManifestPath)
data, err := os.ReadFile(manifestPath)
if err != nil {
d.logger.Error("error reading manifest file",
Expand Down
5 changes: 3 additions & 2 deletions go/runtime/bundle/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
)

const (
ManifestName = manifestPath + "/MANIFEST.MF"
manifestPath = "META-INF"
// ManifestPath is a relative path to manifest file inside a bundle.
ManifestPath = manifestMetadataSubdir + "/MANIFEST.MF"
manifestMetadataSubdir = "META-INF"
)

// Manifest is a deserialized runtime bundle manifest.
Expand Down

0 comments on commit d245a26

Please sign in to comment.