Skip to content

Commit

Permalink
fix: add Registry to helm Options struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-ibra committed Jul 31, 2024
1 parent fe9366e commit 21fecb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions internal/controller/validatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ func (r *ValidatorConfigReconciler) redeployIfNeeded(ctx context.Context, vc *v1

opts := &helm.Options{
Chart: p.Chart.Name,
Repo: fmt.Sprintf("%s/%s", helmConfig.Registry, p.Chart.Repository),
Repo: p.Chart.Repository,
Registry: helmConfig.Registry,
Version: p.Chart.Version,
Values: p.Values,
InsecureSkipTLSVerify: helmConfig.InsecureSkipTLSVerify,
Expand Down Expand Up @@ -201,7 +202,7 @@ func (r *ValidatorConfigReconciler) redeployIfNeeded(ctx context.Context, vc *v1
continue
}
ociOpts := oci.ImageOptions{
Ref: fmt.Sprintf("%s/%s:%s", strings.TrimPrefix(opts.Repo, oci.Scheme), opts.Chart, opts.Version),
Ref: fmt.Sprintf("%s/%s/%s:%s", strings.TrimPrefix(opts.Registry, oci.Scheme), opts.Repo, opts.Chart, opts.Version),
OutDir: opts.Path,
OutFile: opts.Chart,
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func (c *CLIClient) run(name, namespace string, options Options, command string,
args = append(args, options.Path)
} else if options.Chart != "" {
args = append(args, options.Chart)
if options.Registry != "" {
return fmt.Errorf("chart registry cannot be null")
}
if options.Repo == "" {
return fmt.Errorf("chart repo cannot be null")
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/helm/options.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package helm

import "fmt"

// Options holds all the options for installing/pulling/upgrading a chart.
type Options struct {
Chart string
Path string

Registry string
Repo string
Version string
Values string
Expand All @@ -29,7 +32,7 @@ type Options struct {

// ConfigureRepo adds the repo flag to the command.
func (o Options) ConfigureRepo(args []string) []string {
args = append(args, "--repo", o.Repo)
args = append(args, "--repo", fmt.Sprintf("%s/%s", o.Registry, o.Repo))
return args
}

Expand Down

0 comments on commit 21fecb0

Please sign in to comment.