upbound / up

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

Add example support to `xpkg build` #177

Closed tnthornton closed 2 years ago

tnthornton commented 2 years ago

Description of your changes

With this change, xpkg build now includes examples specified in the /examples directory (defaulting to the directory located at the root of the repo or can be configured to a separate location).

In addition xpkg push was extended to include support for adding annotations to the the xpkg layers.

I have:

How has this code been tested

xpkg build

Also examines contents:

$ _output/bin/darwin_arm64/up -f package -e examples
$ ls
provider-jet-aws-960b41c76b04.xpkg
$ tar -xvf provider-jet-aws-960b41c76b04.xpkg
x sha256:506a64c13fb4987d8d936e92a05e0b5053aa8a62624b75be81e29f225a5f9306
x 3f84d5729bdb7d311816026dc36861485e3c06e23753e27cd15121c352ea9507.tar.gz
x d542afccd9fb9aa14947cd5c2f80850f65f0ceba3b2802488fca542a0b410240.tar.gz
x manifest.json
$  cat manifest.json | jq
[
  {
    "Config": "sha256:506a64c13fb4987d8d936e92a05e0b5053aa8a62624b75be81e29f225a5f9306",
    "RepoTags": null,
    "Layers": [
      "3f84d5729bdb7d311816026dc36861485e3c06e23753e27cd15121c352ea9507.tar.gz",
      "d542afccd9fb9aa14947cd5c2f80850f65f0ceba3b2802488fca542a0b410240.tar.gz"
    ]
  }
]
$ tar -xvf 3f84d5729bdb7d311816026dc36861485e3c06e23753e27cd15121c352ea9507.tar.gz
x package.yaml
$ tar -xvf d542afccd9fb9aa14947cd5c2f80850f65f0ceba3b2802488fca542a0b410240.tar.gz
tar: Removing leading '/' from member names
x .up/examples.yaml
xpkg push
$ _output/bin/darwin_arm64/up xpkg push -f provider-jet-aws-960b41c76b04.xpkg index.docker.io/thorntontn/xpkg-test:v0.0.11
$ docker pull thorntontn/xpkg-test:v0.0.11
v0.0.11: Pulling from thorntontn/xpkg-test
3f84d5729bdb: Pull complete
d542afccd9fb: Pull complete
Digest: sha256:960b41c76b04540aaaba84d7a111a1e743c63c4f25b1fd63bd4e8b8858d73bc3
Status: Downloaded newer image for thorntontn/xpkg-test:v0.0.11
docker.io/thorntontn/xpkg-test:v0.0.11
$ docker manifest inspect thorntontn/xpkg-test:v0.0.11
{
    "schemaVersion": 2,
    "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
    "config": {
        "mediaType": "application/vnd.docker.container.image.v1+json",
        "size": 342,
        "digest": "sha256:506a64c13fb4987d8d936e92a05e0b5053aa8a62624b75be81e29f225a5f9306"
    },
    "layers": [
        {
            "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
            "size": 100635,
            "digest": "sha256:3f84d5729bdb7d311816026dc36861485e3c06e23753e27cd15121c352ea9507",
            "annotations": {
                "io.crossplane.xpkg": "base"
            }
        },
        {
            "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
            "size": 3796,
            "digest": "sha256:d542afccd9fb9aa14947cd5c2f80850f65f0ceba3b2802488fca542a0b410240",
            "annotations": {
                "io.crossplane.xpkg": "upbound"
            }
        }
    ]
}