|
| 1 | +# Load the metadata first, so that we immediately get access to the operator name |
| 2 | +meta = read_json('nix/meta.json') |
| 3 | +operator_name = meta['operator']['name'] |
| 4 | + |
| 5 | +# If tilt_options.json exists read it and load the default_registry, default_operator_repository, |
| 6 | +# and default_product_repository value from it |
| 7 | +settings = read_json('tilt_options.json', default={}) |
| 8 | +registry = settings.get('default_registry', 'oci.stackable.tech') |
| 9 | + |
| 10 | +# Construct the operator image repository. It uses the "sandbox" instead of the "sdp" namespace to |
| 11 | +# separate "testing/local" images from official (published) images. |
| 12 | +operator_repository = settings.get('default_operator_repository', registry + '/' + 'sandbox') |
| 13 | +operator_image_name = operator_repository + '/' + operator_name |
| 14 | + |
| 15 | +# For the product image, we want to use the images in the "sdp" namespace, because "sandbox" doesn't |
| 16 | +# contain those images (by default). |
| 17 | +product_repository = settings.get('default_product_repository', registry + '/' + 'sdp') |
| 18 | +# Configure default registry either read from config file above, or with default value of |
| 19 | +# "oci.stackable.tech" |
| 20 | +default_registry(registry) |
| 21 | + |
| 22 | +custom_build( |
| 23 | + operator_image_name, |
| 24 | + 'make regenerate-nix && nix-build . -A docker --argstr dockerName "' + operator_image_name + '" && ./result/load-image | docker load', |
| 25 | + deps=['rust', 'Cargo.toml', 'Cargo.lock', 'default.nix', "nix", 'build.rs', 'vendor'], |
| 26 | + ignore=['*.~undo-tree~'], |
| 27 | + # ignore=['result*', 'Cargo.nix', 'target', *.yaml], |
| 28 | + outputs_image_ref_to='result/ref', |
| 29 | +) |
| 30 | + |
| 31 | +# We need to set the correct image annotation on the operator Deployment to use e.g. |
| 32 | +# oci.stackable.tech/sandbox/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of |
| 33 | +# oci.stackable.tech/sandbox/opa-operator:0.0.0-dev (which does not exist) |
| 34 | +k8s_kind('Deployment', image_json_path='{.spec.template.metadata.annotations.internal\\.stackable\\.tech/image}') |
| 35 | +k8s_kind('DaemonSet', image_json_path='{.spec.template.metadata.annotations.internal\\.stackable\\.tech/image}') |
| 36 | + |
| 37 | +# Optionally specify a custom Helm values file to be passed to the Helm deployment below. |
| 38 | +# This file can for example be used to set custom telemetry options (like log level) which is not |
| 39 | +# supported by helm(set). |
| 40 | +helm_values = settings.get('helm_values', None) |
| 41 | + |
| 42 | +helm_override_operator_image_repository = 'image.repository=' + operator_repository |
| 43 | +helm_override_product_image_repository = 'image.productRepository=' + product_repository |
| 44 | + |
| 45 | +k8s_yaml(helm( |
| 46 | + 'deploy/helm/' + operator_name, |
| 47 | + name=operator_name, |
| 48 | + namespace="stackable-operators", |
| 49 | + set=[ |
| 50 | + helm_override_operator_image_repository, |
| 51 | + helm_override_product_image_repository, |
| 52 | + ], |
| 53 | + values=helm_values, |
| 54 | +)) |
0 commit comments