Skip to content

Commit

Permalink
fixup ability to detect MAP BOX API key and add it to the environment… (
Browse files Browse the repository at this point in the history
#178)

… if present.

## Description

Addition of ability to add the lookup for the MAP_BOX_API key that Superset can use to obtain geo information and map backgrounds for lat / long style queries.



Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
  • Loading branch information
rsiwicki and razvan committed Apr 20, 2022
1 parent 9c875c3 commit e194337
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions deploy/crd/supersetcluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ spec:
loadExamplesOnInit:
nullable: true
type: boolean
mapboxSecret:
nullable: true
type: string
nodes:
nullable: true
properties:
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/superset-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ spec:
loadExamplesOnInit:
nullable: true
type: boolean
mapboxSecret:
nullable: true
type: string
nodes:
nullable: true
properties:
Expand Down
3 changes: 3 additions & 0 deletions deploy/manifests/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spec:
loadExamplesOnInit:
nullable: true
type: boolean
mapboxSecret:
nullable: true
type: string
nodes:
nullable: true
properties:
Expand Down
13 changes: 10 additions & 3 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct SupersetClusterSpec {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub statsd_exporter_version: Option<String>,
pub credentials_secret: String,
pub mapbox_secret: Option<String>,
#[serde(default)]
pub load_examples_on_init: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -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 {
Expand All @@ -144,11 +146,16 @@ impl Configuration for SupersetConfig {
cluster: &Self::Configurable,
_role_name: &str,
) -> Result<BTreeMap<String, Option<String>>, 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(
Expand Down
2 changes: 2 additions & 0 deletions rust/operator-binary/src/superset_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit e194337

Please sign in to comment.