Skip to content

Commit 9fae7fa

Browse files
committed
address feedback on PR
1 parent 4f05048 commit 9fae7fa

9 files changed

Lines changed: 39 additions & 39 deletions

File tree

deploy/helm/opensearch-operator/crds/crds.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
properties:
4141
key:
4242
description: Key in the OpenSearch keystore
43+
minLength: 1
44+
pattern: ^[A-Za-z0-9_\-.]+$
4345
type: string
4446
secretKeyRef:
4547
description: Reference to the Secret containing the value which will be stored in the OpenSearch keystore

docs/modules/opensearch/pages/usage-guide/keystore.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:description: Add entries to the OpenSearch Keystore
33

44
The OpenSearch keystore provides secure storage for sensitive configuration settings such as credentials and API keys.
5-
You can populate the keystore by referencing Secrets from in your OpenSearch configuration.
5+
You can populate the keystore by referencing Secrets within your OpenSearch configuration.
66

77
[source,yaml]
88
----

rust/operator-binary/src/controller.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ use update_status::update_status;
2828
use validate::validate;
2929

3030
use crate::{
31-
crd::{
32-
NodeRoles,
33-
v1alpha1::{self, OpenSearchKeystore},
34-
},
31+
crd::{NodeRoles, v1alpha1},
3532
framework::{
3633
HasName, HasUid, NameIsValidLabelValue,
3734
product_logging::framework::{ValidatedContainerLogConfigChoice, VectorContainerLogConfig},
@@ -172,7 +169,7 @@ pub struct ValidatedCluster {
172169
pub uid: Uid,
173170
pub role_config: GenericRoleConfig,
174171
pub role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>,
175-
pub keystores: Vec<OpenSearchKeystore>,
172+
pub keystores: Vec<v1alpha1::OpenSearchKeystore>,
176173
}
177174

178175
impl ValidatedCluster {
@@ -185,7 +182,7 @@ impl ValidatedCluster {
185182
uid: impl Into<Uid>,
186183
role_config: GenericRoleConfig,
187184
role_group_configs: BTreeMap<RoleGroupName, OpenSearchRoleGroupConfig>,
188-
keystores: Vec<OpenSearchKeystore>,
185+
keystores: Vec<v1alpha1::OpenSearchKeystore>,
189186
) -> Self {
190187
let uid = uid.into();
191188
ValidatedCluster {
@@ -389,7 +386,7 @@ mod tests {
389386
use crate::{
390387
controller::{OpenSearchNodeResources, ValidatedOpenSearchConfig},
391388
crd::{
392-
NodeRoles,
389+
NodeRoles, OpenSearchKeystoreKey,
393390
v1alpha1::{self, OpenSearchKeystore, SecretKeyRef},
394391
},
395392
framework::{
@@ -511,7 +508,7 @@ mod tests {
511508
]
512509
.into(),
513510
vec![OpenSearchKeystore {
514-
key: "Keystore1".to_string(),
511+
key: OpenSearchKeystoreKey::from_str_unsafe("Keystore1"),
515512
secret_key_ref: SecretKeyRef {
516513
name: SecretName::from_str_unsafe("my-keystore-secret"),
517514
key: SecretKey::from_str_unsafe("my-keystore-file"),

rust/operator-binary/src/controller/build.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ mod tests {
7777
ContextNames, OpenSearchNodeResources, OpenSearchRoleGroupConfig, ValidatedCluster,
7878
ValidatedContainerLogConfigChoice, ValidatedLogging, ValidatedOpenSearchConfig,
7979
},
80-
crd::{
81-
NodeRoles,
82-
v1alpha1::{self, OpenSearchKeystore, SecretKeyRef},
83-
},
80+
crd::{NodeRoles, OpenSearchKeystoreKey, v1alpha1},
8481
framework::{
8582
builder::pod::container::EnvVarSet,
8683
role_utils::GenericProductSpecificCommonConfig,
@@ -200,9 +197,9 @@ mod tests {
200197
),
201198
]
202199
.into(),
203-
vec![OpenSearchKeystore {
204-
key: "Keystore1".to_string(),
205-
secret_key_ref: SecretKeyRef {
200+
vec![v1alpha1::OpenSearchKeystore {
201+
key: OpenSearchKeystoreKey::from_str_unsafe("Keystore1"),
202+
secret_key_ref: v1alpha1::SecretKeyRef {
206203
name: SecretName::from_str_unsafe("my-keystore-secret"),
207204
key: SecretKey::from_str_unsafe("my-keystore-file"),
208205
},

rust/operator-binary/src/controller/build/role_group_builder.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,7 @@ mod tests {
757757
ContextNames, OpenSearchRoleGroupConfig, ValidatedCluster,
758758
ValidatedContainerLogConfigChoice, ValidatedLogging, ValidatedOpenSearchConfig,
759759
},
760-
crd::{
761-
NodeRoles,
762-
v1alpha1::{self, OpenSearchKeystore, SecretKeyRef},
763-
},
760+
crd::{NodeRoles, OpenSearchKeystoreKey, v1alpha1},
764761
framework::{
765762
builder::pod::container::EnvVarSet,
766763
product_logging::framework::VectorContainerLogConfig,
@@ -852,9 +849,9 @@ mod tests {
852849
role_group_config.clone(),
853850
)]
854851
.into(),
855-
vec![OpenSearchKeystore {
856-
key: "Keystore1".to_string(),
857-
secret_key_ref: SecretKeyRef {
852+
vec![v1alpha1::OpenSearchKeystore {
853+
key: OpenSearchKeystoreKey::from_str_unsafe("Keystore1"),
854+
secret_key_ref: v1alpha1::SecretKeyRef {
858855
name: SecretName::from_str_unsafe("my-keystore-secret"),
859856
key: SecretKey::from_str_unsafe("my-keystore-file"),
860857
},

rust/operator-binary/src/controller/validate.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,7 @@ mod tests {
286286
use crate::{
287287
built_info,
288288
controller::{ContextNames, ValidatedCluster, ValidatedLogging, ValidatedOpenSearchConfig},
289-
crd::{
290-
NodeRoles,
291-
v1alpha1::{self, OpenSearchKeystore, SecretKeyRef},
292-
},
289+
crd::{NodeRoles, OpenSearchKeystoreKey, v1alpha1},
293290
framework::{
294291
builder::pod::container::{EnvVarName, EnvVarSet},
295292
product_logging::framework::{
@@ -513,9 +510,9 @@ mod tests {
513510
}
514511
)]
515512
.into(),
516-
vec![OpenSearchKeystore {
517-
key: "Keystore1".to_string(),
518-
secret_key_ref: SecretKeyRef {
513+
vec![v1alpha1::OpenSearchKeystore {
514+
key: OpenSearchKeystoreKey::from_str_unsafe("Keystore1"),
515+
secret_key_ref: v1alpha1::SecretKeyRef {
519516
name: SecretName::from_str_unsafe("my-keystore-secret"),
520517
key: SecretKey::from_str_unsafe("my-keystore-file")
521518
}
@@ -697,9 +694,9 @@ mod tests {
697694
image: serde_json::from_str(r#"{"productVersion": "3.1.0"}"#)
698695
.expect("should be a valid ProductImage structure"),
699696
cluster_config: v1alpha1::OpenSearchClusterConfig {
700-
keystore: vec![OpenSearchKeystore {
701-
key: "Keystore1".to_string(),
702-
secret_key_ref: SecretKeyRef {
697+
keystore: vec![v1alpha1::OpenSearchKeystore {
698+
key: OpenSearchKeystoreKey::from_str_unsafe("Keystore1"),
699+
secret_key_ref: v1alpha1::SecretKeyRef {
703700
name: SecretName::from_str_unsafe("my-keystore-secret"),
704701
key: SecretKey::from_str_unsafe("my-keystore-file"),
705702
},

rust/operator-binary/src/crd/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use stackable_operator::{
2727
use strum::{Display, EnumIter};
2828

2929
use crate::{
30-
constant,
30+
attributed_string_type, constant,
3131
framework::{
3232
NameIsValidLabelValue,
3333
role_utils::GenericProductSpecificCommonConfig,
@@ -87,6 +87,7 @@ pub mod versioned {
8787
/// Entries to add to the OpenSearch keystore.
8888
#[serde(default)]
8989
pub keystore: Vec<OpenSearchKeystore>,
90+
9091
/// Name of the Vector aggregator [discovery ConfigMap](DOCS_BASE_URL_PLACEHOLDER/concepts/service_discovery).
9192
/// It must contain the key `ADDRESS` with the address of the Vector aggregator.
9293
/// Follow the [logging tutorial](DOCS_BASE_URL_PLACEHOLDER/tutorials/logging-vector-aggregator)
@@ -99,7 +100,7 @@ pub mod versioned {
99100
#[serde(rename_all = "camelCase")]
100101
pub struct OpenSearchKeystore {
101102
/// Key in the OpenSearch keystore
102-
pub key: String,
103+
pub key: OpenSearchKeystoreKey,
103104

104105
/// Reference to the Secret containing the value which will be stored in the OpenSearch keystore
105106
pub secret_key_ref: SecretKeyRef,
@@ -357,6 +358,15 @@ impl v1alpha1::Container {
357358
}
358359
}
359360

361+
// See https://github.com/opensearch-project/OpenSearch/blob/8ff7c6ee924a49f0f59f80a6e1c73073c8904214/server/src/main/java/org/opensearch/common/settings/KeyStoreWrapper.java#L125
362+
attributed_string_type! {
363+
OpenSearchKeystoreKey,
364+
"Key in an OpenSearch keystore",
365+
"s3.client.default.access_key",
366+
(min_length = 1),
367+
(regex = "[A-Za-z0-9_\\-.]+")
368+
}
369+
360370
#[cfg(test)]
361371
mod tests {
362372
use strum::IntoEnumIterator;

tests/templates/kuttl/backup-restore/10-install-s3-credentials-secret.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ kind: Secret
44
metadata:
55
name: s3-credentials
66
stringData:
7-
s3.client.default.access_key: openSearchAccessKey
8-
s3.client.default.secret_key: openSearchSecretKey
7+
ACCESS_KEY: openSearchAccessKey
8+
SECRET_KEY: openSearchSecretKey

tests/templates/kuttl/backup-restore/21-install-opensearch-1.yaml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ spec:
1515
- key: s3.client.default.access_key
1616
secretKeyRef:
1717
name: s3-credentials
18-
key: s3.client.default.access_key
18+
key: ACCESS_KEY
1919
- key: s3.client.default.secret_key
2020
secretKeyRef:
2121
name: s3-credentials
22-
key: s3.client.default.secret_key
22+
key: SECRET_KEY
2323
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
2424
vectorAggregatorConfigMapName: vector-aggregator-discovery
2525
{% endif %}

0 commit comments

Comments
 (0)