Skip to content

Commit

Permalink
Added terms and conditions flag for GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
tirthct committed Oct 9, 2023
1 parent d9b1346 commit f85a094
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cmd/ocm/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ 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 +73,7 @@ var args struct {
gcpServiceAccountFile arguments.FilePath
etcdEncryption bool
subscriptionType string
marketplaceGcpTerms bool

// Scaling options
computeMachineType string
Expand Down Expand Up @@ -324,6 +327,14 @@ 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 @@ -532,6 +543,14 @@ func preRun(cmd *cobra.Command, argv []string) error {
if isGcpMarketplaceSubscriptionType {
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 @@ -667,6 +686,16 @@ 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 f85a094

Please sign in to comment.