flipt-io / cup

Git Contribution Automation
https://cup.flipt.io
Apache License 2.0
76 stars 1 forks source link

Simplify packaging and configuring controllers #33

Open GeorgeMac opened 1 year ago

GeorgeMac commented 1 year ago

More often than not, controllers will be defined and scoped to a set of supported resource types.

For example, the Flipt controller handles Flipt and Segment resource types only.

It should therefor be possible to bundle both the Controller WASM binary and its support definitions in a single artefact. The most promising format is likely OCI.

With the https://github.com/oras-project/oras-go project we could add support for bundling WASM binaries with their associated resources type directly into cup and cupd. cupd could support sourcing controllers and definitions directly from OCI registries.

Here are some useful links for design ideas around packing:

Quick sketch of what a manifest might look like for cup:

{
  "schemaVersion": 2,
  "artifactType": "application/vnd.io.flipt.cup.controller+type",
  "config": {
    "mediaType": "application/vnd.oci.empty.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2
  },
  "layers": [
    {
      "mediaType": "application/vnd.io.flipt.cup.controller.content.v1.tar+gzip",
      "digest": "sha256:1b251d38cfe948dfc0a5745b7af5ca574ecb61e52aed10b19039db39af6e1617",
      "size": 7364
    },
    {
      "mediaType": "application/vnd.io.flipt.cup.resource.v1+json",
      "digest": "sha256:3e207b409db364b595ba862cdc12be96dcdad8e36c59a03b7b3b61c946a5741a",
      "size": 384
    }
  ]
}

cup subcommands

One of more new subcommand(s) would be useful for packing, publishing and pulling Cup controllers.

We will need to support users being able to:

cupd controller definition

The Controller definition will need extending to support referencing a registry and tag. The controller will need to:

GeorgeMac commented 1 year ago

Something like the following could also be preferable: https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md

This is the solo.io WASM format, that is compatible with docker build and push. That would make the tooling a lot easier to get going with. If you have Docker, it could just be a json file next to a wasm binary with a well-known name or configurable name in the well-known configuration file.