Merge pull request #4 from lukaszraczylo/add-annotations

Add annotations support.
This commit is contained in:
2023-03-16 11:23:48 +00:00
committed by GitHub
6 changed files with 59 additions and 5 deletions
+2
View File
@@ -94,6 +94,8 @@ type ManagedJobParameters struct {
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
// +kubebuilder:validation:Optional
Labels map[string]string `json:"labels,omitempty"`
// +kubebuilder:validation:Optional
Annotations map[string]string `json:"annotations,omitempty"`
}
// ManagedJobSpec defines the desired state of ManagedJob
+7
View File
@@ -213,6 +213,13 @@ func (in *ManagedJobParameters) DeepCopyInto(out *ManagedJobParameters) {
(*out)[key] = val
}
}
if in.Annotations != nil {
in, out := &in.Annotations, &out.Annotations
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedJobParameters.
+2 -2
View File
@@ -13,12 +13,12 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.20
version: 0.0.21
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.20"
appVersion: "0.0.21"
keywords:
- operator
- jobs
@@ -59,6 +59,10 @@ spec:
type: array
compiledParams:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable
@@ -2135,6 +2139,10 @@ spec:
type: boolean
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable
@@ -4205,6 +4213,10 @@ spec:
type: boolean
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable present
@@ -6131,6 +6143,10 @@ spec:
type: array
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable present
@@ -59,6 +59,10 @@ spec:
type: array
compiledParams:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable
@@ -2205,6 +2209,10 @@ spec:
type: boolean
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable
@@ -4345,6 +4353,10 @@ spec:
type: boolean
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable
@@ -6317,6 +6329,10 @@ spec:
type: array
params:
properties:
annotations:
additionalProperties:
type: string
type: object
env:
items:
description: EnvVar represents an environment variable present
+16 -3
View File
@@ -24,6 +24,7 @@ type compiledParams struct {
ImagePullSecrets []corev1.LocalObjectReference
ImagePullPolicy string
Labels map[string]string
Annotations map[string]string
}
func (cp *connPackage) compileParameters(params ...jobsmanagerv1beta1.ManagedJobParameters) jobsmanagerv1beta1.ManagedJobParameters {
@@ -56,6 +57,11 @@ func (cp *connPackage) compileParameters(params ...jobsmanagerv1beta1.ManagedJob
cparams.Labels[k] = v
}
}
if params.Annotations != nil {
for k, v := range params.Annotations {
cparams.Annotations[k] = v
}
}
}
}
return cparams
@@ -242,6 +248,12 @@ func (cp *connPackage) executeJob(j *jobsmanagerv1beta1.ManagedJobDefinition, g
labels[k] = v
}
annotations := map[string]string{}
for k, v := range j.CompiledParams.Annotations {
annotations[k] = v
}
job_handler := kbatch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: generatedJobName,
@@ -250,9 +262,10 @@ func (cp *connPackage) executeJob(j *jobsmanagerv1beta1.ManagedJobDefinition, g
Spec: kbatch.JobSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: generatedJobName,
Namespace: cp.mj.Namespace,
Labels: labels,
Name: generatedJobName,
Namespace: cp.mj.Namespace,
Labels: labels,
Annotations: annotations,
},
Spec: corev1.PodSpec{
Volumes: j.CompiledParams.Volumes,