Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ semv:

.PHONY: test
test:
go test -v -cover ./...
go test -v -cover -race ./...

.PHONY: buildx-machine
buildx-machine: ## create rancher dockerbuildx machine targeting platform defined by DEFAULT_PLATFORMS.
Expand Down
68 changes: 68 additions & 0 deletions cmd/release/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,73 @@ var systemAgentInstallerK3sTagSubCmd = &cobra.Command{
},
}

var rancherPrimeTagSubCmd = &cobra.Command{
Use: "rancher-prime [ga, rc, alpha] [version]",
Short: "Tag Rancher Prime releases",
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
return copyReleaseTypes(), cobra.ShellCompDirectiveNoFileComp
}

if len(args) == 1 {
return copyRancherVersions(), cobra.ShellCompDirectiveNoFileComp
}

return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) < 2 {
return errors.New("expected at least two arguments: [ga,rc,alpha] [version]")
}

releaseType := args[0]
preRelease, err := releaseTypePreRelease(releaseType)
if err != nil {
return err
}

tag := args[1]
rancherRelease, found := rootConfig.Rancher.Versions[tag]
if !found {
return NewVersionNotFoundError(tag, "rancher")
}

repo := config.ValueOrDefault(rootConfig.RancherPrimeRepositoryName, config.RancherPrimeRepositoryName)
owner := config.ValueOrDefault(rootConfig.RancherGithubOrganization, config.RancherGithubOrganization)

releaseBranch, err := rancher.ReleaseBranchFromTag(tag)
if err != nil {
return errors.New("failed to generate release branch from tag: " + err.Error())
}

releaseBranch = config.ValueOrDefault(rancherRelease.ReleaseBranch, releaseBranch)

ctx := context.Background()
ghClient := repository.NewGithub(ctx, rootConfig.Auth.GithubToken)

opts := &repository.CreateReleaseOpts{
Tag: tag,
Repo: repo,
Owner: owner,
Branch: releaseBranch,
Prerelease: true,
Draft: false,
ReleaseNotes: "",
}
fmt.Printf("creating release options: %+v\n", opts)
if dryRun {
fmt.Println("dry run, skipping creating release")
return nil
}
releaseURL, err := rancher.CreateRelease(ctx, ghClient, &rancherRelease, opts, preRelease, releaseType)
if err != nil {
return err
}
fmt.Println("created release: " + releaseURL)
return nil
},
}

var dashboardTagSubCmd = &cobra.Command{
Use: "dashboard [ga,rc,alpha] [version]",
Short: "Tag dashboard releases",
Expand Down Expand Up @@ -437,6 +504,7 @@ func init() {
tagCmd.AddCommand(k3sTagSubCmd)
tagCmd.AddCommand(rke2TagSubCmd)
tagCmd.AddCommand(rancherTagSubCmd)
tagCmd.AddCommand(rancherPrimeTagSubCmd)
tagCmd.AddCommand(systemAgentInstallerK3sTagSubCmd)
tagCmd.AddCommand(dashboardTagSubCmd)
tagCmd.AddCommand(cliTagSubCmd)
Expand Down
52 changes: 27 additions & 25 deletions cmd/release/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
)

const (
RancherGithubOrganization = "rancher"
RancherRepositoryName = "rancher"
UIRepositoryName = "ui"
DashboardRepositoryName = "dashboard"
CLIRepositoryName = "cli"
K3sGithubOrganization = "k3s-io"
K3sRepositoryName = "k3s"
K3sK8sRepositoryName = "kubernetes"
RancherGithubOrganization = "rancher"
RancherRepositoryName = "rancher"
RancherPrimeRepositoryName = "rancher-prime"
UIRepositoryName = "ui"
DashboardRepositoryName = "dashboard"
CLIRepositoryName = "cli"
K3sGithubOrganization = "k3s-io"
K3sRepositoryName = "k3s"
K3sK8sRepositoryName = "kubernetes"
)

const (
Expand Down Expand Up @@ -152,23 +153,24 @@ type Auth struct {

// Config
type Config struct {
User *User `json:"user"`
K3s *K3s `json:"k3s"`
Rancher *Rancher `json:"rancher"`
RKE2 *RKE2 `json:"rke2"`
Charts *ChartsRelease `json:"charts"`
Auth *Auth `json:"auth"`
Dashboard *Dashboard `json:"dashboard"`
CLI *CLI `json:"cli"`
PrimeRegistry string `json:"prime_registry"`
RancherGithubOrganization string `json:"rancher_github_organization"`
RancherRepositoryName string `json:"rancher_repository_name"`
RancherRepositoryGitURI string `json:"rancher_repository_git_uri"`
RancherRepositoryURL string `json:"rancher_repository_url"`
UIRepositoryName string `json:"ui_repository_name"`
DashboardRepositoryName string `json:"dashboard_repository_name"`
CLIRepositoryName string `json:"cli_repository_name"`
CLIRepositoryGitURI string `json:"cli_repository_git_uri"`
User *User `json:"user"`
K3s *K3s `json:"k3s"`
Rancher *Rancher `json:"rancher"`
RKE2 *RKE2 `json:"rke2"`
Charts *ChartsRelease `json:"charts"`
Auth *Auth `json:"auth"`
Dashboard *Dashboard `json:"dashboard"`
CLI *CLI `json:"cli"`
PrimeRegistry string `json:"prime_registry"`
RancherGithubOrganization string `json:"rancher_github_organization"`
RancherRepositoryName string `json:"rancher_repository_name"`
RancherPrimeRepositoryName string `json:"rancher_repository_name"`
RancherRepositoryGitURI string `json:"rancher_repository_git_uri"`
RancherRepositoryURL string `json:"rancher_repository_url"`
UIRepositoryName string `json:"ui_repository_name"`
DashboardRepositoryName string `json:"dashboard_repository_name"`
CLIRepositoryName string `json:"cli_repository_name"`
CLIRepositoryGitURI string `json:"cli_repository_git_uri"`
}

// OpenOnEditor opens the given config file on the user's default text editor.
Expand Down