@@ -49,17 +49,6 @@ var ApplyCmd = &cobra.Command{
4949 if err = apiclient .SetRegion (utils .GetStringParam (cmdRegion )); err != nil {
5050 return err
5151 }
52- if folder == "" && (pipeline == "" || release == "" || outputGCSPath == "" ) {
53- return fmt .Errorf ("atleast one of folder or pipeline, release and outputGCSPath must be supplied" )
54- }
55- if folder != "" && (pipeline != "" || release != "" || outputGCSPath != "" ) {
56- return fmt .Errorf ("both folder and pipeline, release and outputGCSPath cannot be supplied" )
57- }
58- if (pipeline != "" && (release == "" || outputGCSPath == "" )) ||
59- (release != "" && (pipeline == "" && outputGCSPath == "" )) ||
60- (outputGCSPath != "" && (pipeline == "" && release == "" )) {
61- return fmt .Errorf ("release, pipeline and outputGCSPath must be set" )
62- }
6352 cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
6453 clilog .Debug .Printf ("%s: %s\n " , f .Name , f .Value )
6554 })
@@ -71,7 +60,7 @@ var ApplyCmd = &cobra.Command{
7160 var skaffoldConfigUri string
7261
7362 if folder == "" {
74- skaffoldConfigUri , err = apiclient .GetCloudDeployGCSLocations (pipeline , release )
63+ skaffoldConfigUri , err = apiclient .GetCloudDeployGCSLocations (cloudDeployProjectId , cloudDeployLocation , pipeline , release )
7564 if err != nil {
7665 return err
7766 }
@@ -90,6 +79,7 @@ var ApplyCmd = &cobra.Command{
9079 }
9180
9281 createSecret , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("create-secret" )))
82+ cloudDeploy , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("cloud-deploy" )))
9383 grantPermission , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("grant-permission" )))
9484 userLabel := utils .GetStringParam (cmd .Flag ("user-label" ))
9585 wait , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("wait" )))
@@ -110,6 +100,12 @@ var ApplyCmd = &cobra.Command{
110100
111101 apiclient .DisableCmdPrintHttpResponse ()
112102
103+ if cloudDeploy {
104+ if err = storeCloudDeployVariables (); err != nil {
105+ return err
106+ }
107+ }
108+
113109 if ! skipAuthconfigs {
114110 if err = processAuthConfigs (authconfigFolder ); err != nil {
115111 return err
@@ -160,20 +156,17 @@ Apply scaffold configuration, but skip connectors: ` + GetExample(12) + `
160156Apply scaffold configuration and run functional tests: ` + GetExample (18 ),
161157}
162158
163- var serviceAccountName , serviceAccountProject , encryptionKey , pipeline , release , outputGCSPath string
159+ var serviceAccountName , serviceAccountProject , encryptionKey , pipeline string
160+ var release , outputGCSPath , cloudDeployProjectId , cloudDeployLocation string
164161
165162func init () {
166163 var userLabel string
167- grantPermission , createSecret , wait , runTests := false , false , false , false
164+ grantPermission , createSecret , wait , runTests , cloudDeploy := false , false , false , false , false
168165
169166 ApplyCmd .Flags ().StringVarP (& folder , "folder" , "f" ,
170167 "" , "Folder containing scaffolding configuration" )
171- ApplyCmd .Flags ().StringVarP (& pipeline , "pipeline" , "" ,
172- "" , "Cloud Deploy Pipeline name" )
173- ApplyCmd .Flags ().StringVarP (& release , "release" , "" ,
174- "" , "Cloud Deploy Release name" )
175- ApplyCmd .Flags ().StringVarP (& outputGCSPath , "output-gcs-path" , "" ,
176- "" , "Upload a file named results.json containing the results" )
168+ ApplyCmd .Flags ().BoolVarP (& cloudDeploy , "cloud-deploy" , "" ,
169+ false , "Deploy using Cloud Deploy; default is false" )
177170 ApplyCmd .Flags ().BoolVarP (& grantPermission , "grant-permission" , "g" ,
178171 false , "Grant the service account permission to the GCP resource; default is false" )
179172 ApplyCmd .Flags ().StringVarP (& userLabel , "userlabel" , "u" ,
@@ -748,3 +741,17 @@ func processTestCases(testsFolder string, integrationName string, version string
748741 }
749742 return nil
750743}
744+
745+ func storeCloudDeployVariables () (err error ) {
746+ pipeline = os .Getenv ("CLOUD_DEPLOY_DELIVERY_PIPELINE" )
747+ release = os .Getenv ("CLOUD_DEPLOY_RELEASE_NAME" )
748+ outputGCSPath = os .Getenv ("CLOUD_DEPLOY_OUTPUT_GCS_PATH" )
749+ cloudDeployProjectId = os .Getenv ("CLOUD_DEPLOY_PROJECT_ID" )
750+ cloudDeployLocation = os .Getenv ("CLOUD_DEPLOY_LOCATION" )
751+
752+ if pipeline == "" || release == "" || outputGCSPath == "" || cloudDeployProjectId == "" {
753+ return fmt .Errorf ("CLOUD_DEPLOY_DELIVERY_PIPELINE, CLOUD_DEPLOY_RELEASE_NAME, CLOUD_DEPLOY_OUTPUT_GCS_PATH, " +
754+ "CLOUD_DEPLOY_PROJECT_ID, CLOUD_DEPLOY_LOCATION must be set" )
755+ }
756+ return nil
757+ }
0 commit comments