Skip to content

Commit

Permalink
Merge pull request #7 from el-memer/patch-1
Browse files Browse the repository at this point in the history
feat(sync): add scheme check before adding it
  • Loading branch information
jplanckeel authored Jan 8, 2024
2 parents e1f6129 + 217c1b9 commit 8766213
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ func Sync(binaryHelm string, configPath string, repoDest string, registryType st
}

for registry, charts := range cfg {
repo := "https://" + registry
repo := registry
if !strings.HasPrefix(repo, "https://") {
repo = "https://" + repo
}
repoName := strings.Split(registry, "/")
err := h.repoAdd(repoName[0], repo)
if err != nil {
fmt.Printf("error: can add repo %v\n", err)
fmt.Printf("error: can't add repo %v\n", err)
}

for chart, versions := range charts.Charts {
Expand All @@ -38,12 +41,12 @@ func pullAndPush(registry string, chart string, chartName string, version string

listSource, err := h.searchChart(chartName, version)
if err != nil {
fmt.Printf("error: can search chart in repo %v\n", err)
fmt.Printf("error: can't search chart in repo %v\n", err)
}

chartSource, err := chartList(listSource.Bytes())
if err != nil {
fmt.Printf("error: %v\n", err)
fmt.Printf("error: can't list chart in repo %v\n", err)
}

for _, c := range chartSource {
Expand All @@ -52,11 +55,11 @@ func pullAndPush(registry string, chart string, chartName string, version string

err := h.pullChart(c.Name, c.Version)
if err != nil {
fmt.Printf("error: %v\n", err)
fmt.Printf("error: can't pull chart from repo %v\n", err)
}
err = h.pushChart(r, chart, c.Version)
if err != nil {
fmt.Printf("error: %v\n", err)
fmt.Printf("error: can't push chart to repo %v\n", err)
}

}
Expand Down

0 comments on commit 8766213

Please sign in to comment.