lab-ui-manager/operator/operator.py
def manage_bookbag_image_build(namespace, name, bookbag_config, owner_ref, logger=None):
    """
    Create BuildConfig and ImageStream to build Bookbag image.
    """
    build_spec = deepcopy(bookbag_config['imageBuild'])
    build_spec['output'] = {
        "to": {
            "kind": "ImageStreamTag",
            "name": f"{name}:latest",
        }
    }
    if 'strategy' not in build_spec:
        build_spec['strategy'] = {
            "type": "Source",
            "sourceStrategy": {
                "from": {
                    "kind": "DockerImage",
                    "name": "quay.io/openshifthomeroom/workshop-dashboard:5.0.0",
                }
            }
        }
    build_spec['triggers'] = [{"type": "ConfigChange"}]

    image_stream = get_image_stream(namespace, name)
    if not image_stream:
        custom_objects_api.create_namespaced_custom_object(
            'image.openshift.io', 'v1', namespace, 'imagestreams',
            {
                "apiVersion": "image.openshift.io/v1",
                "kind": "ImageStream",
                "metadata": {
                    "name": name,
                    "namespace": namespace,
                    "ownerReferences": [owner_ref],
                },
            }
        )

    build_config = get_build_config(namespace, name)
    if build_config:
        merged_spec = deepmerge(deepcopy(build_config['spec']), build_spec)
        if merged_spec != build_config['spec']:
            try:
                custom_objects_api.replace_namespaced_custom_object(
                    'build.openshift.io', 'v1', namespace, 'buildconfigs', name, {
                        "apiVersion": "build.openshift.io/v1",
                        "kind": "BuildConfig",
                        "metadata": build_config['metadata'],
                        "spec": merged_spec,
                    }
                )
            except kubernetes.client.rest.ApiException as e:
                if e.status == 409:
                    pass
                else:
                    raise
    else:
        custom_objects_api.create_namespaced_custom_object(
            'build.openshift.io', 'v1', namespace, 'buildconfigs',
            {
                "apiVersion": "build.openshift.io/v1",
                "kind": "BuildConfig",
                "metadata": {
                    "name": name,
                    "namespace": namespace,
                    "ownerReferences": [owner_ref],
                },
                "spec": build_spec,
            }
        )

    Create BuildConfig and ImageStream to build Bookbag image.
    
Create BuildConfig and ImageStream to build Bookbag image.
Create BuildConfig and ImageStream to build Bookbag image .
def manage_bookbag_image_build(namespace, name, bookbag_config, owner_ref, logger=None):
    build_spec = deepcopy(bookbag_config['imageBuild'])
    build_spec['output'] = {
        "to": {
            "kind": "ImageStreamTag",
            "name": f"{name}:latest",
        }
    }
    if 'strategy' not in build_spec:
        build_spec['strategy'] = {
            "type": "Source",
            "sourceStrategy": {
                "from": {
                    "kind": "DockerImage",
                    "name": "quay.io/openshifthomeroom/workshop-dashboard:5.0.0",
                }
            }
        }
    build_spec['triggers'] = [{"type": "ConfigChange"}]
    image_stream = get_image_stream(namespace, name)
    if not image_stream:
        custom_objects_api.create_namespaced_custom_object(
            'image.openshift.io', 'v1', namespace, 'imagestreams',
            {
                "apiVersion": "image.openshift.io/v1",
                "kind": "ImageStream",
                "metadata": {
                    "name": name,
                    "namespace": namespace,
                    "ownerReferences": [owner_ref],
                },
            }
        )
    build_config = get_build_config(namespace, name)
    if build_config:
        merged_spec = deepmerge(deepcopy(build_config['spec']), build_spec)
        if merged_spec != build_config['spec']:
            try:
                custom_objects_api.replace_namespaced_custom_object(
                    'build.openshift.io', 'v1', namespace, 'buildconfigs', name, {
                        "apiVersion": "build.openshift.io/v1",
                        "kind": "BuildConfig",
                        "metadata": build_config['metadata'],
                        "spec": merged_spec,
                    }
                )
            except kubernetes.client.rest.ApiException as e:
                if e.status == 409:
                    pass
                else:
                    raise
    else:
        custom_objects_api.create_namespaced_custom_object(
            'build.openshift.io', 'v1', namespace, 'buildconfigs',
            {
                "apiVersion": "build.openshift.io/v1",
                "kind": "BuildConfig",
                "metadata": {
                    "name": name,
                    "namespace": namespace,
                    "ownerReferences": [owner_ref],
                },
                "spec": build_spec,
            }
        )
def manage_bookbag_image_build ( namespace , name , bookbag_config , owner_ref , logger = None ) : build_spec = deepcopy ( bookbag_config [ 'imageBuild' ] ) build_spec [ 'output' ] = { "to" : { "kind" : "ImageStreamTag" , "name" : f"{name}:latest" , } } if 'strategy' not in build_spec : build_spec [ 'strategy' ] = { "type" : "Source" , "sourceStrategy" : { "from" : { "kind" : "DockerImage" , "name" : "quay.io/openshifthomeroom/workshop-dashboard:5.0.0" , } } } build_spec [ 'triggers' ] = [ { "type" : "ConfigChange" } ] image_stream = get_image_stream ( namespace , name ) if not image_stream : custom_objects_api . create_namespaced_custom_object ( 'image.openshift.io' , 'v1' , namespace , 'imagestreams' , { "apiVersion" : "image.openshift.io/v1" , "kind" : "ImageStream" , "metadata" : { "name" : name , "namespace" : namespace , "ownerReferences" : [ owner_ref ] , } , } ) build_config = get_build_config ( namespace , name ) if build_config : merged_spec = deepmerge ( deepcopy ( build_config [ 'spec' ] ) , build_spec ) if merged_spec != build_config [ 'spec' ] : try : custom_objects_api . replace_namespaced_custom_object ( 'build.openshift.io' , 'v1' , namespace , 'buildconfigs' , name , { "apiVersion" : "build.openshift.io/v1" , "kind" : "BuildConfig" , "metadata" : build_config [ 'metadata' ] , "spec" : merged_spec , } ) except kubernetes . client . rest . ApiException as e : if e . status == 409 : pass else : raise else : custom_objects_api . create_namespaced_custom_object ( 'build.openshift.io' , 'v1' , namespace , 'buildconfigs' , { "apiVersion" : "build.openshift.io/v1" , "kind" : "BuildConfig" , "metadata" : { "name" : name , "namespace" : namespace , "ownerReferences" : [ owner_ref ] , } , "spec" : build_spec , } )
Create BuildConfig and ImageStream to build Bookbag image.
Create BuildConfig and ImageStream to build Bookbag image .
"""
    Create BuildConfig and ImageStream to build Bookbag image.
    """
namespace
name
bookbag_config
owner_ref
logger