Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
k8s.io/kubelet v0.35.0
k8s.io/mount-utils v0.35.0
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
sigs.k8s.io/controller-runtime v0.22.4
sigs.k8s.io/controller-runtime v0.23.0
sigs.k8s.io/e2e-framework v0.6.0
sigs.k8s.io/yaml v1.6.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ k8s.io/mount-utils v0.35.0 h1:UDE8RDeqmQh1u/yRd+GZC2EpDibiyAfmMEsm43lKNQI=
k8s.io/mount-utils v0.35.0/go.mod h1:ppC4d+mUpfbAJr/V2E8vvxeCEckNM+S5b0kQBQjd3Pw=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A=
sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8=
sigs.k8s.io/controller-runtime v0.23.0 h1:Ubi7klJWiwEWqDY+odSVZiFA0aDSevOCXpa38yCSYu8=
sigs.k8s.io/controller-runtime v0.23.0/go.mod h1:DBOIr9NsprUqCZ1ZhsuJ0wAnQSIxY/C6VjZbmLgw0j0=
sigs.k8s.io/e2e-framework v0.6.0 h1:p7hFzHnLKO7eNsWGI2AbC1Mo2IYxidg49BiT4njxkrM=
sigs.k8s.io/e2e-framework v0.6.0/go.mod h1:IREnCHnKgRCioLRmNi0hxSJ1kJ+aAdjEKK/gokcZu4k=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
Expand Down
13 changes: 0 additions & 13 deletions pkg/api/latest/dynakube/dynakube_webhook.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/v1alpha1/edgeconnect/edgeconnect_webhook.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/v1alpha2/edgeconnect/edgeconnect_webhook.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/v1beta3/dynakube/dynakube_webhook.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/v1beta4/dynakube/dynakube_webhook.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/v1beta5/dynakube/dynakube_webhook.go

This file was deleted.

8 changes: 4 additions & 4 deletions pkg/api/validation/dynakube/activegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Make sure you don't duplicate an Activegate capability in your custom resource.
warningMissingActiveGateMemoryLimit = `ActiveGate specification missing memory limits. Can cause excess memory usage.`
)

func duplicateActiveGateCapabilities(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func duplicateActiveGateCapabilities(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.ActiveGate().IsEnabled() {
capabilities := dk.Spec.ActiveGate.Capabilities
duplicateChecker := map[activegate.CapabilityDisplayName]bool{}
Expand All @@ -41,7 +41,7 @@ func duplicateActiveGateCapabilities(_ context.Context, _ *Validator, dk *dynaku
return ""
}

func invalidActiveGateCapabilities(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func invalidActiveGateCapabilities(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.ActiveGate().IsEnabled() {
capabilities := dk.Spec.ActiveGate.Capabilities
for _, capability := range capabilities {
Expand All @@ -56,7 +56,7 @@ func invalidActiveGateCapabilities(_ context.Context, _ *Validator, dk *dynakube
return ""
}

func missingActiveGateMemoryLimit(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func missingActiveGateMemoryLimit(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.ActiveGate().IsEnabled() &&
!memoryLimitSet(dk.Spec.ActiveGate.Resources) {
return warningMissingActiveGateMemoryLimit
Expand All @@ -73,7 +73,7 @@ func activeGateMutuallyExclusivePVCSettings(dk *dynakube.DynaKube) bool {
return dk.Spec.ActiveGate.UseEphemeralVolume && dk.Spec.ActiveGate.VolumeClaimTemplate != nil
}

func mutuallyExclusiveActiveGatePVsettings(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func mutuallyExclusiveActiveGatePVsettings(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if activeGateMutuallyExclusivePVCSettings(dk) {
log.Info("requested dynakube specifies mutually exclusive VolumeClaimTemplate settings for ActiveGate.", "name", dk.Name, "namespace", dk.Namespace)

Expand Down
8 changes: 4 additions & 4 deletions pkg/api/validation/dynakube/api_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
errorMutatedAPIURL = `The DynaKube's specification mutated the API URL although it is immutable. Please delete the CR and then apply a new one`
)

func NoAPIURL(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func NoAPIURL(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
apiURL := dk.Spec.APIURL

if apiURL == ExampleAPIURL {
Expand All @@ -42,7 +42,7 @@ func NoAPIURL(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
return ""
}

func IsInvalidAPIURL(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func IsInvalidAPIURL(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
apiURL := dk.Spec.APIURL

if !strings.HasSuffix(apiURL, "/api") {
Expand Down Expand Up @@ -72,15 +72,15 @@ func IsInvalidAPIURL(_ context.Context, _ *Validator, dk *dynakube.DynaKube) str
return ""
}

func IsThirdGenAPIUrl(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func IsThirdGenAPIUrl(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if strings.Contains(dk.APIURL(), ".apps.") {
return errorThirdGenAPIURL
}

return ""
}

func IsMutatedAPIURL(_ context.Context, _ *Validator, oldDk *dynakube.DynaKube, newDk *dynakube.DynaKube) string {
func IsMutatedAPIURL(_ context.Context, _ *validatorClient, oldDk *dynakube.DynaKube, newDk *dynakube.DynaKube) string {
if oldDk.Spec.APIURL != newDk.Spec.APIURL {
return errorMutatedAPIURL
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/validation/dynakube/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
warningHostPathDatabaseVolumeDetected = `Host path database volume detected. If you're on OpenShift, mounting host path volumes will be prohibited by the SCC and cause silent failures. If you still want to do this, make sure to create and bind corresponding roles.`
)

func missingDatabaseExecutorImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func missingDatabaseExecutorImage(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB (for reviwer):

we can also rename validator to validatorType or something similar

type validator[T DynaKubeType] struct {
	*validatorClient
}

and validatorClient back to Validator to reduce amount of changes in this PR

if !dk.Extensions().IsDatabasesEnabled() {
return ""
}
Expand All @@ -36,7 +36,7 @@ func missingDatabaseExecutorImage(_ context.Context, _ *Validator, dk *dynakube.
return ""
}

func conflictingOrInvalidDatabasesVolumeMounts(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func conflictingOrInvalidDatabasesVolumeMounts(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsDatabasesEnabled() {
return ""
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func conflictingOrInvalidDatabasesVolumeMounts(_ context.Context, _ *Validator,
return ""
}

func hostPathDatabaseVolumeFound(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func hostPathDatabaseVolumeFound(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsDatabasesEnabled() {
return ""
}
Expand All @@ -89,7 +89,7 @@ func hostPathDatabaseVolumeFound(_ context.Context, _ *Validator, dk *dynakube.D
return ""
}

func unusedDatabasesVolume(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func unusedDatabasesVolume(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsDatabasesEnabled() {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/dynakube_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
maxNameLengthForKSPM = maxDaemonSetNameLength - len(consts.NodeCollectorNameSuffix)
)

func nameInvalid(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func nameInvalid(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.Name == "" {
// Make unit testing easier. This can never happen in an actual cluster.
return ""
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/validation/dynakube/eec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
warningConflictingAPIURLForExtensions = `You are already using a Dynakube ('%s') that enables extensions. Having multiple Dynakubes with same '.spec.apiUrl' and '.spec.extensions' enabled can have severe side-effects on “sum” and “count” metrics and cause double-billing.`
)

func extensionControllerImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func extensionControllerImage(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsAnyEnabled() {
return ""
}
Expand All @@ -28,13 +28,13 @@ func extensionControllerImage(_ context.Context, _ *Validator, dk *dynakube.Dyna
return ""
}

func conflictingAPIURLForExtensions(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string {
func conflictingAPIURLForExtensions(ctx context.Context, vc *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsAnyEnabled() {
return ""
}

validDynakubes := &dynakube.DynaKubeList{}
if err := dv.apiReader.List(ctx, validDynakubes, &client.ListOptions{Namespace: dk.Namespace}); err != nil {
if err := vc.apiReader.List(ctx, validDynakubes, &client.ListOptions{Namespace: dk.Namespace}); err != nil {
log.Info("error occurred while listing dynakubes", "err", err.Error())

return ""
Expand All @@ -53,7 +53,7 @@ func conflictingAPIURLForExtensions(ctx context.Context, dv *Validator, dk *dyna
return ""
}

func extensionControllerPVCStorageDevice(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func extensionControllerPVCStorageDevice(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.Extensions().IsAnyEnabled() {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
warningExtensionsWithoutK8SMonitoring = "The Dynakube is configured with extensions without an ActiveGate with `kubernetes-monitoring` enabled or the `automatic-kubernetes-api-monitoring` feature flag. You need to ensure that Kubernetes monitoring is setup for this cluster."
)

func extensionsWithoutK8SMonitoring(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string {
func extensionsWithoutK8SMonitoring(ctx context.Context, vc *validatorClient, dk *dynakube.DynaKube) string {
if dk.Extensions().IsAnyEnabled() && (!dk.ActiveGate().IsKubernetesMonitoringEnabled() || !dk.FF().IsAutomaticK8sAPIMonitoring()) {
return warningExtensionsWithoutK8SMonitoring
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/featureflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var deprecatedFeatureFlags = []string{
exp.AGDisableUpdatesKey, //nolint:staticcheck
}

func deprecatedFeatureFlag(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func deprecatedFeatureFlag(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
results := strings.Builder{}

for _, flag := range deprecatedFeatureFlags {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
errorUnparsableImageRef = `Custom %s image can't be parsed, make sure it's a valid image reference.`
)

func imageFieldHasTenantImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func imageFieldHasTenantImage(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
type imageField struct {
value string
section string
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/dynakube/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const (
errorFailToInitIstioClient = `Failed to initialize istio client`
)

func noResourcesAvailable(_ context.Context, dv *Validator, dk *dynakube.DynaKube) string {
func noResourcesAvailable(_ context.Context, vc *validatorClient, dk *dynakube.DynaKube) string {
if dk.Spec.EnableIstio {
istioClient, err := istio.NewClient(dv.cfg, dk)
istioClient, err := istio.NewClient(vc.cfg, dk)
if err != nil {
return errorFailToInitIstioClient
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/validation/dynakube/kspm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ const (
errorKSPMRelativeHostPath = `The Dynakube's specification specifies KSPM, relative path found on the MappedHostPath list. Use absolute paths only. Relative path: %s`
)

func tooManyAGReplicas(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func tooManyAGReplicas(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.KSPM().IsEnabled() && dk.ActiveGate().GetReplicas() > 1 {
return errorTooManyAGReplicas
}

return ""
}

func kspmWithoutK8SMonitoring(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func kspmWithoutK8SMonitoring(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.KSPM().IsEnabled() && (!dk.ActiveGate().IsKubernetesMonitoringEnabled() || !dk.FF().IsAutomaticK8sAPIMonitoring()) {
return errorKSPMMissingKubemon
}

return ""
}

func missingKSPMImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func missingKSPMImage(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.KSPM().IsEnabled() {
return ""
}
Expand All @@ -46,7 +46,7 @@ func missingKSPMImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) st
return ""
}

func noMappedHostPaths(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func noMappedHostPaths(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.KSPM().IsEnabled() {
return ""
}
Expand All @@ -58,7 +58,7 @@ func noMappedHostPaths(_ context.Context, _ *Validator, dk *dynakube.DynaKube) s
return ""
}

func mappedHostPathsWithRootPath(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func mappedHostPathsWithRootPath(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.KSPM().IsEnabled() {
return ""
}
Expand All @@ -72,7 +72,7 @@ func mappedHostPathsWithRootPath(_ context.Context, _ *Validator, dk *dynakube.D
return ""
}

func relativeMappedHostPaths(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func relativeMappedHostPaths(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.KSPM().IsEnabled() {
return ""
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/validation/dynakube/logmonitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const (
errorLogMonitoringMissingImage = `The Dynakube's specification specifies standalone Log monitoring, but no image repository/tag is configured.`
)

func logMonitoringWithoutK8SMonitoring(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string {
func logMonitoringWithoutK8SMonitoring(ctx context.Context, vc *validatorClient, dk *dynakube.DynaKube) string {
if dk.LogMonitoring().IsEnabled() && (!dk.ActiveGate().IsKubernetesMonitoringEnabled() || !dk.FF().IsAutomaticK8sAPIMonitoring()) {
return warningLogMonitoringWithoutK8SMonitoring
}

return ""
}

func ignoredLogMonitoringTemplate(ctx context.Context, dv *Validator, dk *dynakube.DynaKube) string {
func ignoredLogMonitoringTemplate(ctx context.Context, vc *validatorClient, dk *dynakube.DynaKube) string {
if dk.LogMonitoring().IsStandalone() {
return ""
}
Expand All @@ -32,7 +32,7 @@ func ignoredLogMonitoringTemplate(ctx context.Context, dv *Validator, dk *dynaku
return ""
}

func missingLogMonitoringImage(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func missingLogMonitoringImage(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if !dk.LogMonitoring().IsStandalone() {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/metadata_enrichment.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
warningMetadataEnrichmentDisabledForInjection = "metadataEnrichment.enabled is set to false, but OneAgent injection is enabled (applicationMonitoring/cloudNativeFullstack). Metadata enrichment will still be applied and this setting is ignored."
)

func disabledMetadataEnrichmentForInjectionModes(_ context.Context, _ *Validator, dk *dynakube.DynaKube) string {
func disabledMetadataEnrichmentForInjectionModes(_ context.Context, _ *validatorClient, dk *dynakube.DynaKube) string {
if dk.Spec.MetadataEnrichment.Enabled == nil || *dk.Spec.MetadataEnrichment.Enabled {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/dynakube/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestIsModuleDisabled(t *testing.T) {

for _, test := range testCases {
t.Run(test.title, func(t *testing.T) {
errMsg := test.moduleFunc(ctx, &Validator{modules: test.modules}, &test.dk)
errMsg := test.moduleFunc(ctx, &validatorClient{modules: test.modules}, &test.dk)
assert.Equal(t, test.expectedMessage, errMsg)
})
}
Expand Down
Loading