Skip to content
Permalink
Browse files
fix(bundles): fix werf-bundle-publish command error when --tag contai…
…ns underscore chars

Werf bundle publish command automatically generates chart.version metadata field, which equals 0.0.0-TIMESTAMP-SLUG(TAG), when TAG is not a valid semver by itself.
  • Loading branch information
distorhead committed Nov 16, 2021
1 parent 65536bb commit 03e8f88ffc05a31d557df11a02d4a1d6df1300e3
Showing with 9 additions and 2 deletions.
  1. +8 −1 cmd/werf/bundle/publish/publish.go
  2. +1 −1 pkg/slug/slug.go
@@ -7,6 +7,8 @@ import (
"path/filepath"
"time"

"github.com/werf/werf/pkg/slug"

"github.com/Masterminds/semver"

"helm.sh/helm/v3/pkg/getter"
@@ -370,7 +372,12 @@ func runPublish(ctx context.Context) error {

chartVersion := cmdData.Tag
if _, err := semver.NewVersion(chartVersion); err != nil {
chartVersion = fmt.Sprintf("0.0.0-%d-%s", time.Now().Unix(), chartVersion)
chartVersion = fmt.Sprintf("0.0.0-%d-%s", time.Now().Unix(), slug.Slug(chartVersion))
if _, err := semver.NewVersion(chartVersion); err != nil {
fallbackChartVersion := fmt.Sprintf("0.0.0-%d", time.Now().Unix())
logboek.Context(ctx).Warn().LogF("Unable to use %q as chart version, will fallback on chart version %q\n", chartVersion, fallbackChartVersion)
chartVersion = fallbackChartVersion
}
}

bundleTmpDir := filepath.Join(werf.GetServiceDir(), "tmp", "bundles", uuid.NewV4().String())
@@ -71,7 +71,7 @@ func ValidateDockerTag(name string) error {
return nil
}

return fmt.Errorf(`%q is not a valid docker tag
return fmt.Errorf(`%q is not a valid docker tag
- a tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes;
- a tag name may not start with a period or a dash and may contain a maximum of 128 characters.`, name)

0 comments on commit 03e8f88

Please sign in to comment.