Skip to content

Commit

Permalink
Merge pull request openshift#1289 from petr-muller/main-branch-fix
Browse files Browse the repository at this point in the history
promotion: support `main` branch
  • Loading branch information
openshift-merge-robot authored Oct 9, 2020
2 parents bd69a8a + fdbe8e9 commit 439c320
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pkg/promotion/promotion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"flag"
"fmt"

cioperatorapi "github.com/openshift/ci-tools/pkg/api"
"github.com/openshift/ci-tools/pkg/config"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/test-infra/prow/flagutil"

cioperatorapi "github.com/openshift/ci-tools/pkg/api"
"github.com/openshift/ci-tools/pkg/config"
)

const (
Expand Down Expand Up @@ -99,13 +100,14 @@ func IsBumpable(branch, currentRelease string) bool {
// DetermineReleaseBranch determines the branch that will be used to the future release,
// based on the branch that is currently promoting to the current release.
func DetermineReleaseBranch(currentRelease, futureRelease, currentBranch string) (string, error) {
if currentBranch == "master" {
switch currentBranch {
case "master", "main":
return fmt.Sprintf("release-%s", futureRelease), nil
} else if currentBranch == fmt.Sprintf("openshift-%s", currentRelease) {
case fmt.Sprintf("openshift-%s", currentRelease):
return fmt.Sprintf("openshift-%s", futureRelease), nil
} else if currentBranch == fmt.Sprintf("release-%s", currentRelease) {
case fmt.Sprintf("release-%s", currentRelease):
return fmt.Sprintf("release-%s", futureRelease), nil
} else {
default:
return "", fmt.Errorf("invalid branch %q promoting to current release", currentBranch)
}
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/promotion/promotion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"github.com/google/go-cmp/cmp"
"k8s.io/apimachinery/pkg/util/sets"

"k8s.io/test-infra/prow/flagutil"

cioperatorapi "github.com/openshift/ci-tools/pkg/api"
"github.com/openshift/ci-tools/pkg/config"
"k8s.io/test-infra/prow/flagutil"
)

func TestPromotesOfficialImages(t *testing.T) {
Expand Down Expand Up @@ -183,6 +184,14 @@ func TestDetermineReleaseBranches(t *testing.T) {
expectedFutureBranch: "release-4.1",
expectedError: false,
},
{
name: "promotion from main makes a release branch",
currentRelease: "4.0",
futureRelease: "4.1",
currentBranch: "main",
expectedFutureBranch: "release-4.1",
expectedError: false,
},
{
name: "promotion from openshift release branch makes a new release branch",
currentRelease: "4.0",
Expand Down

0 comments on commit 439c320

Please sign in to comment.