score-compose
score-compose copied to clipboard
[feature request] Support generic OCI image in `init --provisioners`
To complete https://github.com/score-spec/score-compose/pull/175, it would be great to support generic OCI image to import external provisioners.
https://opencontainers.org/
Example:
score-compose init --provisioners oci://...
Wondering if for this we could use the ORAS client:
- https://oras.land/
- https://github.com/oras-project/oras-go/blob/main/example_test.go
@mathieu-benoit how would that work? What would the archive format be inside the image and how would users create an image file with a single yaml file inside it?
Why is this better than just an https url?
Simple as:
oras push registry/name:tag my-provisioner.yaml
Then you can use it:
oras pull registry/name:tag
Or more embedded:
score-compose init --provisioners registry/name:tag
Why it's appealing? Because you now have your provisioners as OCI artifacts in your private secure artifact/container registry.
Not directly related, but I went through this full picture/story in a GitOps flow with Policies files, as an illustration: https://medium.com/p/e1233429ae2.
Ah ok I see so this is a common pattern used in oras 👍 .
So score-k8s init --provisioners oci://reg/name:tag would be fairly equivalent to
score-k8s init
oras pull oci://reg/name:tag --output .score-k8s
Thankfully looks like there's a useful go library here: https://github.com/oras-project/oras-go.
Cool @mathieu-benoit I think this is a good idea. Note that we MUST keep the oci:// or oras:// scheme prefix on the URI to unambiguate it.
Also note: This would import ALL the files from that oci reference: all provisioner files and possibility utility scripts as needed.
Yup, I think oci:// is the right approach, very generic, and that's what oras recommends too.
And yes, you can do this below to upload multiple files in a folder:
oras push registry/name:tag my-folder-container-files/
hey, since it's a good first issue, Can I try to fix it?
@7h3-3mp7y-m4n For sure, that sounds great! You can go ahead and assign the issue to yourself whenever you're ready to get started. If you have any questions in regards to the implementation @mathieu-benoit and @delca85 should be able to assist. Thanks a lot!
thanks @mathieu-benoit and @sujaya-sys I'll start working on this and I'll be happy if you folks could help me if I run into some confusion :)
@7h3-3mp7y-m4n, like discussed offline, the implementation of this needs to actually happen in the https://github.com/score-spec/score-go repo, see example here: https://github.com/score-spec/score-go/pull/45.
And then, we will be able to release a new version of score-go and include it here for this OCI support (and in score-k8s in the meantime ;)).
Thanks @mathieu-benoit :)
Good progress here, it's now in score-go 1.8.3: https://github.com/score-spec/score-go/releases/tag/v1.8.3.
We'll need to do the following things next in order to officially release this new feature:
- [X] Integrate
score-go1.8.3 inscore-compose: https://github.com/score-spec/score-compose/pull/194 - [X] Integrate
score-go1.8.3 inscore-k8s: https://github.com/score-spec/score-k8s/pull/63 - [x] Test/validate this new feature integrated in
score-compose'smain - [x] Test/validate this new feature integrated in
score-k8s'smain - [x] In https://github.com/score-spec/score-k8s/blob/main/main_init.go#L170 add the
oci://example: https://github.com/score-spec/score-k8s/pull/69 - [x] In https://github.com/score-spec/score-compose/blob/main/internal/command/init.go#L228 add the
oci://example: https://github.com/score-spec/score-compose/pull/196 - [x] In https://github.com/score-spec/docs/blob/main/content/en/docs/score%20implementation/score-compose/cli.md?plain=1#L52 add the
oci://example - [x] In https://github.com/score-spec/docs/blob/main/content/en/docs/score%20implementation/score-k8s/cli.md?plain=1, add the provisioner parameter missing here, like we have in
score-composedoc just above.
Out of scope for now (right?):
- We don't add associated unit test in
score-k8slike here: https://github.com/score-spec/score-k8s/blob/main/main_init_test.go#L128 - We don't add associated unit test in
score-composelike here: https://github.com/score-spec/score-compose/blob/main/internal/command/init_test.go#L234
Now implemented in https://github.com/score-spec/score-compose/releases/tag/0.20.0 and https://github.com/score-spec/score-k8s/releases/tag/0.1.15, with the integration of https://github.com/score-spec/score-go/releases/tag/v1.8.4. Closing now!