Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 96d4d9b

Browse files
author
Ian Campbell
committed
metadata: Add helper to extract docker-app metadata from a bundle.
Signed-off-by: Ian Campbell <[email protected]>
1 parent 368989a commit 96d4d9b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

types/metadata/metadata.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package metadata
22

33
import (
44
"strings"
5+
6+
"github.com/deislabs/cnab-go/bundle"
57
)
68

79
// Maintainer represents one of the apps's maintainers
@@ -38,3 +40,19 @@ type AppMetadata struct {
3840
Description string `json:"description,omitempty"`
3941
Maintainers Maintainers `json:"maintainers,omitempty"`
4042
}
43+
44+
// Metadata extracts the docker-app metadata from the bundle
45+
func FromBundle(bndl *bundle.Bundle) AppMetadata {
46+
meta := AppMetadata{
47+
Name: bndl.Name,
48+
Version: bndl.Version,
49+
Description: bndl.Description,
50+
}
51+
for _, m := range bndl.Maintainers {
52+
meta.Maintainers = append(meta.Maintainers, Maintainer{
53+
Name: m.Name,
54+
Email: m.Email,
55+
})
56+
}
57+
return meta
58+
}

0 commit comments

Comments
 (0)