-
Notifications
You must be signed in to change notification settings - Fork 318
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
keep only master branch for latest #160
Changes from 4 commits
d8ba908
0fb22db
197b737
3c1cfa6
0927e34
ff05dfd
c591da7
5fa26eb
13ce200
ce53e21
a5011aa
bb68110
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 |
---|---|---|
|
@@ -37,18 +37,20 @@ type ( | |
|
||
// Build defines Docker build parameters. | ||
Build struct { | ||
Remote string // Git remote URL | ||
Name string // Docker build using default named tag | ||
Dockerfile string // Docker build Dockerfile | ||
Context string // Docker build context | ||
Tags []string // Docker build tags | ||
Args []string // Docker build args | ||
ArgsEnv []string // Docker build args from env | ||
Squash bool // Docker build squash | ||
Pull bool // Docker build pull | ||
Compress bool // Docker build compress | ||
Repo string // Docker build repository | ||
LabelSchema []string // Label schema map | ||
Remote string // Git remote URL | ||
Name string // Docker build using default named tag | ||
Dockerfile string // Docker build Dockerfile | ||
Context string // Docker build context | ||
Tags []string // Docker build tags | ||
Args []string // Docker build args | ||
ArgsEnv []string // Docker build args from env | ||
Squash bool // Docker build squash | ||
Pull bool // Docker build pull | ||
Compress bool // Docker build compress | ||
Repo string // Docker build repository | ||
LabelSchema []string // Label schema map | ||
Branch string // Docker build branch | ||
DefaultBranch string // Docker latest branch | ||
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. I think this can be removed since it isn't being used 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. Done. c591da7 |
||
} | ||
|
||
// Plugin defines the Docker plugin parameters. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ import ( | |
|
||
// DefaultTagSuffix returns a set of default suggested tags | ||
// based on the commit ref with an attached suffix. | ||
func DefaultTagSuffix(ref, suffix string) []string { | ||
tags := DefaultTags(ref) | ||
func DefaultTagSuffix(ref, suffix, commitBranch, defaultBranch string) []string { | ||
tags := DefaultTags(ref, commitBranch, defaultBranch) | ||
if len(suffix) == 0 { | ||
return tags | ||
} | ||
|
@@ -26,10 +26,16 @@ func DefaultTagSuffix(ref, suffix string) []string { | |
|
||
// DefaultTags returns a set of default suggested tags based on | ||
// the commit ref. | ||
func DefaultTags(ref string) []string { | ||
func DefaultTags(ref, commitBranch, defaultBranch string) []string { | ||
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. I think we can remove 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. Done. 0927e34 |
||
|
||
if defaultBranch != "" && commitBranch != defaultBranch && !strings.HasPrefix(ref, "refs/tags/") { | ||
return []string{} | ||
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. I am not sure we ever want to return an empty string here. We should always return a default tag. 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. maybe we can add a new flag to confirm that if the user wants to build tags from another branch which is not equal the default branch.
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.
An empty tag is not valid and will fail to publish. What is the goal with returning an empty branch? 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. @bradrydzewski I meant empty value like 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. and we can check the tag array in if len(p.Build.Tags) == 0 {
fmt.Println("build tags not found")
return nil
} 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. @bradrydzewski Any other suggestion? |
||
} | ||
|
||
if !strings.HasPrefix(ref, "refs/tags/") { | ||
return []string{"latest"} | ||
} | ||
|
||
v := stripTagPrefix(ref) | ||
version, err := semver.NewVersion(v) | ||
if err != nil { | ||
|
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.
let's call this
repo.branch
which is consistent with some of the other plugins and the plugin starterThere 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.
Done. 0927e34