@@ -45,21 +45,41 @@ var ApplyCmd = &cobra.Command{
4545 Args : func (cmd * cobra.Command , args []string ) (err error ) {
4646 cmdProject := cmd .Flag ("proj" )
4747 cmdRegion := cmd .Flag ("reg" )
48+ cloudDeploy , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("cloud-deploy" )))
4849
49- if err = apiclient .SetRegion (utils .GetStringParam (cmdRegion )); err != nil {
50- return err
51- }
5250 cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
5351 clilog .Debug .Printf ("%s: %s\n " , f .Name , f .Value )
5452 })
53+
54+ if ! cloudDeploy && folder == "" {
55+ return fmt .Errorf ("either --folder or --cloud-deploy must be set" )
56+ }
57+
58+ if err = apiclient .SetRegion (utils .GetStringParam (cmdRegion )); err != nil {
59+ return err
60+ }
61+
5562 return apiclient .SetProjectID (utils .GetStringParam (cmdProject ))
5663 },
5764 RunE : func (cmd * cobra.Command , args []string ) (err error ) {
5865 cmd .SilenceUsage = true
5966
6067 var skaffoldConfigUri string
6168
62- if folder == "" {
69+ cloudDeploy , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("cloud-deploy" )))
70+ createSecret , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("create-secret" )))
71+ grantPermission , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("grant-permission" )))
72+ userLabel := utils .GetStringParam (cmd .Flag ("user-label" ))
73+ wait , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("wait" )))
74+ runTests , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("run-tests" )))
75+
76+ apiclient .DisableCmdPrintHttpResponse ()
77+
78+ if cloudDeploy {
79+ if err = storeCloudDeployVariables (); err != nil {
80+ return err
81+ }
82+
6383 skaffoldConfigUri , err = apiclient .GetCloudDeployGCSLocations (cloudDeployProjectId , cloudDeployLocation , pipeline , release )
6484 if err != nil {
6585 return err
@@ -78,14 +98,6 @@ var ApplyCmd = &cobra.Command{
7898 return fmt .Errorf ("problem with supplied path, %w" , err )
7999 }
80100
81- createSecret , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("create-secret" )))
82- cloudDeploy , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("cloud-deploy" )))
83- grantPermission , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("grant-permission" )))
84- userLabel := utils .GetStringParam (cmd .Flag ("user-label" ))
85- wait , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("wait" )))
86- runTests , _ := strconv .ParseBool (utils .GetStringParam (cmd .Flag ("run-tests" )))
87-
88- integrationFolder := path .Join (srcFolder , "src" )
89101 testsFolder := path .Join (folder , "tests" )
90102 testsConfigFolder := path .Join (folder , "test-configs" )
91103 authconfigFolder := path .Join (folder , "authconfigs" )
@@ -98,13 +110,7 @@ var ApplyCmd = &cobra.Command{
98110 endpointsFolder := path .Join (folder , "endpoints" )
99111 zonesFolder := path .Join (folder , "zones" )
100112
101- apiclient .DisableCmdPrintHttpResponse ()
102-
103- if cloudDeploy {
104- if err = storeCloudDeployVariables (); err != nil {
105- return err
106- }
107- }
113+ integrationFolder := path .Join (srcFolder , "src" )
108114
109115 if ! skipAuthconfigs {
110116 if err = processAuthConfigs (authconfigFolder ); err != nil {
@@ -744,13 +750,19 @@ func processTestCases(testsFolder string, integrationName string, version string
744750
745751func storeCloudDeployVariables () (err error ) {
746752 pipeline = os .Getenv ("CLOUD_DEPLOY_DELIVERY_PIPELINE" )
747- release = os .Getenv ("CLOUD_DEPLOY_RELEASE_NAME " )
753+ release = os .Getenv ("CLOUD_DEPLOY_RELEASE " )
748754 outputGCSPath = os .Getenv ("CLOUD_DEPLOY_OUTPUT_GCS_PATH" )
749755 cloudDeployProjectId = os .Getenv ("CLOUD_DEPLOY_PROJECT_ID" )
750756 cloudDeployLocation = os .Getenv ("CLOUD_DEPLOY_LOCATION" )
751757
758+ clilog .Debug .Printf ("CLOUD_DEPLOY_DELIVERY_PIPELINE: %s\n " , pipeline )
759+ clilog .Debug .Printf ("CLOUD_DEPLOY_RELEASE: %s\n " , release )
760+ clilog .Debug .Printf ("CLOUD_DEPLOY_OUTPUT_GCS_PATH: %s\n " , outputGCSPath )
761+ clilog .Debug .Printf ("CLOUD_DEPLOY_PROJECT_ID: %s\n " , cloudDeployProjectId )
762+ clilog .Debug .Printf ("CLOUD_DEPLOY_LOCATION: %s\n " , cloudDeployLocation )
763+
752764 if pipeline == "" || release == "" || outputGCSPath == "" || cloudDeployProjectId == "" {
753- return fmt .Errorf ("CLOUD_DEPLOY_DELIVERY_PIPELINE, CLOUD_DEPLOY_RELEASE_NAME , CLOUD_DEPLOY_OUTPUT_GCS_PATH, " +
765+ return fmt .Errorf ("CLOUD_DEPLOY_DELIVERY_PIPELINE, CLOUD_DEPLOY_RELEASE , CLOUD_DEPLOY_OUTPUT_GCS_PATH, " +
754766 "CLOUD_DEPLOY_PROJECT_ID, CLOUD_DEPLOY_LOCATION must be set" )
755767 }
756768 return nil
0 commit comments