-
Notifications
You must be signed in to change notification settings - Fork 263
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
add git ops options #1122
add git ops options #1122
Conversation
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.
@itsmurugappan: 4 warnings.
In response to this:
Description
Adds Gitops mode where in the changes are made in a local directory instead of a remote cluster
Changes
- This PR only enables the option for kn service create/delete/update/list/describe
- Gitops client implementing the knservingclient interface
- Client injection is based on the command
- Tests pending
Need reveiwers input on the below
- When '--in-dir' flag is provided this mode is enabled
- Named the new client gitops client
Reference
Partially fixes #30
/hold
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
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.
Good start. Important feature. Thanks for starting 💯
@@ -68,7 +68,7 @@ func executeRevisionCommand(client clientservingv1.KnServingClient, args ...stri | |||
|
|||
output := new(bytes.Buffer) | |||
knParams.Output = output | |||
knParams.NewServingClient = func(namespace string) (clientservingv1.KnServingClient, error) { | |||
knParams.NewServingClient = func(namespace string, cmd *cobra.Command) (clientservingv1.KnServingClient, error) { |
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.
What about typing this CreateClient(...)
function type?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: itsmurugappan, maximilien The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@itsmurugappan sorry that I couldn't review it yet. This week is still crazy busy for me, but let me give it a quick review at least about the UX tomorrow. |
tests are passing and unit tests are added |
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.
Thanks a lot and sorry for the late reply.
I like the simplicity of the implementation but have some stylistic comment though.
There are probably some edge case, and we should "cleanup" the service from the empty / default value before writing it out (same as we do the for kn service apply
command)
Not sure about the name of the option though, and maybe we should allow also to operate on a single file (eg. with an option that points to a file instead of a directory).
The directory option is nice because it will allow to add other objects (e.g. from eventing) into the mix.
Let's discuss tomorrow the naming a bit, I need to sleep over it ;-)
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.
Except for the tmpdir calculation, looks good to me ! We still need to think about a proper option name, as I think that in-dir
is not descriptive enough.
What's about:
--offline-dir
(emphasizing that we are 'offline')--local-dir
(emphasizing that no cluster is used, but lacks an indication that its for the output)--target-dir
(emphasizing that it is generating something in the directory)
Or we could also have something like --offline
/ --local
together with the --target-dir
to make it even clearer that we:
- Don't connect to a cluster
- Create something in a target-dir. We could default to "." for the target dir if not given.
- Allows also to add later an
--target-file
which then would point to a single file to update.
Instead of target
we could also use output
(e.g. (--output-dir
, --output
(for a file) or --output-file
. However, --output
(or -o
) is already kind of occupied by the output format for the read-only commands, so I probably wouldn't reuse it in this context. (but --target
, --target-dir
would be also possible)
Finally we might think if the extra namespace directory level is needed. E.g do we expect to create many services across namespaces or is the major use case to create a single service or multiple services in the same namespace. Because if the latter is the case, we might first implement a single file argument --target mysvcl.yml
and later maybe add options for bulk operations.
wdyt ?
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.
Also, while trying it out, I think we need to tune the output message as this still is focussed on cluster-side creation. E.g. we see an empty URL (which is natural), and we might need to adapt / check certain output methods that they can work with an empty status:
field.
IMO having namespaces will have the following benefits
|
I like offline-dir |
My preferential list would be:
However, I wonder if we need to have
|
Yeah, I discussed this with @itsmurugappan on slack and my current preference would be And also I think we can use a single option for both modes that we might want to support: I think we should not create the top-level dir automatically and when we use So for the directory mode, we would require an existing directory (the structure within the directory can then be built up by us) For the file mode, we require a proper extension and create the file if needed. |
@rhuss @itsmurugappan +1 sounds well thought through. |
This pull request introduces 1 alert when merging 3fd6e3b into bfd1834 - view on LGTM.com new alerts:
|
The following is the coverage report on the affected files.
|
|
||
// AddGitOpsFlags adds flags to enable gitops mode | ||
func AddGitOpsFlags(flags *pflag.FlagSet) { | ||
flags.String("target", "", "work on local directory instead of a remote cluster") |
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.
A little formatting nit to align with the rest.
flags.String("target", "", "work on local directory instead of a remote cluster") | |
flags.String("target", "", "Work on local directory instead of a remote cluster.") |
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.
On a second thought I wonder if the message shouldn't be more descriptive/verbose. The following is just an example feel free to change or ignore it. :)
Create Knative resources in local directory or file instead of a remote cluster. Default mode is current directory, in addition path to custom directory or file extensions .yaml, .yml, .json are accepted.
@rhuss I recall you've mentioned the feature is experimental. Therefore we should add (experimental)
suffix at the end of description, right?
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.
Yes, we should mark it as experimental and we should definitely include it for 0.20
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.
To not lose to much time, lets merge this and create a followup PR to add the indication that this feature is experimental in a followup PR.
@itsmurugappan thanks a ton ! hope to jump on a next round of review tomorrow or the day after. End of the year is always crazy busy, but I will be there next week, too, when things are slowing down. So confident to get this landed within this year still ! |
/lgtm let's merge it now to get it into 0.20 and address the remaining minor issues (marking as "experimental" in the description in a new PR (which we should also merge right before 0.20) |
/unhold |
Description
Adds Gitops mode where in the changes are made in a local directory instead of a remote cluster
Changes
* Tests pendingNeed reveiwers input on the below
Reference
Partially fixes #30
/hold
cc @rhuss @navidshaikh @dsimansk @maximilien