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

Experimental: Get the Tanzu Hub Endpoint based on the Central Config Metadata #764

Merged
merged 4 commits into from
May 9, 2024

Conversation

anujc25
Copy link
Contributor

@anujc25 anujc25 commented May 8, 2024

What this PR does / why we need it

  • Get the Tanzu Hub Endpoint based on the Central Config Metadata
  • Adds following new configuration to the central config
cli.core.tanzu_hub_metadata:
  cspProductIdentifier: "TANZU-SAAS"
  cspDisplayName: "Tanzu Platform"
  endpointProduction: https://www.production.fake.vmware.com/hub
  endpointStaging: https://www.staging.fake.vmware.com/hub
  useCentralConfig: false
  • If useCentralConfig is false, Tanzu CLI will use CSP to get the hub endpoint

    • While using CSP it will get the cspProductIdentifier and cspDisplayName from central config keys cli.core.tanzu_platform_csp_product_identifier and cli.core.tanzu_platform_csp_display_name respectively.
  • If useCentralConfig is true, Tanzu CLI uses the central config key endpointProduction to get the endpoint for production and endpointStaging for staging. If the values are empty it will use default values specified within the CLI.

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

  • To be added

Release note

Experimental: Get the Tanzu Hub Endpoint based on the Central Config Metadata

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested a review from a team as a code owner May 8, 2024 22:49
@anujc25 anujc25 changed the title Get the Tanzu Hub Endpoint based on the Central Config Metadata Experimental: Get the Tanzu Hub Endpoint based on the Central Config Metadata May 8, 2024
@anujc25 anujc25 force-pushed the hub-endpoint-from-central-config branch from d1a5e94 to b00a5cb Compare May 8, 2024 22:55
Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. This gives us much more flexibility.

I on the fence about the config format using 5 separate keys instead of a single key. I see that the code reads one value at a time to make decisions so I see why you used different keys, but I still wonder if it would be more readable to have a single key with a struct; then you'd read the whole struct at the start and use only the content that you need.

I'm only suggesting this because it would make the central_config.yaml file more readable for a human, which is not something that is critical, so I'm not set on it.

I'll leave it up to you and other reviewers.

LGTM

pkg/auth/csp/tanzu.go Outdated Show resolved Hide resolved
// We will get the central configuration from the default discovery source
discoverySource, err := config.GetCLIDiscoverySource(cliconfig.DefaultStandaloneDiscoveryName)
if err != nil {
return "", err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corner case, but if the user has done a tanzu plugin source delete default (which is a hidden command), and error will be return here. Should we fallback to CSP in that case, or should we error out?

pkg/auth/csp/tanzu.go Outdated Show resolved Hide resolved
pkg/auth/csp/tanzu.go Outdated Show resolved Hide resolved
pkg/auth/csp/tanzu.go Outdated Show resolved Hide resolved
@anujc25 anujc25 force-pushed the hub-endpoint-from-central-config branch from fe67ada to a10f441 Compare May 9, 2024 17:19
Copy link
Contributor

@vuil vuil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the updates!

Copy link
Contributor

@marckhouzam marckhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice
LGTM!

@anujc25 anujc25 merged commit 87df35c into vmware-tanzu:main May 9, 2024
7 checks passed
@marckhouzam marckhouzam added this to the v1.3.0 milestone May 9, 2024
vuil pushed a commit to vuil/tanzu-cli that referenced this pull request May 9, 2024
…Metadata (vmware-tanzu#764)

* Update Test Central Config to include Hub metadata

* Get the Tanzu Hub Endpoint based on the Central Config Metadata
vuil pushed a commit that referenced this pull request May 9, 2024
…Metadata (#764)

* Update Test Central Config to include Hub metadata

* Get the Tanzu Hub Endpoint based on the Central Config Metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants