@@ -3,12 +3,16 @@ package rofl
33import (
44 "errors"
55 "fmt"
6+ "maps"
7+ "net/mail"
8+ "net/url"
69 "os"
710 "path/filepath"
811 "strings"
912
1013 "gopkg.in/yaml.v3"
1114
15+ "github.com/github/go-spdx/v2/spdxexp"
1216 "github.com/oasisprotocol/oasis-core/go/common/version"
1317
1418 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/rofl"
@@ -45,6 +49,16 @@ type Manifest struct {
4549 Name string `yaml:"name" json:"name"`
4650 // Version is the ROFL app version.
4751 Version string `yaml:"version" json:"version"`
52+ // Repository is the ROFL app repository URL.
53+ Repository string `yaml:"repository,omitempty" json:"repository,omitempty"`
54+ // Author is the ROFL app author full name and e-mail.
55+ Author string `yaml:"author,omitempty" json:"author,omitempty"`
56+ // License is the ROFL app SPDX license expression.
57+ License string `yaml:"license,omitempty" json:"license,omitempty"`
58+ // Homepage is the ROFL app homepage.
59+ Homepage string `yaml:"homepage,omitempty" json:"homepage,omitempty"`
60+ // Description is the ROFL app description.
61+ Description string `yaml:"description,omitempty" json:"description,omitempty"`
4862 // TEE is the type of TEE to build for.
4963 TEE string `yaml:"tee" json:"tee"`
5064 // Kind is the kind of ROFL app to build.
@@ -122,6 +136,19 @@ func (m *Manifest) Validate() error {
122136 return fmt .Errorf ("malformed version: %w" , err )
123137 }
124138
139+ if _ , err := url .Parse (m .Repository ); err != nil && m .Repository != "" {
140+ return fmt .Errorf ("malformed repository URL: %w" , err )
141+ }
142+ if _ , err := mail .ParseAddress (m .Author ); err != nil && m .Author != "" {
143+ return fmt .Errorf ("malformed author: %w" , err )
144+ }
145+ if _ , err := spdxexp .ExtractLicenses (m .License ); err != nil && m .License != "" {
146+ return fmt .Errorf ("malformed license: %w" , err )
147+ }
148+ if _ , err := url .Parse (m .Homepage ); err != nil && m .Homepage != "" {
149+ return fmt .Errorf ("malformed homepage URL: %w" , err )
150+ }
151+
125152 switch m .TEE {
126153 case TEETypeSGX , TEETypeTDX :
127154 default :
@@ -154,6 +181,38 @@ func (m *Manifest) Validate() error {
154181 return nil
155182}
156183
184+ // globalMetadataPrefix is the prefix used for all global metadata.
185+ const globalMetadataPrefix = "net.oasis.rofl."
186+
187+ // GetMetadata derives metadata from the attributes defined in the manifest and combines it with
188+ // the metadata for the specified deployment.
189+ func (m * Manifest ) GetMetadata (deployment string ) map [string ]string {
190+ meta := make (map [string ]string )
191+ for _ , md := range []struct {
192+ name string
193+ value string
194+ }{
195+ {"name" , m .Name },
196+ {"version" , m .Version },
197+ {"repository" , m .Repository },
198+ {"author" , m .Author },
199+ {"license" , m .License },
200+ {"homepage" , m .Homepage },
201+ {"description" , m .Description },
202+ } {
203+ if md .value == "" {
204+ continue
205+ }
206+ meta [globalMetadataPrefix + md .name ] = md .value
207+ }
208+
209+ d , ok := m .Deployments [deployment ]
210+ if ok {
211+ maps .Copy (meta , d .Metadata )
212+ }
213+ return meta
214+ }
215+
157216// SourceFileName returns the filename of the manifest file from which the manifest was loaded or
158217// an empty string in case the filename is not available.
159218func (m * Manifest ) SourceFileName () string {
0 commit comments