4141
4242 appTEE string
4343 appKind string
44+ reset bool
4445
4546 //go:embed init_artifacts/compose.yaml
4647 initArtifactCompose []byte
@@ -64,31 +65,44 @@ 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 )
@@ -828,6 +842,8 @@ func detectOrCreateComposeFile() string {
828842func init () {
829843 initCmd .Flags ().StringVar (& appTEE , "tee" , "tdx" , "TEE kind [tdx, sgx]" )
830844 initCmd .Flags ().StringVar (& appKind , "kind" , "container" , "ROFL app kind [container, raw]" )
845+ initCmd .Flags ().BoolVar (& reset , "reset" , false , "reset the existing ROFL manifest" )
846+ initCmd .Flags ().AddFlagSet (common .AnswerYesFlag )
831847
832848 createCmd .Flags ().AddFlagSet (common .SelectorFlags )
833849 createCmd .Flags ().AddFlagSet (common .RuntimeTxFlags )
0 commit comments