Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add destproject option to push to different project #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion chartmuseum2oci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var (
harborUsername string //nolint:gochecknoglobals
harborPassword string //nolint:gochecknoglobals
harborHost string //nolint:gochecknoglobals
destProject string //nolint:gochecknoglobals
destPath string //nolint:gochecknoglobals
projectsToMigrate ProjectsToMigrateList //nolint:gochecknoglobals
)
Expand All @@ -63,6 +64,7 @@ func initFlags() {
flag.StringVar(&harborURL, "url", "", "Harbor registry url")
flag.StringVar(&harborUsername, "username", "", "Harbor registry username")
flag.StringVar(&harborPassword, "password", "", "Harbor registry password")
flag.StringVar(&destProject, "destproject", "", "Destination project")
flag.StringVar(&destPath, "destpath", "", "Destination subpath")
flag.Var(&projectsToMigrate, "project", "Name of the project(s) to migrate")
flag.Parse()
Expand Down Expand Up @@ -274,7 +276,14 @@ func pullChartFromChartmuseum(helmChart HelmChart) error {
}

func pushChartToOCI(helmChart HelmChart) error {
repoURL := fmt.Sprintf("oci://%s/%s%s", harborHost, helmChart.Project, destPath)
var harborProject string
if destProject != "" {
harborProject = destProject
} else {
harborProject = helmChart.Project
}

repoURL := fmt.Sprintf("oci://%s/%s%s", harborHost, harborProject, destPath)
cmd := exec.Command(helmBinaryPath, "push", helmChart.ChartFileName(), repoURL) //nolint:gosec

var stdErr bytes.Buffer
Expand Down