-
Notifications
You must be signed in to change notification settings - Fork 124
feat(app push): add --build-tag flag for custom image tags #2909
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
Open
kwiatekus
wants to merge
11
commits into
kyma-project:main
Choose a base branch
from
kwiatekus:app-push-add-image-tag-flag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+144
−3
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
41e89c4
feat(app push): add --image-tag flag to appPushConfig
kwiatekus a34b858
refactor(app push): move imageTag field next to imagePullSecretName i…
kwiatekus f3cbb68
feat(app push): validate --image-tag format in complete()
kwiatekus d24417f
fix(app push): hoist imageTagRegexp to package level, fix test conven…
kwiatekus 6bea286
fix(app push): correct exceeds-128-chars test string to exactly 129 c…
kwiatekus 47bf004
feat(app push): wire --image-tag through buildImage() via resolveImag…
kwiatekus c126464
fix(app push): remove redundant imageTag param, rename test, fix erro…
kwiatekus 897abe6
docs(app push): add --image-tag usage examples to help text
kwiatekus a7ae976
fix(app push): fix gofmt alignment in push_test.go
kwiatekus c4fb525
refactor(app push): rename --image-tag to --build-tag for clarity
kwiatekus a6e662e
docs: regenerate kyma_app_push.md with --build-tag flag
kwiatekus 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package app | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func Test_appPushConfig_complete_buildTag(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| buildTag string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "empty tag skips validation - no error", | ||
| buildTag: "", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid commit sha", | ||
| buildTag: "abc1234def5678", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid semver", | ||
| buildTag: "1.0.0", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid underscore prefix", | ||
| buildTag: "_build", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid single char", | ||
| buildTag: "1", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "valid with dots and dashes", | ||
| buildTag: "v1.2.3-beta.1", | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "invalid: contains space", | ||
| buildTag: "my tag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: contains colon", | ||
| buildTag: "my:tag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: contains slash", | ||
| buildTag: "my/tag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: contains @", | ||
| buildTag: "my@tag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: starts with dot", | ||
| buildTag: ".mytag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: starts with dash", | ||
| buildTag: "-mytag", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid: exceeds 128 chars", | ||
| buildTag: "abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| cfg := &appPushConfig{ | ||
| buildTag: tt.buildTag, | ||
| } | ||
| err := cfg.complete() | ||
| if tt.wantErr { | ||
| require.NotNil(t, err, "expected validation error for buildTag=%q", tt.buildTag) | ||
| } else { | ||
| require.Nil(t, err, "expected no error for buildTag=%q", tt.buildTag) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func Test_resolveImageTag(t *testing.T) { | ||
| t.Run("provided tag is used in image name", func(t *testing.T) { | ||
| imageTag := "abc1234" | ||
| resolvedTag := resolveImageTag(imageTag) | ||
| require.Equal(t, "abc1234", resolvedTag) | ||
| }) | ||
|
|
||
| t.Run("empty tag resolves to timestamp format", func(t *testing.T) { | ||
| resolvedTag := resolveImageTag("") | ||
| require.Regexp(t, `^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$`, resolvedTag) | ||
| }) | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.
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 lives in the
completemethod which as I understand is responsible for populating config data based on some logic. We don't populate thebuildTaghere but rather check if it's complaint with regex so I would move this piece to thevalidatemethod