diff --git a/cmd/krel/cmd/obs_stage.go b/cmd/krel/cmd/obs_stage.go index 33c23d473c2..3f2010fea19 100644 --- a/cmd/krel/cmd/obs_stage.go +++ b/cmd/krel/cmd/obs_stage.go @@ -23,6 +23,7 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "k8s.io/release/pkg/gcp/gcb" "k8s.io/release/pkg/obs" "k8s.io/release/pkg/release" ) @@ -115,7 +116,7 @@ func init() { ) obsStageCmd.PersistentFlags(). - StringArrayVar( + StringSliceVar( &obsStageOptions.Packages, obsPackagesFlag, obsStageOptions.Packages, @@ -123,7 +124,7 @@ func init() { ) obsStageCmd.PersistentFlags(). - StringArrayVar( + StringSliceVar( &obsStageOptions.Architectures, obsArchitecturesFlag, obsStageOptions.Architectures, @@ -181,6 +182,23 @@ func init() { func runOBSStage(options *obs.StageOptions) error { options.NoMock = rootOpts.nomock + + // Allow submitting packages and architectures separated by the string + // slice separator. This allows us to pass the GCB substitution, which + // already uses comma as default separator. + // We cannot use the GCB separator substitution (see `gcloud topic + // escaping`) because GCB complains that a 'build tag must match format + // "^[\\w][\\w.-]{0,127}$"'. + archSplit := strings.Split(options.Architectures[0], gcb.StringSliceSeparator) + if len(archSplit) > 1 { + options.Architectures = archSplit + } + + packageSplit := strings.Split(options.Packages[0], gcb.StringSliceSeparator) + if len(packageSplit) > 1 { + options.Packages = packageSplit + } + stage := obs.NewStage(options) if submitJob { // Perform a local check of the specified options before launching a diff --git a/gcb/obs-stage/cloudbuild.yaml b/gcb/obs-stage/cloudbuild.yaml index 4146e4a83f4..7dc4f40112e 100644 --- a/gcb/obs-stage/cloudbuild.yaml +++ b/gcb/obs-stage/cloudbuild.yaml @@ -82,8 +82,7 @@ steps: - "--log-level=${_LOG_LEVEL}" - "--template-dir=${_SPEC_TEMPLATE_PATH}" - "--packages=${_PACKAGES}" - # TODO(xmudrii) - followup: solve problem with delimiter - # - "--architectures=${_ARCHITECTURES}" + - "--architectures=${_ARCHITECTURES}" - "--version=${_VERSION}" - "--project=${_OBS_PROJECT}" - "--source=${_PACKAGE_SOURCE}" @@ -97,6 +96,7 @@ tags: - ${_TYPE_TAG} - ${_TYPE} - ${_PACKAGES} +- ${_ARCHITECTURES} - ${_VERSION} - ${_OBS_PROJECT_TAG} diff --git a/pkg/gcp/gcb/gcb.go b/pkg/gcp/gcb/gcb.go index 6722d7ee900..f9e62464026 100644 --- a/pkg/gcp/gcb/gcb.go +++ b/pkg/gcp/gcb/gcb.go @@ -42,6 +42,10 @@ import ( "sigs.k8s.io/release-utils/util" ) +// StringSliceSeparator is the separator used for passing string slices as GCB +// substitutions. +const StringSliceSeparator = "..." + // GCB is the main structure of this package. type GCB struct { options *Options @@ -391,9 +395,8 @@ func (g *GCB) SetGCBSubstitutions(toolOrg, toolRepo, toolRef, gcsBucket string) switch { case g.options.OBSStage: gcbSubs["SPEC_TEMPLATE_PATH"] = g.options.SpecTemplatePath - gcbSubs["PACKAGES"] = strings.Join(g.options.Packages, ",") - //nolint:gocritic // This needs some fixes that will be done in a follow-up - // gcbSubs["ARCHITECTURES"] = strings.Join(g.options.Architectures, ",") + gcbSubs["PACKAGES"] = strings.Join(g.options.Packages, StringSliceSeparator) + gcbSubs["ARCHITECTURES"] = strings.Join(g.options.Architectures, StringSliceSeparator) gcbSubs["VERSION"] = g.options.Version gcbSubs["OBS_PROJECT"] = g.options.OBSProject gcbSubs["OBS_PROJECT_TAG"] = strings.ReplaceAll(g.options.OBSProject, ":", "-") @@ -402,7 +405,7 @@ func (g *GCB) SetGCBSubstitutions(toolOrg, toolRepo, toolRef, gcsBucket string) // Stop here when doing OBS stage return gcbSubs, nil case g.options.OBSRelease: - gcbSubs["PACKAGES"] = strings.Join(g.options.Packages, ",") + gcbSubs["PACKAGES"] = strings.Join(g.options.Packages, StringSliceSeparator) gcbSubs["OBS_PROJECT"] = g.options.OBSProject gcbSubs["OBS_PROJECT_TAG"] = strings.ReplaceAll(g.options.OBSProject, ":", "-")