Skip to content

Commit

Permalink
Merge pull request #566 from tirthct/ocm-3993
Browse files Browse the repository at this point in the history
OCM 3993 | Feat | Add GCP marketplace terms and conditions for marketplace GCP clusters
  • Loading branch information
gdbranco authored Oct 9, 2023
2 parents 557a66b + 1f5481b commit 4818e93
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions cmd/ocm/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 accept Google Terms and Agreements in order to proceed"
)

var args struct {
Expand All @@ -71,6 +74,7 @@ var args struct {
gcpServiceAccountFile arguments.FilePath
etcdEncryption bool
subscriptionType string
marketplaceGcpTerms bool

// Scaling options
computeMachineType string
Expand Down Expand Up @@ -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 accepted Google Terms and Agreements:")
}

func osdProviderOptions(_ *sdk.Connection) ([]arguments.Option, error) {
Expand Down Expand Up @@ -516,6 +529,18 @@ func preRun(cmd *cobra.Command, argv []string) error {
if isGcpMarketplace {
fmt.Println("setting provider to", c.ProviderGCP)
args.provider = c.ProviderGCP
fmt.Println("setting ccs to 'true'")
args.ccs.Enabled = true
if args.interactive {
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)
}
} else {
err = arguments.PromptOneOf(fs, "provider", providers)
if err != nil {
Expand All @@ -529,11 +554,6 @@ func preRun(cmd *cobra.Command, argv []string) error {
args.clusterWideProxy.Enabled = true
}

// If marketplace-gcp subscription type is used, ccs should by default be true
if isGcpMarketplace {
fmt.Println("setting ccs to 'true'")
args.ccs.Enabled = true
}
err = promptCCS(fs, args.ccs.Enabled)
if err != nil {
return err
Expand Down

0 comments on commit 4818e93

Please sign in to comment.