1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Maintenance] Inspector Generics (#1752)

This commit is contained in:
Adam Janikowski 2024-10-31 13:05:01 +01:00 committed by GitHub
parent f91155478a
commit 87d14d510b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 3053 additions and 5299 deletions

View file

@ -8,6 +8,7 @@
- (Maintenance) Proto Lint
- (Feature) (Integration) SchedulerV2
- (Feature) (Integration) Basic Envs
- (Maintenance) Inspector Generics
## [1.2.43](https://github.com/arangodb/kube-arangodb/tree/1.2.43) (2024-10-14)
- (Feature) ArangoRoute CRD

View file

@ -195,7 +195,7 @@ Flags:
--kubernetes.max-batch-size int Size of batch during objects read (default 256)
--kubernetes.qps float32 Number of queries per second for k8s API (default 15)
--log.format string Set log format. Allowed values: 'pretty', 'JSON'. If empty, default format is used (default "pretty")
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, generic-parent-operator, http, inspector, integration-config-v1, integration-envoy-auth-v3, integrations, k8s-client, kubernetes-informer, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, scheduler-batchjob-operator, scheduler-cronjob-operator, scheduler-deployment-operator, scheduler-pod-operator, scheduler-profile-operator, server, server-authentication (default [info])
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, generic-parent-operator, helm, http, inspector, integration-config-v1, integration-envoy-auth-v3, integration-scheduler-v2, integrations, k8s-client, kubernetes-informer, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, scheduler-batchjob-operator, scheduler-cronjob-operator, scheduler-deployment-operator, scheduler-pod-operator, scheduler-profile-operator, server, server-authentication (default [info])
--log.sampling If true, operator will try to minimize duplication of logging events (default true)
--memory-limit uint Define memory limit for hard shutdown and the dump of goroutines. Used for testing
--metrics.excluded-prefixes stringArray List of the excluded metrics prefixes

View file

@ -47,7 +47,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
)
@ -296,7 +296,7 @@ func createClient(endpoints []string, certCA *x509.CertPool, auth connection.Aut
}
// getJWTTokenFromSecrets returns token from the secret.
func getJWTTokenFromSecrets(ctx context.Context, secrets secretv1.ReadInterface, name string) (connection.Authentication, error) {
func getJWTTokenFromSecrets(ctx context.Context, secrets generic.ReadClient[*core.Secret], name string) (connection.Authentication, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
@ -314,7 +314,7 @@ func getJWTTokenFromSecrets(ctx context.Context, secrets secretv1.ReadInterface,
}
// getCACertificate returns CA certificate from the secret.
func getCACertificate(ctx context.Context, secrets secretv1.ReadInterface, name string) (*x509.CertPool, error) {
func getCACertificate(ctx context.Context, secrets generic.ReadClient[*core.Secret], name string) (*x509.CertPool, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()

View file

@ -80,7 +80,7 @@ Flags:
--kubernetes.max-batch-size int Size of batch during objects read (default 256)
--kubernetes.qps float32 Number of queries per second for k8s API (default 15)
--log.format string Set log format. Allowed values: 'pretty', 'JSON'. If empty, default format is used (default "pretty")
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, generic-parent-operator, http, inspector, integration-config-v1, integration-envoy-auth-v3, integrations, k8s-client, kubernetes-informer, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, scheduler-batchjob-operator, scheduler-cronjob-operator, scheduler-deployment-operator, scheduler-pod-operator, scheduler-profile-operator, server, server-authentication (default [info])
--log.level stringArray Set log levels in format <level> or <logger>=<level>. Possible loggers: action, agency, api-server, assertion, backup-operator, chaos-monkey, crd, deployment, deployment-ci, deployment-reconcile, deployment-replication, deployment-resilience, deployment-resources, deployment-storage, deployment-storage-pc, deployment-storage-service, generic-parent-operator, helm, http, inspector, integration-config-v1, integration-envoy-auth-v3, integration-scheduler-v2, integrations, k8s-client, kubernetes-informer, monitor, networking-route-operator, operator, operator-arangojob-handler, operator-v2, operator-v2-event, operator-v2-worker, panics, pod_compare, root, root-event-recorder, scheduler-batchjob-operator, scheduler-cronjob-operator, scheduler-deployment-operator, scheduler-pod-operator, scheduler-profile-operator, server, server-authentication (default [info])
--log.sampling If true, operator will try to minimize duplication of logging events (default true)
--memory-limit uint Define memory limit for hard shutdown and the dump of goroutines. Used for testing
--metrics.excluded-prefixes stringArray List of the excluded metrics prefixes

View file

@ -51,6 +51,11 @@ Flags:
--integration.scheduler.v1.internal Defones if Internal access to service scheduler.v1 is enabled (Env: INTEGRATION_SCHEDULER_V1_INTERNAL) (default true)
--integration.scheduler.v1.namespace string Kubernetes Namespace (Env: INTEGRATION_SCHEDULER_V1_NAMESPACE) (default "default")
--integration.scheduler.v1.verify-access Verify the CRD Access (Env: INTEGRATION_SCHEDULER_V1_VERIFY_ACCESS) (default true)
--integration.scheduler.v2 SchedulerV2 Integration (Env: INTEGRATION_SCHEDULER_V2)
--integration.scheduler.v2.deployment string ArangoDeployment Name (Env: INTEGRATION_SCHEDULER_V2_DEPLOYMENT)
--integration.scheduler.v2.external Defones if External access to service scheduler.v2 is enabled (Env: INTEGRATION_SCHEDULER_V2_EXTERNAL)
--integration.scheduler.v2.internal Defones if Internal access to service scheduler.v2 is enabled (Env: INTEGRATION_SCHEDULER_V2_INTERNAL) (default true)
--integration.scheduler.v2.namespace string Kubernetes Namespace (Env: INTEGRATION_SCHEDULER_V2_NAMESPACE) (default "default")
--integration.shutdown.v1 ShutdownV1 Handler (Env: INTEGRATION_SHUTDOWN_V1)
--integration.shutdown.v1.external Defones if External access to service shutdown.v1 is enabled (Env: INTEGRATION_SHUTDOWN_V1_EXTERNAL)
--integration.shutdown.v1.internal Defones if Internal access to service shutdown.v1 is enabled (Env: INTEGRATION_SHUTDOWN_V1_INTERNAL) (default true)

9
pkg/api/jwt.go generated
View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,13 +26,14 @@ import (
"time"
jg "github.com/golang-jwt/jwt"
core "k8s.io/api/core/v1"
typedCore "k8s.io/client-go/kubernetes/typed/core/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secret "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
)
@ -67,7 +68,7 @@ func ensureJWT(cli typedCore.CoreV1Interface, cfg ServerConfig) (string, error)
// generateAndSaveJWT tries to generate new JWT using signing key retrieved from secret.
// If it is not present, it creates a new key.
// The resulting JWT is stored in secrets.
func generateAndSaveJWT(secrets secret.Interface, cfg ServerConfig) error {
func generateAndSaveJWT(secrets generic.InspectorInterface[*core.Secret], cfg ServerConfig) error {
claims := jg.MapClaims{
"iss": fmt.Sprintf("kube-arangodb/%s", cfg.ServerName),
"iat": time.Now().Unix(),
@ -79,7 +80,7 @@ func generateAndSaveJWT(secrets secret.Interface, cfg ServerConfig) error {
return err
}
func createSigningKey(secrets secret.ModInterface, keySecretName string) (string, error) {
func createSigningKey(secrets generic.ModClient[*core.Secret], keySecretName string) (string, error) {
signingKey := make([]byte, 32)
_, err := util.Rand().Read(signingKey)
if err != nil {

View file

@ -619,6 +619,13 @@ v1alpha1:
type: array
podSecurityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -655,6 +662,8 @@ v1alpha1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -769,6 +778,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -786,6 +797,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -962,6 +980,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1348,6 +1368,13 @@ v1alpha1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:
@ -1991,6 +2018,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -2006,6 +2035,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2137,6 +2173,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:

View file

@ -23,6 +23,8 @@ v1:
completions:
format: int32
type: integer
managedBy:
type: string
manualSelector:
type: boolean
maxFailedIndexes:
@ -84,6 +86,19 @@ v1:
type: string
type: object
type: object
successPolicy:
properties:
rules:
items:
properties:
succeededCount:
format: int32
type: integer
succeededIndexes:
type: string
type: object
type: array
type: object
suspend:
type: boolean
template:
@ -842,6 +857,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -859,6 +876,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1009,6 +1033,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1383,6 +1409,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1400,6 +1428,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1552,6 +1587,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1930,6 +1967,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1947,6 +1986,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2097,6 +2143,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2141,14 +2189,11 @@ v1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2165,6 +2210,13 @@ v1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2201,6 +2253,8 @@ v1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2674,6 +2728,13 @@ v1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1005,6 +1007,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1022,6 +1026,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1172,6 +1183,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1546,6 +1559,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1563,6 +1578,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1715,6 +1737,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2093,6 +2117,8 @@ v1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -2110,6 +2136,13 @@ v1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2260,6 +2293,8 @@ v1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2304,14 +2339,11 @@ v1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2328,6 +2360,13 @@ v1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2364,6 +2403,8 @@ v1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2837,6 +2878,13 @@ v1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:
@ -3180,6 +3228,8 @@ v2alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -4156,6 +4206,8 @@ v2alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -4173,6 +4225,13 @@ v2alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -4323,6 +4382,8 @@ v2alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -4697,6 +4758,8 @@ v2alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -4714,6 +4777,13 @@ v2alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -4866,6 +4936,8 @@ v2alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -5244,6 +5316,8 @@ v2alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -5261,6 +5335,13 @@ v2alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -5411,6 +5492,8 @@ v2alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -5455,14 +5538,11 @@ v2alpha1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -5479,6 +5559,13 @@ v2alpha1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -5515,6 +5602,8 @@ v2alpha1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -5988,6 +6077,13 @@ v2alpha1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,8 @@ v1alpha1:
completions:
format: int32
type: integer
managedBy:
type: string
manualSelector:
type: boolean
maxFailedIndexes:
@ -78,6 +80,19 @@ v1alpha1:
type: string
type: object
type: object
successPolicy:
properties:
rules:
items:
properties:
succeededCount:
format: int32
type: integer
succeededIndexes:
type: string
type: object
type: array
type: object
suspend:
type: boolean
template:
@ -836,6 +851,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -853,6 +870,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1003,6 +1027,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1377,6 +1403,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1394,6 +1422,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1546,6 +1581,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1924,6 +1961,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1941,6 +1980,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2091,6 +2137,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2135,14 +2183,11 @@ v1alpha1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2159,6 +2204,13 @@ v1alpha1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2195,6 +2247,8 @@ v1alpha1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2668,6 +2722,13 @@ v1alpha1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -102,6 +102,8 @@ v1alpha1:
completions:
format: int32
type: integer
managedBy:
type: string
manualSelector:
type: boolean
maxFailedIndexes:
@ -163,6 +165,19 @@ v1alpha1:
type: string
type: object
type: object
successPolicy:
properties:
rules:
items:
properties:
succeededCount:
format: int32
type: integer
succeededIndexes:
type: string
type: object
type: array
type: object
suspend:
type: boolean
template:
@ -921,6 +936,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -938,6 +955,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1088,6 +1112,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1462,6 +1488,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1479,6 +1507,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1631,6 +1666,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2009,6 +2046,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -2026,6 +2065,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2176,6 +2222,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2220,14 +2268,11 @@ v1alpha1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2244,6 +2289,13 @@ v1alpha1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2280,6 +2332,8 @@ v1alpha1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2753,6 +2807,13 @@ v1alpha1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -408,6 +408,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -423,6 +425,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -554,6 +563,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:

View file

@ -17,6 +17,8 @@ v1beta1:
completions:
format: int32
type: integer
managedBy:
type: string
manualSelector:
type: boolean
maxFailedIndexes:
@ -82,6 +84,19 @@ v1beta1:
type: string
type: object
type: object
successPolicy:
properties:
rules:
items:
properties:
succeededCount:
format: int32
type: integer
succeededIndexes:
type: string
type: object
type: array
type: object
suspend:
type: boolean
template:
@ -840,6 +855,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -857,6 +874,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1007,6 +1031,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1381,6 +1407,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1398,6 +1426,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1550,6 +1585,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1928,6 +1965,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1945,6 +1984,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2095,6 +2141,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2139,14 +2187,11 @@ v1beta1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2163,6 +2208,13 @@ v1beta1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2199,6 +2251,8 @@ v1beta1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2672,6 +2726,13 @@ v1beta1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -102,6 +102,8 @@ v1beta1:
completions:
format: int32
type: integer
managedBy:
type: string
manualSelector:
type: boolean
maxFailedIndexes:
@ -163,6 +165,19 @@ v1beta1:
type: string
type: object
type: object
successPolicy:
properties:
rules:
items:
properties:
succeededCount:
format: int32
type: integer
succeededIndexes:
type: string
type: object
type: array
type: object
suspend:
type: boolean
template:
@ -921,6 +936,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -938,6 +955,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1088,6 +1112,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1462,6 +1488,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1479,6 +1507,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1631,6 +1666,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2009,6 +2046,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -2026,6 +2065,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2176,6 +2222,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2220,14 +2268,11 @@ v1beta1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2244,6 +2289,13 @@ v1beta1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2280,6 +2332,8 @@ v1beta1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2753,6 +2807,13 @@ v1beta1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -811,6 +811,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -828,6 +830,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -978,6 +987,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1352,6 +1363,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1369,6 +1382,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1521,6 +1541,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1899,6 +1921,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1916,6 +1940,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2066,6 +2097,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2110,14 +2143,11 @@ v1beta1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2134,6 +2164,13 @@ v1beta1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2170,6 +2207,8 @@ v1beta1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2643,6 +2682,13 @@ v1beta1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -679,6 +679,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -696,6 +698,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -846,6 +855,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1220,6 +1231,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1237,6 +1250,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1389,6 +1409,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1767,6 +1789,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -1784,6 +1808,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -1934,6 +1965,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -1982,14 +2015,11 @@ v1beta1:
properties:
name:
type: string
source:
properties:
resourceClaimName:
type: string
resourceClaimTemplateName:
type: string
type: object
type: object
type: array
restartPolicy:
type: string
@ -2006,6 +2036,13 @@ v1beta1:
type: array
securityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2042,6 +2079,8 @@ v1beta1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -2515,6 +2554,13 @@ v1beta1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -113,6 +113,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -449,6 +451,8 @@ v1alpha1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -464,6 +468,13 @@ v1alpha1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -595,6 +606,8 @@ v1alpha1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -982,6 +995,13 @@ v1alpha1:
type: array
podSecurityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -1018,6 +1038,8 @@ v1alpha1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -1441,6 +1463,13 @@ v1alpha1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:
@ -1864,6 +1893,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2202,6 +2233,8 @@ v1beta1:
properties:
name:
type: string
request:
type: string
type: object
type: array
limits:
@ -2217,6 +2250,13 @@ v1beta1:
properties:
allowPrivilegeEscalation:
type: boolean
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
capabilities:
properties:
add:
@ -2348,6 +2388,8 @@ v1beta1:
type: string
readOnly:
type: boolean
recursiveReadOnly:
type: string
subPath:
type: string
subPathExpr:
@ -2735,6 +2777,13 @@ v1beta1:
type: array
podSecurityContext:
properties:
appArmorProfile:
properties:
localhostProfile:
type: string
type:
type: string
type: object
fsGroup:
format: int64
type: integer
@ -2771,6 +2820,8 @@ v1beta1:
format: int64
type: integer
type: array
supplementalGroupsPolicy:
type: string
sysctls:
items:
properties:
@ -3194,6 +3245,13 @@ v1beta1:
type:
type: string
type: object
image:
properties:
pullPolicy:
type: string
reference:
type: string
type: object
iscsi:
properties:
chapAuthDiscovery:

View file

@ -24,60 +24,11 @@ import (
"context"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/list"
)
type ObjectList[T meta.Object] map[types.UID]T
func (d ObjectList[T]) ByName(name string) (T, bool) {
for _, obj := range d {
if obj.GetName() == name {
return obj, true
}
}
return util.Default[T](), false
}
func (d ObjectList[T]) AsList() util.List[T] {
list := make([]T, 0, len(d))
for _, p := range d {
list = append(list, p)
}
return list
}
func MapObjects[L generic.ListContinue, T meta.Object](ctx context.Context, k generic.ListInterface[L], extract func(result L) []T) (ObjectList[T], error) {
objects := ObjectList[T]{}
if err := k8sutil.APIList[L](ctx, k, meta.ListOptions{}, func(result L, err error) error {
if err != nil {
return err
}
for _, obj := range extract(result) {
obj.SetManagedFields(nil)
objects[obj.GetUID()] = obj
}
return nil
}); err != nil {
return nil, err
}
return objects, nil
}
func ListObjects[L generic.ListContinue, T meta.Object](ctx context.Context, k generic.ListInterface[L], extract func(result L) []T) ([]T, error) {
objects, err := MapObjects[L, T](ctx, k, extract)
if err != nil {
return nil, err
}
return objects.AsList(), nil
return list.APIList[L, T](ctx, k, meta.ListOptions{}, extract)
}

View file

@ -31,8 +31,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
pvcv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
)
@ -63,7 +62,7 @@ func (d *Deployment) removePodFinalizers(ctx context.Context, cachedStatus inspe
}
}
return nil
}, podv1.FilterPodsByLabels(k8sutil.LabelsForDeployment(d.GetName(), ""))); err != nil {
}, generic.FilterByLabels[*core.Pod](k8sutil.LabelsForDeployment(d.GetName(), ""))); err != nil {
return false, err
}
@ -85,7 +84,7 @@ func (d *Deployment) removePVCFinalizers(ctx context.Context, cachedStatus inspe
found = true
}
return nil
}, pvcv1.FilterPersistentVolumeClaimsByLabels(k8sutil.LabelsForDeployment(d.GetName(), ""))); err != nil {
}, generic.FilterByLabels[*core.PersistentVolumeClaim](k8sutil.LabelsForDeployment(d.GetName(), ""))); err != nil {
return false, err
}

View file

@ -26,7 +26,9 @@ import (
"net"
"strconv"
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
core "k8s.io/api/core/v1"
policy "k8s.io/api/policy/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
@ -57,13 +59,7 @@ import (
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
persistentvolumeclaimv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
poddisruptionbudgetv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
servicev1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
serviceaccountv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
servicemonitorv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
)
@ -557,37 +553,37 @@ func (d *Deployment) WithStatusUpdate(ctx context.Context, action reconciler.Dep
})
}
func (d *Deployment) SecretsModInterface() secretv1.ModInterface {
func (d *Deployment) SecretsModInterface() generic.ModClient[*core.Secret] {
d.acs.CurrentClusterCache().GetThrottles().Secret().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).Secrets()
}
func (d *Deployment) PodsModInterface() podv1.ModInterface {
func (d *Deployment) PodsModInterface() generic.ModClient[*core.Pod] {
d.acs.CurrentClusterCache().GetThrottles().Pod().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).Pods()
}
func (d *Deployment) ServiceAccountsModInterface() serviceaccountv1.ModInterface {
func (d *Deployment) ServiceAccountsModInterface() generic.ModClient[*core.ServiceAccount] {
d.acs.CurrentClusterCache().GetThrottles().ServiceAccount().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).ServiceAccounts()
}
func (d *Deployment) ServicesModInterface() servicev1.ModInterface {
func (d *Deployment) ServicesModInterface() generic.ModClient[*core.Service] {
d.acs.CurrentClusterCache().GetThrottles().Service().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).Services()
}
func (d *Deployment) PersistentVolumeClaimsModInterface() persistentvolumeclaimv1.ModInterface {
func (d *Deployment) PersistentVolumeClaimsModInterface() generic.ModClient[*core.PersistentVolumeClaim] {
d.acs.CurrentClusterCache().GetThrottles().PersistentVolumeClaim().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).PersistentVolumeClaims()
}
func (d *Deployment) PodDisruptionBudgetsModInterface() poddisruptionbudgetv1.ModInterface {
func (d *Deployment) PodDisruptionBudgetsModInterface() generic.ModClient[*policy.PodDisruptionBudget] {
d.acs.CurrentClusterCache().GetThrottles().PodDisruptionBudget().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).PodDisruptionBudgets()
}
func (d *Deployment) ServiceMonitorsModInterface() servicemonitorv1.ModInterface {
func (d *Deployment) ServiceMonitorsModInterface() generic.ModClient[*monitoring.ServiceMonitor] {
d.acs.CurrentClusterCache().GetThrottles().ServiceMonitor().Invalidate()
return kclient.NewModInterface(d.deps.Client, d.namespace).ServiceMonitors()
}

View file

@ -34,10 +34,10 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
)
func createTLSSNISecret(t *testing.T, client secretv1.ModInterface, name, namespace string) {
func createTLSSNISecret(t *testing.T, client generic.ModClient[*core.Secret], name, namespace string) {
secret := core.Secret{
ObjectMeta: meta.ObjectMeta{
Name: name,

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -233,7 +233,6 @@ func runTestCase(t *testing.T, testCase testCaseStruct) {
// Assert
if testCase.ExpectedError != nil {
if !assert.EqualError(t, err, testCase.ExpectedError.Error()) {
println(fmt.Sprintf("%+v", err))
}

View file

@ -36,7 +36,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/interfaces"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
)
@ -66,7 +66,7 @@ func GroupEncryptionSupported(mode api.DeploymentMode, group api.ServerGroup) bo
}
}
func GetEncryptionKey(ctx context.Context, secrets secretv1.ReadInterface, name string) (string, []byte, bool, error) {
func GetEncryptionKey(ctx context.Context, secrets generic.ReadClient[*core.Secret], name string) (string, []byte, bool, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()

View file

@ -29,6 +29,7 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
@ -89,7 +90,7 @@ func (a *actionPVCResize) Start(ctx context.Context) (bool, error) {
return true, nil
}
am := cache.ArangoMember().V1().GetSimpleOptional(m.ArangoMemberName(a.actionCtx.GetName(), group))
am := util.InitOptional(cache.ArangoMember().V1().GetSimple(m.ArangoMemberName(a.actionCtx.GetName(), group)))
var res core.ResourceList
if am.Spec.Overrides.HasVolumeClaimTemplate(&groupSpec) {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -113,7 +113,7 @@ func (r *Reconciler) isStorageClassChanged(_ context.Context, apiObject k8sutil.
return false, "", nil
}
am := cache.ArangoMember().V1().GetSimpleOptional(member.ArangoMemberName(context.GetName(), group))
am := util.InitOptional(cache.ArangoMember().V1().GetSimple(member.ArangoMemberName(context.GetName(), group)))
groupSpec := spec.GetServerGroupSpec(group)
storageClassName := am.Spec.Overrides.GetStorageClassName(&groupSpec)
@ -186,7 +186,7 @@ func (r *Reconciler) isVolumeSizeChanged(_ context.Context, _ k8sutil.APIObject,
return false, "", nil
}
am := cache.ArangoMember().V1().GetSimpleOptional(member.ArangoMemberName(context.GetName(), group))
am := util.InitOptional(cache.ArangoMember().V1().GetSimple(member.ArangoMemberName(context.GetName(), group)))
pvc, ok := cache.PersistentVolumeClaim().V1().GetSimple(member.PersistentVolumeClaim.GetName())
if !ok {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -28,6 +28,7 @@ import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/actions"
sharedReconcile "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
)
@ -97,7 +98,7 @@ func (r *Reconciler) createRotateServerStorageResizePlanInternal(spec api.Deploy
continue
}
am := cache.ArangoMember().V1().GetSimpleOptional(member.Member.ArangoMemberName(context.GetName(), member.Group))
am := util.InitOptional(cache.ArangoMember().V1().GetSimple(member.Member.ArangoMemberName(context.GetName(), member.Group)))
if groupSpec.VolumeResizeMode.Get() != mode {
continue

View file

@ -31,6 +31,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
core "k8s.io/api/core/v1"
policy "k8s.io/api/policy/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
@ -59,14 +60,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors/panics"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
arangomemberv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
persistentvolumeclaimv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
poddisruptionbudgetv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
servicev1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
serviceaccountv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
servicemonitorv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
"github.com/arangodb/kube-arangodb/pkg/util/tests"
)
@ -184,35 +178,35 @@ func (c *testContext) GetAgencyCache() (state.State, bool) {
return state.State{}, true
}
func (c *testContext) SecretsModInterface() secretv1.ModInterface {
func (c *testContext) SecretsModInterface() generic.ModClient[*core.Secret] {
panic("implement me")
}
func (c *testContext) PodsModInterface() podv1.ModInterface {
func (c *testContext) PodsModInterface() generic.ModClient[*core.Pod] {
panic("implement me")
}
func (c *testContext) ServiceAccountsModInterface() serviceaccountv1.ModInterface {
func (c *testContext) ServiceAccountsModInterface() generic.ModClient[*core.ServiceAccount] {
panic("implement me")
}
func (c *testContext) ServicesModInterface() servicev1.ModInterface {
func (c *testContext) ServicesModInterface() generic.ReadClient[*core.Service] {
panic("implement me")
}
func (c *testContext) PersistentVolumeClaimsModInterface() persistentvolumeclaimv1.ModInterface {
func (c *testContext) PersistentVolumeClaimsModInterface() generic.ModClient[*core.PersistentVolumeClaim] {
panic("implement me")
}
func (c *testContext) PodDisruptionBudgetsModInterface() poddisruptionbudgetv1.ModInterface {
func (c *testContext) PodDisruptionBudgetsModInterface() generic.ModClient[*policy.PodDisruptionBudget] {
panic("implement me")
}
func (c *testContext) ServiceMonitorsModInterface() servicemonitorv1.ModInterface {
func (c *testContext) ServiceMonitorsModInterface() generic.ModClient[*core.Service] {
panic("implement me")
}
func (c *testContext) ArangoMembersModInterface() arangomemberv1.ModInterface {
func (c *testContext) ArangoMembersModInterface() generic.ModClient[*api.ArangoMember] {
panic("implement me")
}
@ -264,7 +258,7 @@ func (c *testContext) GetBackup(_ context.Context, backup string) (*backupApi.Ar
panic("implement me")
}
func (c *testContext) SecretsInterface() secretv1.Interface {
func (c *testContext) SecretsInterface() generic.ModClient[*core.Secret] {
panic("implement me")
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -21,10 +21,12 @@
package reconcile
import (
core "k8s.io/api/core/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
"github.com/arangodb/kube-arangodb/pkg/generated/timezones"
"github.com/arangodb/kube-arangodb/pkg/util"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
)
const defaultTimezone = "UTC"
@ -36,7 +38,7 @@ func GetTimezone(tz *string) (timezones.Timezone, bool) {
return timezones.GetTimezone(*tz)
}
func IsTimezoneValid(cache secretv1.Inspector, name string, timezone timezones.Timezone) bool {
func IsTimezoneValid(cache generic.Inspector[*core.Secret], name string, timezone timezones.Timezone) bool {
sn := pod.TimezoneSecret(name)
tzd, ok := timezone.GetData()

View file

@ -24,19 +24,20 @@ import (
"context"
"fmt"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
ktls "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls"
)
// createClientAuthCACertificate creates a client authentication CA certificate and stores it in a secret with name
// specified in the given spec.
func (r *Resources) createClientAuthCACertificate(ctx context.Context, secrets secretv1.ModInterface, spec api.SyncAuthenticationSpec, deploymentName string, ownerRef *meta.OwnerReference) error {
func (r *Resources) createClientAuthCACertificate(ctx context.Context, secrets generic.ModClient[*core.Secret], spec api.SyncAuthenticationSpec, deploymentName string, ownerRef *meta.OwnerReference) error {
log := r.log.Str("section", "secrets")
cert, priv, err := ktls.CreateTLSCACertificate(fmt.Sprintf("%s Client Authentication Root Certificate", deploymentName))

View file

@ -24,6 +24,7 @@ import (
"context"
"fmt"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
@ -33,14 +34,14 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
ktls "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls"
)
// createTLSCACertificate creates a CA certificate and stores it in a secret with name
// specified in the given spec.
func (r *Resources) createTLSCACertificate(ctx context.Context, secrets secretv1.ModInterface, spec api.TLSSpec,
func (r *Resources) createTLSCACertificate(ctx context.Context, secrets generic.ModClient[*core.Secret], spec api.TLSSpec,
deploymentName string, ownerRef *meta.OwnerReference) error {
log := r.log.Str("section", "tls").Str("secret", spec.GetCASecretName())
@ -64,7 +65,7 @@ func (r *Resources) createTLSCACertificate(ctx context.Context, secrets secretv1
// createTLSServerCertificate creates a TLS certificate for a specific server and stores
// it in a secret with the given name.
func createTLSServerCertificate(ctx context.Context, log logging.Logger, cachedStatus inspectorInterface.Inspector, secrets secretv1.ModInterface, names ktls.KeyfileInput, spec api.TLSSpec,
func createTLSServerCertificate(ctx context.Context, log logging.Logger, cachedStatus inspectorInterface.Inspector, secrets generic.ModClient[*core.Secret], names ktls.KeyfileInput, spec api.TLSSpec,
secretName string, ownerRef *meta.OwnerReference) (bool, error) {
log = log.Str("secret", secretName)
// Setup defaults

View file

@ -40,11 +40,11 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
configMapsV1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/configmap/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/patcher"
)
func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps configMapsV1.ModInterface) error {
func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps generic.ModClient[*core.ConfigMap]) error {
deploymentName := r.context.GetAPIObject().GetName()
configMapName := GetGatewayConfigMapName(deploymentName)

View file

@ -33,7 +33,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
configMapsV1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/configmap/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/patcher"
)
@ -49,7 +49,7 @@ const (
type memberConfigMapRenderer func(ctx context.Context, cachedStatus inspectorInterface.Inspector, member api.DeploymentStatusMemberElement) (map[string]string, error)
func (r *Resources) ensureMemberConfig(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps configMapsV1.ModInterface) error {
func (r *Resources) ensureMemberConfig(ctx context.Context, cachedStatus inspectorInterface.Inspector, configMaps generic.ModClient[*core.ConfigMap]) error {
status := r.context.GetStatus()
log := r.log.Str("section", "member-config-render")

View file

@ -24,12 +24,12 @@ import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +49,18 @@ func (p arangoClusterSynchronizationsInspectorLoader) Component() definitions.Co
func (p arangoClusterSynchronizationsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q arangoClusterSynchronizationsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*api.ArangoClusterSynchronizationList, *api.ArangoClusterSynchronization](ctx,
constants.ArangoClusterSynchronizationGRv1(),
constants.ArangoClusterSynchronizationGKv1(),
i.client.Arango().DatabaseV1().ArangoClusterSynchronizations(i.namespace),
arangoclustersynchronization.List())
i.arangoClusterSynchronizations = &q
q.state = i
q.last = time.Now()
}
func (p arangoClusterSynchronizationsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *arangoClusterSynchronizationsInspector) {
var z arangoClusterSynchronizationsInspectorV1
z.arangoClusterSynchronizationInspector = q
z.arangoClusterSynchronizations, z.err = p.getV1ArangoClusterSynchronizations(ctx, i)
q.v1 = &z
}
func (p arangoClusterSynchronizationsInspectorLoader) getV1ArangoClusterSynchronizations(ctx context.Context, i *inspectorState) (map[string]*api.ArangoClusterSynchronization, error) {
objs, err := p.getV1ArangoClusterSynchronizationsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*api.ArangoClusterSynchronization, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p arangoClusterSynchronizationsInspectorLoader) getV1ArangoClusterSynchronizationsList(ctx context.Context, i *inspectorState) ([]*api.ArangoClusterSynchronization, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoClusterSynchronizations(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*api.ArangoClusterSynchronization, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ArangoClusterSynchronizationsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p arangoClusterSynchronizationsInspectorLoader) getV1ArangoClusterSynchronizationsListRequest(ctx context.Context, i *inspectorState, cont string) ([]api.ArangoClusterSynchronization, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoClusterSynchronizations(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p arangoClusterSynchronizationsInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +85,7 @@ type arangoClusterSynchronizationsInspector struct {
last time.Time
v1 *arangoClusterSynchronizationsInspectorV1
v1 *inspectorVersion[*api.ArangoClusterSynchronization]
}
func (p *arangoClusterSynchronizationsInspector) LastRefresh() time.Time {
@ -190,3 +116,11 @@ func (p *arangoClusterSynchronizationsInspector) validate() error {
return p.v1.validate()
}
func (p *arangoClusterSynchronizationsInspector) V1() (generic.Inspector[*api.ArangoClusterSynchronization], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ArangoClusterSynchronizationGKv1()
}
func (p *arangoClusterSynchronizationsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ArangoClusterSynchronizationGRv1()
}
func (p *arangoClusterSynchronizationsInspector) GroupKind() schema.GroupKind {
return constants.ArangoClusterSynchronizationGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ package inspector
import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
arangoclustersynchronizationv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
@ -38,7 +37,7 @@ type arangoClusterSynchronizationMod struct {
i *inspectorState
}
func (p arangoClusterSynchronizationMod) V1() arangoclustersynchronizationv1.ModInterface {
func (p arangoClusterSynchronizationMod) V1() generic.ModStatusClient[*api.ArangoClusterSynchronization] {
return wrapMod[*api.ArangoClusterSynchronization](definitions.ArangoClusterSynchronization, p.i.GetThrottles, p.clientv1)
}

View file

@ -1,138 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoclustersynchronization/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoClusterSynchronizationsInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type arangoClusterSynchronizationsInspectorV1 struct {
arangoClusterSynchronizationInspector *arangoClusterSynchronizationsInspector
arangoClusterSynchronizations map[string]*api.ArangoClusterSynchronization
err error
}
func (p *arangoClusterSynchronizationsInspectorV1) Filter(filters ...ins.Filter) []*api.ArangoClusterSynchronization {
z := p.ListSimple()
r := make([]*api.ArangoClusterSynchronization, 0, len(z))
for _, o := range z {
if !ins.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *arangoClusterSynchronizationsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ArangoClusterSynchronizationsV1Inspector is nil")
}
if p.arangoClusterSynchronizationInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.arangoClusterSynchronizations == nil && p.err == nil {
return errors.Errorf("ListSimple or err should be not nil")
}
if p.arangoClusterSynchronizations != nil && p.err != nil {
return errors.Errorf("ListSimple or err cannot be not nil together")
}
return nil
}
func (p *arangoClusterSynchronizationsInspectorV1) ListSimple() []*api.ArangoClusterSynchronization {
var r []*api.ArangoClusterSynchronization
for _, arangoClusterSynchronization := range p.arangoClusterSynchronizations {
r = append(r, arangoClusterSynchronization)
}
return r
}
func (p *arangoClusterSynchronizationsInspectorV1) GetSimple(name string) (*api.ArangoClusterSynchronization, bool) {
arangoClusterSynchronization, ok := p.arangoClusterSynchronizations[name]
if !ok {
return nil, false
}
return arangoClusterSynchronization, true
}
func (p *arangoClusterSynchronizationsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, arangoClusterSynchronization := range p.arangoClusterSynchronizations {
if err := p.iterateArangoClusterSynchronization(arangoClusterSynchronization, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *arangoClusterSynchronizationsInspectorV1) iterateArangoClusterSynchronization(arangoClusterSynchronization *api.ArangoClusterSynchronization, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(arangoClusterSynchronization) {
return nil
}
}
return action(arangoClusterSynchronization)
}
func (p *arangoClusterSynchronizationsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *arangoClusterSynchronizationsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoClusterSynchronization, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ArangoClusterSynchronizationGR(), name)
} else {
return s, nil
}
}

View file

@ -24,12 +24,12 @@ import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +49,18 @@ func (p arangoMembersInspectorLoader) Component() definitions.Component {
func (p arangoMembersInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q arangoMembersInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*api.ArangoMemberList, *api.ArangoMember](ctx,
constants.ArangoMemberGRv1(),
constants.ArangoMemberGKv1(),
i.client.Arango().DatabaseV1().ArangoMembers(i.namespace),
arangomember.List())
i.arangoMembers = &q
q.state = i
q.last = time.Now()
}
func (p arangoMembersInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *arangoMembersInspector) {
var z arangoMembersInspectorV1
z.arangoMemberInspector = q
z.arangoMembers, z.err = p.getV1ArangoMembers(ctx, i)
q.v1 = &z
}
func (p arangoMembersInspectorLoader) getV1ArangoMembers(ctx context.Context, i *inspectorState) (map[string]*api.ArangoMember, error) {
objs, err := p.getV1ArangoMembersList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*api.ArangoMember, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p arangoMembersInspectorLoader) getV1ArangoMembersList(ctx context.Context, i *inspectorState) ([]*api.ArangoMember, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoMembers(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*api.ArangoMember, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ArangoMembersListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p arangoMembersInspectorLoader) getV1ArangoMembersListRequest(ctx context.Context, i *inspectorState, cont string) ([]api.ArangoMember, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoMembers(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p arangoMembersInspectorLoader) Verify(i *inspectorState) error {
if err := i.arangoMembers.v1.err; err != nil {
return err
@ -163,7 +89,7 @@ type arangoMembersInspector struct {
last time.Time
v1 *arangoMembersInspectorV1
v1 *inspectorVersion[*api.ArangoMember]
}
func (p *arangoMembersInspector) LastRefresh() time.Time {
@ -194,3 +120,7 @@ func (p *arangoMembersInspector) validate() error {
return p.v1.validate()
}
func (p *arangoMembersInspector) V1() generic.Inspector[*api.ArangoMember] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoMembersInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ArangoMemberGKv1()
}
func (p *arangoMembersInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ArangoMemberGRv1()
}
func (p *arangoMembersInspector) GroupKind() schema.GroupKind {
return constants.ArangoMemberGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ package inspector
import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
arangomemberv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
@ -38,7 +37,7 @@ type arangoMemberMod struct {
i *inspectorState
}
func (p arangoMemberMod) V1() arangomemberv1.ModInterface {
func (p arangoMemberMod) V1() generic.ModStatusClient[*api.ArangoMember] {
return wrapMod[*api.ArangoMember](definitions.ArangoMember, p.i.GetThrottles, p.clientv1)
}

View file

@ -1,126 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoMembersInspector) V1() ins.Inspector {
return p.v1
}
type arangoMembersInspectorV1 struct {
arangoMemberInspector *arangoMembersInspector
arangoMembers map[string]*api.ArangoMember
err error
}
func (p *arangoMembersInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ArangoMembersV1Inspector is nil")
}
if p.arangoMemberInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.arangoMembers == nil {
return errors.Errorf("ArangoMembers or err should be not nil")
}
if p.err != nil {
return errors.Errorf("ArangoMembers or err cannot be not nil together")
}
return nil
}
func (p *arangoMembersInspectorV1) ArangoMembers() []*api.ArangoMember {
var r []*api.ArangoMember
for _, arangoMember := range p.arangoMembers {
r = append(r, arangoMember)
}
return r
}
func (p *arangoMembersInspectorV1) GetSimple(name string) (*api.ArangoMember, bool) {
arangoMember, ok := p.arangoMembers[name]
if !ok {
return nil, false
}
return arangoMember, true
}
func (p *arangoMembersInspectorV1) GetSimpleOptional(name string) *api.ArangoMember {
a, ok := p.GetSimple(name)
if !ok {
return &api.ArangoMember{}
}
return a
}
func (p *arangoMembersInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, arangoMember := range p.arangoMembers {
if err := p.iterateArangoMember(arangoMember, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *arangoMembersInspectorV1) iterateArangoMember(arangoMember *api.ArangoMember, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(arangoMember) {
return nil
}
}
return action(arangoMember)
}
func (p *arangoMembersInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *arangoMembersInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoMember, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ArangoMemberGR(), name)
} else {
return s, nil
}
}

View file

@ -24,12 +24,12 @@ import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoprofile"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +49,18 @@ func (p arangoProfilesInspectorLoader) Component() definitions.Component {
func (p arangoProfilesInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q arangoProfilesInspector
p.loadV1Beta1(ctx, i, &q)
q.v1beta1 = newInspectorVersion[*schedulerApi.ArangoProfileList, *schedulerApi.ArangoProfile](ctx,
constants.ArangoProfileGRv1(),
constants.ArangoProfileGKv1(),
i.client.Arango().SchedulerV1beta1().ArangoProfiles(i.namespace),
arangoprofile.List())
i.arangoProfiles = &q
q.state = i
q.last = time.Now()
}
func (p arangoProfilesInspectorLoader) loadV1Beta1(ctx context.Context, i *inspectorState, q *arangoProfilesInspector) {
var z arangoProfilesInspectorV1Beta1
z.arangoProfileInspector = q
z.arangoProfiles, z.err = p.getV1ArangoProfiles(ctx, i)
q.v1beta1 = &z
}
func (p arangoProfilesInspectorLoader) getV1ArangoProfiles(ctx context.Context, i *inspectorState) (map[string]*schedulerApi.ArangoProfile, error) {
objs, err := p.getV1ArangoProfilesList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*schedulerApi.ArangoProfile, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p arangoProfilesInspectorLoader) getV1ArangoProfilesList(ctx context.Context, i *inspectorState) ([]*schedulerApi.ArangoProfile, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().SchedulerV1beta1().ArangoProfiles(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*schedulerApi.ArangoProfile, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ArangoProfilesListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p arangoProfilesInspectorLoader) getV1ArangoProfilesListRequest(ctx context.Context, i *inspectorState, cont string) ([]schedulerApi.ArangoProfile, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().SchedulerV1beta1().ArangoProfiles(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p arangoProfilesInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +85,7 @@ type arangoProfilesInspector struct {
last time.Time
v1beta1 *arangoProfilesInspectorV1Beta1
v1beta1 *inspectorVersion[*schedulerApi.ArangoProfile]
}
func (p *arangoProfilesInspector) LastRefresh() time.Time {
@ -190,3 +116,11 @@ func (p *arangoProfilesInspector) validate() error {
return p.v1beta1.validate()
}
func (p *arangoProfilesInspector) V1Beta1() (generic.Inspector[*schedulerApi.ArangoProfile], error) {
if p.v1beta1.err != nil {
return nil, p.v1beta1.err
}
return p.v1beta1, nil
}

View file

@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoProfilesInspectorV1Beta1) GroupVersionKind() schema.GroupVersionKind {
return constants.ArangoProfileGKv1()
}
func (p *arangoProfilesInspectorV1Beta1) GroupVersionResource() schema.GroupVersionResource {
return constants.ArangoProfileGRv1()
}
func (p *arangoProfilesInspector) GroupKind() schema.GroupKind {
return constants.ArangoProfileGK()
}

View file

@ -22,7 +22,6 @@ package inspector
import (
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
arangoProfilev1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoprofile/v1beta1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
@ -38,7 +37,7 @@ type arangoProfileMod struct {
i *inspectorState
}
func (p arangoProfileMod) V1Beta1() arangoProfilev1.ModInterface {
func (p arangoProfileMod) V1Beta1() generic.ModStatusClient[*schedulerApi.ArangoProfile] {
return wrapMod[*schedulerApi.ArangoProfile](definitions.ArangoProfile, p.i.GetThrottles, p.clientv1beta1)
}

View file

@ -1,138 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
schedulerApi "github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoprofile/v1beta1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoProfilesInspector) V1Beta1() (ins.Inspector, error) {
if p.v1beta1.err != nil {
return nil, p.v1beta1.err
}
return p.v1beta1, nil
}
type arangoProfilesInspectorV1Beta1 struct {
arangoProfileInspector *arangoProfilesInspector
arangoProfiles map[string]*schedulerApi.ArangoProfile
err error
}
func (p *arangoProfilesInspectorV1Beta1) Filter(filters ...ins.Filter) []*schedulerApi.ArangoProfile {
z := p.ListSimple()
r := make([]*schedulerApi.ArangoProfile, 0, len(z))
for _, o := range z {
if !ins.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *arangoProfilesInspectorV1Beta1) validate() error {
if p == nil {
return errors.Errorf("ArangoProfilesV1AlphaInspector is nil")
}
if p.arangoProfileInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.arangoProfiles == nil && p.err == nil {
return errors.Errorf("ArangoProfiles or err should be not nil")
}
if p.arangoProfiles != nil && p.err != nil {
return errors.Errorf("ArangoProfiles or err cannot be not nil together")
}
return nil
}
func (p *arangoProfilesInspectorV1Beta1) ListSimple() []*schedulerApi.ArangoProfile {
var r []*schedulerApi.ArangoProfile
for _, arangoProfile := range p.arangoProfiles {
r = append(r, arangoProfile)
}
return r
}
func (p *arangoProfilesInspectorV1Beta1) GetSimple(name string) (*schedulerApi.ArangoProfile, bool) {
arangoProfile, ok := p.arangoProfiles[name]
if !ok {
return nil, false
}
return arangoProfile, true
}
func (p *arangoProfilesInspectorV1Beta1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, arangoProfile := range p.arangoProfiles {
if err := p.iterateArangoProfile(arangoProfile, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *arangoProfilesInspectorV1Beta1) iterateArangoProfile(arangoProfile *schedulerApi.ArangoProfile, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(arangoProfile) {
return nil
}
}
return action(arangoProfile)
}
func (p *arangoProfilesInspectorV1Beta1) Read() ins.ReadInterface {
return p
}
func (p *arangoProfilesInspectorV1Beta1) Get(ctx context.Context, name string, opts meta.GetOptions) (*schedulerApi.ArangoProfile, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ArangoProfileGR(), name)
} else {
return s, nil
}
}

View file

@ -24,12 +24,12 @@ import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoroute"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +49,18 @@ func (p arangoRoutesInspectorLoader) Component() definitions.Component {
func (p arangoRoutesInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q arangoRoutesInspector
p.loadV1Alpha1(ctx, i, &q)
q.v1alpha1 = newInspectorVersion[*networkingApi.ArangoRouteList, *networkingApi.ArangoRoute](ctx,
constants.ArangoRouteGRv1(),
constants.ArangoRouteGKv1(),
i.client.Arango().NetworkingV1alpha1().ArangoRoutes(i.namespace),
arangoroute.List())
i.arangoRoutes = &q
q.state = i
q.last = time.Now()
}
func (p arangoRoutesInspectorLoader) loadV1Alpha1(ctx context.Context, i *inspectorState, q *arangoRoutesInspector) {
var z arangoRoutesInspectorV1Alpha1
z.arangoRouteInspector = q
z.arangoRoutes, z.err = p.getV1ArangoRoutes(ctx, i)
q.v1alpha1 = &z
}
func (p arangoRoutesInspectorLoader) getV1ArangoRoutes(ctx context.Context, i *inspectorState) (map[string]*networkingApi.ArangoRoute, error) {
objs, err := p.getV1ArangoRoutesList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*networkingApi.ArangoRoute, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p arangoRoutesInspectorLoader) getV1ArangoRoutesList(ctx context.Context, i *inspectorState) ([]*networkingApi.ArangoRoute, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().NetworkingV1alpha1().ArangoRoutes(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*networkingApi.ArangoRoute, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ArangoRoutesListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p arangoRoutesInspectorLoader) getV1ArangoRoutesListRequest(ctx context.Context, i *inspectorState, cont string) ([]networkingApi.ArangoRoute, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().NetworkingV1alpha1().ArangoRoutes(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p arangoRoutesInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +85,7 @@ type arangoRoutesInspector struct {
last time.Time
v1alpha1 *arangoRoutesInspectorV1Alpha1
v1alpha1 *inspectorVersion[*networkingApi.ArangoRoute]
}
func (p *arangoRoutesInspector) LastRefresh() time.Time {
@ -190,3 +116,11 @@ func (p *arangoRoutesInspector) validate() error {
return p.v1alpha1.validate()
}
func (p *arangoRoutesInspector) V1Alpha1() (generic.Inspector[*networkingApi.ArangoRoute], error) {
if p.v1alpha1.err != nil {
return nil, p.v1alpha1.err
}
return p.v1alpha1, nil
}

View file

@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoRoutesInspectorV1Alpha1) GroupVersionKind() schema.GroupVersionKind {
return constants.ArangoRouteGKv1()
}
func (p *arangoRoutesInspectorV1Alpha1) GroupVersionResource() schema.GroupVersionResource {
return constants.ArangoRouteGRv1()
}
func (p *arangoRoutesInspector) GroupKind() schema.GroupKind {
return constants.ArangoRouteGK()
}

View file

@ -22,7 +22,6 @@ package inspector
import (
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
arangoRoutev1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoroute/v1alpha1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
@ -38,7 +37,7 @@ type arangoRouteMod struct {
i *inspectorState
}
func (p arangoRouteMod) V1Alpha1() arangoRoutev1.ModInterface {
func (p arangoRouteMod) V1Alpha1() generic.ModStatusClient[*networkingApi.ArangoRoute] {
return wrapMod[*networkingApi.ArangoRoute](definitions.ArangoRoute, p.i.GetThrottles, p.clientv1alpha1)
}

View file

@ -1,138 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
networkingApi "github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangoroute/v1alpha1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoRoutesInspector) V1Alpha1() (ins.Inspector, error) {
if p.v1alpha1.err != nil {
return nil, p.v1alpha1.err
}
return p.v1alpha1, nil
}
type arangoRoutesInspectorV1Alpha1 struct {
arangoRouteInspector *arangoRoutesInspector
arangoRoutes map[string]*networkingApi.ArangoRoute
err error
}
func (p *arangoRoutesInspectorV1Alpha1) Filter(filters ...ins.Filter) []*networkingApi.ArangoRoute {
z := p.ListSimple()
r := make([]*networkingApi.ArangoRoute, 0, len(z))
for _, o := range z {
if !ins.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *arangoRoutesInspectorV1Alpha1) validate() error {
if p == nil {
return errors.Errorf("ArangoRoutesV1AlphaInspector is nil")
}
if p.arangoRouteInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.arangoRoutes == nil && p.err == nil {
return errors.Errorf("ArangoRoutes or err should be not nil")
}
if p.arangoRoutes != nil && p.err != nil {
return errors.Errorf("ArangoRoutes or err cannot be not nil together")
}
return nil
}
func (p *arangoRoutesInspectorV1Alpha1) ListSimple() []*networkingApi.ArangoRoute {
var r []*networkingApi.ArangoRoute
for _, arangoRoute := range p.arangoRoutes {
r = append(r, arangoRoute)
}
return r
}
func (p *arangoRoutesInspectorV1Alpha1) GetSimple(name string) (*networkingApi.ArangoRoute, bool) {
arangoRoute, ok := p.arangoRoutes[name]
if !ok {
return nil, false
}
return arangoRoute, true
}
func (p *arangoRoutesInspectorV1Alpha1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, arangoRoute := range p.arangoRoutes {
if err := p.iterateArangoRoute(arangoRoute, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *arangoRoutesInspectorV1Alpha1) iterateArangoRoute(arangoRoute *networkingApi.ArangoRoute, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(arangoRoute) {
return nil
}
}
return action(arangoRoute)
}
func (p *arangoRoutesInspectorV1Alpha1) Read() ins.ReadInterface {
return p
}
func (p *arangoRoutesInspectorV1Alpha1) Get(ctx context.Context, name string, opts meta.GetOptions) (*networkingApi.ArangoRoute, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ArangoRouteGR(), name)
} else {
return s, nil
}
}

View file

@ -24,12 +24,12 @@ import (
"context"
"time"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangotask"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +49,18 @@ func (p arangoTasksInspectorLoader) Component() definitions.Component {
func (p arangoTasksInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q arangoTasksInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*api.ArangoTaskList, *api.ArangoTask](ctx,
constants.ArangoTaskGRv1(),
constants.ArangoTaskGKv1(),
i.client.Arango().DatabaseV1().ArangoTasks(i.namespace),
arangotask.List())
i.arangoTasks = &q
q.state = i
q.last = time.Now()
}
func (p arangoTasksInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *arangoTasksInspector) {
var z arangoTasksInspectorV1
z.arangoTaskInspector = q
z.arangoTasks, z.err = p.getV1ArangoTasks(ctx, i)
q.v1 = &z
}
func (p arangoTasksInspectorLoader) getV1ArangoTasks(ctx context.Context, i *inspectorState) (map[string]*api.ArangoTask, error) {
objs, err := p.getV1ArangoTasksList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*api.ArangoTask, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p arangoTasksInspectorLoader) getV1ArangoTasksList(ctx context.Context, i *inspectorState) ([]*api.ArangoTask, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoTasks(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*api.ArangoTask, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ArangoTasksListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p arangoTasksInspectorLoader) getV1ArangoTasksListRequest(ctx context.Context, i *inspectorState, cont string) ([]api.ArangoTask, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Arango().DatabaseV1().ArangoTasks(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p arangoTasksInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +85,7 @@ type arangoTasksInspector struct {
last time.Time
v1 *arangoTasksInspectorV1
v1 *inspectorVersion[*api.ArangoTask]
}
func (p *arangoTasksInspector) LastRefresh() time.Time {
@ -190,3 +116,11 @@ func (p *arangoTasksInspector) validate() error {
return p.v1.validate()
}
func (p *arangoTasksInspector) V1() (generic.Inspector[*api.ArangoTask], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoTasksInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ArangoTaskGKv1()
}
func (p *arangoTasksInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ArangoTaskGRv1()
}
func (p *arangoTasksInspector) GroupKind() schema.GroupKind {
return constants.ArangoTaskGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ package inspector
import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
arangotaskv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangotask/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
@ -38,7 +37,7 @@ type arangoTaskMod struct {
i *inspectorState
}
func (p arangoTaskMod) V1() arangotaskv1.ModInterface {
func (p arangoTaskMod) V1() generic.ModStatusClient[*api.ArangoTask] {
return wrapMod[*api.ArangoTask](definitions.ArangoTask, p.i.GetThrottles, p.clientv1)
}

View file

@ -1,138 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangotask/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *arangoTasksInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type arangoTasksInspectorV1 struct {
arangoTaskInspector *arangoTasksInspector
arangoTasks map[string]*api.ArangoTask
err error
}
func (p *arangoTasksInspectorV1) Filter(filters ...ins.Filter) []*api.ArangoTask {
z := p.ListSimple()
r := make([]*api.ArangoTask, 0, len(z))
for _, o := range z {
if !ins.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *arangoTasksInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ArangoTasksV1Inspector is nil")
}
if p.arangoTaskInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.arangoTasks == nil && p.err == nil {
return errors.Errorf("ArangoTasks or err should be not nil")
}
if p.arangoTasks != nil && p.err != nil {
return errors.Errorf("ArangoTasks or err cannot be not nil together")
}
return nil
}
func (p *arangoTasksInspectorV1) ListSimple() []*api.ArangoTask {
var r []*api.ArangoTask
for _, arangoTask := range p.arangoTasks {
r = append(r, arangoTask)
}
return r
}
func (p *arangoTasksInspectorV1) GetSimple(name string) (*api.ArangoTask, bool) {
arangoTask, ok := p.arangoTasks[name]
if !ok {
return nil, false
}
return arangoTask, true
}
func (p *arangoTasksInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, arangoTask := range p.arangoTasks {
if err := p.iterateArangoTask(arangoTask, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *arangoTasksInspectorV1) iterateArangoTask(arangoTask *api.ArangoTask, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(arangoTask) {
return nil
}
}
return action(arangoTask)
}
func (p *arangoTasksInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *arangoTasksInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*api.ArangoTask, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ArangoTaskGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/configmap"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p configMapsInspectorLoader) Component() definitions.Component {
func (p configMapsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q configMapsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.ConfigMapList, *core.ConfigMap](ctx,
constants.ConfigMapGRv1(),
constants.ConfigMapGKv1(),
i.client.Kubernetes().CoreV1().ConfigMaps(i.namespace),
configmap.List())
i.configMaps = &q
q.state = i
q.last = time.Now()
}
func (p configMapsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *configMapsInspector) {
var z configMapsInspectorV1
z.configMapInspector = q
z.configMaps, z.err = p.getV1ConfigMaps(ctx, i)
q.v1 = &z
}
func (p configMapsInspectorLoader) getV1ConfigMaps(ctx context.Context, i *inspectorState) (map[string]*core.ConfigMap, error) {
objs, err := p.getV1ConfigMapsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.ConfigMap, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p configMapsInspectorLoader) getV1ConfigMapsList(ctx context.Context, i *inspectorState) ([]*core.ConfigMap, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().ConfigMaps(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.ConfigMap, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ConfigMapsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p configMapsInspectorLoader) getV1ConfigMapsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.ConfigMap, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().ConfigMaps(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p configMapsInspectorLoader) Verify(i *inspectorState) error {
if err := i.configMaps.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type configMapsInspector struct {
last time.Time
v1 *configMapsInspectorV1
v1 *inspectorVersion[*core.ConfigMap]
}
func (p *configMapsInspector) LastRefresh() time.Time {
@ -194,3 +121,7 @@ func (p *configMapsInspector) validate() error {
return p.v1.validate()
}
func (p *configMapsInspector) V1() generic.Inspector[*core.ConfigMap] {
return p.v1
}

View file

@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *configMapsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ConfigMapGKv1()
}
func (p *configMapsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ConfigMapGRv1()
}
func (p *configMapsInspector) GroupKind() schema.GroupKind {
return constants.ConfigMapGK()
}

View file

@ -23,7 +23,6 @@ package inspector
import (
core "k8s.io/api/core/v1"
configMapv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/configmap/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
@ -40,7 +39,7 @@ type configMapsMod struct {
i *inspectorState
}
func (p configMapsMod) V1() configMapv1.ModInterface {
func (p configMapsMod) V1() generic.ModClient[*core.ConfigMap] {
return wrapMod[*core.ConfigMap](definitions.ConfigMap, p.i.GetThrottles, generic.WithModStatusGetter[*core.ConfigMap](constants.ConfigMapGKv1(), p.clientv1))
}

View file

@ -1,118 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/configmap/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *configMapsInspector) V1() ins.Inspector {
return p.v1
}
type configMapsInspectorV1 struct {
configMapInspector *configMapsInspector
configMaps map[string]*core.ConfigMap
err error
}
func (p *configMapsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ConfigMapsV1Inspector is nil")
}
if p.configMapInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.configMaps == nil {
return errors.Errorf("ConfigMaps or err should be not nil")
}
if p.err != nil {
return errors.Errorf("ConfigMaps or err cannot be not nil together")
}
return nil
}
func (p *configMapsInspectorV1) ListSimple() []*core.ConfigMap {
var r []*core.ConfigMap
for _, configMap := range p.configMaps {
r = append(r, configMap)
}
return r
}
func (p *configMapsInspectorV1) GetSimple(name string) (*core.ConfigMap, bool) {
configMap, ok := p.configMaps[name]
if !ok {
return nil, false
}
return configMap, true
}
func (p *configMapsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, configMap := range p.configMaps {
if err := p.iterateConfigMap(configMap, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *configMapsInspectorV1) iterateConfigMap(configMap *core.ConfigMap, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(configMap) {
return nil
}
}
return action(configMap)
}
func (p *configMapsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *configMapsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.ConfigMap, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ConfigMapGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/endpoints"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p endpointsInspectorLoader) Component() definitions.Component {
func (p endpointsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q endpointsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.EndpointsList, *core.Endpoints](ctx,
constants.EndpointsGRv1(),
constants.EndpointsGKv1(),
i.client.Kubernetes().CoreV1().Endpoints(i.namespace),
endpoints.List())
i.endpoints = &q
q.state = i
q.last = time.Now()
}
func (p endpointsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *endpointsInspector) {
var z endpointsInspectorV1
z.endpointsInspector = q
z.endpoints, z.err = p.getV1Endpoints(ctx, i)
q.v1 = &z
}
func (p endpointsInspectorLoader) getV1Endpoints(ctx context.Context, i *inspectorState) (map[string]*core.Endpoints, error) {
objs, err := p.getV1EndpointsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.Endpoints, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p endpointsInspectorLoader) getV1EndpointsList(ctx context.Context, i *inspectorState) ([]*core.Endpoints, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Endpoints(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.Endpoints, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1EndpointsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p endpointsInspectorLoader) getV1EndpointsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.Endpoints, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Endpoints(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p endpointsInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +86,7 @@ type endpointsInspector struct {
last time.Time
v1 *endpointsInspectorV1
v1 *inspectorVersion[*core.Endpoints]
}
func (p *endpointsInspector) LastRefresh() time.Time {
@ -190,3 +117,11 @@ func (p *endpointsInspector) validate() error {
return p.v1.validate()
}
func (p *endpointsInspector) V1() (generic.Inspector[*core.Endpoints], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *endpointsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.EndpointsGKv1()
}
func (p *endpointsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.EndpointsGRv1()
}
func (p *endpointsInspector) GroupKind() schema.GroupKind {
return constants.EndpointsGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
endpointsv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/endpoints/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
)
@ -40,7 +39,7 @@ type endpointsMod struct {
i *inspectorState
}
func (p endpointsMod) V1() endpointsv1.ModInterface {
func (p endpointsMod) V1() generic.ModClient[*core.Endpoints] {
return wrapMod[*core.Endpoints](definitions.Endpoints, p.i.GetThrottles, generic.WithModStatusGetter[*core.Endpoints](constants.EndpointsGKv1(), p.clientv1))
}

View file

@ -1,138 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/endpoints/v1"
)
func (p *endpointsInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type endpointsInspectorV1 struct {
endpointsInspector *endpointsInspector
endpoints map[string]*core.Endpoints
err error
}
func (p *endpointsInspectorV1) Filter(filters ...ins.Filter) []*core.Endpoints {
z := p.ListSimple()
r := make([]*core.Endpoints, 0, len(z))
for _, o := range z {
if !ins.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *endpointsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("EndpointsV1Inspector is nil")
}
if p.endpointsInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.endpoints == nil && p.err == nil {
return errors.Errorf("Endpoints or err should be not nil")
}
if p.endpoints != nil && p.err != nil {
return errors.Errorf("Endpoints or err cannot be not nil together")
}
return nil
}
func (p *endpointsInspectorV1) ListSimple() []*core.Endpoints {
var r []*core.Endpoints
for _, endpoints := range p.endpoints {
r = append(r, endpoints)
}
return r
}
func (p *endpointsInspectorV1) GetSimple(name string) (*core.Endpoints, bool) {
endpoints, ok := p.endpoints[name]
if !ok {
return nil, false
}
return endpoints, true
}
func (p *endpointsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, endpoints := range p.endpoints {
if err := p.iterateEndpoints(endpoints, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *endpointsInspectorV1) iterateEndpoints(endpoints *core.Endpoints, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(endpoints) {
return nil
}
}
return action(endpoints)
}
func (p *endpointsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *endpointsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Endpoints, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.EndpointsGR(), name)
} else {
return s, nil
}
}

View file

@ -0,0 +1,154 @@
//
// DISCLAIMER
//
// Copyright 2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
"github.com/pkg/errors"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/list"
)
func List[L generic.ListContinue, S meta.Object](ctx context.Context, i generic.ListInterface[L], call generic.ExtractorList[L, S]) (map[string]S, error) {
return list.APIMap[L, S](ctx, i, meta.ListOptions{}, call)
}
func newInspectorVersion[L generic.ListContinue, S meta.Object](ctx context.Context,
gvr schema.GroupVersionResource,
gvk schema.GroupVersionKind,
i generic.ListInterface[L],
call generic.ExtractorList[L, S]) *inspectorVersion[S] {
var r inspectorVersion[S]
r.gvr = gvr
r.gvk = gvk
r.items, r.err = List(ctx, i, call)
return &r
}
type inspectorVersion[S meta.Object] struct {
items map[string]S
gvr schema.GroupVersionResource
gvk schema.GroupVersionKind
err error
}
func (p *inspectorVersion[S]) GroupVersionKind() schema.GroupVersionKind {
return p.gvk
}
func (p *inspectorVersion[S]) GroupVersionResource() schema.GroupVersionResource {
return p.gvr
}
func (p *inspectorVersion[S]) Filter(filters ...generic.Filter[S]) []S {
z := p.ListSimple()
r := make([]S, 0, len(z))
for _, o := range z {
if !generic.FilterObject(o, filters...) {
continue
}
r = append(r, o)
}
return r
}
func (p *inspectorVersion[S]) validate() error {
if p == nil {
return errors.Errorf("Inspector is nil")
}
if p.items == nil && p.err == nil {
return errors.Errorf("Items or err should be not nil")
}
if p.items != nil && p.err != nil {
return errors.Errorf("Items or err cannot be not nil together")
}
return nil
}
func (p *inspectorVersion[S]) ListSimple() []S {
var r []S
for _, item := range p.items {
r = append(r, item)
}
return r
}
func (p *inspectorVersion[S]) GetSimple(name string) (S, bool) {
item, ok := p.items[name]
if !ok {
return util.Default[S](), false
}
return item, true
}
func (p *inspectorVersion[S]) Iterate(action generic.Action[S], filters ...generic.Filter[S]) error {
for _, item := range p.items {
if err := p.iterateArangoProfile(item, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *inspectorVersion[S]) iterateArangoProfile(item S, action generic.Action[S], filters ...generic.Filter[S]) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(item) {
return nil
}
}
return action(item)
}
func (p *inspectorVersion[S]) Read() generic.ReadClient[S] {
return p
}
func (p *inspectorVersion[S]) Get(ctx context.Context, name string, opts meta.GetOptions) (S, error) {
if s, ok := p.GetSimple(name); !ok {
return util.Default[S](), apiErrors.NewNotFound(p.gvr.GroupResource(), name)
} else {
return s, nil
}
}

View file

@ -174,7 +174,7 @@ func (i *inspectorState) RegisterInformers(k8s informers.SharedInformerFactory,
arango.Database().V1().ArangoTasks().Informer().AddEventHandler(i.eventHandler(definitions.ArangoTask))
}
if _, err := i.ArangoProfiles().V1Beta1(); err == nil {
if _, err := i.ArangoProfile().V1Beta1(); err == nil {
arango.Scheduler().V1beta1().ArangoProfiles().Informer().AddEventHandler(i.eventHandler(definitions.ArangoProfile))
}
@ -346,10 +346,6 @@ func (i *inspectorState) ArangoProfile() arangoprofile.Definition {
return i.arangoProfiles
}
func (i *inspectorState) ArangoProfiles() arangoprofile.Definition {
return i.arangoProfiles
}
func (i *inspectorState) Refresh(ctx context.Context) error {
return i.refresh(ctx, inspectorLoadersList...)
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/node"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p nodesInspectorLoader) Component() definitions.Component {
func (p nodesInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q nodesInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.NodeList, *core.Node](ctx,
constants.NodeGRv1(),
constants.NodeGKv1(),
i.client.Kubernetes().CoreV1().Nodes(),
node.List())
i.nodes = &q
q.state = i
q.last = time.Now()
}
func (p nodesInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *nodesInspector) {
var z nodesInspectorV1
z.nodeInspector = q
z.nodes, z.err = p.getV1Nodes(ctx, i)
q.v1 = &z
}
func (p nodesInspectorLoader) getV1Nodes(ctx context.Context, i *inspectorState) (map[string]*core.Node, error) {
objs, err := p.getV1NodesList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.Node, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p nodesInspectorLoader) getV1NodesList(ctx context.Context, i *inspectorState) ([]*core.Node, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Nodes().List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.Node, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1NodesListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p nodesInspectorLoader) getV1NodesListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.Node, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Nodes().List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p nodesInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +86,7 @@ type nodesInspector struct {
last time.Time
v1 *nodesInspectorV1
v1 *inspectorVersion[*core.Node]
}
func (p *nodesInspector) LastRefresh() time.Time {
@ -190,3 +117,11 @@ func (p *nodesInspector) validate() error {
return p.v1.validate()
}
func (p *nodesInspector) V1() (generic.Inspector[*core.Node], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *nodesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.NodeGKv1()
}
func (p *nodesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.NodeGRv1()
}
func (p *nodesInspector) GroupKind() schema.GroupKind {
return constants.NodeGK()
}

View file

@ -1,122 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/node/v1"
)
func (p *nodesInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type nodesInspectorV1 struct {
nodeInspector *nodesInspector
nodes map[string]*core.Node
err error
}
func (p *nodesInspectorV1) validate() error {
if p == nil {
return errors.Errorf("NodesV1Inspector is nil")
}
if p.nodeInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.nodes == nil && p.err == nil {
return errors.Errorf("Nodes or err should be not nil")
}
if p.nodes != nil && p.err != nil {
return errors.Errorf("Nodes or err cannot be not nil together")
}
return nil
}
func (p *nodesInspectorV1) ListSimple() []*core.Node {
var r []*core.Node
for _, node := range p.nodes {
r = append(r, node)
}
return r
}
func (p *nodesInspectorV1) GetSimple(name string) (*core.Node, bool) {
node, ok := p.nodes[name]
if !ok {
return nil, false
}
return node, true
}
func (p *nodesInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, node := range p.nodes {
if err := p.iterateNode(node, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *nodesInspectorV1) iterateNode(node *core.Node, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(node) {
return nil
}
}
return action(node)
}
func (p *nodesInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *nodesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Node, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.NodeGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
policy "k8s.io/api/policy/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -51,10 +52,13 @@ func (p podDisruptionBudgetsInspectorLoader) Load(ctx context.Context, i *inspec
var q podDisruptionBudgetsInspector
if i.versionInfo.CompareTo("1.21") >= 1 {
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*policy.PodDisruptionBudgetList, *policy.PodDisruptionBudget](ctx,
constants.PodDisruptionBudgetGRv1(),
constants.PodDisruptionBudgetGKv1(),
i.client.Kubernetes().PolicyV1().PodDisruptionBudgets(i.namespace),
poddisruptionbudget.List())
} else {
q.v1 = &podDisruptionBudgetsInspectorV1{
podDisruptionBudgetInspector: &q,
q.v1 = &inspectorVersion[*policy.PodDisruptionBudget]{
err: newMinK8SVersion("1.20"),
}
}
@ -64,86 +68,6 @@ func (p podDisruptionBudgetsInspectorLoader) Load(ctx context.Context, i *inspec
q.last = time.Now()
}
func (p podDisruptionBudgetsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *podDisruptionBudgetsInspector) {
var z podDisruptionBudgetsInspectorV1
z.podDisruptionBudgetInspector = q
z.podDisruptionBudgets, z.err = p.getV1PodDisruptionBudgets(ctx, i)
q.v1 = &z
}
func (p podDisruptionBudgetsInspectorLoader) getV1PodDisruptionBudgets(ctx context.Context, i *inspectorState) (map[string]*policy.PodDisruptionBudget, error) {
objs, err := p.getV1PodDisruptionBudgetsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*policy.PodDisruptionBudget, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p podDisruptionBudgetsInspectorLoader) getV1PodDisruptionBudgetsList(ctx context.Context, i *inspectorState) ([]*policy.PodDisruptionBudget, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().PolicyV1().PodDisruptionBudgets(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*policy.PodDisruptionBudget, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1PodDisruptionBudgetsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p podDisruptionBudgetsInspectorLoader) getV1PodDisruptionBudgetsListRequest(ctx context.Context, i *inspectorState, cont string) ([]policy.PodDisruptionBudget, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().PolicyV1().PodDisruptionBudgets(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p podDisruptionBudgetsInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -168,7 +92,7 @@ type podDisruptionBudgetsInspector struct {
last time.Time
v1 *podDisruptionBudgetsInspectorV1
v1 *inspectorVersion[*policy.PodDisruptionBudget]
}
func (p *podDisruptionBudgetsInspector) LastRefresh() time.Time {
@ -205,3 +129,11 @@ func (p *podDisruptionBudgetsInspector) validate() error {
return nil
}
func (p *podDisruptionBudgetsInspector) V1() (generic.Inspector[*policy.PodDisruptionBudget], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *podDisruptionBudgetsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.PodDisruptionBudgetGKv1()
}
func (p *podDisruptionBudgetsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.PodDisruptionBudgetGRv1()
}
func (p *podDisruptionBudgetsInspector) GroupKind() schema.GroupKind {
return constants.PodDisruptionBudgetGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
policyv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
)
func (i *inspectorState) PodDisruptionBudgetsModInterface() mods.PodDisruptionBudgetsMods {
@ -40,7 +39,7 @@ type podDisruptionBudgetsMod struct {
i *inspectorState
}
func (p podDisruptionBudgetsMod) V1() policyv1.ModInterface {
func (p podDisruptionBudgetsMod) V1() generic.ModClient[*policy.PodDisruptionBudget] {
return wrapMod[*policy.PodDisruptionBudget](definitions.PodDisruptionBudget, p.i.GetThrottles, generic.WithModStatusGetter[*policy.PodDisruptionBudget](constants.PodDisruptionBudgetGKv1(), p.clientv1))
}

View file

@ -1,122 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
policy "k8s.io/api/policy/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/poddisruptionbudget/v1"
)
func (p *podDisruptionBudgetsInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type podDisruptionBudgetsInspectorV1 struct {
podDisruptionBudgetInspector *podDisruptionBudgetsInspector
podDisruptionBudgets map[string]*policy.PodDisruptionBudget
err error
}
func (p *podDisruptionBudgetsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("PodDisruptionBudgetsV1Inspector is nil")
}
if p.podDisruptionBudgetInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.podDisruptionBudgets == nil && p.err == nil {
return errors.Errorf("PodDisruptionBudgets or err should be not nil")
}
if p.podDisruptionBudgets != nil && p.err != nil {
return errors.Errorf("PodDisruptionBudgets or err cannot be not nil together")
}
return nil
}
func (p *podDisruptionBudgetsInspectorV1) PodDisruptionBudgets() []*policy.PodDisruptionBudget {
var r []*policy.PodDisruptionBudget
for _, podDisruptionBudget := range p.podDisruptionBudgets {
r = append(r, podDisruptionBudget)
}
return r
}
func (p *podDisruptionBudgetsInspectorV1) GetSimple(name string) (*policy.PodDisruptionBudget, bool) {
podDisruptionBudget, ok := p.podDisruptionBudgets[name]
if !ok {
return nil, false
}
return podDisruptionBudget, true
}
func (p *podDisruptionBudgetsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, podDisruptionBudget := range p.podDisruptionBudgets {
if err := p.iteratePodDisruptionBudget(podDisruptionBudget, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *podDisruptionBudgetsInspectorV1) iteratePodDisruptionBudget(podDisruptionBudget *policy.PodDisruptionBudget, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(podDisruptionBudget) {
return nil
}
}
return action(podDisruptionBudget)
}
func (p *podDisruptionBudgetsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *podDisruptionBudgetsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*policy.PodDisruptionBudget, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.PodDisruptionBudgetGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p podsInspectorLoader) Component() definitions.Component {
func (p podsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q podsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.PodList, *core.Pod](ctx,
constants.PodGRv1(),
constants.PodGKv1(),
i.client.Kubernetes().CoreV1().Pods(i.namespace),
pod.List())
i.pods = &q
q.state = i
q.last = time.Now()
}
func (p podsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *podsInspector) {
var z podsInspectorV1
z.podInspector = q
z.pods, z.err = p.getV1Pods(ctx, i)
q.v1 = &z
}
func (p podsInspectorLoader) getV1Pods(ctx context.Context, i *inspectorState) (map[string]*core.Pod, error) {
objs, err := p.getV1PodsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.Pod, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p podsInspectorLoader) getV1PodsList(ctx context.Context, i *inspectorState) ([]*core.Pod, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Pods(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.Pod, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1PodsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p podsInspectorLoader) getV1PodsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.Pod, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Pods(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p podsInspectorLoader) Verify(i *inspectorState) error {
if err := i.pods.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type podsInspector struct {
last time.Time
v1 *podsInspectorV1
v1 *inspectorVersion[*core.Pod]
}
func (p *podsInspector) LastRefresh() time.Time {
@ -194,3 +121,8 @@ func (p *podsInspector) validate() error {
return p.v1.validate()
}
func (p *podsInspector) V1() generic.Inspector[*core.Pod] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *podsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.PodGKv1()
}
func (p *podsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.PodGRv1()
}
func (p *podsInspector) GroupKind() schema.GroupKind {
return constants.PodGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
)
func (i *inspectorState) PodsModInterface() mods.PodsMods {
@ -40,7 +39,7 @@ type podsMod struct {
i *inspectorState
}
func (p podsMod) V1() podv1.ModInterface {
func (p podsMod) V1() generic.ModClient[*core.Pod] {
return wrapMod[*core.Pod](definitions.Pod, p.i.GetThrottles, generic.WithModStatusGetter[*core.Pod](constants.PodGKv1(), p.clientv1))
}

View file

@ -1,119 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
)
func (p *podsInspector) V1() ins.Inspector {
return p.v1
}
type podsInspectorV1 struct {
podInspector *podsInspector
pods map[string]*core.Pod
err error
}
func (p *podsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("PodsV1Inspector is nil")
}
if p.podInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.pods == nil {
return errors.Errorf("Pods or err should be not nil")
}
if p.err != nil {
return errors.Errorf("Pods or err cannot be not nil together")
}
return nil
}
func (p *podsInspectorV1) ListSimple() []*core.Pod {
var r []*core.Pod
for _, pod := range p.pods {
r = append(r, pod)
}
return r
}
func (p *podsInspectorV1) GetSimple(name string) (*core.Pod, bool) {
pod, ok := p.pods[name]
if !ok {
return nil, false
}
return pod, true
}
func (p *podsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, pod := range p.pods {
if err := p.iteratePod(pod, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *podsInspectorV1) iteratePod(pod *core.Pod, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(pod) {
return nil
}
}
return action(pod)
}
func (p *podsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *podsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Pod, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.PodGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p persistentVolumeClaimsInspectorLoader) Component() definitions.Component
func (p persistentVolumeClaimsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q persistentVolumeClaimsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.PersistentVolumeClaimList, *core.PersistentVolumeClaim](ctx,
constants.PersistentVolumeClaimGRv1(),
constants.PersistentVolumeClaimGKv1(),
i.client.Kubernetes().CoreV1().PersistentVolumeClaims(i.namespace),
persistentvolumeclaim.List())
i.persistentVolumeClaims = &q
q.state = i
q.last = time.Now()
}
func (p persistentVolumeClaimsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *persistentVolumeClaimsInspector) {
var z persistentVolumeClaimsInspectorV1
z.persistentVolumeClaimInspector = q
z.persistentVolumeClaims, z.err = p.getV1PersistentVolumeClaims(ctx, i)
q.v1 = &z
}
func (p persistentVolumeClaimsInspectorLoader) getV1PersistentVolumeClaims(ctx context.Context, i *inspectorState) (map[string]*core.PersistentVolumeClaim, error) {
objs, err := p.getV1PersistentVolumeClaimsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.PersistentVolumeClaim, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p persistentVolumeClaimsInspectorLoader) getV1PersistentVolumeClaimsList(ctx context.Context, i *inspectorState) ([]*core.PersistentVolumeClaim, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().PersistentVolumeClaims(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.PersistentVolumeClaim, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1PersistentVolumeClaimsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p persistentVolumeClaimsInspectorLoader) getV1PersistentVolumeClaimsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.PersistentVolumeClaim, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().PersistentVolumeClaims(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p persistentVolumeClaimsInspectorLoader) Verify(i *inspectorState) error {
if err := i.persistentVolumeClaims.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type persistentVolumeClaimsInspector struct {
last time.Time
v1 *persistentVolumeClaimsInspectorV1
v1 *inspectorVersion[*core.PersistentVolumeClaim]
}
func (p *persistentVolumeClaimsInspector) LastRefresh() time.Time {
@ -194,3 +121,7 @@ func (p *persistentVolumeClaimsInspector) validate() error {
return p.v1.validate()
}
func (p *persistentVolumeClaimsInspector) V1() generic.Inspector[*core.PersistentVolumeClaim] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *persistentVolumeClaimsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.PersistentVolumeClaimGKv1()
}
func (p *persistentVolumeClaimsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.PersistentVolumeClaimGRv1()
}
func (p *persistentVolumeClaimsInspector) GroupKind() schema.GroupKind {
return constants.PersistentVolumeClaimGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
persistentvolumeclaimv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
)
func (i *inspectorState) PersistentVolumeClaimsModInterface() mods.PersistentVolumeClaimsMods {
@ -40,7 +39,7 @@ type persistentVolumeClaimsMod struct {
i *inspectorState
}
func (p persistentVolumeClaimsMod) V1() persistentvolumeclaimv1.ModInterface {
func (p persistentVolumeClaimsMod) V1() generic.ModClient[*core.PersistentVolumeClaim] {
return wrapMod[*core.PersistentVolumeClaim](definitions.PersistentVolumeClaim, p.i.GetThrottles, generic.WithModStatusGetter[*core.PersistentVolumeClaim](constants.PersistentVolumeClaimGKv1(), p.clientv1))
}

View file

@ -1,118 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolumeclaim/v1"
)
func (p *persistentVolumeClaimsInspector) V1() ins.Inspector {
return p.v1
}
type persistentVolumeClaimsInspectorV1 struct {
persistentVolumeClaimInspector *persistentVolumeClaimsInspector
persistentVolumeClaims map[string]*core.PersistentVolumeClaim
err error
}
func (p *persistentVolumeClaimsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("PersistentVolumeClaimsV1Inspector is nil")
}
if p.persistentVolumeClaimInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.persistentVolumeClaims == nil {
return errors.Errorf("PersistentVolumeClaims or err should be not nil")
}
if p.err != nil {
return errors.Errorf("PersistentVolumeClaims or err cannot be not nil together")
}
return nil
}
func (p *persistentVolumeClaimsInspectorV1) ListSimple() []*core.PersistentVolumeClaim {
var r []*core.PersistentVolumeClaim
for _, persistentVolumeClaim := range p.persistentVolumeClaims {
r = append(r, persistentVolumeClaim)
}
return r
}
func (p *persistentVolumeClaimsInspectorV1) GetSimple(name string) (*core.PersistentVolumeClaim, bool) {
persistentVolumeClaim, ok := p.persistentVolumeClaims[name]
if !ok {
return nil, false
}
return persistentVolumeClaim, true
}
func (p *persistentVolumeClaimsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, persistentVolumeClaim := range p.persistentVolumeClaims {
if err := p.iteratePersistentVolumeClaim(persistentVolumeClaim, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *persistentVolumeClaimsInspectorV1) iteratePersistentVolumeClaim(persistentVolumeClaim *core.PersistentVolumeClaim, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(persistentVolumeClaim) {
return nil
}
}
return action(persistentVolumeClaim)
}
func (p *persistentVolumeClaimsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *persistentVolumeClaimsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.PersistentVolumeClaim, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.PersistentVolumeClaimGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolume"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p persistentVolumesInspectorLoader) Component() definitions.Component {
func (p persistentVolumesInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q persistentVolumesInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.PersistentVolumeList, *core.PersistentVolume](ctx,
constants.PersistentVolumeGRv1(),
constants.PersistentVolumeGKv1(),
i.client.Kubernetes().CoreV1().PersistentVolumes(),
persistentvolume.List())
i.persistentVolumes = &q
q.state = i
q.last = time.Now()
}
func (p persistentVolumesInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *persistentVolumesInspector) {
var z persistentVolumesInspectorV1
z.persistentVolumeInspector = q
z.persistentVolumes, z.err = p.getV1PersistentVolumes(ctx, i)
q.v1 = &z
}
func (p persistentVolumesInspectorLoader) getV1PersistentVolumes(ctx context.Context, i *inspectorState) (map[string]*core.PersistentVolume, error) {
objs, err := p.getV1PersistentVolumesList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.PersistentVolume, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p persistentVolumesInspectorLoader) getV1PersistentVolumesList(ctx context.Context, i *inspectorState) ([]*core.PersistentVolume, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().PersistentVolumes().List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.PersistentVolume, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1PersistentVolumesListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p persistentVolumesInspectorLoader) getV1PersistentVolumesListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.PersistentVolume, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().PersistentVolumes().List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p persistentVolumesInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -159,7 +86,7 @@ type persistentVolumesInspector struct {
last time.Time
v1 *persistentVolumesInspectorV1
v1 *inspectorVersion[*core.PersistentVolume]
}
func (p *persistentVolumesInspector) LastRefresh() time.Time {
@ -190,3 +117,11 @@ func (p *persistentVolumesInspector) validate() error {
return p.v1.validate()
}
func (p *persistentVolumesInspector) V1() (generic.Inspector[*core.PersistentVolume], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *persistentVolumesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.PersistentVolumeGKv1()
}
func (p *persistentVolumesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.PersistentVolumeGRv1()
}
func (p *persistentVolumesInspector) GroupKind() schema.GroupKind {
return constants.PersistentVolumeGK()
}

View file

@ -1,122 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/persistentvolume/v1"
)
func (p *persistentVolumesInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type persistentVolumesInspectorV1 struct {
persistentVolumeInspector *persistentVolumesInspector
persistentVolumes map[string]*core.PersistentVolume
err error
}
func (p *persistentVolumesInspectorV1) validate() error {
if p == nil {
return errors.Errorf("PersistentVolumesV1Inspector is nil")
}
if p.persistentVolumeInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.persistentVolumes == nil && p.err == nil {
return errors.Errorf("PersistentVolumes or err should be not nil")
}
if p.persistentVolumes != nil && p.err != nil {
return errors.Errorf("PersistentVolumes or err cannot be not nil together")
}
return nil
}
func (p *persistentVolumesInspectorV1) ListSimple() []*core.PersistentVolume {
var r []*core.PersistentVolume
for _, persistentVolume := range p.persistentVolumes {
r = append(r, persistentVolume)
}
return r
}
func (p *persistentVolumesInspectorV1) GetSimple(name string) (*core.PersistentVolume, bool) {
persistentVolume, ok := p.persistentVolumes[name]
if !ok {
return nil, false
}
return persistentVolume, true
}
func (p *persistentVolumesInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, persistentVolume := range p.persistentVolumes {
if err := p.iteratePersistentVolume(persistentVolume, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *persistentVolumesInspectorV1) iteratePersistentVolume(persistentVolume *core.PersistentVolume, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(persistentVolume) {
return nil
}
}
return action(persistentVolume)
}
func (p *persistentVolumesInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *persistentVolumesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.PersistentVolume, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.PersistentVolumeGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p serviceAccountsInspectorLoader) Component() definitions.Component {
func (p serviceAccountsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q serviceAccountsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.ServiceAccountList, *core.ServiceAccount](ctx,
constants.ServiceAccountGRv1(),
constants.ServiceAccountGKv1(),
i.client.Kubernetes().CoreV1().ServiceAccounts(i.namespace),
serviceaccount.List())
i.serviceAccounts = &q
q.state = i
q.last = time.Now()
}
func (p serviceAccountsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *serviceAccountsInspector) {
var z serviceAccountsInspectorV1
z.serviceAccountInspector = q
z.serviceAccounts, z.err = p.getV1ServiceAccounts(ctx, i)
q.v1 = &z
}
func (p serviceAccountsInspectorLoader) getV1ServiceAccounts(ctx context.Context, i *inspectorState) (map[string]*core.ServiceAccount, error) {
objs, err := p.getV1ServiceAccountsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.ServiceAccount, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p serviceAccountsInspectorLoader) getV1ServiceAccountsList(ctx context.Context, i *inspectorState) ([]*core.ServiceAccount, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().ServiceAccounts(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.ServiceAccount, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ServiceAccountsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p serviceAccountsInspectorLoader) getV1ServiceAccountsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.ServiceAccount, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().ServiceAccounts(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p serviceAccountsInspectorLoader) Verify(i *inspectorState) error {
if err := i.serviceAccounts.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type serviceAccountsInspector struct {
last time.Time
v1 *serviceAccountsInspectorV1
v1 *inspectorVersion[*core.ServiceAccount]
}
func (p *serviceAccountsInspector) LastRefresh() time.Time {
@ -194,3 +121,7 @@ func (p *serviceAccountsInspector) validate() error {
return p.v1.validate()
}
func (p *serviceAccountsInspector) V1() generic.Inspector[*core.ServiceAccount] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *serviceAccountsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ServiceAccountGKv1()
}
func (p *serviceAccountsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ServiceAccountGRv1()
}
func (p *serviceAccountsInspector) GroupKind() schema.GroupKind {
return constants.ServiceAccountGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
serviceaccountv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
)
func (i *inspectorState) ServiceAccountsModInterface() mods.ServiceAccountsMods {
@ -40,7 +39,7 @@ type serviceAccountsMod struct {
i *inspectorState
}
func (p serviceAccountsMod) V1() serviceaccountv1.ModInterface {
func (p serviceAccountsMod) V1() generic.ModClient[*core.ServiceAccount] {
return wrapMod[*core.ServiceAccount](definitions.ServiceAccount, p.i.GetThrottles, generic.WithModStatusGetter[*core.ServiceAccount](constants.ServiceAccountGKv1(), p.clientv1))
}

View file

@ -1,118 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/serviceaccount/v1"
)
func (p *serviceAccountsInspector) V1() ins.Inspector {
return p.v1
}
type serviceAccountsInspectorV1 struct {
serviceAccountInspector *serviceAccountsInspector
serviceAccounts map[string]*core.ServiceAccount
err error
}
func (p *serviceAccountsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ServiceAccountsV1Inspector is nil")
}
if p.serviceAccountInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.serviceAccounts == nil {
return errors.Errorf("ServiceAccounts or err should be not nil")
}
if p.err != nil {
return errors.Errorf("ServiceAccounts or err cannot be not nil together")
}
return nil
}
func (p *serviceAccountsInspectorV1) ServiceAccounts() []*core.ServiceAccount {
var r []*core.ServiceAccount
for _, serviceAccount := range p.serviceAccounts {
r = append(r, serviceAccount)
}
return r
}
func (p *serviceAccountsInspectorV1) GetSimple(name string) (*core.ServiceAccount, bool) {
serviceAccount, ok := p.serviceAccounts[name]
if !ok {
return nil, false
}
return serviceAccount, true
}
func (p *serviceAccountsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, serviceAccount := range p.serviceAccounts {
if err := p.iterateServiceAccount(serviceAccount, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *serviceAccountsInspectorV1) iterateServiceAccount(serviceAccount *core.ServiceAccount, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(serviceAccount) {
return nil
}
}
return action(serviceAccount)
}
func (p *serviceAccountsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *serviceAccountsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.ServiceAccount, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ServiceAccountGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p secretsInspectorLoader) Component() definitions.Component {
func (p secretsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q secretsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.SecretList, *core.Secret](ctx,
constants.SecretGRv1(),
constants.SecretGKv1(),
i.client.Kubernetes().CoreV1().Secrets(i.namespace),
secret.List())
i.secrets = &q
q.state = i
q.last = time.Now()
}
func (p secretsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *secretsInspector) {
var z secretsInspectorV1
z.secretInspector = q
z.secrets, z.err = p.getV1Secrets(ctx, i)
q.v1 = &z
}
func (p secretsInspectorLoader) getV1Secrets(ctx context.Context, i *inspectorState) (map[string]*core.Secret, error) {
objs, err := p.getV1SecretsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.Secret, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p secretsInspectorLoader) getV1SecretsList(ctx context.Context, i *inspectorState) ([]*core.Secret, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Secrets(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.Secret, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1SecretsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p secretsInspectorLoader) getV1SecretsListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.Secret, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Secrets(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p secretsInspectorLoader) Verify(i *inspectorState) error {
if err := i.secrets.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type secretsInspector struct {
last time.Time
v1 *secretsInspectorV1
v1 *inspectorVersion[*core.Secret]
}
func (p *secretsInspector) LastRefresh() time.Time {
@ -194,3 +121,7 @@ func (p *secretsInspector) validate() error {
return p.v1.validate()
}
func (p *secretsInspector) V1() generic.Inspector[*core.Secret] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *secretsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.SecretGKv1()
}
func (p *secretsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.SecretGRv1()
}
func (p *secretsInspector) GroupKind() schema.GroupKind {
return constants.SecretGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
)
func (i *inspectorState) SecretsModInterface() mods.SecretsMods {
@ -40,7 +39,7 @@ type secretsMod struct {
i *inspectorState
}
func (p secretsMod) V1() secretv1.ModInterface {
func (p secretsMod) V1() generic.ModClient[*core.Secret] {
return wrapMod[*core.Secret](definitions.Secret, p.i.GetThrottles, generic.WithModStatusGetter[*core.Secret](constants.SecretGKv1(), p.clientv1))
}

View file

@ -1,118 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
)
func (p *secretsInspector) V1() ins.Inspector {
return p.v1
}
type secretsInspectorV1 struct {
secretInspector *secretsInspector
secrets map[string]*core.Secret
err error
}
func (p *secretsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("SecretsV1Inspector is nil")
}
if p.secretInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.secrets == nil {
return errors.Errorf("Secrets or err should be not nil")
}
if p.err != nil {
return errors.Errorf("Secrets or err cannot be not nil together")
}
return nil
}
func (p *secretsInspectorV1) ListSimple() []*core.Secret {
var r []*core.Secret
for _, secret := range p.secrets {
r = append(r, secret)
}
return r
}
func (p *secretsInspectorV1) GetSimple(name string) (*core.Secret, bool) {
secret, ok := p.secrets[name]
if !ok {
return nil, false
}
return secret, true
}
func (p *secretsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, secret := range p.secrets {
if err := p.iterateSecret(secret, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *secretsInspectorV1) iterateSecret(secret *core.Secret, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(secret) {
return nil
}
}
return action(secret)
}
func (p *secretsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *secretsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Secret, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.SecretGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,92 +50,18 @@ func (p servicesInspectorLoader) Component() definitions.Component {
func (p servicesInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q servicesInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*core.ServiceList, *core.Service](ctx,
constants.ServiceGRv1(),
constants.ServiceGKv1(),
i.client.Kubernetes().CoreV1().Services(i.namespace),
service.List())
i.services = &q
q.state = i
q.last = time.Now()
}
func (p servicesInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *servicesInspector) {
var z servicesInspectorV1
z.serviceInspector = q
z.services, z.err = p.getV1Services(ctx, i)
q.v1 = &z
}
func (p servicesInspectorLoader) getV1Services(ctx context.Context, i *inspectorState) (map[string]*core.Service, error) {
objs, err := p.getV1ServicesList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*core.Service, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p servicesInspectorLoader) getV1ServicesList(ctx context.Context, i *inspectorState) ([]*core.Service, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Services(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*core.Service, 0, s)
for {
for id := range items {
ptrs = append(ptrs, &items[id])
}
if cont == "" {
break
}
items, cont, err = p.getV1ServicesListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p servicesInspectorLoader) getV1ServicesListRequest(ctx context.Context, i *inspectorState, cont string) ([]core.Service, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Kubernetes().CoreV1().Services(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p servicesInspectorLoader) Verify(i *inspectorState) error {
if err := i.services.v1.err; err != nil {
return err
@ -163,7 +90,7 @@ type servicesInspector struct {
last time.Time
v1 *servicesInspectorV1
v1 *inspectorVersion[*core.Service]
}
func (p *servicesInspector) LastRefresh() time.Time {
@ -194,3 +121,7 @@ func (p *servicesInspector) validate() error {
return p.v1.validate()
}
func (p *servicesInspector) V1() generic.Inspector[*core.Service] {
return p.v1
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *servicesInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ServiceGKv1()
}
func (p *servicesInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ServiceGRv1()
}
func (p *servicesInspector) GroupKind() schema.GroupKind {
return constants.ServiceGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
servicev1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
)
func (i *inspectorState) ServicesModInterface() mods.ServicesMods {
@ -40,7 +39,7 @@ type servicesMod struct {
i *inspectorState
}
func (p servicesMod) V1() servicev1.ModInterface {
func (p servicesMod) V1() generic.ModClient[*core.Service] {
return wrapMod[*core.Service](definitions.Service, p.i.GetThrottles, generic.WithModStatusGetter[*core.Service](constants.ServiceGKv1(), p.clientv1))
}

View file

@ -1,109 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
core "k8s.io/api/core/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/service/v1"
)
func (p *servicesInspector) V1() ins.Inspector {
return p.v1
}
type servicesInspectorV1 struct {
serviceInspector *servicesInspector
services map[string]*core.Service
err error
}
func (p *servicesInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ServicesV1Inspector is nil")
}
if p.serviceInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.services == nil {
return errors.Errorf("Services or err should be not nil")
}
if p.err != nil {
return errors.Errorf("Services or err cannot be not nil together")
}
return nil
}
func (p *servicesInspectorV1) GetSimple(name string) (*core.Service, bool) {
service, ok := p.services[name]
if !ok {
return nil, false
}
return service, true
}
func (p *servicesInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, service := range p.services {
if err := p.iterateService(service, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *servicesInspectorV1) iterateService(service *core.Service, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(service) {
return nil
}
}
return action(service)
}
func (p *servicesInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *servicesInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*core.Service, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ServiceGR(), name)
} else {
return s, nil
}
}

View file

@ -25,11 +25,12 @@ import (
"time"
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/throttle"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/version"
)
@ -49,88 +50,18 @@ func (p serviceMonitorsInspectorLoader) Component() definitions.Component {
func (p serviceMonitorsInspectorLoader) Load(ctx context.Context, i *inspectorState) {
var q serviceMonitorsInspector
p.loadV1(ctx, i, &q)
q.v1 = newInspectorVersion[*monitoring.ServiceMonitorList, *monitoring.ServiceMonitor](ctx,
constants.ServiceMonitorGRv1(),
constants.ServiceMonitorGKv1(),
i.client.Monitoring().MonitoringV1().ServiceMonitors(i.namespace),
servicemonitor.List())
i.serviceMonitors = &q
q.state = i
q.last = time.Now()
}
func (p serviceMonitorsInspectorLoader) loadV1(ctx context.Context, i *inspectorState, q *serviceMonitorsInspector) {
var z serviceMonitorsInspectorV1
z.serviceMonitorInspector = q
z.serviceMonitors, z.err = p.getV1ServiceMonitors(ctx, i)
q.v1 = &z
}
func (p serviceMonitorsInspectorLoader) getV1ServiceMonitors(ctx context.Context, i *inspectorState) (map[string]*monitoring.ServiceMonitor, error) {
objs, err := p.getV1ServiceMonitorsList(ctx, i)
if err != nil {
return nil, err
}
r := make(map[string]*monitoring.ServiceMonitor, len(objs))
for id := range objs {
r[objs[id].GetName()] = objs[id]
}
return r, nil
}
func (p serviceMonitorsInspectorLoader) getV1ServiceMonitorsList(ctx context.Context, i *inspectorState) ([]*monitoring.ServiceMonitor, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Monitoring().MonitoringV1().ServiceMonitors(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
})
if err != nil {
return nil, err
}
items := obj.Items
cont := obj.Continue
var s = int64(len(items))
if z := obj.RemainingItemCount; z != nil {
s += *z
}
ptrs := make([]*monitoring.ServiceMonitor, 0, s)
for {
ptrs = append(ptrs, items...)
if cont == "" {
break
}
items, cont, err = p.getV1ServiceMonitorsListRequest(ctx, i, cont)
if err != nil {
return nil, err
}
}
return ptrs, nil
}
func (p serviceMonitorsInspectorLoader) getV1ServiceMonitorsListRequest(ctx context.Context, i *inspectorState, cont string) ([]*monitoring.ServiceMonitor, string, error) {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
obj, err := i.client.Monitoring().MonitoringV1().ServiceMonitors(i.namespace).List(ctxChild, meta.ListOptions{
Limit: globals.GetGlobals().Kubernetes().RequestBatchSize().Get(),
Continue: cont,
})
if err != nil {
return nil, "", err
}
return obj.Items, obj.Continue, err
}
func (p serviceMonitorsInspectorLoader) Verify(i *inspectorState) error {
return nil
}
@ -155,7 +86,7 @@ type serviceMonitorsInspector struct {
last time.Time
v1 *serviceMonitorsInspectorV1
v1 *inspectorVersion[*monitoring.ServiceMonitor]
}
func (p *serviceMonitorsInspector) LastRefresh() time.Time {
@ -186,3 +117,11 @@ func (p *serviceMonitorsInspector) validate() error {
return p.v1.validate()
}
func (p *serviceMonitorsInspector) V1() (generic.Inspector[*monitoring.ServiceMonitor], error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,14 +26,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
)
func (p *serviceMonitorsInspectorV1) GroupVersionKind() schema.GroupVersionKind {
return constants.ServiceMonitorGKv1()
}
func (p *serviceMonitorsInspectorV1) GroupVersionResource() schema.GroupVersionResource {
return constants.ServiceMonitorGRv1()
}
func (p *serviceMonitorsInspector) GroupKind() schema.GroupKind {
return constants.ServiceMonitorGK()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/mods"
servicemonitorv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
)
func (i *inspectorState) ServiceMonitorsModInterface() mods.ServiceMonitorsMods {
@ -40,7 +39,7 @@ type serviceMonitorsMod struct {
i *inspectorState
}
func (p serviceMonitorsMod) V1() servicemonitorv1.ModInterface {
func (p serviceMonitorsMod) V1() generic.ModClient[*monitoring.ServiceMonitor] {
return wrapMod[*monitoring.ServiceMonitor](definitions.ServiceMonitor, p.i.GetThrottles, generic.WithModStatusGetter[*monitoring.ServiceMonitor](constants.ServiceMonitorGKv1(), p.clientv1))
}

View file

@ -1,122 +0,0 @@
//
// DISCLAIMER
//
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
package inspector
import (
"context"
monitoring "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/constants"
ins "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/servicemonitor/v1"
)
func (p *serviceMonitorsInspector) V1() (ins.Inspector, error) {
if p.v1.err != nil {
return nil, p.v1.err
}
return p.v1, nil
}
type serviceMonitorsInspectorV1 struct {
serviceMonitorInspector *serviceMonitorsInspector
serviceMonitors map[string]*monitoring.ServiceMonitor
err error
}
func (p *serviceMonitorsInspectorV1) validate() error {
if p == nil {
return errors.Errorf("ServiceMonitorsV1Inspector is nil")
}
if p.serviceMonitorInspector == nil {
return errors.Errorf("Parent is nil")
}
if p.serviceMonitors == nil && p.err == nil {
return errors.Errorf("ServiceMonitors or err should be not nil")
}
if p.serviceMonitors != nil && p.err != nil {
return errors.Errorf("ServiceMonitors or err cannot be not nil together")
}
return nil
}
func (p *serviceMonitorsInspectorV1) ServiceMonitors() []*monitoring.ServiceMonitor {
var r []*monitoring.ServiceMonitor
for _, serviceMonitor := range p.serviceMonitors {
r = append(r, serviceMonitor)
}
return r
}
func (p *serviceMonitorsInspectorV1) GetSimple(name string) (*monitoring.ServiceMonitor, bool) {
serviceMonitor, ok := p.serviceMonitors[name]
if !ok {
return nil, false
}
return serviceMonitor, true
}
func (p *serviceMonitorsInspectorV1) Iterate(action ins.Action, filters ...ins.Filter) error {
for _, serviceMonitor := range p.serviceMonitors {
if err := p.iterateServiceMonitor(serviceMonitor, action, filters...); err != nil {
return err
}
}
return nil
}
func (p *serviceMonitorsInspectorV1) iterateServiceMonitor(serviceMonitor *monitoring.ServiceMonitor, action ins.Action, filters ...ins.Filter) error {
for _, f := range filters {
if f == nil {
continue
}
if !f(serviceMonitor) {
return nil
}
}
return action(serviceMonitor)
}
func (p *serviceMonitorsInspectorV1) Read() ins.ReadInterface {
return p
}
func (p *serviceMonitorsInspectorV1) Get(ctx context.Context, name string, opts meta.GetOptions) (*monitoring.ServiceMonitor, error) {
if s, ok := p.GetSimple(name); !ok {
return nil, apiErrors.NewNotFound(constants.ServiceMonitorGR(), name)
} else {
return s, nil
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -34,7 +34,6 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
arangomemberv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/arangomember/v1"
)
const (
@ -190,7 +189,9 @@ func (r *Resources) EnsureArangoMembers(ctx context.Context, cachedStatus inspec
}
return nil
}, arangomemberv1.FilterByDeploymentUID(obj.GetUID())); err != nil {
}, func(obj *api.ArangoMember) bool {
return obj != nil && obj.Spec.DeploymentUID == obj.GetUID()
}); err != nil {
return err
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/info"
podv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/generic"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
)
@ -104,7 +104,7 @@ func (r *Resources) CleanupTerminatedPods(ctx context.Context) (util.Interval, e
}
return nil
}, podv1.FilterPodsByLabels(k8sutil.LabelsForDeployment(r.context.GetAPIObject().GetName(), "")))
}, generic.FilterByLabels[*core.Pod](k8sutil.LabelsForDeployment(r.context.GetAPIObject().GetName(), "")))
}); err != nil {
return 0, err
}

Some files were not shown because too many files have changed in this diff Show more