Skip to content

Commit 1f5481b

Browse files
committed
Add GCP marketplace terms and conditions for marketplace GCP clusters
1 parent 557a66b commit 1f5481b

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

cmd/ocm/create/cluster/cmd.go

+25-5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const (
4646
defaultIngressExcludedNamespacesFlag = "default-ingress-excluded-namespaces"
4747
defaultIngressWildcardPolicyFlag = "default-ingress-wildcard-policy"
4848
defaultIngressNamespaceOwnershipPolicyFlag = "default-ingress-namespace-ownership-policy"
49+
gcpTermsAgreementsHyperlink = "https://console.cloud.google.com" +
50+
"/marketplace/agreements/redhat-marketplace/red-hat-openshift-dedicated"
51+
gcpTermsAgreementError = "Please accept Google Terms and Agreements in order to proceed"
4952
)
5053

5154
var args struct {
@@ -71,6 +74,7 @@ var args struct {
7174
gcpServiceAccountFile arguments.FilePath
7275
etcdEncryption bool
7376
subscriptionType string
77+
marketplaceGcpTerms bool
7478

7579
// Scaling options
7680
computeMachineType string
@@ -324,6 +328,15 @@ func init() {
324328
)
325329
arguments.SetQuestion(fs, "subscription-type", "Subscription type:")
326330
Cmd.RegisterFlagCompletionFunc("subscription-type", arguments.MakeCompleteFunc(getSubscriptionTypeOptions))
331+
332+
fs.BoolVar(
333+
&args.marketplaceGcpTerms,
334+
"marketplace-gcp-terms",
335+
false,
336+
fmt.Sprintf("Review and accept Google Terms and Agreements on %s. "+
337+
"Set the flag to true once agreed in order to proceed further.", gcpTermsAgreementsHyperlink),
338+
)
339+
arguments.SetQuestion(fs, "marketplace-gcp-terms", "I have accepted Google Terms and Agreements:")
327340
}
328341

329342
func osdProviderOptions(_ *sdk.Connection) ([]arguments.Option, error) {
@@ -516,6 +529,18 @@ func preRun(cmd *cobra.Command, argv []string) error {
516529
if isGcpMarketplace {
517530
fmt.Println("setting provider to", c.ProviderGCP)
518531
args.provider = c.ProviderGCP
532+
fmt.Println("setting ccs to 'true'")
533+
args.ccs.Enabled = true
534+
if args.interactive {
535+
fmt.Println("Review and accept Google Terms and Agreements on", gcpTermsAgreementsHyperlink)
536+
err = arguments.PromptBool(fs, "marketplace-gcp-terms")
537+
if err != nil {
538+
return err
539+
}
540+
}
541+
if !args.marketplaceGcpTerms {
542+
return fmt.Errorf(gcpTermsAgreementError)
543+
}
519544
} else {
520545
err = arguments.PromptOneOf(fs, "provider", providers)
521546
if err != nil {
@@ -529,11 +554,6 @@ func preRun(cmd *cobra.Command, argv []string) error {
529554
args.clusterWideProxy.Enabled = true
530555
}
531556

532-
// If marketplace-gcp subscription type is used, ccs should by default be true
533-
if isGcpMarketplace {
534-
fmt.Println("setting ccs to 'true'")
535-
args.ccs.Enabled = true
536-
}
537557
err = promptCCS(fs, args.ccs.Enabled)
538558
if err != nil {
539559
return err

0 commit comments

Comments
 (0)