Skip to content

Commit

Permalink
Remove secretLabels option from k8sSearch backend (#123)
Browse files Browse the repository at this point in the history
## Description

This never had any real purpose, since we always add the name of the `SecretClass` as a required label anyway.
  • Loading branch information
nightkr committed May 5, 2022
1 parent 5c48098 commit 296e68d
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 34 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ All notable changes to this project will be documented in this file.

### Changed

- autoTls CA generation now requires opt-in ([#77]).
- `autoTls` CA generation now requires opt-in ([#77]).
- The default `tls` `SecretClass` now has this opt-in by default.

### Removed

- `k8sSearch` backend's option `secretLabels` has been removed ([#123]).

[#77]: https://github.com/stackabletech/secret-operator/pull/77
[#114]: https://github.com/stackabletech/secret-operator/pull/114
[#123]: https://github.com/stackabletech/secret-operator/pull/123
[commons-#20]: https://github.com/stackabletech/commons-operator/pull/20

## [0.2.0] - 2022-02-14
Expand Down
5 changes: 0 additions & 5 deletions deploy/helm/secret-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ spec:
pod:
type: object
type: object
secretLabels:
additionalProperties:
type: string
default: {}
type: object
required:
- searchNamespace
type: object
Expand Down
5 changes: 0 additions & 5 deletions deploy/manifests/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ spec:
pod:
type: object
type: object
secretLabels:
additionalProperties:
type: string
default: {}
type: object
required:
- searchNamespace
type: object
Expand Down
2 changes: 0 additions & 2 deletions docs/modules/ROOT/examples/secretclass-tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ spec:
pod: {}
# or...
name: my-namespace
secretLabels:
type: custom-secret
3 changes: 0 additions & 3 deletions docs/modules/ROOT/pages/secretclass.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ spec:
pod: {}
# or...
name: my-namespace
secretLabels:
type: custom-secret
----

`k8sSearch`:: Declares that the `k8sSearch` backend is used.
Expand All @@ -89,7 +87,6 @@ spec:
for secrets that are provisioned by the application administrator.
`k8sSearch.searchNamespace.name`:: The `Secret` objects are located in a single global namespace. Should be used for secrets
that are provisioned by the cluster administrator.
`k8sSearch.secretLabels`:: Extra labels that are required for a `Secret` to be bound.

[#format]
== Format
Expand Down
2 changes: 0 additions & 2 deletions examples/simple-consumer-shell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ spec:
k8sSearch:
searchNamespace:
pod: {}
secretLabels:
type: custom-secret
---
# A Secret that matches SecretClass/secret, for the Node kind-control-plane
apiVersion: v1
Expand Down
14 changes: 6 additions & 8 deletions rust/operator-binary/src/backend/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ pub async fn from_class(
class: SecretClass,
) -> Result<Box<Dynamic>, FromClassError> {
Ok(match class.spec.backend {
crd::SecretClassBackend::K8sSearch(crd::K8sSearchBackend {
search_namespace,
secret_labels,
}) => from(super::K8sSearch {
client: client.clone(),
search_namespace,
secret_labels,
}),
crd::SecretClassBackend::K8sSearch(crd::K8sSearchBackend { search_namespace }) => {
from(super::K8sSearch {
client: client.clone(),
search_namespace,
})
}
crd::SecretClassBackend::AutoTls(crd::AutoTlsBackend {
ca:
crd::AutoTlsCa {
Expand Down
6 changes: 2 additions & 4 deletions rust/operator-binary/src/backend/k8s_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl SecretBackendError for Error {
pub struct K8sSearch {
pub client: stackable_operator::client::Client,
pub search_namespace: SearchNamespace,
pub secret_labels: BTreeMap<String, String>,
}

#[async_trait]
Expand All @@ -55,11 +54,10 @@ impl SecretBackend for K8sSearch {
selector: &SecretVolumeSelector,
pod_info: PodInfo,
) -> Result<SecretContents, Self::Error> {
let mut label_selector = self.secret_labels.clone();
label_selector.insert(
let mut label_selector = BTreeMap::from([(
"secrets.stackable.tech/class".to_string(),
selector.class.to_string(),
);
)]);
for scope in &selector.scope {
match scope {
SecretScope::Node => {
Expand Down
4 changes: 0 additions & 4 deletions rust/operator-binary/src/crd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::BTreeMap;

use serde::{Deserialize, Serialize};
use stackable_operator::k8s_openapi::api::core::v1::SecretReference;
use stackable_operator::kube::CustomResource;
Expand Down Expand Up @@ -32,8 +30,6 @@ pub enum SecretClassBackend {
#[serde(rename_all = "camelCase")]
pub struct K8sSearchBackend {
pub search_namespace: SearchNamespace,
#[serde(default)]
pub secret_labels: BTreeMap<String, String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
Expand Down

0 comments on commit 296e68d

Please sign in to comment.