Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to read YAML from stdin to all create commands #741

Closed
16 of 17 tasks
stgraber opened this issue Apr 8, 2024 · 22 comments · Fixed by #891
Closed
16 of 17 tasks

Add ability to read YAML from stdin to all create commands #741

stgraber opened this issue Apr 8, 2024 · 22 comments · Fixed by #891
Assignees
Labels
Easy Good for new contributors Feature New feature, not a bug
Milestone

Comments

@stgraber
Copy link
Member

stgraber commented Apr 8, 2024

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:

  • incus cluster group create
  • incus config template create
  • incus network acl create
  • incus network forward create
  • incus network integration create
  • incus network load-balancer create
  • incus network peer create
  • incus network zone create
  • incus network zone record create
  • incus profile create
  • incus project create
  • incus snapshot create
  • incus storage bucket create
  • incus storage bucket key create
  • incus storage create
  • 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.

@stgraber stgraber added Feature New feature, not a bug Easy Good for new contributors labels Apr 8, 2024
@stgraber stgraber added this to the soon milestone Apr 8, 2024
@awalvie
Copy link
Contributor

awalvie commented Apr 8, 2024

I'd like to work on this issue, can it be assigned to me please!

@stgraber
Copy link
Member Author

stgraber commented Apr 8, 2024

sure, done!

@awalvie
Copy link
Contributor

awalvie commented Apr 9, 2024

Where can I find valid example config.yaml files as reference for these?

@rvveber
Copy link

rvveber commented Apr 9, 2024

@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.

@awalvie
Copy link
Contributor

awalvie commented Apr 9, 2024

Maybe we could add minimal example configs for each resource to the docs? In much the same way the kubernetes docs do? For example:

@stgraber
Copy link
Member Author

stgraber commented Apr 9, 2024

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.

@stgraber
Copy link
Member Author

stgraber commented Apr 9, 2024

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 pushed a commit to awalvie/incus that referenced this issue Apr 16, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
awalvie added a commit to awalvie/incus that referenced this issue Apr 17, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
@awalvie
Copy link
Contributor

awalvie commented Apr 17, 2024

@stgraber incus snapshot create uses an exiting instance so does it make sense to allow creation of a snapshot via a config yaml?

@stgraber
Copy link
Member Author

@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).

awalvie added a commit to awalvie/incus that referenced this issue Apr 17, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit to awalvie/incus that referenced this issue Apr 17, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
awalvie added a commit to awalvie/incus that referenced this issue Apr 18, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
awalvie added a commit to awalvie/incus that referenced this issue Apr 20, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit to awalvie/incus that referenced this issue Apr 20, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
awalvie added a commit to awalvie/incus that referenced this issue Apr 22, 2024
Part of lxc#741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
@awalvie
Copy link
Contributor

awalvie commented Apr 23, 2024

@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

@stgraber
Copy link
Member Author

That one is indeed a file API so no struct, stdin should be the file we upload instead.

@awalvie
Copy link
Contributor

awalvie commented May 13, 2024

It doesn't seem to follow the same pattern of embedding though. In this case StorageVolumeSnapshot embeds StorageVolumeSnapshotPut instead of StorageVolumeSnapshotPost

@stgraber
Copy link
Member Author

I'm confused, the exact same is true of InstanceSnapshot embedding InstanceSnapshotPut, am I missing something?

@stgraber stgraber modified the milestones: soon, incus-6.2 May 22, 2024
@stgraber
Copy link
Member Author

@awalvie any luck with that last one?

@awalvie
Copy link
Contributor

awalvie commented May 23, 2024

Sorry about the delay, was out on vacation the past week, I'll get back here shortly!

@awalvie
Copy link
Contributor

awalvie commented May 23, 2024

Oh, yup, my bad, the way I phrased it was unclear.

In the current Run() function for cmdStorageVolumeSnapshotCreate:

func (c *cmdStorageVolumeSnapshotCreate) Run(cmd *cobra.Command, args []string) error {

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.

stgraber added a commit to stgraber/incus that referenced this issue May 23, 2024
Closes lxc#741

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
@stgraber
Copy link
Member Author

#891 is basically a copy/paste from incus/snapshot.go and seems to work.

stgraber added a commit to stgraber/incus that referenced this issue May 23, 2024
Closes lxc#741

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
@awalvie
Copy link
Contributor

awalvie commented May 24, 2024

#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!

stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
`incus network acl create` already has support for creation from a yaml
configuration file, but the same wasn't printed in the usage information
of the command.

This commit updates `incus network acl create` to show example text for
`incus network acl create`

Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
incus network forward create` already has support for creation from a
yaml configuration file, but the same wasn't printed in the usage
information of the command.

This commit updates `incus network forward create` to include an example

Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
incus storage bucket create already has support for creation from a yaml
configuration file, but the same wasn't printed in the usage information
of the command.

This commit updates `incus storage bucket create` to include an example.

Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
incus network peer create already has support for creation from a
yaml configuration file, but the same wasn't printed in the usage
information of the command.

This commit updates `incus network peer create` to include an example.

Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber pushed a commit that referenced this issue May 27, 2024
Part of #741

Signed-off-by: Vishesh Agrawal <agrawal.vishesh.178@gmail.com>
stgraber added a commit that referenced this issue May 27, 2024
Closes #741

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Good for new contributors Feature New feature, not a bug
Development

Successfully merging a pull request may close this issue.

3 participants