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

[feature request] Add a new score-compose provisioners list command #237

Open
mathieu-benoit opened this issue Jan 13, 2025 · 16 comments · May be fixed by #252
Open

[feature request] Add a new score-compose provisioners list command #237

mathieu-benoit opened this issue Jan 13, 2025 · 16 comments · May be fixed by #252
Assignees
Labels
enhancement New feature or request go Pull requests that update Go code good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mathieu-benoit
Copy link
Contributor

mathieu-benoit commented Jan 13, 2025

Add a new score-compose provisioners list command generating in the output this table or a more advanced/detailed version with -o json: https://docs.score.dev/docs/score-implementation/score-compose/resources-provisioners/.

  • It's not something in score-go as it's specific to each implementation.
  • This should list the overriden provisioners imported via the score-compose init --provisioners command
@mathieu-benoit mathieu-benoit added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed go Pull requests that update Go code labels Jan 13, 2025
@astromechza
Copy link
Member

Can I rather recommend we use score-compose provisioners list instead and look at moving the --provisioners flag over to score-compose provisioners add in future?

@mathieu-benoit
Copy link
Contributor Author

score-compose provisioners list is better, updating this ticket accordingly.

Fo score-compose provisioners add, good idea, but it will be another dedicated ticket.

@mathieu-benoit mathieu-benoit changed the title [feature request] Add a new score-compose resources available-provisioners command [feature request] Add a new score-compose provisioners list command Jan 15, 2025
@lekaf974
Copy link
Contributor

@mathieu-benoit I could give it a try

@mathieu-benoit
Copy link
Contributor Author

That would be awesome! If you have any questions while implementing this, please do let us know. There is a #score-dev channel in the CNCF Slack for this purpose.

@lekaf974
Copy link
Contributor

Have a question related to array to display, currently after running score-compose init --provisioners <rprovisioners source> --project <project name> I am seeing the Z-xxx.xxxx.provisioners.yaml is created.
The array have 4 headers type, class, params, output

From this file I can easily extract type and output, I see that params will need a little more work but nothing reallay hard. Finally it is for the class header I am not sure where it is defined and I did not found any documentation that describe this field. Could you give me some guidance here ?

@mathieu-benoit
Copy link
Contributor Author

mathieu-benoit commented Jan 19, 2025

Good question, it's not yet well documented for this part, I'll add a note to this one score-spec/docs#121 to make sure we'll document this properly.

In the meantime, here is the tl,dr about class:

apiVersion: score.dev/v1b1
metadata:
  name: my-workload
containers:
  my-container:
    image: .
resources:
  dns:
    type: dns
    class: public # optional, default if omitted
  route:
    type: route
    params:
      host: ${resources.dns.host}
      path: /
      port: 8080
service:
  ports:
    tcp:
      port: 8080
      targetPort: 8080

Hope this helps for more context?

@lekaf974
Copy link
Contributor

Think I got it so basically if the field class is not specified I can assume it is default ?

@astromechza
Copy link
Member

@lekaf974 @mathieu-benoit actually a small clarrification!

If the provisioner doesn't specify a class, it will match ALL classes. Same with the id parameter.

So a provisioner for type: postgres, class: "", will still be able to provision a resource with type: postgres, class: advanced.

@mathieu-benoit
Copy link
Contributor Author

If the provisioner doesn't specify a class, it will match ALL classes.

Thanks for the clarification, @astromechza. But just to make sure about that:

Think I got it so basically if the field class is not specified I can assume it is default ?

So score-compose provisioners list will display default if no class has been provided in the provisioner, right?

@lekaf974
Copy link
Contributor

Thanks you for feedback to you.

Having a look deeper in the code, did not found existing code that I can reuse or I missed something @astromechza could you give an advice ?

My first idea is to loop on all Z-xx.xxx.providers.yaml files in .score-compose does it make sense ?

@mathieu-benoit
Copy link
Contributor Author

@lekaf974
Copy link
Contributor

lekaf974 commented Jan 21, 2025

What about LoadProvisioners in there? https://github.com/score-spec/score-compose/blob/main/internal/provisioners/loader/load.go

Used here as an example: https://github.com/score-spec/score-compose/blob/main/internal/command/generate.go#L216

Tried this way but it returns this interface which does not expose the required information

type Provisioner interface {

From what I have seen looks this struct contains the required data

type Input struct {
but did not yet find how I can do it

@astromechza
Copy link
Member

astromechza commented Jan 21, 2025

@lekaf974 modify the interface to expose the type, class, id as well.

@mathieu-benoit no the class should be displayed as "*" or "any" rather than "default" if it is blank or not specified.

@mathieu-benoit
Copy link
Contributor Author

no the class should be displayed as "*" or "any" rather than "default" if it is blank or not specified.

Gotcha, makes sense with (any) like we have (none) for the params, updating the docs accordingly for consistency:

@lekaf974
Copy link
Contributor

thanks will update interface

@lekaf974 lekaf974 linked a pull request Jan 24, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants