-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 support for setting default-repo in global config #1057
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
820ab0d
wip; figuring out default repo substitution. check todos
nkubala 7b2dbd7
wip; default repo works for gcr. other registries next, also need to …
nkubala ed0e793
move kubectl context resolution into getter methods
nkubala 8f66eb2
subbed in helm values. need to add support for ECR/EKS
nkubala a19603f
fix up repo substitution in image replacer
nkubala a234fe7
don't warn twice if we can't parse image. add tests
nkubala 97b7c29
implement concat/truncate
nkubala 3e8d301
fix tests
nkubala 44761dc
fix merge conflicts
nkubala fe0e9bc
fix corner case where no config values are set
nkubala 5f79b57
log instead of error when no config entry is found for particular con…
nkubala 2f90dcd
substitute default-repo into test cases
nkubala 5c701ee
fallback to global value if no context-local value is set. add suppor…
nkubala 1d837cb
fix merge conflicts
nkubala 452e29e
linter
nkubala 93bfb30
fix merge issue
nkubala 9d06902
fix tests
nkubala 1c4111d
fix setting kubectl context in tests
nkubala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -46,15 +46,17 @@ type HelmDeployer struct { | |||||
|
||||||
kubeContext string | ||||||
namespace string | ||||||
defaultRepo string | ||||||
} | ||||||
|
||||||
// NewHelmDeployer returns a new HelmDeployer for a DeployConfig filled | ||||||
// with the needed configuration for `helm` | ||||||
func NewHelmDeployer(cfg *latest.HelmDeploy, kubeContext string, namespace string) *HelmDeployer { | ||||||
func NewHelmDeployer(cfg *latest.HelmDeploy, kubeContext string, namespace string, defaultRepo string) *HelmDeployer { | ||||||
return &HelmDeployer{ | ||||||
HelmDeploy: cfg, | ||||||
kubeContext: kubeContext, | ||||||
namespace: namespace, | ||||||
defaultRepo: defaultRepo, | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -125,7 +127,7 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates | |||||
color.Red.Fprintf(out, "Helm release %s not installed. Installing...\n", releaseName) | ||||||
isInstalled = false | ||||||
} | ||||||
params, err := joinTagsToBuildResult(builds, r.Values) | ||||||
params, err := h.joinTagsToBuildResult(builds, r.Values) | ||||||
if err != nil { | ||||||
return nil, errors.Wrap(err, "matching build results to chart values") | ||||||
} | ||||||
|
@@ -336,6 +338,24 @@ func (h *HelmDeployer) deleteRelease(ctx context.Context, out io.Writer, r lates | |||||
return nil | ||||||
} | ||||||
|
||||||
func (h *HelmDeployer) joinTagsToBuildResult(builds []build.Artifact, params map[string]string) (map[string]build.Artifact, error) { | ||||||
imageToBuildResult := map[string]build.Artifact{} | ||||||
for _, build := range builds { | ||||||
imageToBuildResult[build.ImageName] = build | ||||||
} | ||||||
|
||||||
paramToBuildResult := map[string]build.Artifact{} | ||||||
for param, imageName := range params { | ||||||
newImageName := util.SubstituteDefaultRepoIntoImage(h.defaultRepo, imageName) | ||||||
build, ok := imageToBuildResult[newImageName] | ||||||
if !ok { | ||||||
return nil, fmt.Errorf("No build present for %s", imageName) | ||||||
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.
Suggested change
nit: errors shouldn't start capitalized https://github.com/golang/go/wiki/CodeReviewComments#error-strings |
||||||
} | ||||||
paramToBuildResult[param] = build | ||||||
} | ||||||
return paramToBuildResult, nil | ||||||
} | ||||||
|
||||||
func evaluateReleaseName(nameTemplate string) (string, error) { | ||||||
tmpl, err := util.ParseEnvTemplate(nameTemplate) | ||||||
if err != nil { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ux-nit: this feels like a bit of clutter on the screen - can we make it available only for debug logging?