Skip to content

Commit

Permalink
more var renames
Browse files Browse the repository at this point in the history
  • Loading branch information
pedjak committed Sep 3, 2020
1 parent 49b2592 commit e5a854a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions pkg/helm/chartproxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ var (
)

type config struct {
repoUrl string
repoCaFile string
repoURL string
repoCAFile string
}

func RegisterFlags(fs *flag.FlagSet) *config {

cfg := new(config)

fs.StringVar(&cfg.repoUrl, "helm-chart-repo-url", "https://redhat-developer.github.io/redhat-helm-charts", "Helm chart repository URL")
fs.StringVar(&cfg.repoCaFile, "helm-chart-repo-ca-file", "", "CA bundle for Helm chart repository.")
fs.StringVar(&cfg.repoURL, "helm-chart-repo-url", "https://redhat-developer.github.io/redhat-helm-charts", "Helm chart repository URL")
fs.StringVar(&cfg.repoCAFile, "helm-chart-repo-ca-file", "", "CA bundle for Helm chart repository.")

return cfg
}

func (cfg *config) Configure() {
repoURL := bridge.ValidateFlagIsURL("helm-chart-repo-repoUrl", cfg.repoUrl)
repoURL := bridge.ValidateFlagIsURL("helm-chart-repo-url", cfg.repoURL)

var rootCAs *x509.CertPool
if cfg.repoCaFile != "" {
if cfg.repoCAFile != "" {
rootCAs = x509.NewCertPool()
certPEM, err := ioutil.ReadFile(cfg.repoCaFile)
certPEM, err := ioutil.ReadFile(cfg.repoCAFile)
if err != nil {
log.Fatalf("failed to read helm chart repo ca file %v : %v", cfg.repoCaFile, err)
log.Fatalf("failed to read helm chart repo ca file %v : %v", cfg.repoCAFile, err)
}
if !rootCAs.AppendCertsFromPEM(certPEM) {
log.Fatalf("No CA found for Helm chart repo proxy")
Expand All @@ -51,7 +51,7 @@ func (cfg *config) Configure() {

DefaultRepo = helmRepo{
Name: "redhat-helm-charts",
Url: repoURL,
URL: repoURL,
TLSClientConfig: oscrypto.SecureTLSConfig(&tls.Config{
RootCAs: rootCAs,
CipherSuites: oscrypto.DefaultCiphers(),
Expand Down
12 changes: 6 additions & 6 deletions pkg/helm/chartproxy/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (

type helmRepo struct {
Name string
Url *url.URL
URL *url.URL
TLSClientConfig *tls.Config
}

Expand Down Expand Up @@ -67,11 +67,11 @@ func (hr helmRepo) IndexFile() (*repo.IndexFile, error) {
if err != nil {
return nil, err
}
indexUrl := hr.Url.String()
if !strings.HasSuffix(indexUrl, "/index.yaml") {
indexUrl += "/index.yaml"
indexURL := hr.URL.String()
if !strings.HasSuffix(indexURL, "/index.yaml") {
indexURL += "/index.yaml"
}
resp, err := httpClient.Get(indexUrl)
resp, err := httpClient.Get(indexURL)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (b helmRepoGetter) unmarshallConfig(repo unstructured.Unstructured) (*helmR
return nil, err
}

h.Url, err = url.Parse(urlValue)
h.URL, err = url.Parse(urlValue)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/helm/chartproxy/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestHelmRepoGetter_List(t *testing.T) {
indexFileContennts = append(indexFileContennts, "")
}
client := fake.K8sDynamicClient(indexFileContennts...)
cfg := config{repoUrl: "https://default-url.com"}
cfg := config{repoURL: "https://default-url.com"}
cfg.Configure()
repoGetter := NewRepoGetter(client, nil)
repos, err := repoGetter.List()
Expand Down

0 comments on commit e5a854a

Please sign in to comment.