-
Notifications
You must be signed in to change notification settings - Fork 138
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: image name derivation and flag precidence #1185
Conversation
c01945d
to
57c2529
Compare
57c2529
to
0a16525
Compare
1913e8c
to
279c390
Compare
Codecov Report
@@ Coverage Diff @@
## main #1185 +/- ##
==========================================
+ Coverage 45.20% 45.32% +0.12%
==========================================
Files 68 68
Lines 9745 9699 -46
==========================================
- Hits 4405 4396 -9
+ Misses 4940 4914 -26
+ Partials 400 389 -11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
if !interactiveTerminal() || !c.Confirm { | ||
return c, nil | ||
} | ||
|
||
bc := buildConfig{Verbose: c.Verbose} | ||
imageName := deriveImage(c.Image, c.Registry, c.Path) |
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.
Two things happen here: The current state of the config is allowed to flow through as the defaults to the prompts, and we move down the line which is calculating the default image name to after preconditions.
@@ -223,119 +181,3 @@ created: 2009-11-10 23:00:00`, | |||
}) | |||
} | |||
} | |||
|
|||
func testBuilderPersistence(t *testing.T, testRegistry string, cmdBuilder func(ClientFactory) *cobra.Command) { |
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 implementations of the shared tests are moved into deploy_test.go since it is the superset of deploy+build
} | ||
|
||
// TestBuild_registryConfigurationInYaml tests that a build will execute successfully | ||
// when there is no registry provided on the command line, but one exists in func.yaml | ||
func TestBuild_registryConfigurationInYaml(t *testing.T) { |
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.
Most of the tests are just moved/shared. This was more heavily refactored to use the client API rather than a func.yaml
as a sub-assertion in TestBuild_RegistryLoads
if function.Image == "" && currentBuildType != "disabled" { | ||
// AND a --registry was not provided, then we need to | ||
// prompt for a registry from which we can derive an image name. | ||
if config.Registry == "" { | ||
fmt.Println("A registry for function images is required. For example, 'docker.io/tigerteam'.") | ||
|
||
err = survey.AskOne( | ||
&survey.Input{Message: "Registry for function images:"}, | ||
&config.Registry, survey.WithValidator(survey.Required)) | ||
if err != nil { | ||
if err == terminal.InterruptErr { | ||
return nil | ||
} | ||
return | ||
} | ||
} | ||
|
||
// We have the registry, so let's use it to derive the function image name | ||
config.Image = deriveImage(config.Image, config.Registry, config.Path) | ||
function.Image = config.Image |
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 prompt block is part of the flow initiated by --confirm
(config.Prompt
), with normal execution mode usually expected to result in an immediate non-zero exit code and error message printed to stderr.
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 great improvement :)
/hold for others
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lkingland, zroubalik 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 |
Since parent PR (#1079) already got a few approvals when these changes were originally included therein, I am presuming this derivitave is GTG with the single approval |
🧹 clean up image name derivation logic
🐛 image flag now correctly respected
🎁 tests in commands and core codifying
registry
vsimage
treatement🎁 prompts on deploy should now correctly calculate image default
🧹 clean up namespace derivation logic and add a test
Clean up logic used to derive and update image name based on registry, function name etc.
Adds requisite tests to both
deploy
andbuild
./kind cleanup