upbound / up

The @upbound CLI
Apache License 2.0
52 stars 41 forks source link

xpkg batch subcommand to batch process provider packages #332

Closed ulucinar closed 1 year ago

ulucinar commented 1 year ago

Description of your changes

This PR introduces an xpkg batch subcommand to batch process a family of provider packages. The xpkg build implementation dumps the built packages onto the file system for xpkg push to load them from the filesystem and push them to a package registry. These two subcommands should stay as is with this PR and a new xpkg batch command is added that does not need to store the built provider packages in the filesystem. The packages are instead directly pushed to the configured registry. xpkg batch has batch processing capabilities to streamline the build process of a family of smaller provider packages. An example invocation for the command looks like:

up xpkg batch --service monolith,config,acm,rds,ec2 --family-base-image build-e46f4576/provider-aws --provider-name provider-aws --family-package-url-format xpkg.upbound.io/upbound-release-candidates/%s:v0.35.0-rc.0 --package-repo-override monolith=provider-aws --package-repo-override config=provider-family-aws --provider-bin-root .../provider-aws/_output/bin --examples-root .../provider-aws/examples --examples-group-override monolith=* --examples-group-override config=providerconfig --auth-ext .../provider-aws/package/auth.yaml --crd-root .../provider-aws/package/crds --crd-group-override monolith=* --crd-group-override config=aws --package-metadata-template .../provider-aws/package/crossplane.yaml.tmpl --template-var XpkgRegOrg=xpkg.upbound.io/upbound-release-candidates --template-var DepConstraint=">= 0.0.0-0" --concurrency 4

All smaller packages built by this command share a common base image and this common base is specified with the --family-base-image option. The providers to be built and pushed are specified via the --service option. xpkg batch adds the base and the upbound layers as before, as well as a layer containing the provider binary. The base and upbound labeled layers are shared between all the architectures of a provider's package.

xpkg batch builds & pushes the provider packages in parallel with the configured (via the --concurrency option) maximum concurrency.

xpkg batch also has a templating engine so that the family of providers being built can share a template provider metadata. The templating engine substitutes the {{ .Service }} and {{ .Name }} template variables with the service and package repo names, respectively, and further template variables can also be supplied via multiple --template-var command-line options.

The --family-package-url-format should specify the package URL format string and must contain a single string specifier, which will be substituted with the repo name of the provider being processed. The provider binaries should reside under --provider-bin-root in their respective platform folders. The platforms for which the provider packages will be built can be specified via the --platform option.

I have:

How has this code been tested

Tested both locally and in Github workflows against upbound/provider-aws packages.

ulucinar commented 1 year ago

@turkenh, could you please take a look at the last commit that introduces the option to be able to selectively dump provider packages onto the filesystem? I had to introduce this option for the local-deploy and uptest make targets.