Skip to content

Commit

Permalink
Add GCP marketplace terms and conditions for marketplace GCP clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
tirthct committed Oct 9, 2023
1 parent eecf5d4 commit cc6f605
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 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 agree to 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 agreed to Google Marketplace terms and conditions:")
}

func osdProviderOptions(_ *sdk.Connection) ([]arguments.Option, error) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cc6f605

Please sign in to comment.