-
Notifications
You must be signed in to change notification settings - Fork 135
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
Fix #377: Removing name flag from the tink template create/update command #385
Conversation
Codecov Report
@@ Coverage Diff @@
## master #385 +/- ##
=======================================
Coverage 33.08% 33.08%
=======================================
Files 24 24
Lines 2170 2170
=======================================
Hits 718 718
Misses 1376 1376
Partials 76 76 Continue to review full report at Codecov.
|
This is a BC break and I think we should take this opportunity to carefully review our UX. This is what I mean in practice: |
That's the reason why we had to use |
Thank you for clarifying @gauravgahlot but my point is the same: hardware use Should we use the same one? 👍 👎 |
Oh yes totally. Initially, we had thought of removing |
Never say to me that something is required for ONE single company.. :) but yeah for now I think we should use |
cmd/tink-cli/cmd/template/create.go
Outdated
filePath string | ||
templateName string | ||
) | ||
|
||
type TemplateName struct { |
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.
Should not be an exported type.
cmd/tink-cli/cmd/template/create.go
Outdated
// createCmd represents the create subcommand for template command | ||
var createCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "create a workflow template ", | ||
Example: `tink template create [flags] | ||
cat /tmp/example.tmpl | tink template create -n example`, | ||
cat /tmp/example.tmpl | tink template create `, |
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.
Can we please add more examples in the Long
description?
For reference, you can check tink events watch
.
cmd/tink-cli/cmd/template/create.go
Outdated
templateName = templ.Name | ||
return nil | ||
} | ||
return errors.New("Template does not have `name` field which is mandatory") |
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.
Please move all the error messages to a const
block and ensure they all start with a lower case.
name
flag from the 'tink template create/update' command
Facility is only really used for the cert generation stuff, something I'd actually like to get rid of. Let me open up an issue for that (#389). |
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.
Great, @parauliya do you mind changing -p
with --file
and we are good? Thanks
cmd/tink-cli/cmd/template/create.go
Outdated
var templ TemplateName | ||
err := yaml.Unmarshal([]byte(data), &templ) | ||
if err != nil { | ||
return err | ||
} | ||
if templ.Name != "" { | ||
templateName = templ.Name | ||
return nil | ||
} | ||
return errors.New("Template does not have `name` field which is mandatory") |
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.
This should use github.com/tinkerbell/tink/workflow.Parse
instead.
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.
This is a bc break, according with the proposal 0011 https://github.com/tinkerbell/proposals/blob/master/proposals/0011/README.md can you add a chapter in the PR description:
How to migrate
https://github.com/tinkerbell/proposals/blob/master/proposals/0011/README.md#how-to-migrate
Explaining what is not working anymore and how to do the same in the new way, thanks
cmd/tink-cli/cmd/template/create.go
Outdated
@@ -69,16 +74,23 @@ func readAll(reader io.Reader) []byte { | |||
func addFlags() { | |||
flags := createCmd.PersistentFlags() | |||
flags.StringVarP(&filePath, "path", "p", "", "path to the template file") |
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.
Please change this with --file
to unify with hardware push
28250b4
to
b0a5672
Compare
@mmlb Please let me know once you are back, and I will update the branch (one last time). 😄 |
cmd/tink-cli/cmd/template/create.go
Outdated
file = "file" | ||
filePath string |
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 don't quite see the reason for file
global var when its not used in the flags.StringVarP
call. It should either be named a little more descriptively (filePathArgName?) and used there too or we just hard code use of "file"
every where.
I'm not a fan of the "variable for the variable name" approach...
cmd/tink-cli/cmd/template/create.go
Outdated
PreRunE: func(c *cobra.Command, args []string) error { | ||
if !isInputFromPipe() { | ||
path, _ := c.Flags().GetString(fPath) | ||
path, _ := c.Flags().GetString(file) |
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.
path isn't ever being used right?
cmd/tink-cli/cmd/template_test.go
Outdated
@@ -61,8 +61,8 @@ func Test_templateCmd(t *testing.T) { | |||
if err := root.Execute(); err != nil { | |||
t.Error(err) | |||
} | |||
if !strings.Contains(out.String(), "create a workflow template") { | |||
t.Error("expected output should include create a workflow template") | |||
if !strings.Contains(out.String(), "Create template using the --file flag") { |
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.
can be DRY'd by doing:
want := "Create template using the --file flag"
if !strings.Contains(out.String(), want) {
t.Error("unexpected output, looking for %q as a substring in %q", want, out.String())
}
or similar
cmd/tink-cli/cmd/template_test.go
Outdated
@@ -112,8 +112,8 @@ func Test_templateCmd(t *testing.T) { | |||
if err := root.Execute(); err != nil { | |||
t.Error(err) | |||
} | |||
if !strings.Contains(out.String(), "update a template") { | |||
t.Error("expected output should include update a template") | |||
if !strings.Contains(out.String(), "Update an existing template") { |
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.
ditto
…te/update' command in tink-cli Signed-off-by: parauliya <[email protected]>
Signed-off-by: Gaurav Gahlot <[email protected]>
Signed-off-by: Gaurav Gahlot <[email protected]>
Signed-off-by: Gaurav Gahlot <[email protected]>
Few weeks ago we decided to use --file for template creation: #385 But a few days days ago probably during a rebase I broke that behavior and left the template create command in a broken state 76793ee#diff-f5b9b4afa42ee036d5b6836337e9d6273de8c341267f7ea75eddc561f0ad6441 As detected by Dan #445 This commit should fix the issue, and it will require a documentation update as soon as we release a new version of sandbox.
Few weeks ago we decided to use --file for template creation: #385 But a few days days ago probably during a rebase I broke that behavior and left the template create command in a broken state 76793ee#diff-f5b9b4afa42ee036d5b6836337e9d6273de8c341267f7ea75eddc561f0ad6441 As detected by Dan #445 This commit should fix the issue, and it will require a documentation update as soon as we release a new version of sandbox. Signed-off-by: Gianluca Arbezzano <[email protected]>
A few weeks ago we decided to use --file for template creation: #385 But a few days ago probably during a rebase, I broke that behavior and left the template to create command in a broken state 76793ee#diff-f5b9b4afa42ee036d5b6836337e9d6273de8c341267f7ea75eddc561f0ad6441 As detected by Dan #445 This commit should fix the issue, and it will require a documentation update as soon as we release a new version of the sandbox. Fixed #445
Description
This PR will remove the
name
flag from thetink template create/update
command in tink-cli.Why is this needed
Fixes: #377
How Has This Been Tested?
This has been tested manually over the vagrant setup.
How to migrate?
Current Behaviour:
At present, the
tink template create -n <name>
allows users to provide a name to a workflow template. A user can also update this name using thetink template update -n <new-name>
command.The workflow template also has the
name
field. So, a workflow is getting itss name from two different and places and this can be confusing to users.New Behaviour:
With this PR,
tink template create
andtink template update
CLI will not accept a name for the template to be created or updated. Instead, the template name will be picked from thename
field in the template definition.The existing users need to run the
tink template update <id> --file <template-file>
command. This will update the name of each template as per the value ofname
field in the template definition.Checklist:
I have: