mirror of
https://github.com/kubevirt/containerized-data-importer.git
synced 2025-06-03 06:30:22 +00:00
Generate release CSV from code
Signed-off-by: David Vossel <davidvossel@gmail.com>
This commit is contained in:
parent
7ca8893edf
commit
2292ea1700
@ -49,6 +49,7 @@ generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-rbac" "rba
|
|||||||
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-deployment" "cdi-operator-deployment.yaml"
|
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-deployment" "cdi-operator-deployment.yaml"
|
||||||
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-cdi-crd" "cdi-crd.yaml"
|
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-cdi-crd" "cdi-crd.yaml"
|
||||||
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-configmap-cr" "cdi-configmap-cr.yaml"
|
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-configmap-cr" "cdi-configmap-cr.yaml"
|
||||||
|
generateResourceManifest $generator $MANIFEST_GENERATED_DIR "operator-csv" "cdi-operator-csv.yaml"
|
||||||
|
|
||||||
#process templated manifests and populate them with generated manifests
|
#process templated manifests and populate them with generated manifests
|
||||||
tempDir=${MANIFEST_TEMPLATE_DIR}
|
tempDir=${MANIFEST_TEMPLATE_DIR}
|
||||||
|
@ -1,126 +1 @@
|
|||||||
apiVersion: operators.coreos.com/v1alpha1
|
{{index .GeneratedManifests "cdi-operator-csv.yaml"}}
|
||||||
kind: ClusterServiceVersion
|
|
||||||
metadata:
|
|
||||||
name: cdioperator.{{.CsvVersion}}
|
|
||||||
namespace: placeholder
|
|
||||||
annotations:
|
|
||||||
capabilities: "Full Lifecycle"
|
|
||||||
categories: "Storage,Virtualization"
|
|
||||||
alm-examples: |
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"apiVersion":"cdi.kubevirt.io/v1alpha1",
|
|
||||||
"kind":"CDI",
|
|
||||||
"metadata": {
|
|
||||||
"name":"cdi",
|
|
||||||
"namespace":"cdi"
|
|
||||||
},
|
|
||||||
"spec": {
|
|
||||||
"imagePullPolicy":"IfNotPresent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
description: Creates and maintains CDI deployments
|
|
||||||
spec:
|
|
||||||
displayName: CDI
|
|
||||||
description: |
|
|
||||||
CDI is a kubernetes extension that provides the ability to populate PVCs with VM images upon creation. Multiple image formats and sources are supported
|
|
||||||
|
|
||||||
_The CDI Operator does not support updates yet._
|
|
||||||
keywords:
|
|
||||||
- CDI
|
|
||||||
- Virtualization
|
|
||||||
- Storage
|
|
||||||
version: {{.CsvVersion}}
|
|
||||||
maturity: alpha
|
|
||||||
{{.ReplacesCsvVersion}}
|
|
||||||
maintainers:
|
|
||||||
- name: KubeVirt project
|
|
||||||
email: kubevirt-dev@googlegroups.com
|
|
||||||
provider:
|
|
||||||
name: KubeVirt/CDI project
|
|
||||||
links:
|
|
||||||
- name: CDI
|
|
||||||
url: https://github.com/kubevirt/containerized-data-importer/blob/master/README.md
|
|
||||||
- name: Source Code
|
|
||||||
url: https://github.com/kubevirt/containerized-data-importer
|
|
||||||
icon:
|
|
||||||
- base64data: {{.CDILogo}}
|
|
||||||
mediatype: image/png
|
|
||||||
labels:
|
|
||||||
alm-owner-cdi: cdi-operator
|
|
||||||
operated-by: cdi-operator
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
alm-owner-cdi: cdi-operator
|
|
||||||
operated-by: cdi-operator
|
|
||||||
installModes:
|
|
||||||
- type: OwnNamespace
|
|
||||||
supported: true
|
|
||||||
- type: SingleNamespace
|
|
||||||
supported: true
|
|
||||||
- type: MultiNamespace
|
|
||||||
supported: true
|
|
||||||
- type: AllNamespaces
|
|
||||||
supported: true
|
|
||||||
install:
|
|
||||||
strategy: deployment
|
|
||||||
spec:
|
|
||||||
clusterPermissions:
|
|
||||||
- serviceAccountName: cdi-operator
|
|
||||||
rules:
|
|
||||||
{{.OperatorRules}}
|
|
||||||
deployments:
|
|
||||||
- name: cdi-operator
|
|
||||||
spec:
|
|
||||||
{{.OperatorDeploymentSpec}}
|
|
||||||
customresourcedefinitions:
|
|
||||||
owned:
|
|
||||||
- name: cdis.cdi.kubevirt.io
|
|
||||||
version: v1alpha1
|
|
||||||
kind: CDI
|
|
||||||
displayName: CDI deployment
|
|
||||||
description: Represents a CDI deployment.
|
|
||||||
resources:
|
|
||||||
- kind: ConfigMap
|
|
||||||
name: cdi-operator-leader-election-helper
|
|
||||||
version: v1
|
|
||||||
specDescriptors:
|
|
||||||
- description: The ImageRegistry to use for the CDI components.
|
|
||||||
displayName: ImageRegistry
|
|
||||||
path: imageRegistry
|
|
||||||
x-descriptors:
|
|
||||||
- 'urn:alm:descriptor:text'
|
|
||||||
- description: The ImageTag to use for the CDI components.
|
|
||||||
displayName: ImageTag
|
|
||||||
path: imageTag
|
|
||||||
x-descriptors:
|
|
||||||
- 'urn:alm:descriptor:text'
|
|
||||||
- description: The ImagePullPolicy to use for the CDI components.
|
|
||||||
displayName: ImagePullPolicy
|
|
||||||
path: imagePullPolicy
|
|
||||||
x-descriptors:
|
|
||||||
- 'urn:alm:descriptor:io.kubernetes:imagePullPolicy'
|
|
||||||
statusDescriptors:
|
|
||||||
- description: The deployment phase.
|
|
||||||
displayName: Phase
|
|
||||||
path: phase
|
|
||||||
x-descriptors:
|
|
||||||
- 'urn:alm:descriptor:io.kubernetes.phase'
|
|
||||||
- description: Explanation for the current status of the CDI deployment.
|
|
||||||
displayName: Condition
|
|
||||||
path: CDICondition
|
|
||||||
x-descriptors:
|
|
||||||
- 'urn:alm:descriptor:io.kubernetes.conditions'
|
|
||||||
- description: The observed version of the CDI deployment.
|
|
||||||
displayName: Observed CDI Version
|
|
||||||
path: observedVersion
|
|
||||||
- 'urn:alm:descriptor:text'
|
|
||||||
- description: The targeted version of the CDI deployment.
|
|
||||||
displayName: Target CDI Version
|
|
||||||
path: targetVersion
|
|
||||||
- 'urn:alm:descriptor:text'
|
|
||||||
- description: The version of the CDI Operator.
|
|
||||||
displayName: CDI Operator Version
|
|
||||||
path: operatorVersion
|
|
||||||
- 'urn:alm:descriptor:text'
|
|
||||||
|
@ -39,6 +39,9 @@ type FactoryArgs struct {
|
|||||||
Verbosity string `required:"true"`
|
Verbosity string `required:"true"`
|
||||||
PullPolicy string `required:"true" split_words:"true"`
|
PullPolicy string `required:"true" split_words:"true"`
|
||||||
Namespace string
|
Namespace string
|
||||||
|
CsvVersion string `required:"true"`
|
||||||
|
ReplacesCsvVersion string
|
||||||
|
CDILogo string
|
||||||
}
|
}
|
||||||
|
|
||||||
type operatorFactoryFunc func(*FactoryArgs) []runtime.Object
|
type operatorFactoryFunc func(*FactoryArgs) []runtime.Object
|
||||||
@ -52,6 +55,8 @@ const (
|
|||||||
OperatorCdiCRD string = "operator-cdi-crd"
|
OperatorCdiCRD string = "operator-cdi-crd"
|
||||||
//OperatorConfigMapCR - operartor configmap
|
//OperatorConfigMapCR - operartor configmap
|
||||||
OperatorConfigMapCR string = "operator-configmap-cr"
|
OperatorConfigMapCR string = "operator-configmap-cr"
|
||||||
|
//OperatorCSV - operator csv
|
||||||
|
OperatorCSV string = "operator-csv"
|
||||||
)
|
)
|
||||||
|
|
||||||
var operatorFactoryFunctions = map[string]operatorFactoryFunc{
|
var operatorFactoryFunctions = map[string]operatorFactoryFunc{
|
||||||
@ -59,6 +64,7 @@ var operatorFactoryFunctions = map[string]operatorFactoryFunc{
|
|||||||
OperatorDeployment: createOperatorClusterDeployment,
|
OperatorDeployment: createOperatorClusterDeployment,
|
||||||
OperatorCdiCRD: createOperatorCDIClusterResource,
|
OperatorCdiCRD: createOperatorCDIClusterResource,
|
||||||
OperatorConfigMapCR: createOperatorConfigMapClusterResource,
|
OperatorConfigMapCR: createOperatorConfigMapClusterResource,
|
||||||
|
OperatorCSV: createOperatorClusterServiceVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
//IsFactoryResource returns true id codeGroupo belolngs to factory functions
|
//IsFactoryResource returns true id codeGroupo belolngs to factory functions
|
||||||
|
@ -637,6 +637,39 @@ func createPrometheusPorts() *[]corev1.ContainerPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createOperatorClusterServiceVersion(args *FactoryArgs) []runtime.Object {
|
||||||
|
|
||||||
|
cdiImageNames := CdiImages{
|
||||||
|
ControllerImage: args.ControllerImage,
|
||||||
|
ImporterImage: args.ImporterImage,
|
||||||
|
ClonerImage: args.ClonerImage,
|
||||||
|
APIServerImage: args.APIServerImage,
|
||||||
|
UplodaProxyImage: args.UploadProxyImage,
|
||||||
|
UplodaServerImage: args.UploadServerImage,
|
||||||
|
OperatorImage: args.OperatorImage,
|
||||||
|
}
|
||||||
|
|
||||||
|
data := NewClusterServiceVersionData{
|
||||||
|
CsvVersion: args.CsvVersion,
|
||||||
|
ReplacesCsvVersion: args.ReplacesCsvVersion,
|
||||||
|
Namespace: args.Namespace,
|
||||||
|
ImagePullPolicy: args.PullPolicy,
|
||||||
|
IconBase64: args.CDILogo,
|
||||||
|
Verbosity: args.Verbosity,
|
||||||
|
|
||||||
|
DockerPrefix: args.DockerRepo,
|
||||||
|
DockerTag: args.DockerTag,
|
||||||
|
CdiImageNames: cdiImageNames.FillDefaults(),
|
||||||
|
}
|
||||||
|
|
||||||
|
csv, err := createClusterServiceVersion(&data)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return []runtime.Object{csv}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
type csvClusterPermissions struct {
|
type csvClusterPermissions struct {
|
||||||
ServiceAccountName string `json:"serviceAccountName"`
|
ServiceAccountName string `json:"serviceAccountName"`
|
||||||
Rules []rbacv1.PolicyRule `json:"rules"`
|
Rules []rbacv1.PolicyRule `json:"rules"`
|
||||||
|
@ -16,7 +16,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -61,6 +60,7 @@ var (
|
|||||||
dockerRepo = flag.String("docker-repo", "", "")
|
dockerRepo = flag.String("docker-repo", "", "")
|
||||||
dockertag = flag.String("docker-tag", "", "")
|
dockertag = flag.String("docker-tag", "", "")
|
||||||
csvVersion = flag.String("csv-version", "", "")
|
csvVersion = flag.String("csv-version", "", "")
|
||||||
|
replacesCsvVersion = flag.String("replaces-csv-version", "", "")
|
||||||
cdiLogoPath = flag.String("cdi-logo-path", "", "")
|
cdiLogoPath = flag.String("cdi-logo-path", "", "")
|
||||||
genManifestsPath = flag.String("generated-manifests-path", "", "")
|
genManifestsPath = flag.String("generated-manifests-path", "", "")
|
||||||
bundleOut = flag.String("olm-bundle-dir", "", "")
|
bundleOut = flag.String("olm-bundle-dir", "", "")
|
||||||
@ -95,6 +95,13 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if *templFile != "" {
|
if *templFile != "" {
|
||||||
|
if *replacesCsvVersion == "" {
|
||||||
|
var err error
|
||||||
|
*replacesCsvVersion, err = evalOlmCsvUpdateVersion(*templFile, *csvVersion, *bundleOut, *quayNamespace, *quayRepository)
|
||||||
|
if err != nil {
|
||||||
|
klog.Fatalf("Failed to evaluate CSV Replaces Version! %s, %v", *csvVersion, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
generateFromFile(*templFile)
|
generateFromFile(*templFile)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -130,6 +137,10 @@ func getOperatorDeploymentSpec() string {
|
|||||||
UploadServerImage: *uploadServerImage,
|
UploadServerImage: *uploadServerImage,
|
||||||
PullPolicy: *pullPolicy,
|
PullPolicy: *pullPolicy,
|
||||||
Namespace: *namespace,
|
Namespace: *namespace,
|
||||||
|
|
||||||
|
CsvVersion: *csvVersion,
|
||||||
|
ReplacesCsvVersion: *replacesCsvVersion,
|
||||||
|
CDILogo: getCdiLogo(*cdiLogoPath),
|
||||||
}
|
}
|
||||||
|
|
||||||
spec := cdioperator.GetOperatorDeploymentSpec(args)
|
spec := cdioperator.GetOperatorDeploymentSpec(args)
|
||||||
@ -183,7 +194,7 @@ func evalOlmCsvUpdateVersion(inFile, csvVersion, bundleOutDir, quayNamespace, qu
|
|||||||
if strings.HasSuffix(latestVersion, csvVersion) {
|
if strings.HasSuffix(latestVersion, csvVersion) {
|
||||||
klog.Fatalf("CSV version %s is already published!", csvVersion)
|
klog.Fatalf("CSV version %s is already published!", csvVersion)
|
||||||
}
|
}
|
||||||
replacesCsvVersion = fmt.Sprintf(" replaces: %v", latestVersion)
|
replacesCsvVersion = latestVersion
|
||||||
// also copy old manifests to out dir
|
// also copy old manifests to out dir
|
||||||
if *bundleOut != "" {
|
if *bundleOut != "" {
|
||||||
bundleHelper.AddOldManifests(bundleOutDir, csvVersion)
|
bundleHelper.AddOldManifests(bundleOutDir, csvVersion)
|
||||||
@ -217,11 +228,7 @@ func generateFromFile(templFile string) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
data.ReplacesCsvVersion, err = evalOlmCsvUpdateVersion(templFile, *csvVersion, *bundleOut, *quayNamespace, *quayRepository)
|
data.ReplacesCsvVersion = *replacesCsvVersion
|
||||||
if err != nil {
|
|
||||||
klog.Fatalf("Failed to evaluate CSV Replaces Version! %s, %v", *csvVersion, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data.QuayRepository = *quayRepository
|
data.QuayRepository = *quayRepository
|
||||||
data.QuayNamespace = *quayNamespace
|
data.QuayNamespace = *quayNamespace
|
||||||
data.OperatorRules = getOperatorRules()
|
data.OperatorRules = getOperatorRules()
|
||||||
@ -340,6 +347,10 @@ func getOperatorClusterResources(codeGroup string) ([]runtime.Object, error) {
|
|||||||
UploadServerImage: *uploadServerImage,
|
UploadServerImage: *uploadServerImage,
|
||||||
PullPolicy: *pullPolicy,
|
PullPolicy: *pullPolicy,
|
||||||
Namespace: *namespace,
|
Namespace: *namespace,
|
||||||
|
|
||||||
|
CsvVersion: *csvVersion,
|
||||||
|
ReplacesCsvVersion: *replacesCsvVersion,
|
||||||
|
CDILogo: getCdiLogo(*cdiLogoPath),
|
||||||
}
|
}
|
||||||
|
|
||||||
if codeGroup == ClusterResourcesCodeOperatorGroupEverything {
|
if codeGroup == ClusterResourcesCodeOperatorGroupEverything {
|
||||||
|
Loading…
Reference in New Issue
Block a user