The ClusterServiceVersion class

class operator_csv_libs.csv.ClusterServiceVersion(csv, name=None, target_version=None, replaces=None, skiprange=None, logger=None)
LATEST_IMAGE_INDICATOR = '-latest'
NO_UPGRADE_LIST = ['3.1.1']
RELATED_IMAGE_IDENTIFIER = 'olm.relatedImage.'
add_image_pullsecret(name)

Add image pull secret for all operator deployment deployments. Existing pull secrets will be kept

Parameters

name (string, list) – String or list of strings containing name of the pull secret to add

generate_spec_relatedImages()

Generates spec.relatedImages based on information found in operator deployment annotations marked with ‘olm.relatedImage.*’

Return a list of images found in ‘olm.relatedImages.*’ deployment annotations

Returns

Returns a List of Images as defined in Images class

Return type

list

get_formatted_csv()

Returns a stringified save ready formatted ClusterServiceVersion This allows maintaining the format of the alm-examples: |- block

get_hidden_crds()
get_init_container_images()

Return a list of images used for init containers

Returns

Returns a List of Images as defined in Images class

Return type

list

get_operator_deployments(api_version='apps/v1', kind='Deployment')

Return a list of kubernetes deployment objects constructed from the CSV deployments section

Returns

List of kubernetes deployment objects

Return type

list

get_operator_images()

Return a list of images used for operator deployment

Returns

Returns a List of Images as defined in Images class

Return type

list

get_owned_crds()

Returns a list of owned CustomResourceDefinitions

Returns

List of owned custom resource definitions as dict object

Return type

list

get_replaces()

Return String

Returns

Returns the csv file name with previous version

Return type

string

get_updated_csv()

Returns the updated CSV object

Returns

CSV with updated version and image information

Return type

dict

set_container_image_annotation(image)

Set metadata.annotations.containerImage with Image.image passed in

Parameters

image (Image) – Image that will be assigned to metadata.annotations.containerImage

set_deployments_annotations(key=None, value=None)

Set key with value passed in for each deployment in the CSV

Parameters
  • key (string) – Key being search for in deployment annotations

  • value (string) – Value that will be assigned to the key passed in

set_image_pullsecret(name)

Set the image pull secret for all operator deployment deployments. Overwrites any existing pull secret

Parameters

name (string, list) – String or list of strings containing name of the pull secret to add

set_replaces(replaces)

Set the release that this replaces

Parameters

replaces (string) – The versioned name of the csv that this csv replaces

set_version(version)

Set the target version for the CSV

Parameters

version (string) – Target version in semver format X.Y.Z with optional -nnnn for pre-release