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
src(commands): remove --path flag from most commands #125
Conversation
This commit removes the `--path -p` flag for the build, delete, deploy, describe, run and update commands. The init and create commands have been left alone for now, pending the outcome of knative#123. The list command doesn't need to know a path, because it's about seeing all deployed Functions. Adds a `faas.LoadFunction(path string)` function to load an existing Function project from disk and return an error if one does not already exist.
deleteCmd.Flags().StringP("namespace", "n", "", "Override namespace in which to search for Functions. Default is to use currently active underlying platform setting - $FAAS_NAMESPACE") | ||
} | ||
|
||
var deleteCmd = &cobra.Command{ | ||
Use: "delete <name>", | ||
Use: "delete", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not allow to delete function by name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually, the idea that this PR puts forward is that without a --path
flag, all commands must be run from within a project directory where for all commands, there is a configuration file .faas.yaml
that describes the context, and the commands run within this context.
Related... the delete
command almost seems unnecessary to me, since this is already possible with kn
, and our ultimate intent is to embed these commands inline in our kn
distro. I considered removing it entirely, considering kn service delete <service-name>
does exactly the same thing as kn faas delete
.
With both of these scenarios in mind, today @rhuss and I discussed the potential for the project configuration file to move into upstream. If that happens, then it would be kn service delete
and kn faas delete
doing exactly the same thing and that really seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kn service delete and kn faas delete doing exactly the same thing
Yes they practically are same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed the potential for the project configuration file to move into upstream.
Not sure what this mean, what conf file, what upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this mean, what conf file, what upstream?
The .faas.yaml
file, moving to something like .kn.yaml
in knative/client to generically describe a Knative project.
@@ -28,18 +27,26 @@ func init() { | |||
} | |||
|
|||
var describeCmd = &cobra.Command{ | |||
Use: "describe <name> [options]", | |||
Use: "describe [options]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't be I able to ask for description of function by name (which is not in cwd)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically for the same reasons I wrote in my comment above about delete
. I think describe
is another candidate for removal because how is kn service describe <service-name>
any worse than kn faas describe
? And again, if config moves upstream, then kn service describe
=== kn faas describe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kn service describe === kn faas describe
Not exactly same, faas
has slightly different formatting and it also pulls info about subscriptions/triggers which kn
doesn't IIRC, am I right @rhuss?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kn
has separate sub-command for subscriptions/triggers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly same, faas has slightly different formatting and it also pulls info about subscriptions/triggers which kn doesn't
Fair point. Let's discuss all of these commands in #126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If there is a compelling reason to remove this flag, I am all for agreeing, but I beleve there is a compelling reason it was added in the first place, which I will present below: The reason for the path flag is primarily to support users who would like to script their usage of the The idea of the --path flag is to run the command as if the command had been run from within that directory. I believe this to be a valid and quite helpful use case. Furthermore, by providing this flag as a configuration parameter, we ensure that this variable is explicitly provided in the client API. By removing it we run the risk of the client library thinking it can sample the current working directory willy-nilly, which could cause problems when used as a library in multi-threaded applications which legitimately change directories during operation. So If this flag is only being removed to enforce that the client user is running the command from within the directory, I actually would have to disagree. Commands should take their effective directory as an explicit input, which can be defaulted to the current working directory. I hope that adequately presents the case for the existence of this flag, but am happy to capitulate with but a modicum of pushback! |
// OverrideImage overwrites (or sets) the value of the Function's .Image | ||
// property, which preempts the default functionality of deriving the value as: | ||
// Deafult: [config.Repository]/[config.Name]:latest | ||
func (f Function) OverrideImage(image string) error { | ||
if image == "" { | ||
return nil | ||
} | ||
f.Image = image | ||
return f.WriteConfig() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, in casd you are wondering why this function was in the CLI codebase not the "core" logic: it was because this overriding is specifically an override of that image prior to the invocation of the client. In away mutating the state of the function prior to actually invoking the client. This is a way to provide the ability to override the image name via a flag without "muddying up" the client library such that it can instead always trust what is in .faas.yaml.
Marking as a draft for now and may rework some of this. @zroubalik will stalling this affect #127? |
@zroubalik check out #128. I think we can use that to iterate on what the CLI behavior should be, with concrete descriptions, etc. I've written it to reflect how the CLI behaves today with the exception of |
This commit removes the
--path -p
flag for the build, delete, deploy,describe, run and update commands. The init and create commands have been
left alone for now, pending the outcome of #123.
The list command doesn't need to know a path, because it's about seeing
all deployed Functions.
Adds a
faas.LoadFunction(path string)
function to load an existing Functionproject from disk and return an error if one does not already exist.
Note: I realize this might be controversial. Speak up if you disagree with this proposal!
Edit: The idea here is to enforce the notion that all commands (other than
init
andcreate
) are run from within a Function project directory where the configuration file.faas.yaml
defines the context. Some of the comments from @matejvasek identified areas where functionality has been reduced - e.g. you can't describe or delete a function by name. I think we should actually consider removing these, and possibly even consider removingfaas deploy
andfaas update
.BREAKING CHANGE