Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Add support for OCI based plugin discovery and distribution#1043

Merged
anujc25 merged 4 commits intovmware-tanzu:mainfrom
anujc25:cli-plugin-oci-support-1
Nov 5, 2021
Merged

Add support for OCI based plugin discovery and distribution#1043
anujc25 merged 4 commits intovmware-tanzu:mainfrom
anujc25:cli-plugin-oci-support-1

Conversation

@anujc25
Copy link
Copy Markdown
Contributor

@anujc25 anujc25 commented Nov 2, 2021

What this PR does / why we need it

  • Implement plugin artifacts publish to OCI image with 'builder' plugin
    • This change adds support for oci discovery/distribution with
      tanzu builder publish command
    • Adds a new Makefile section for "Building and publishing CLIPlugin
      Discovery resources and binaries to OCI image
  • Implement OCI based plugin discovery and distribution
    • Adds support for OCI based plugin discovery and artifact downloads
    • Adds support to use carvel package as an OCI discovery endpoint. This
      change uses ytt and kbld library to read the carvel package
  • Add unit tests

Which issue(s) this PR fixes

Fixes #946

Describe testing done for PR

  • Added unit tests
  • Manually tested the publishing script to publish plugin discovery and artifacts to remote registry repo
  • Use the published discovery source as part of the tanzu configuration and use it to fetch available plugins as well as download plugins

Release note

Added support for OCI based plugin discovery and distribution for CLIPlugin discovery

PR Checklist

  • Squash the commits into one or a small number of logical commits
  • Use good commit messages
  • Ensure PR contains terms all contributors can understand and links all contributors can access

Additional information

Special notes for your reviewer

@anujc25 anujc25 requested review from a team, miclettej and prkalle as code owners November 2, 2021 21:10
@anujc25 anujc25 requested a review from a team November 2, 2021 21:10
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 2, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211102212200/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from 1390a65 to 047853f Compare November 2, 2021 22:42
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 2, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211102225726/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from 047853f to c8a28f3 Compare November 3, 2021 17:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 3, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211103174559/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 requested a review from zjs November 3, 2021 17:55
@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from c8a28f3 to d824e90 Compare November 3, 2021 18:41
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 3, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211103185426/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from d824e90 to 3a7c874 Compare November 3, 2021 19:36
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 3, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211103194703/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from 3a7c874 to f82f837 Compare November 3, 2021 21:23
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 3, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211103213405/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

Copy link
Copy Markdown
Member

@zjs zjs left a comment

Choose a reason for hiding this comment

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

I appreciate the quick progress on this! Overall, it looks like things are coming together as planned. (Which means good job on the design as well 🙂)

I left a few minor comments. Let me know if anything is unclear!

Comment on lines +45 to +46
func (r *registry) GetFile(imageWithTag, filename string) ([]byte, error) {
ref, err := regname.ParseReference(imageWithTag, regname.WeakValidation)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: What's driving this change? (Naively, passing in the image and tag and handling the concatenation within the method seems better.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The main reason behind this change is to support sha256 based images as well. For example, User can also provide the image as projects.registry.vmware.com/tanzu/tanzu-plugins/standalone-cliplugins@sha256:e78f0c57a68737561b6217dcbe4976b46393e1ee6615f7c957f162ef428d5ac8.

For this type of images, providing image as projects.registry.vmware.com/tanzu/tanzu-plugins/standalone-cliplugins@sha256 and tag as e78f0c57a68737561b6217dcbe4976b46393e1ee6615f7c957f162ef428d5ac8 seems odd and hence the refactoring.

@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch 2 times, most recently from fdd21e3 to d20be10 Compare November 4, 2021 06:57
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211104070324/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211104071128/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@anujc25 anujc25 added area/cli area/plugin area/release kind/feature Categorizes issue or PR as related to a new feature labels Nov 4, 2021
Copy link
Copy Markdown
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.

Thanks for the changes! I have some minor comments and questions.


for path, fileData := range filesMap {
// Skip any testing related directory paths if bundled
if utils.ContainsString(filepath.SplitList(path), "test") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there some convention where these test related directories are often bundled in the image that we have to explicitly filter them? If so are they always named 'test'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The publish script takes the artifacts directory as an input. And for publishing the artifacts, It traverse to the specific plugin/version artifact directory at bundles the plugins from there. Sometimes, if the test plugin directory exists the bundle also includes test plugin directory, and this change just trying to skip that if it exists.

To improve around this, we can make some changes in the publish script to make sure it only publishes plugin binary and skip the publishing of the directory. But this check has been added as a safeguard for now.

@vuil vuil added the ok-to-merge PRs should be labelled with this before merging label Nov 4, 2021
- This change adds support for `oci` discovery/distribution with
  `tanzu builder publish` command
- Adds a new `Makefile` section for "Building and publishing CLIPlugin
  Discovery resources and binaries to OCI image
- Adds support for OCI based plugin discovery and artifact downloads
- Adds support to use carvel package as an OCI discovery endpoint. This
  change uses ytt and kbld library to read the carvel package
@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from d20be10 to 9cc9029 Compare November 4, 2021 18:06
@anujc25 anujc25 force-pushed the cli-plugin-oci-support-1 branch from 9cc9029 to cc71669 Compare November 4, 2021 18:10
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211104181923/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211104182526/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2021

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/1043/20211104212122/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

Copy link
Copy Markdown
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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/cli area/plugin area/release cla-not-required kind/feature Categorizes issue or PR as related to a new feature ok-to-merge PRs should be labelled with this before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Support for OCI based Discovery and Distribution for CLIPlugin API discovery work

4 participants