diff --git a/cmd/ocm/create/cluster/cmd.go b/cmd/ocm/create/cluster/cmd.go index dcdcb89b..3e175d80 100644 --- a/cmd/ocm/create/cluster/cmd.go +++ b/cmd/ocm/create/cluster/cmd.go @@ -46,6 +46,9 @@ const ( defaultIngressExcludedNamespacesFlag = "default-ingress-excluded-namespaces" defaultIngressWildcardPolicyFlag = "default-ingress-wildcard-policy" defaultIngressNamespaceOwnershipPolicyFlag = "default-ingress-namespace-ownership-policy" + gcpTermsAgreementsHyperlink = "https://console.cloud.google.com" + + "/marketplace/agreements/redhat-marketplace/red-hat-openshift-dedicated" + gcpTermsAgreementError = "Please agree to Google Terms and Agreements in order to proceed" ) var args struct { @@ -71,6 +74,7 @@ var args struct { gcpServiceAccountFile arguments.FilePath etcdEncryption bool subscriptionType string + marketplaceGcpTerms bool // Scaling options computeMachineType string @@ -324,6 +328,15 @@ func init() { ) arguments.SetQuestion(fs, "subscription-type", "Subscription type:") Cmd.RegisterFlagCompletionFunc("subscription-type", arguments.MakeCompleteFunc(getSubscriptionTypeOptions)) + + fs.BoolVar( + &args.marketplaceGcpTerms, + "marketplace-gcp-terms", + false, + fmt.Sprintf("Review and accept Google Terms and Agreements on %s. "+ + "Set the flag to true once agreed in order to proceed further.", gcpTermsAgreementsHyperlink), + ) + arguments.SetQuestion(fs, "marketplace-gcp-terms", "I have agreed to Google Marketplace terms and conditions:") } func osdProviderOptions(_ *sdk.Connection) ([]arguments.Option, error) { @@ -533,6 +546,14 @@ func preRun(cmd *cobra.Command, argv []string) error { if isGcpMarketplace { fmt.Println("setting ccs to 'true'") args.ccs.Enabled = true + fmt.Println("Review and accept Google Terms and Agreements on", gcpTermsAgreementsHyperlink) + err = arguments.PromptBool(fs, "marketplace-gcp-terms") + if err != nil { + return err + } + if !args.marketplaceGcpTerms { + return fmt.Errorf(gcpTermsAgreementError) + } } err = promptCCS(fs, args.ccs.Enabled) if err != nil { @@ -668,6 +689,17 @@ func run(cmd *cobra.Command, argv []string) error { args.subscriptionType = parseSubscriptionType(args.subscriptionType) } + // If marketplace-gcp subscription type is used, flag marketplace-gcp-terms must be set to true. + gcpBillingModel, _ := billing.GetBillingModel(connection, billing.MarketplaceGcpSubscriptionType) + gcpSubscriptionTypeTemplate := parseSubscriptionType(subscriptionTypeOption(gcpBillingModel.ID(), + gcpBillingModel.Description()).Value) + isGcpMarketplaceSubscriptionType := args.subscriptionType == gcpSubscriptionTypeTemplate + if isGcpMarketplaceSubscriptionType { + if !args.marketplaceGcpTerms { + return fmt.Errorf(gcpTermsAgreementError) + } + } + clusterConfig := c.Spec{ Name: args.clusterName, Region: args.region,