4141
4242 appTEE string
4343 appKind string
44+ reset bool
4445
4546 //go:embed init_artifacts/compose.yaml
4647 initArtifactCompose []byte
@@ -64,38 +65,59 @@ var (
6465 err = os .Chdir (appPath )
6566 cobra .CheckErr (err )
6667
67- // Fail in case there is an existing manifest.
68- if buildRofl .ManifestExists () {
69- cobra .CheckErr ("refusing to overwrite existing manifest" )
70- }
68+ var manifest * buildRofl.Manifest
69+ if ! reset {
70+ // Fail in case there is an existing manifest.
71+ if buildRofl .ManifestExists () {
72+ cobra .CheckErr ("Refusing to overwrite existing manifest.\n Hint: To reset existing ROFL manifest, pass --reset flag." )
73+ }
7174
72- // Create a default manifest without any deployments.
73- // TODO: Extract author and repository from Git configuration if available.
74- manifest := buildRofl.Manifest {
75- Name : appName ,
76- Version : "0.1.0" ,
77- TEE : appTEE ,
78- Kind : appKind ,
79- Resources : buildRofl.ResourcesConfig {
80- Memory : 512 ,
81- CPUCount : 1 ,
82- Storage : & buildRofl.StorageConfig {
83- Kind : buildRofl .StorageKindDiskPersistent ,
84- Size : 512 ,
75+ fmt .Printf ("Creating a new app with default policy...\n " )
76+
77+ // Create a default manifest without any deployments.
78+ manifest = & buildRofl.Manifest {
79+ Name : appName ,
80+ Version : "0.1.0" ,
81+ TEE : appTEE ,
82+ Kind : appKind ,
83+ Resources : buildRofl.ResourcesConfig {
84+ Memory : 512 ,
85+ CPUCount : 1 ,
8586 },
86- },
87+ }
88+ } else {
89+ manifest , err = buildRofl .LoadManifest ()
90+ cobra .CheckErr (err )
91+
92+ fmt .Printf ("\n " )
93+ if ! common .GetAnswerYes () {
94+ common .Confirm ("Reset existing app manifest file by removing all configured ROFL deployments, secrets and policies" , "not resetting" )
95+ }
96+
97+ manifest .Name = appName
98+ manifest .Deployments = make (map [string ]* buildRofl.Deployment )
8799 }
100+
101+ // TODO: Extract author and repository from Git configuration if available.
102+
88103 err = manifest .Validate ()
89104 cobra .CheckErr (err )
90105
91- fmt .Printf ("Creating a new ROFL app with default policy...\n " )
92106 fmt .Printf ("Name: %s\n " , manifest .Name )
93107 fmt .Printf ("Version: %s\n " , manifest .Version )
94108 fmt .Printf ("TEE: %s\n " , manifest .TEE )
95109 fmt .Printf ("Kind: %s\n " , manifest .Kind )
96110
97111 switch manifest .TEE {
98112 case buildRofl .TEETypeTDX :
113+ // TDX requires storage settings.
114+ if ! reset {
115+ manifest .Resources .Storage = & buildRofl.StorageConfig {
116+ Kind : buildRofl .StorageKindDiskPersistent ,
117+ Size : 512 ,
118+ }
119+ }
120+
99121 switch appKind {
100122 case buildRofl .AppKindRaw :
101123 artifacts := buildRofl .LatestBasicArtifacts // Copy.
@@ -221,6 +243,12 @@ var (
221243 debugMode = params .DebugAllowTestRuntimes
222244 }
223245
246+ // For TDX assign empty quote policies by default.
247+ var tdxQuotePolicy * pcs.TdxQuotePolicy
248+ if manifest .TEE == buildRofl .TEETypeTDX {
249+ tdxQuotePolicy = & pcs.TdxQuotePolicy {}
250+ }
251+
224252 // Generate manifest and a default policy which does not accept any enclaves.
225253 deployment = & buildRofl.Deployment {
226254 Network : npa .NetworkName ,
@@ -232,7 +260,7 @@ var (
232260 PCS : & pcs.QuotePolicy {
233261 TCBValidityPeriod : 30 ,
234262 MinTCBEvaluationDataNumber : 18 ,
235- TDX : & pcs. TdxQuotePolicy {} ,
263+ TDX : tdxQuotePolicy ,
236264 },
237265 },
238266 Endorsements : []rofl.AllowedEndorsement {
@@ -828,6 +856,8 @@ func detectOrCreateComposeFile() string {
828856func init () {
829857 initCmd .Flags ().StringVar (& appTEE , "tee" , "tdx" , "TEE kind [tdx, sgx]" )
830858 initCmd .Flags ().StringVar (& appKind , "kind" , "container" , "ROFL app kind [container, raw]" )
859+ initCmd .Flags ().BoolVar (& reset , "reset" , false , "reset the existing ROFL manifest" )
860+ initCmd .Flags ().AddFlagSet (common .AnswerYesFlag )
831861
832862 createCmd .Flags ().AddFlagSet (common .SelectorFlags )
833863 createCmd .Flags ().AddFlagSet (common .RuntimeTxFlags )
0 commit comments