Skip to content

Commit

Permalink
fix: set to latest if git tag is empty (#798)
Browse files Browse the repository at this point in the history
* fix: set to latest if git tag is empty

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>

* chore: rename

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>

Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
  • Loading branch information
hezhizhen authored Aug 20, 2022
1 parent dc0f87f commit c85766c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 1 addition & 5 deletions pkg/lang/ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,10 @@ func (g Graph) EnvString() []string {

func (g Graph) DefaultCacheImporter() (*string, error) {
// The base remote cache should work for all languages.
v := version.GetGitTagFromVersion()
if v == "" {
v = "latest"
}
res := fmt.Sprintf(
"type=registry,ref=docker.io/%s/python-cache:envd-%s",
viper.GetString(flag.FlagDockerOrganization),
v)
version.GetVersionForImageTag())
return &res, nil
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/lang/ir/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ func (g *Graph) compileBase() (llb.State, error) {

var base llb.State
org := viper.GetString(flag.FlagDockerOrganization)
v := version.GetGitTagFromVersion()
if v == "" {
// empty version tag only appear in dev built, set to `latest` if so.
v = "latest"
}
v := version.GetVersionForImageTag()
// Do not update user permission in the base image.
if g.Image != nil {
logger.WithField("image", *g.Image).Debugf("using custom base image")
Expand Down
8 changes: 5 additions & 3 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ func (v Version) String() string {
return v.Version
}

// GetGitTagFromVersion gets the git tag.
func GetGitTagFromVersion() string {
// GetVersionForImageTag gets the version for an image tag.
func GetVersionForImageTag() string {
if gitTag != "" {
return gitTag
}
return ""
// Empty version tag only appears in dev built.
// Set to `latest` if so.
return "latest"
}

// SetGitTagForE2ETest sets the gitTag for test purpose.
Expand Down

0 comments on commit c85766c

Please sign in to comment.