diff --git a/CHANGELOG.md b/CHANGELOG.md index e690f902..92bb413f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ - Configuration option `rowLimit` added ([#173]). - Configuration and environment overrides enabled ([#173]). +- Ability to add MAPBOX_API_KEY from secret added ([#178]). [#173]: https://github.com/stackabletech/superset-operator/pull/173 +[#178]: https://github.com/stackabletech/superset-operator/pull/178 ## [0.4.0] - 2022-04-05 diff --git a/deploy/crd/supersetcluster.crd.yaml b/deploy/crd/supersetcluster.crd.yaml index 0902a429..2538fdea 100644 --- a/deploy/crd/supersetcluster.crd.yaml +++ b/deploy/crd/supersetcluster.crd.yaml @@ -27,6 +27,9 @@ spec: loadExamplesOnInit: nullable: true type: boolean + mapboxSecret: + nullable: true + type: string nodes: nullable: true properties: diff --git a/deploy/helm/superset-operator/crds/crds.yaml b/deploy/helm/superset-operator/crds/crds.yaml index 5fe0e6ce..180a3ca7 100644 --- a/deploy/helm/superset-operator/crds/crds.yaml +++ b/deploy/helm/superset-operator/crds/crds.yaml @@ -29,6 +29,9 @@ spec: loadExamplesOnInit: nullable: true type: boolean + mapboxSecret: + nullable: true + type: string nodes: nullable: true properties: diff --git a/deploy/manifests/crds.yaml b/deploy/manifests/crds.yaml index 15a37301..2d88ac58 100644 --- a/deploy/manifests/crds.yaml +++ b/deploy/manifests/crds.yaml @@ -30,6 +30,9 @@ spec: loadExamplesOnInit: nullable: true type: boolean + mapboxSecret: + nullable: true + type: string nodes: nullable: true properties: diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 06903b8e..d51ff136 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -88,6 +88,7 @@ pub struct SupersetClusterSpec { #[serde(default, skip_serializing_if = "Option::is_none")] pub statsd_exporter_version: Option, pub credentials_secret: String, + pub mapbox_secret: Option, #[serde(default)] pub load_examples_on_init: Option, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -134,6 +135,7 @@ pub struct SupersetConfig { impl SupersetConfig { pub const CREDENTIALS_SECRET_PROPERTY: &'static str = "credentialsSecret"; + pub const MAPBOX_SECRET_PROPERTY: &'static str = "mapboxSecret"; } impl Configuration for SupersetConfig { @@ -144,11 +146,16 @@ impl Configuration for SupersetConfig { cluster: &Self::Configurable, _role_name: &str, ) -> Result>, ConfigError> { - Ok([( + let mut result = BTreeMap::new(); + result.insert( Self::CREDENTIALS_SECRET_PROPERTY.to_string(), Some(cluster.spec.credentials_secret.clone()), - )] - .into()) + ); + if let Some(msec) = &cluster.spec.mapbox_secret { + result.insert(Self::MAPBOX_SECRET_PROPERTY.to_string(), Some(msec.clone())); + } + + Ok(result) } fn compute_cli( diff --git a/rust/operator-binary/src/superset_controller.rs b/rust/operator-binary/src/superset_controller.rs index e60091cb..8180e8a6 100644 --- a/rust/operator-binary/src/superset_controller.rs +++ b/rust/operator-binary/src/superset_controller.rs @@ -402,6 +402,8 @@ fn build_server_rolegroup_statefulset( &value, "connections.sqlalchemyDatabaseUri", ); + } else if name == SupersetConfig::MAPBOX_SECRET_PROPERTY { + cb.add_env_var_from_secret("MAPBOX_API_KEY", &value, "connections.mapboxApiKey"); } else { cb.add_env_var(name, value); };