feat: differentiate simple/advanced API for fabrica payloads - #131
Conversation
Implement API changes from OpenCHAMI/fabrica#64. Add --envelope flag to fabrica resource commands to allow the user to specify additional metadata that envelops the spec, which contains the actual data. By default (without --envelope), the payload is just the spec and additional metadata is ignored. Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
|
I need to refactor this a bit due to some potential confusion arising from the current simple-vs-advanced API data structure (see https://github.com/OpenCHAMI/ochami/pull/131/changes/BASE..ee8d4d1a4457f7c7ee1fe2d1126bcc2fe5bfd303#r3676368580). |
Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
|
@davidallendj I've refactored the code so that the simple API only accepts the spec (without having to specify |
|
Alright, let me have another look at it. |
|
This works how I would expect it to and fails with a validation error when trying to use the simple API to add and works when the [rocky@openchami-testing ochami]$ ./ochami metadata defaults add -d@/etc/openchami/data/cloud-init/ci-defaults.yaml
2026-07-30T17:58:54Z ERR add.go:151 > failed to add cluster defaults error="failed to add cluster defaults \"\" ({Description: BaseURL: CloudProvider: Region: AvailabilityZone: ClusterName: ShortName: NidLength:0 PublicKeys:[]}): API error (400): validation failed: base_url is required; cluster_name is required"
2026-07-30T17:58:54Z ERR cli.go:652 > see 'ochami metadata defaults add --help' for long command help
2026-07-30T17:58:54Z WRN add.go:166 > Cluster defaults addition completed with errors
[rocky@openchami-testing ochami]$ ./ochami metadata defaults add -e -d@/etc/openchami/data/cloud-init/ci-defaults.yamlHere is the file contents that are used in the commands above. [rocky@openchami-testing ochami]$ cat /etc/openchami/data/cloud-init/ci-defaults.yaml
{
"spec": {
"base_url": "http://172.16.0.254:8081/cloud-init",
"cluster_name": "demo",
"nid-length": 2,
"public-keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPhN/tcp4FPcZtym/yvDpeGdbCr0mMH0gA7ULBE1m7sk rocky@openchami-testing.novalocal"
],
"short-name": "de"
}
}I tried the simple version again with removing the [rocky@openchami-testing ochami]$ ./ochami metadata defaults add -d@/etc/openchami/data/cloud-init/ci-defaults.simple.yaml
[rocky@openchami-testing ochami]$ cat /etc/openchami/data/cloud-init/ci-defaults.simple.yaml
{
"base_url": "http://172.16.0.254:8081/cloud-init",
"cluster_name": "demo",
"nid-length": 2,
"public-keys": [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPhN/tcp4FPcZtym/yvDpeGdbCr0mMH0gA7ULBE1m7sk rocky@openchami-testing.novalocal"
],
"short-name": "de"
}I tried adding the simple data format using the advanced API with [rocky@openchami-testing ochami]$ ./ochami metadata defaults add -e -d@/etc/openchami/data/cloud-init/ci-defaults.simple.yaml
2026-07-30T18:08:21Z ERR add.go:151 > failed to add cluster defaults error="failed to add cluster defaults {Metadata:{Name: UID: Labels:map[] Annotations:map[] CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC} Spec:{Description: BaseURL: CloudProvider: Region: AvailabilityZone: ClusterName: ShortName: NidLength:0 PublicKeys:[]} Labels:map[] Annotations:map[]}: API error (400): validation failed: base_url is required; cluster_name is required"
2026-07-30T18:08:21Z ERR cli.go:652 > see 'ochami metadata defaults add --help' for long command help
2026-07-30T18:08:21Z WRN add.go:166 > Cluster defaults addition completed with errors |
davidallendj
left a comment
There was a problem hiding this comment.
Code changes looks good, works like expected, and all tests passed.
Description
Implement API changes from OpenCHAMI/fabrica#64.
Add
--envelopeflag to fabrica resource commands to allow the user to specify additional metadata that envelops the spec, which contains the actual data. By default (without--envelope), the payload is just the spec and additional metadata is ignored.Fixes #115
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryType of Change
For more info, see Contributing Guidelines.