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 defaultRegistryURL and defaultRepoType for non-OCI HelmRepository support #239

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 22 additions & 16 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,34 @@ func init() {
}

func main() {
var metricsAddr string
var probeAddr string
var secureMetrics bool
var enableHTTP2 bool
var defaultOCIRegistry string
var insecureRegistry bool
var registryCredentialsSecret string
var createManagement bool
var createTemplates bool
var hmcTemplatesChartName string
var enableTelemetry bool
var enableWebhook bool
var webhookPort int
var webhookCertDir string
var (
metricsAddr string
probeAddr string
secureMetrics bool
enableHTTP2 bool
defaultRegistryURL string
defaultRepoType string
insecureRegistry bool
registryCredentialsSecret string
createManagement bool
createTemplates bool
hmcTemplatesChartName string
enableTelemetry bool
enableWebhook bool
webhookPort int
webhookCertDir string
)

flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&secureMetrics, "metrics-secure", false,
"If set the metrics endpoint is served securely")
flag.BoolVar(&enableHTTP2, "enable-http2", false,
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
flag.StringVar(&defaultOCIRegistry, "default-oci-registry", "oci://ghcr.io/mirantis/hmc/charts",
flag.StringVar(&defaultRegistryURL, "default-registry-url", "oci://ghcr.io/mirantis/hmc/charts",
"The default OCI registry to download Helm charts from.")
squizzi marked this conversation as resolved.
Show resolved Hide resolved
flag.StringVar(&defaultRepoType, "default-repo-type", "oci",
"The default repository type to download Helm charts from specify 'default' for http/https or 'oci' for oci.")
flag.StringVar(&registryCredentialsSecret, "registry-creds-secret", "",
"Secret containing authentication credentials for the registry.")
flag.BoolVar(&insecureRegistry, "insecure-registry", false, "Allow connecting to an HTTP registry.")
Expand Down Expand Up @@ -180,7 +185,8 @@ func main() {
Config: mgr.GetConfig(),
CreateManagement: createManagement,
CreateTemplates: createTemplates,
DefaultOCIRegistry: defaultOCIRegistry,
DefaultRegistryURL: defaultRegistryURL,
DefaultRepoType: defaultRepoType,
RegistryCredentialsSecret: registryCredentialsSecret,
InsecureRegistry: insecureRegistry,
HMCTemplatesChartName: hmcTemplatesChartName,
Expand Down
10 changes: 7 additions & 3 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ type Poller struct {
CreateManagement bool
CreateTemplates bool

DefaultOCIRegistry string
// DefaultRepoType is the type specified by default in HelmRepository
// objects. Valid types are 'default' for http/https repositories, and
// 'oci' for OCI repositories.
DefaultRepoType string
DefaultRegistryURL string
RegistryCredentialsSecret string
InsecureRegistry bool
HMCTemplatesChartName string
Expand Down Expand Up @@ -183,8 +187,8 @@ func (p *Poller) reconcileDefaultHelmRepo(ctx context.Context) error {
}
helmRepo.Labels[hmc.HMCManagedLabelKey] = hmc.HMCManagedLabelValue
helmRepo.Spec = sourcev1.HelmRepositorySpec{
Type: defaultRepoType,
URL: p.DefaultOCIRegistry,
Type: p.DefaultRepoType,
URL: p.DefaultRegistryURL,
Interval: metav1.Duration{Duration: defaultReconcileInterval},
Insecure: p.InsecureRegistry,
}
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ import (
)

const (
defaultRepoName = "hmc-templates"
defaultRepoType = "oci"

defaultRepoName = "hmc-templates"
defaultReconcileInterval = 10 * time.Minute
)

Expand Down
3 changes: 2 additions & 1 deletion templates/hmc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ spec:
spec:
containers:
- args:
- --default-oci-registry={{ .Values.controller.defaultOCIRegistry }}
- --default-registry-url={{ .Values.controller.defaultRegistryURL }}
- --default-repo-type={{ .Values.controller.defaultRepoType}}
- --insecure-registry={{ .Values.controller.insecureRegistry }}
{{- if .Values.controller.registryCredsSecret }}
- --registry-creds-secret={{ .Values.controller.registryCredsSecret }}
Expand Down
3 changes: 2 additions & 1 deletion templates/hmc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ admissionWebhook:
certDir: "/tmp/k8s-webhook-server/serving-certs/"

controller:
defaultOCIRegistry: "oci://ghcr.io/mirantis/hmc/charts"
defaultRegistryURL: "oci://ghcr.io/mirantis/hmc/charts"
defaultRepoType: "oci"
squizzi marked this conversation as resolved.
Show resolved Hide resolved
registryCredsSecret: ""
insecureRegistry: false
createManagement: true
Expand Down