Replies: 1 comment 1 reply
-
|
@olblak 👋🏻 I'm trying to solve the following need: I want to generate SDKs for every version of an OpenAPI spec living an upstream repository. I have been looking at the problem from multiple angles and landed on the option of building this as custom UpdateCLI autodiscovery plugin. My aim is to (sort of) replay the various releases from the upstream location into a git repository which will hold the generated SDK sources. The process implemented in my custom plugin would try to enumerate from the oldest version instead of the most recent one which seems to be the default in a number of plugins currently. So here is how I would implement this:
The upstream location could have a major version and some maintenance releases active in parallel. Hence, the commit and tag needs to be done on the correct branch:
Such a specific workflow is a good candidate for a custom external UpdateCLI plugin. But to implement this, I would very much like to reuse a lot of the functionality. I investigated the current architecture and found the current archicture lacking for the usecase I want to implement. For instance, to implement step 1 of my process, fetching the existing versions, I can import Go code from the UpdateCLI repository, but I would rather not. Main reason is that I would need to import all the code for the various upstream locations I want to support, like git tags, github releases, gitlab releases and so on. It would lead to a very wide "interface" on my autodiscovery plugins to pass the required config properties for the various options. As an example, you see that already happening on the # updatecli.d/npm-private.yaml
autodiscovery:
crawlers:
npm:
rootdir: "."
# URL of your private npm registry
url: "https://npm.example.com"
# Authentication token (use environment variables for security)
registrytoken: "${NPM_TOKEN}"
# Optional: path to custom .npmrc file
npmrcpath: "/path/to/.npmrc"
versionfilter:
kind: semver
pattern: ">=1.0.0"Source: https://www.updatecli.io/docs/plugins/autodiscovery/npm/#_private_registry_example The current split in updatecli/pkg/plugins/scms/github/pullrequest.go Lines 3 to 12 in d3152a8 ProposalWhile my first aim is to solve the reusability of existing functionality for custom autodiscovery plugins, the proposal here is broader but will (in my opinion) result in a much more fluent design. If I want to reuse existing resources within the implementation of an autodiscovery plugin (bundled or external), I would like to use a preconfigured resource. If I take the resources:
example_registry:
name: Get latest axios version from npm registry
kind: npm
spec:
# URL of your private npm registry
url: "https://npm.example.com"
# Authentication token (use environment variables for security)
registrytoken: "${NPM_TOKEN}"
# Optional: path to custom .npmrc file
npmrcpath: "/path/to/.npmrc"
autodiscovery:
crawlers:
npm:
registry: example_registry
rootdir: "."
versionfilter:
kind: semver
pattern: ">=1.0.0"This reuses already a lot of the Now comes the biggest change, which I'm conceptually taking from Concourse CI: resource types. I propose an UpdateCLI plugin (bundled or external) to become a resource type. A resource type implementation can expose what it can be used for:
A resource can be created under the resources:
my_ghe_codebase:
name: My codebase on Github Enterprise
kind: github
spec:
# URL of your Github Enterprise endpoint
# optional, defaults to https://api.github.com
url: "https://api.mycompany.ghe.com"
# Authentication token (use environment variables for security)
token: "${GITHUB_TOKEN}"
# Github owner
owner: "me"
# Repository to use
repository: "mycodebase"A resource type can expose more than one instance of each of the concepts above. For example, for the Github plugin, which works via the Github REST API, there would be various features offered for the core UpdateCLI concepts:
The benefit towards the code structure is that you would only have a single Using this resource in a pipeline would now be more like: scms:
default:
kind: github
spec:
resource: my_ghe_codebaseEach of these resources should be passable to an autodiscovery plugin when their implementation allows it: autodiscovery:
crawlers:
my_discovery:
# pass a github resource allowing me to fetch github releases
github: my_ghe_codebase
# other attributes...If a plugin can expose different concepts, an external WASM plugin would not only be able to implement autodiscovery functionality, but it would also be able to offer custom resource types out-of-tree to the UpdateCLI repository. Open Issues
Closing remarks
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This discussion is about getting feedback on the Updatecli external autodiscovery plugin feature.
It's still experimental, and we need as much feedback as possible to confidently move it to stable without future breaking changes
Problem
Defining update strategies in YAML is convenient, saves time, and helps teams collaborate. But when update rules grow complex, a small DSL can become limiting. Recently, we explored using WASM to let teams write manifest generators in the language they prefer. The feature is still experimental, and we welcome feedback from teams with complex update scenarios.
Solutions
Plugins can be written in any language that compiles to WebAssembly (WASM). We explored using the Extism framework.
We implemented on the Updatecli side this pull request:
And an example of a custom plugin named demo.
A plugin must export the function
_start(WASI). It is expected to receive a JSON object as input and return a JSON object containing the generated Updatecli manifests.Input
A plugin receives a JSON object with the following fields:
{ "scmid": "default", "actionid": "default", "rootdir"": "current directory" "spec": { "plugin_param1": "", "plugin_param2": "" } }The
scmidfield is provided by Updatecli, it's up to the plugin maintainer to decide how to use that information, but typically it's used to link resources to a scm configuration specified in the Updatecli manifest.The
actionidfield is provided by Updatecli, it's up to the plugin maintainer to decide how to use that information but typically it's used to specify an action title.The
specfield is the plugin parameters detected by Updatecli.Output
A plugin must output a JSON object such as
{ "manifests": [ "Updatecli manifest 1", "Updatecli manifest 2" ] }Where
manifestscontains the list of generated Updatecli manifestsGuidelines:
versionfield in generated manifests to indicate the minimum Updatecli version required.pipelineidin generated manifests (Updatecli overrides it).Improvement
Beta Was this translation helpful? Give feedback.
All reactions