Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM 3993 | Feat | Add GCP marketplace terms and conditions for marketplace GCP clusters #566

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
cristianoveiga marked this conversation as resolved.
Show resolved Hide resolved
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
Loading