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

List of available melange Pipelines #172

Open
ArnobKumarSaha opened this issue Nov 16, 2022 · 7 comments
Open

List of available melange Pipelines #172

ArnobKumarSaha opened this issue Nov 16, 2022 · 7 comments

Comments

@ArnobKumarSaha
Copy link

I was looking for a complete list of the action-names that we use in the pipeline.uses in melange files (For example: https://github.com/wolfi-dev/os/blob/main/bash.yaml#L42-L44), but didn't find any.

Even the docs has not specified anything. Is there any resources available on it ?

@tuananh
Copy link
Contributor

tuananh commented Nov 16, 2022

@ArnobKumarSaha
Copy link
Author

Thanks for the quick response @tuananh.
I missed this package somehow!!

@imjasonh
Copy link
Member

I think it would be useful to have some commands like melange pipelines list, melange pipelines get split/dev, etc. to inspect the built-in pipelines from the commandline. Shouldn't be too hard to do either, if anybody's interested I can help.

@ArnobKumarSaha
Copy link
Author

@imjasonh That sounds awesome!! I am interested to do that. Guide me please.

@imjasonh
Copy link
Member

To add a new command, add a new cmd.AddCommand(Pipelines()) here: https://github.com/chainguard-dev/melange/blob/main/pkg/cli/commands.go#L33

Create pkg/cli/commands/pipelines.go. Take inspiration from sign.go -- it returns a cmd which specifies a RunE which gets called when the command is called. In this case, melange pipelines doesn't actually do anything, so its RunE should fail.

func Pipelines() *cobra.Command {
	cmd := &cobra.Command{
		Use:     "pipelines",
		Short:   "Commands for inspecting pipeline definitions",
		Args:    cobra.NoArgs,
		RunE: func(cmd *cobra.Command, args []string) error {
			return errors.New("must call get or list")
		},
	}
	cmd.AddCommand(list())
	cmd.AddCommand(get())
	return cmd
}

func list() *cobra.Command {
	//same as above, with a RunE that lists available pipelines.
}

To list pipelines, we need some method to inspect the contents of the embedded filesystem available here:

var f embed.FS

To list files, call f.ReadDir("pipelines/") (I think) to get entries. Each available pipeline is named after its path, so fetch.yaml is fetch, and split/dev.yaml is split/dev, and so on.

That should be enough to list available pipelines for melange pipelines list.

For melange pipelines get <name> it's pretty much the same, except once you find a pipeline with that name you need to read it and print it out. If no pipeline is found with that name (melange pipelines get does-not-exist) then return an error.

Let me know if there's anything else I can help with, I'd love to see this work, and I think it would be a helpful addition to the tool.

@ArnobKumarSaha
Copy link
Author

Hi @imjasonh , I was going to start. But seems like, @tuananh is already working on this. Have a check on his pr #165 .

@mritunjaysharma394
Copy link
Contributor

Hello folks, I see that the PR #165 of @tuananh is closed and if no one is actively working on it, I would love to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants