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

Specify a local file on disk for the function store #984

Open
alexellis opened this issue Oct 24, 2023 · 6 comments · May be fixed by #985
Open

Specify a local file on disk for the function store #984

alexellis opened this issue Oct 24, 2023 · 6 comments · May be fixed by #985

Comments

@alexellis
Copy link
Member

Expected Behaviour

I'd like to be able to specify a local file on disk for the function store to test out definitions before publishing them on GitHub.

Current Behaviour

I can test any HTTP url via --url, but not a local file via a flag.

Why do you need this?

Better testing experience and contributing experience.

Which Solution Do You Recommend?

A new flag perhaps, or a url like file://. I think a flag fits better with the intuitive developer experience of a UNIX CLI.

Steps to Reproduce (for bugs)

  1. git clone https://github.com/openfaas/store-functions && cd store-functions
  2. faas-cli store deploy --file ./functions.json
  3. See an error
@LucasRoesler
Copy link
Member

I think the cleanest solution is to support the file:// scheme or to treat scheme-less urls as local paths.

@alexellis
Copy link
Member Author

file:// is the easiest solution, but not the cleanest.

It's confusing vs. faas-cli deploy -f / --yaml local-file, and many other tools people are used to like "kubectl" work with "kubectl apply -f https://andkuebctl apply -f ./some-local-file.yaml`

A mix of the two might work. --url with a local path, with or without a file:// scheme could be accepted and resolve to a local file if it looks like one.

@LucasRoesler
Copy link
Member

Maybe move from --url to a more generic --store which supports local files or a url, like kubectl and others.

Then add a flag alias from --store to --url for backwards compat and then convert all docs to only reference --store. It is also possible to make --url hidden so that it is supported but doesn't show in the cli --help

@alexellis
Copy link
Member Author

I think that could work 👍

Are you interested in contributing it?

@rgee0
Copy link
Contributor

rgee0 commented Oct 24, 2023

Lucas' approach but treading carefully with the word in the new flag.

faas-cli store deploy figlet --store ./functions.json

jars slightly because the same word is a command and a flag. Ultimately, however the file is retrieved its a file:

faas-cli store deploy figlet --file ./functions.json

and

faas-cli store deploy figlet --file https://raw.githubusercontent.com/openfaas/store/master/functions.json

Side note: From a UX / PO perspective I'd suggest that faas-cli template store mirrors whatever behaviour is settled on here

@LucasRoesler
Copy link
Member

Sure I can do this.

Good point by @rgee0, I originally thought file or url was a bit like showing the details of how it works, but it probably isn't an issue here. It is not likely to be the most popular flag in the CLI :) I will stick with --file

@LucasRoesler LucasRoesler linked a pull request Oct 29, 2023 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants