From 578e465be50e3f4012e438b0951093066dee6e8a Mon Sep 17 00:00:00 2001 From: Rafael Breno <32229014+rafaelbreno@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:06:14 -0300 Subject: [PATCH] remove unused fields --- cmd/release/cmd/tag.go | 4 ++-- cmd/release/cmd/update.go | 2 +- cmd/release/config/config.go | 15 +++++++++------ release/dashboard/dashboard.go | 4 ---- release/rancher/rancher.go | 8 ++++---- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cmd/release/cmd/tag.go b/cmd/release/cmd/tag.go index 3d178d98..bc4b582b 100644 --- a/cmd/release/cmd/tag.go +++ b/cmd/release/cmd/tag.go @@ -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, } diff --git a/cmd/release/cmd/update.go b/cmd/release/cmd/update.go index 598f7249..f5bf6436 100644 --- a/cmd/release/cmd/update.go +++ b/cmd/release/cmd/update.go @@ -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) }, } diff --git a/cmd/release/config/config.go b/cmd/release/config/config.go index 8be929a5..37bf452d 100644 --- a/cmd/release/config/config.go +++ b/cmd/release/config/config.go @@ -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"` } @@ -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 diff --git a/release/dashboard/dashboard.go b/release/dashboard/dashboard.go index 34c0427e..aeaa8ee1 100644 --- a/release/dashboard/dashboard.go +++ b/release/dashboard/dashboard.go @@ -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 diff --git a/release/rancher/rancher.go b/release/rancher/rancher.go index 782e6e29..eb0e1338 100644 --- a/release/rancher/rancher.go +++ b/release/rancher/rancher.go @@ -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 { @@ -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), @@ -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 }