plexsystems/sinker

[Feature] Support update manifest from List type

Closed this issue · 8 comments

For example, I would like to be able to run something like:

kubectl deploy,ds,statefulset -A -oyaml > all.yaml
sinker update all.yaml

This would enable generating a manifest from all the objects in a cluster.

The list format is something like this

apiVersion: v1
items:
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:

@sudermanjr I think this is reasonable, the changes would be minimal anyway. This has similarities to #20.

How important is driving update from a List type in your workflow? I've had plans to support lists of images like what you're asking for, but just based on some delimiter.

For example you could do:

$ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}"

Which returns a list of all images, and then Sinker could take input from Stdin

$ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | sinker update -

(or even a text file if so desired, similar to the list command that's already provided)

$ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" > images.txt
$ sinker update images.txt

@sudermanjr support for standard input has been added via https://github.com/plexsystems/sinker/pull/24/files -- that functionality is now in main.

This enables calling Sinker like so:

(create)

$ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | ./sinker create - --target repo

(update)

$ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" | ./sinker update -

I'm still open to adding metav1.List as an input, but am holding off to see if this satisfies your requirements.

Documentation updated and some additional verification to prefer using hosts found in the manifest before trying to figure it out. https://github.com/plexsystems/sinker/pull/25/files

That would work for sure. I think think it would be convenient to support kubectl get po -A -oyaml | sinker, just because I'm lazy. Not a requirement, but a nice to have.

@sudermanjr Understood, I'm not completely against the idea. The core functionality all revolves around registry paths, so as long as we get to that point, supporting a large number of inputs shouldn't add too much complexity. I'll most likely take a stab at implementing this over the weekend.

When you have a moment could you verify if the current functionality on main behaves as you expect using standard in?

Standard input has been released in 0.11.0

https://github.com/plexsystems/sinker/releases/tag/v0.11.0

When you have a moment could you verify if the current functionality on main behaves as you expect using standard in?

I was out all last week, so I wasn't able to look. Thanks again for the quick implementation!

No problem! Hope it works out for you :)