incus
incus copied to clipboard
Add ability to read YAML from stdin to all `create` commands
Currently only incus create
and incus launch
will read YAML data from stdin to create a new instance (reading an InstancePut which gets embeded in the InstancePost struct).
The same logic should be supported for all other create
commands:
- [x] incus cluster group create
- [x] incus config template create
- [x] incus network acl create
- [x] incus network forward create
- [x] incus network integration create
- [x] incus network load-balancer create
- [x] incus network peer create
- [x] incus network zone create
- [x] incus network zone record create
- [x] incus profile create
- [x] incus project create
- [x] incus snapshot create
- [x] incus storage bucket create
- [x] incus storage bucket key create
- [x] incus storage create
- [x] incus storage volume create
- [ ] incus storage volume snapshot create
That list was based from a quick grep + some hand filtering, so there may be some entries where reading from stdin doesn't make sense.
I'd like to work on this issue, can it be assigned to me please!
sure, done!
Where can I find valid example config.yaml
files as reference for these?
@awalvie
Try to take a look at the --expanded
flag that is used with incus config show <instance> --expanded
If i read the docs correctly, it displays all information there is about the entity. It needs to get its information from somewhere, hopefully from an object, that is/exists for all entities.
This object then could be the source of truth to base all possible config keys from.
From my testing, it looks like, it is not implemented in every show
command.
So, implementing it for every show command, would be a thing to do in the future anyways.
@stgraber Correct me if i'm wrong.
Maybe we could add minimal example configs for each resource to the docs? In much the same way the kubernetes docs do? For example:
- https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment
- https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#example
Where can I find valid example
config.yaml
files as reference for these?
In general, the same data as you get from the matching show
command.
Maybe we could add minimal example configs for each resource to the docs? In much the same way the kubernetes docs do? For example:
https://linuxcontainers.org/incus/docs/main/rest-api-spec/
This has example values for all the objects, it's not the best looking thing ever but it doesn't need to be manually updated.
@stgraber incus snapshot create
uses an exiting instance
so does it make sense to allow creation of a snapshot
via a config yaml?
@awalvie the user would still provide the instance and snapshot names but there can still be modifiable fields within a snapshot (see InstanceSnapshotPut), currently that's just the expiry date (ExpiresAt).
@stgraber are there any configuration options for incus config template create
? I couldn't find a api
PUT
object or in the API spec.
PS. Could we check off other items from the original list please! Easier to keep track on what's been done :p
That one is indeed a file API so no struct, stdin should be the file we upload instead.
@stgraber Can you also mark off:
- incus network acl create
- incus profile create
Might've missed them with so many PRs!
@stgraber For incus storage volume snapshot create
, there doesn't seem to be a Put
struct for api.StorageVolumeSnapshots
api.StorageVolumeSnapshotPut
should be it, no?
ah, crap, ripgrep didn't show it in vim for some reason, I see it now!
It doesn't seem to follow the same pattern of embedding though. In this case StorageVolumeSnapshot
embeds StorageVolumeSnapshotPut
instead of StorageVolumeSnapshotPost
I'm confused, the exact same is true of InstanceSnapshot embedding InstanceSnapshotPut, am I missing something?
@awalvie any luck with that last one?
Sorry about the delay, was out on vacation the past week, I'll get back here shortly!
Oh, yup, my bad, the way I phrased it was unclear.
In the current Run()
function for cmdStorageVolumeSnapshotCreate
:
https://github.com/lxc/incus/blob/73914201345e8763566aa1e2a1d3ebcc60480a19/cmd/incus/storage_volume.go#L2337
We create a req
object of the type StorageVolumeSnapshotsPost
(with an extra s) and use that during the creation of the volume snapshot in CreateStoragePoolVolumeSnapshot
.
If I do read the data from stdin into an object of the type StorageVolumeSnapshotPut
I'm having a hard time understanding where to embed that struct. There's only StorageVolumeSnapshot
but we don't use that object in the function as far as I can tell.
https://github.com/lxc/incus/pull/891 is basically a copy/paste from incus/snapshot.go
and seems to work.
https://github.com/lxc/incus/pull/891 is basically a copy/paste from
incus/snapshot.go
and seems to work.
Oh, yeah, I see it now. My brain got confused for some reason. Thank You!