-
Notifications
You must be signed in to change notification settings - Fork 111
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
Kubetest2 Version Addition #111
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,8 @@ func runE( | |
opts.bindFlags(kubetest2Flags) | ||
artifacts.MustBindFlags(kubetest2Flags) | ||
|
||
cmd.Printf("Running deployer %s version: %s\n", deployerName, shim.GitTag) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add this after deployer versions are added |
||
|
||
// NOTE: unknown flags are forwarded to the deployer as arguments | ||
kubetest2Flags.ParseErrorsWhitelist.UnknownFlags = true | ||
|
||
|
@@ -91,6 +93,7 @@ func runE( | |
if err != nil { | ||
return fmt.Errorf("unable to find tester %v: %v", opts.test, err) | ||
} | ||
cmd.Printf("Running tester %s version: %s\n", opts.test, shim.GitTag) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add this after testers versions are added |
||
|
||
// Get tester usage by running it with --help | ||
var helpArgs []string | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,6 +26,9 @@ import ( | |||||||||||
"sigs.k8s.io/kubetest2/pkg/process" | ||||||||||||
) | ||||||||||||
|
||||||||||||
// GitTag captures the git commit SHA of the build. This gets printed by all the deployers and testers | ||||||||||||
var GitTag string | ||||||||||||
|
||||||||||||
// Main implements the kubetest2 root binary entrypoint | ||||||||||||
func Main() { | ||||||||||||
if err := Run(); err != nil { | ||||||||||||
|
@@ -66,22 +69,29 @@ func NewCommand() *cobra.Command { | |||||||||||
|
||||||||||||
// runE implements the actual command logic | ||||||||||||
func runE(cmd *cobra.Command, args []string) error { | ||||||||||||
cmd.Printf("Running %s version: %s\n", BinaryName, GitTag) | ||||||||||||
// there should be at least one argument (the deployer) unless the user | ||||||||||||
// is asking for help on the shim itself | ||||||||||||
if len(args) < 1 { | ||||||||||||
return cmd.Help() | ||||||||||||
} | ||||||||||||
|
||||||||||||
// gracefully handle -h or --help if it is the only argument | ||||||||||||
// gracefully handle help or version command if it is the only argument | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this feature, but if other arguments are set AND --help is included, it will try to deploy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no Lines 139 to 143 in 96ab8c9
|
||||||||||||
if len(args) == 1 { | ||||||||||||
// check for -h, --help | ||||||||||||
flags := pflag.NewFlagSet(BinaryName, pflag.ContinueOnError) | ||||||||||||
help := flags.BoolP("help", "h", false, "") | ||||||||||||
// check for -v, --version | ||||||||||||
ver := flags.BoolP("version", "v", false, fmt.Sprintf("prints %s version", BinaryName)) | ||||||||||||
// we don't care about errors, only if -h / --help was set | ||||||||||||
_ = flags.Parse(args) | ||||||||||||
if *help { | ||||||||||||
return cmd.Help() | ||||||||||||
} | ||||||||||||
if *ver { | ||||||||||||
fmt.Printf("%s version %s\n", BinaryName, GitTag) | ||||||||||||
return nil | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
// otherwise find and execute the deployer with the remaining arguments | ||||||||||||
|
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.
unfortunately, handling the deployers won't be so straightforward :)
this will just always get the kubetest2 shim version. but we can have deployers built at different commits.