Skip to content

Commit

Permalink
Implement OBS staging workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Mudrinić <[email protected]>
  • Loading branch information
xmudrii committed May 26, 2023
1 parent 213ba5d commit d53cce7
Show file tree
Hide file tree
Showing 4 changed files with 1,029 additions and 0 deletions.
97 changes: 97 additions & 0 deletions cmd/krel/cmd/obs_stage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// TODO(xmudrii): add variables for flags, add flags for missing options, etc.
package cmd

import (
"fmt"
"strings"

"github.com/spf13/cobra"

stage "k8s.io/release/pkg/obs"
"k8s.io/release/pkg/release"
)

// stageCmd represents the subcommand for `krel stage`
var obsStageCmd = &cobra.Command{
Use: "stage",
Short: "Run OBS stage workflow",
Long: "Run OBS stage workflow.",
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
return runOBSStage(obsStageOptions)
},
}

var (
obsStageOptions = stage.DefaultStageOptions()
)

const (
obsBuildVersionFlag = "build-version"
)

func init() {
obsStageCmd.PersistentFlags().
StringVar(
&obsStageOptions.ReleaseType,
"type",
obsStageOptions.ReleaseType,
fmt.Sprintf("The release type, must be one of: '%s'",
strings.Join([]string{
release.ReleaseTypeAlpha,
release.ReleaseTypeBeta,
release.ReleaseTypeRC,
release.ReleaseTypeOfficial,
}, "', '"),
))

obsStageCmd.PersistentFlags().
StringVar(
&obsStageOptions.ReleaseBranch,
"branch",
obsStageOptions.ReleaseBranch,
"The release branch for which the release should be build",
)

obsStageCmd.PersistentFlags().
StringVar(
&obsStageOptions.BuildVersion,
buildVersionFlag,
"",
"The build version to be released.",
)

// for _, flag := range []string{buildVersionFlag, submitJobFlag} {
// if err := stageCmd.PersistentFlags().MarkHidden(flag); err != nil {
// logrus.Fatal(err)
// }
// }

obsCmd.AddCommand(obsStageCmd)
}

func runOBSStage(options *stage.StageOptions) error {
options.NoMock = rootOpts.nomock
// TODO(xmudrii): solve this
options.BuildVersion = "v1.26.4-64+8b09b36478f65c"
stageRun := stage.NewStage(options)

return stageRun.Run()
}
Loading

0 comments on commit d53cce7

Please sign in to comment.