Skip to content

Commit

Permalink
✨ allow specifying container proxy settings
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed May 14, 2024
1 parent f33c194 commit 14d45f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha2/mondoooperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type MondooOperatorConfigSpec struct {
SkipContainerResolution bool `json:"skipContainerResolution,omitempty"`
// HttpProxy specifies a proxy to use for HTTP requests to the Mondoo Platform.
HttpProxy *string `json:"httpProxy,omitempty"`
// ContainerProxy specifies a proxy to use for container images.
ContainerProxy *string `json:"containerProxy,omitempty"`
}

type Metrics struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/crd/bases/k8s.mondoo.com_mondoooperatorconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ spec:
spec:
description: MondooOperatorConfigSpec defines the desired state of MondooOperatorConfig
properties:
containerProxy:
description: ContainerProxy specifies a proxy to use for container
images.
type: string
httpProxy:
description: HttpProxy specifies a proxy to use for HTTP requests
to the Mondoo Platform.
Expand Down
4 changes: 4 additions & 0 deletions controllers/container_image/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func CronJob(image, integrationMrn, clusterUid, privateImageScanningSecretName s
cmd = append(cmd, []string{"--api-proxy", *cfg.Spec.HttpProxy}...)
}

if cfg.Spec.ContainerProxy != nil {
cmd = append(cmd, []string{"--container-proxy", *cfg.Spec.ContainerProxy}...)
}

envVars := feature_flags.AllFeatureFlagsAsEnv()
envVars = append(envVars, corev1.EnvVar{Name: "MONDOO_AUTO_UPDATE", Value: "false"})
envVars = k8s.MergeEnv(envVars, m.Spec.Containers.Env)
Expand Down
4 changes: 2 additions & 2 deletions controllers/mondoooperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func (r *MondooOperatorConfigReconciler) Reconcile(ctx context.Context, req ctrl
return ctrl.Result{}, nil
}

if config.Spec.HttpProxy != nil {
urlParsed, err := url.Parse(*config.Spec.HttpProxy)
if config.Spec.ContainerProxy != nil {
urlParsed, err := url.Parse(*config.Spec.ContainerProxy)
if err != nil {
return ctrl.Result{}, err
}
Expand Down

0 comments on commit 14d45f0

Please sign in to comment.