Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavborbat committed Jan 17, 2024
1 parent 40a382d commit fe05117
Show file tree
Hide file tree
Showing 21 changed files with 967 additions and 20 deletions.
75 changes: 75 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5046,6 +5046,10 @@
"description": "CDIConfig at CDI level",
"$ref": "#/definitions/v1beta1.CDIConfigSpec"
},
"customizeComponents": {
"default": {},
"$ref": "#/definitions/v1beta1.CustomizeComponents"
},
"imagePullPolicy": {
"description": "PullPolicy describes a policy for if/when to pull a container image\n\nPossible enum values:\n - `\"Always\"` means that kubelet always attempts to pull the latest image. Container will fail If the pull fails.\n - `\"IfNotPresent\"` means that kubelet pulls if the image isn't present on disk. Container will fail if the image isn't present and the pull fails.\n - `\"Never\"` means that kubelet never pulls an image, but only uses a local image. Container will fail if the image isn't present",
"type": "string",
Expand Down Expand Up @@ -5159,6 +5163,50 @@
}
}
},
"v1beta1.CustomizeComponents": {
"type": "object",
"properties": {
"flags": {
"description": "Configure the value used for deployment and daemonset resources",
"$ref": "#/definitions/v1beta1.Flags"
},
"patches": {
"type": "array",
"items": {
"default": {},
"$ref": "#/definitions/v1beta1.CustomizeComponentsPatch"
},
"x-kubernetes-list-type": "atomic"
}
}
},
"v1beta1.CustomizeComponentsPatch": {
"type": "object",
"required": [
"resourceName",
"resourceType",
"patch",
"type"
],
"properties": {
"patch": {
"type": "string",
"default": ""
},
"resourceName": {
"type": "string",
"default": ""
},
"resourceType": {
"type": "string",
"default": ""
},
"type": {
"type": "string",
"default": ""
}
}
},
"v1beta1.DataImportCron": {
"description": "DataImportCron defines a cron job for recurring polling/importing disk images as PVCs into a golden image namespace",
"type": "object",
Expand Down Expand Up @@ -5935,6 +5983,33 @@
}
}
},
"v1beta1.Flags": {
"description": "Flags will create a patch that will replace all flags for the container's command field. The only flags that will be used are those define. There are no guarantees around forward/backward compatibility. If set incorrectly this will cause the resource when rolled out to error until flags are updated.",
"type": "object",
"properties": {
"api": {
"type": "object",
"additionalProperties": {
"type": "string",
"default": ""
}
},
"controller": {
"type": "object",
"additionalProperties": {
"type": "string",
"default": ""
}
},
"uploadProxy": {
"type": "object",
"additionalProperties": {
"type": "string",
"default": ""
}
}
}
},
"v1beta1.ImportProxy": {
"description": "ImportProxy provides the information on how to configure the importer pod proxy.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/coreos/go-semver v0.3.1
github.com/docker/go-units v0.5.0
github.com/emicklei/go-restful/v3 v3.10.2
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.2.4
github.com/golang/snappy v0.0.4
Expand Down Expand Up @@ -83,7 +84,6 @@ require (
github.com/docker/docker v23.0.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
Expand Down
148 changes: 147 additions & 1 deletion pkg/apis/core/v1beta1/openapi_generated.go

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

9 changes: 9 additions & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ const (
// CDIOperatorName is the CDI operator name
CDIOperatorName = "cdi-operator"

// CDIControllerResourceName is the CDI controller resource name
CDIControllerResourceName = "cdi-deployment"
// CDIApiServerResourceName is the CDI apiserver resource name
CDIApiServerResourceName = "cdi-apiserver"
// CDIUploadProxyResourceName is the CDI uploadproxy resource name
CDIUploadProxyResourceName = "cdi-uploadproxy"
// CDICronJobResourceName is the CDI cronjob resource name
CDICronJobResourceName = "cdi-cronjob"

// AppKubernetesPartOfLabel is the Kubernetes recommended part-of label
AppKubernetesPartOfLabel = "app.kubernetes.io/part-of"
// AppKubernetesVersionLabel is the Kubernetes recommended version label
Expand Down
11 changes: 7 additions & 4 deletions pkg/controller/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const (
// AnnCloneType is the comuuted/requested clone type
AnnCloneType = AnnAPIGroup + "/cloneType"
// AnnCloneSourcePod name of the source clone pod
AnnCloneSourcePod = "cdi.kubevirt.io/storage.sourceClonePodName"
AnnCloneSourcePod = AnnAPIGroup + "/storage.sourceClonePodName"

// AnnUploadRequest marks that a PVC should be made available for upload
AnnUploadRequest = AnnAPIGroup + "/storage.upload.target"
Expand Down Expand Up @@ -249,7 +249,7 @@ const (
AnnGarbageCollected = AnnAPIGroup + "/garbageCollected"

// CloneUniqueID is used as a special label to be used when we search for the pod
CloneUniqueID = "cdi.kubevirt.io/storage.clone.cloneUniqeId"
CloneUniqueID = AnnAPIGroup + "/storage.clone.cloneUniqeId"

// CloneSourceInUse is reason for event created when clone source pvc is in use
CloneSourceInUse = "CloneSourceInUse"
Expand Down Expand Up @@ -320,9 +320,12 @@ const (
ProgressDone = "100.0%"

// AnnEventSourceKind is the source kind that should be related to events
AnnEventSourceKind = "cdi.kubevirt.io/events.source.kind"
AnnEventSourceKind = AnnAPIGroup + "/events.source.kind"
// AnnEventSource is the source that should be related to events (namespace/name)
AnnEventSource = "cdi.kubevirt.io/events.source"
AnnEventSource = AnnAPIGroup + "/events.source"

// This annotation is a hash of all customizations that live under spec.CustomizeComponents
AnnCdiCustomizeComponentHash = AnnAPIGroup + "/customizer-identifier"
)

// Size-detection pod error codes
Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/controller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_library(
"cr-manager.go",
"cruft.go",
"handler.go",
"patches.go",
"prometheus.go",
"reconciler-hooks.go",
"route.go",
Expand All @@ -31,6 +32,7 @@ go_library(
"//pkg/operator/resources/utils:go_default_library",
"//pkg/util:go_default_library",
"//staging/src/kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1:go_default_library",
"//vendor/github.com/evanphx/json-patch:go_default_library",
"//vendor/github.com/go-logr/logr:go_default_library",
"//vendor/github.com/kelseyhightower/envconfig:go_default_library",
"//vendor/github.com/openshift/api/route/v1:go_default_library",
Expand All @@ -57,6 +59,7 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
Expand Down Expand Up @@ -84,6 +87,7 @@ go_test(
"certrotation_test.go",
"controller_suite_test.go",
"controller_test.go",
"patches_test.go",
],
embed = [":go_default_library"],
deps = [
Expand Down
8 changes: 8 additions & 0 deletions pkg/operator/controller/cr-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,13 @@ func (r *ReconcileCDI) GetAllResources(crObject client.Object) ([]client.Object,
}
}

customizer, err := NewCustomizer(cr.Spec.CustomizeComponents)
if err != nil {
return nil, err
}
if err := customizer.Apply(resources); err != nil {
return nil, err
}

return resources, nil
}
Loading

0 comments on commit fe05117

Please sign in to comment.