-
Notifications
You must be signed in to change notification settings - Fork 102
Delete credential flags #774
Delete credential flags #774
Conversation
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br> merge
35c1293
to
e23b3c9
Compare
…credential-flags Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br> # Conflicts: # pkg/cmd/cmd.go # pkg/cmd/delete_credential.go # pkg/cmd/delete_credential_test.go
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br> Fixing tests and mocks
d5e8ff4
to
0e9de1b
Compare
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
…credential-flags Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br> # Conflicts: # internal/mocks/mocks.go
Codecov Report
@@ Coverage Diff @@
## master #774 +/- ##
==========================================
+ Coverage 83.77% 83.81% +0.04%
==========================================
Files 110 110
Lines 3840 3856 +16
==========================================
+ Hits 3217 3232 +15
+ Misses 444 443 -1
- Partials 179 181 +2
Continue to review full report at Codecov.
|
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
@@ -12,6 +13,15 @@ import ( | |||
"github.com/ZupIT/ritchie-cli/pkg/stdin" | |||
) | |||
|
|||
const ( | |||
providerFlagName = "provider" |
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.
could you extract the flag
struct from the formula.go and use addReservedFlags
function to generate all flags to any commands?
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.
Sorry I am a bit lost, are core commands supposed to have reserved flags?
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
pkg/cmd/delete_credential.go
Outdated
} | ||
prompt.Info(fmt.Sprintf("Current env: %s", env)) | ||
func addFlags(flags *pflag.FlagSet) { | ||
flags.String(providerFlagName, "", providerFlagDescription) |
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 think that you can use the
flag
struct to represent a flag.
ritchie-cli/pkg/cmd/formula.go
Line 78 in 84b0008
type flag struct { -
you can use this function to create your flags.
ritchie-cli/pkg/cmd/formula.go
Line 227 in 84b0008
func addReservedFlags(flags *pflag.FlagSet) { -
here we have an example of how to use it:
ritchie-cli/pkg/cmd/formula.go
Line 47 in 84b0008
reservedFlags = flags{
you can extract this function and struct to cmd.go 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.
now I see...
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
…credential-flags Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br> # Conflicts: # pkg/cmd/formula.go
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 job 🚀
/merge qa |
👌 Merged branch hm/delete-credential-flags into qa |
pkg/cmd/delete_credential.go
Outdated
return inputConfig{}, errors.New("you have no defined credentials in this env") | ||
} | ||
|
||
providers := make([]string, len(data)) |
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.
When you declare an array like this, you are saying that its capacity is the data size and you are giving each position of the array an empty value, by appending it will add to the next position displaying to the user a select with empty fields.
For example, if the data has a size of 3 you will have an array with size 3, and when appending it will add one more position and the size of your array will be 6 with the first 3 empty positions.
we have two ways to fix this:
var providers []string // Simpler
providers := make([]string, 0, len(data)) // More complex
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.
the first option does not pass the linter since we need to preallocate it, going for the second
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
/merge qa |
👌 Merged branch hm/delete-credential-flags into qa |
Description
Added flag capacity on delete credential
How to verify it
Run the command
rit delete credential --provider=<your provider>
Changelog
Added flag capacity to
rit delete credential