Skip to content

Commit

Permalink
remove unused fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbreno committed Oct 2, 2024
1 parent ca6df69 commit 578e465
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cmd/release/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ var dashboardTagSubCmd = &cobra.Command{
ghClient := repository.NewGithub(ctx, rootConfig.Auth.GithubToken)
opts := &repository.CreateReleaseOpts{
Tag: tag,
Repo: "dashboard",
Owner: dashboardRelease.DashboardRepoOwner,
Repo: rootConfig.Dashboard.RepoName,
Owner: rootConfig.Dashboard.RepoOwner,
Branch: dashboardRelease.ReleaseBranch,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/release/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var updateRancherDashboardCmd = &cobra.Command{

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

return rancher.UpdateDashboardReferences(ctx, ghClient, &dashboardRelease, rootConfig.User)
return rancher.UpdateDashboardReferences(ctx, rootConfig.Dashboard, ghClient, &dashboardRelease, rootConfig.User)
},
}

Expand Down
15 changes: 9 additions & 6 deletions cmd/release/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ type UIRelease struct {
}

type DashboardRelease struct {
DashboardRepoOwner string `json:"dashboard_repo_owner" validate:"required"`
DashboardRepoName string `json:"dashboard_repo_name"`
PreviousTag string `json:"previous_tag"`
PreviousTag string `json:"previous_tag" validate:"required"`
ReleaseBranch string `json:"release_branch" validate:"required"`
Tag string
RancherUpstreamURL string `json:"rancher_upstream_url" validate:"required"`
RancherUpstreamRepo string `json:"rancher_upstream_repo" validate:"required"`
RancherReleaseBranch string `json:"rancher_release_branch" validate:"required"`
DryRun bool `json:"dry_run"`
}
Expand Down Expand Up @@ -97,7 +93,14 @@ type UI struct {

// Dashboard
type Dashboard struct {
Versions map[string]DashboardRelease `json:"versions" validate:"dive"`
Versions map[string]DashboardRelease `json:"versions" validate:"dive"`
RepoOwner string `json:"repo_owner" validate:"required"`
RepoName string `json:"repo_name" validate:"required"`
UIRepoOwner string `json:"ui_repo_owner" validate:"required"`
UIRepoName string `json:"ui_repo_name" validate:"required"`
RancherRepoOwner string `json:"rancher_repo_owner" validate:"required"`
RancherRepoName string `json:"rancher_repo_name" validate:"required"`
RancherUpstreamURL string `json:"rancher_upstream_url" validate:"required"`
}

// Auth
Expand Down
4 changes: 0 additions & 4 deletions release/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func CreateRelease(ctx context.Context, client *github.Client, r *ecmConfig.Dash
return errors.New("tag isn't a valid semver: " + opts.Tag)
}

if r.DashboardRepoName != "" {
opts.Repo = r.DashboardRepoName
}

latestRC, err := release.LatestRC(ctx, opts.Owner, opts.Repo, opts.Tag, opts.Tag, client)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions release/rancher/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ func GeneratePrimeArtifactsIndex(ctx context.Context, path string, ignoreVersion
return os.WriteFile(filepath.Join(path, "index-prerelease.html"), preReleaseIndex, 0644)
}

func UpdateDashboardReferences(ctx context.Context, ghClient *github.Client, r *config.DashboardRelease, u *config.User) error {
func UpdateDashboardReferences(ctx context.Context, cfg *config.Dashboard, ghClient *github.Client, r *config.DashboardRelease, u *config.User) error {
if err := updateDashboardReferencesAndPush(r, u); err != nil {
return err
}

return createDashboardReferencesPR(ctx, ghClient, r, u)
return createDashboardReferencesPR(ctx, cfg, ghClient, r, u)
}

func updateDashboardReferencesAndPush(r *ecmConfig.DashboardRelease, _ *ecmConfig.User) error {
Expand All @@ -224,7 +224,7 @@ func updateDashboardReferencesAndPush(r *ecmConfig.DashboardRelease, _ *ecmConfi
return nil
}

func createDashboardReferencesPR(ctx context.Context, ghClient *github.Client, r *ecmConfig.DashboardRelease, u *ecmConfig.User) error {
func createDashboardReferencesPR(ctx context.Context, cfg *config.Dashboard, ghClient *github.Client, r *ecmConfig.DashboardRelease, u *ecmConfig.User) error {
pull := &github.NewPullRequest{
Title: github.String(fmt.Sprintf("Bump Dashboard to `%s`", r.Tag)),
Base: github.String(r.RancherReleaseBranch),
Expand All @@ -233,7 +233,7 @@ func createDashboardReferencesPR(ctx context.Context, ghClient *github.Client, r
}

// creating a pr from your fork branch
_, _, err := ghClient.PullRequests.Create(ctx, r.DashboardRepoOwner, r.RancherUpstreamRepo, pull)
_, _, err := ghClient.PullRequests.Create(ctx, cfg.RancherRepoOwner, cfg.RancherRepoName, pull)

return err
}
Expand Down

0 comments on commit 578e465

Please sign in to comment.