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

Cherry Pick PR- Update the JoinUrl function to handle urls without schema (#364) #366

Conversation

mpanchajanya
Copy link
Contributor

@mpanchajanya mpanchajanya commented Jun 20, 2023

(cherry picked from commit f1580b0)
#364

What this PR does / why we need it

  • IP address as baseURL without schema is not parsed correctly with net/url package

Which issue(s) this PR fixes

Fixes #365

Describe testing done for PR

  • Added more unit tests
  • Test the plugin upload-bundle command
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz version
version: v1.0.0-dev
buildDate: 2023-06-20
sha: 07167447
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> make start-test-central-repo
Stopped docker test central repo
echo "Adding docker test central repo cert to the config file"
Adding docker test central repo cert to the config file
TANZU_CLI_CEIP_OPT_IN_PROMPT_ANSWER="No" TANZU_CLI_EULA_PROMPT_ANSWER="Yes" /Users/mpanchajanya/vmw/repository/tanzu-cli/bin/tanzu config cert delete localhost:9876 || true
[x] : cert configuration for localhost:9876 not found
/Users/mpanchajanya/vmw/repository/tanzu-cli/bin/tanzu config cert add --host localhost:9876 --ca-certificate /Users/mpanchajanya/vmw/repository/tanzu-cli/hack/central-repo/certs/localhost.crt
[ok] successfully added certificate data for host localhost:9876
Started docker test central repo with images:
=> localhost:9876/tanzu-cli/plugins/central:small
    - a small amount of plugins matching product plugin names
    - only versions v0.0.1 and v9.9.9 can be installed
=> localhost:9876/tanzu-cli/plugins/central:large with 100 plugins
    - the same content as the small image with extra plugins for a total of 100
    - none of the 'stubXY' plugins can be installed
    - only versions v0.0.1 and v9.9.9 can be installed
=> localhost:9876/tanzu-cli/plugins/sandbox1:small
    - an extra v11.11.11 version of the plugins of the small image
=> localhost:9876/tanzu-cli/plugins/sandbox2:small
    - an extra v22.22.22 version of the plugins of the small image
=> localhost:9876/tanzu-cli/plugins/airgapped:small
    - a small amount of plugins matching product plugin names
    - contains only versions v0.0.1 and v9.9.9 of plugins and all of them can be installed
=> localhost:9876/tanzu-cli/plugins/airgapped:large
    - all plugins matching product plugin names
    - contains only versions v0.0.1 and v9.9.9 of plugins and all of them can be installed
=> localhost:9876/tanzu-cli/plugins/shas:small
    - a small amount of plugins matching product plugin names
    - contains only versions v0.0.1 and v9.9.9 of plugins and all of them can be installed
    - SHAs are used to reference the v9.9.9 plugin binaries and tags for v0.0.1
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin source init
[ok] successfully initialized discovery source
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz config get
clientOptions:
    cli:
        edition: tkg
        bomRepo: projects.registry.vmware.com/tkg
        compatibilityFilePath: tkg-compatibility
    features:
        global:
            context-target-v2: "true"
cli:
    eulaStatus: accepted
    discoverySources:
        - oci:
            name: default
            image: projects.registry.vmware.com/tanzu_cli/plugins/plugin-inventory:latest
certs:
    - host: localhost:9876
      caCertData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURtekNDQW9PZ0F3SUJBZ0lKQU43MmtGUTFOdnJtTUEwR0NTcUdTSWIzRFFFQkN3VUFNQ2t4Q3pBSkJnTlYKQkFZVEFsVlRNUm93R0FZRFZRUUREQkZVWVc1NmRTQkRURWt0VW05dmRDMURRVEFlRncweU16QTBNalV3TURJMApNVFJhRncwek16QTBNakl3TURJME1UUmFNSFF4Q3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRSURBcERZV3hwClptOXlibWxoTVJZd0ZBWURWUVFIREExVFlXNGdSbkpoYm1OcGMyTnZNUjR3SEFZRFZRUUtEQlZTWldkcGMzUnkKZVMxRFpYSjBhV1pwWTJGMFpYTXhHREFXQmdOVkJBTU1EMnh2WTJGc2FHOX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BpZkJKMEFFZEhoajk5NGVhawp4SmJ4Vjg5am1XT1o4T0dadWZxaGNNQ2JxZFpnNSttYmJ3YVRaWC9ENERzbzVjQUE2UEtDM1E4OUNPWlZVRy95ClpCSHErMXgrTWh0Y3RFNVNleUowY2NNa1plTm5zL2pWQWpKaGNEWW5NUUNwSHJQNUZoNXg2cWU4OHJwdnZQYXcKMHpqakkzMEh2Q1JMdjdyZ1p1YXAKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
      insecure: "false"
      skipCertVerify: "false"

mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin search
[i] Reading plugin inventory for "projects.registry.vmware.com/tanzu_cli/plugins/plugin-inventory:latest", this will take a few seconds.
  NAME                DESCRIPTION                                                        TARGET      LATEST
  builder             Build Tanzu components                                             global      v0.90.0
  isolated-cluster    Prepopulating images/bundle for internet-restricted environments   global      v0.29.0
  pinniped-auth       Pinniped authentication operations (usually not directly invoked)  global      v0.29.0
  test                Test the CLI                                                       global      v0.90.0
  cluster             Kubernetes cluster operations                                      kubernetes  v0.29.0
  feature             Operate on features and featuregates                               kubernetes  v0.29.0
  kubernetes-release  Kubernetes release operations                                      kubernetes  v0.29.0
  management-cluster  Kubernetes management cluster operations                           kubernetes  v0.29.0
  namespaces          Discover vSphere Supervisor namespaces you have access to          kubernetes  v1.0.0
  package             Tanzu package management                                           kubernetes  v0.29.0
  secret              Tanzu secret management                                            kubernetes  v0.29.0
  telemetry           configure cluster-wide settings for vmware tanzu telemetry         kubernetes  v0.29.0
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin source update default -u localhost:9876/tanzu-cli/plugins/airgapped:small
[i] Reading plugin inventory for "localhost:9876/tanzu-cli/plugins/airgapped:small", this will take a few seconds.
[!] Unable to verify the plugins discovery image signature: failed validating the signature of the image localhost:9876/tanzu-cli/plugins/airgapped:small :no matching signatures:
invalid signature when validating ASN.1 encoded signature
[x] Fatal, plugins discovery image signature verification failed. The `tanzu` CLI can not ensure the integrity of the plugins to be installed. To ignore this validation please append "localhost:9876/tanzu-cli/plugins/airgapped:small" to the comma-separated list in the environment variable "TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST".  This is NOT RECOMMENDED and could put your environment at risk!
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address) [1]> export TANZU_CLI_PLUGIN_DISCOVERY_IMAGE_SIGNATURE_VERIFICATION_SKIP_LIST=localhost:9876/tanzu-cli/plugins/airgapped:small
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin source update default -u localhost:9876/tanzu-cli/plugins/airgapped:small
[i] Reading plugin inventory for "localhost:9876/tanzu-cli/plugins/airgapped:small", this will take a few seconds.
[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/airgapped:small"

[ok] updated discovery source default
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin search
  NAME              DESCRIPTION                TARGET           LATEST
  isolated-cluster  Desc for isolated-cluster  global           v9.9.9
  cluster           Desc for cluster           kubernetes       v9.9.9
  account           Desc for account           mission-control  v9.9.9
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin download-bundle --image localhost:9876/tanzu-cli/plugins/airgapped:small --to-tar plugin_bundle.tar --group vmware-tkg/default
[!] Skipping the plugins discovery image signature verification for "localhost:9876/tanzu-cli/plugins/airgapped:small"

[i] will be downloading the one plugin from group: vmware-tkg/default:v9.9.9
[i] downloading image "localhost:9876/tanzu-cli/plugins/airgapped:small"
[i] copy | exporting 2 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/airgapped@sha256:21cbc18f6d8783820d84bd2523c7b3ed77ebab99cdc2a8701f4bd144fc7f5c96
[i] copy | will export localhost:9876/tanzu-cli/plugins/airgapped@sha256:a9bd729d26a2e57c0c549be7dd2756cc02d17ed4df8621852311dfdc2586df68
[i] copy | exported 2 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (55.875µs)
[i] copy | done: file 'sha256-b797f6b38013d8284af26100a0e316c7946abd08383ed351c388a91db1331f63.tar.gz' (77.708µs)
[i] copy | done: file 'sha256-c59d5a492d7779ef4523d26ae2d69a95a25a9875d938d04df4a07abd79c8443d.tar.gz' (49.084µs)
[i] ---------------------------
[i] downloading image "localhost:9876/tanzu-cli/plugins/vmware/tkg/darwin/amd64/kubernetes/cluster:v9.9.9"
[i] copy | exporting 1 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/vmware/tkg/darwin/amd64/kubernetes/cluster@sha256:04d46370ef735c0fe710306911a40dec8fbdc176e1a54c60caf15460454f04fd
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (5.917µs)
[i] copy | done: file 'sha256-bed3e352bcda48d967dad08b19dffac9b38bb4a2c5d0f9df10d7f0a69e226a1e.tar.gz' (61.541µs)
[i] ---------------------------
[i] downloading image "localhost:9876/tanzu-cli/plugins/vmware/tkg/darwin/arm64/kubernetes/cluster:v9.9.9"
[i] copy | exporting 1 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/vmware/tkg/darwin/arm64/kubernetes/cluster@sha256:04d46370ef735c0fe710306911a40dec8fbdc176e1a54c60caf15460454f04fd
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (6.917µs)
[i] copy | done: file 'sha256-bed3e352bcda48d967dad08b19dffac9b38bb4a2c5d0f9df10d7f0a69e226a1e.tar.gz' (61.208µs)
[i] ---------------------------
[i] downloading image "localhost:9876/tanzu-cli/plugins/vmware/tkg/linux/amd64/kubernetes/cluster:v9.9.9"
[i] copy | exporting 1 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/vmware/tkg/linux/amd64/kubernetes/cluster@sha256:04d46370ef735c0fe710306911a40dec8fbdc176e1a54c60caf15460454f04fd
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (7µs)
[i] copy | done: file 'sha256-bed3e352bcda48d967dad08b19dffac9b38bb4a2c5d0f9df10d7f0a69e226a1e.tar.gz' (24µs)
[i] ---------------------------
[i] downloading image "localhost:9876/tanzu-cli/plugins/vmware/tkg/windows/amd64/kubernetes/cluster:v9.9.9"
[i] copy | exporting 1 images...
[i] copy | will export localhost:9876/tanzu-cli/plugins/vmware/tkg/windows/amd64/kubernetes/cluster@sha256:04d46370ef735c0fe710306911a40dec8fbdc176e1a54c60caf15460454f04fd
[i] copy | exported 1 images
[i] copy | writing layers...
[i] copy | done: file 'manifest.json' (6.5µs)
[i] copy | done: file 'sha256-bed3e352bcda48d967dad08b19dffac9b38bb4a2c5d0f9df10d7f0a69e226a1e.tar.gz' (37.084µs)
[i] saving plugin bundle at: plugin_bundle.tar
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin upload-bundle --tar plugin_bundle.tar --to-repo localhost:9876/test/airgapped/v7/tanzu-cli/plugins/
[i] extracting "plugin_bundle.tar" for processing...
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped"
[i] copy | importing 2 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/darwin/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/darwin/arm64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/linux/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/windows/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] ---------------------------
[i] publishing plugin inventory metadata image...
[i] plugin inventory metadata image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped-metadata:small" is present. Merging the plugin inventory metadata
[i] uploading image "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped-metadata:small"
[i] ---------------------------
[i] successfully published all plugin images to "localhost:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped:small"
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)>

mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address) [1]> tz config cert add --host 127.0.0.1:9876 --ca-certificate hack/central-repo/certs/localhost.crt
[ok] successfully added certificate data for host 127.0.0.1:9876

mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)> tz plugin upload-bundle --tar plugin_bundle.tar --to-repo 127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/
[i] extracting "plugin_bundle.tar" for processing...
[i] ---------------------------
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped"
[i] copy | importing 2 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/darwin/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/darwin/arm64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/linux/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/vmware/tkg/windows/amd64/kubernetes/cluster"
[i] copy | importing 1 images...

[i] copy |
copy | done uploading images
[i] copy | Tagging images
[i] ---------------------------
[i] ---------------------------
[i] publishing plugin inventory metadata image...
[i] plugin inventory metadata image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped-metadata:small" is present. Merging the plugin inventory metadata
[i] uploading image "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped-metadata:small"
[i] ---------------------------
[i] successfully published all plugin images to "127.0.0.1:9876/test/airgapped/v7/tanzu-cli/plugins/airgapped:small"
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix/joinURL_fails_ip_address)>


Release note

Fix the `tanzu plugin upload-bundle` command to support ip-address along with the hostname for the plugin repository

Additional information

Special notes for your reviewer

@mpanchajanya mpanchajanya requested a review from a team as a code owner June 20, 2023 19:35
@mpanchajanya mpanchajanya self-assigned this Jun 20, 2023
@mpanchajanya mpanchajanya requested a review from anujc25 June 20, 2023 19:41
@mpanchajanya mpanchajanya merged commit 7d577b6 into vmware-tanzu:release-0.90 Jun 20, 2023
@mpanchajanya mpanchajanya deleted the cherry-pick-pr-plugin-upload-bundle-fix branch September 25, 2023 19:56
@marckhouzam marckhouzam added this to the v0.90.1 milestone Oct 20, 2023
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.

4 participants