-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: olm deployment helper #546
Merged
Merged
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b0b0c79
wip: added olm-deployer
razvan fa11668
wip
razvan 5b75e2a
wip: checkpoint
razvan bbe0762
wip
razvan 31b0372
wip: working version
razvan 3a69789
reorg test manifests
razvan 0893d20
impl owner ref
razvan e92acd3
Added readme, update manifests, successful run
razvan 7729878
reorg modules
razvan e7a156c
wip
razvan 5a3302b
test env
razvan 46996ab
copy resources
razvan acee691
add secret op lib crate
razvan a827fab
patch namespace
razvan 4693dfa
Revert "add secret op lib crate"
razvan 87cfab2
added test for namespace patch
razvan df3b6ab
cargo fmt
razvan 5ea0b36
Merge branch 'main' into feat/olm-deployer
razvan 5736913
main merge
razvan 4d3b7e7
added owner name cli param
razvan 28a7f00
obtain clusterrole by label selector
razvan 1f880c9
olm creates multiple clusterroles per subscription
razvan 75d21e2
Merge branch 'main' into feat/olm-deployer
razvan 0e77dfd
delete tests in favor of olm manifests
razvan 1299ffd
modify DynamicObjects in place and reduce cloning
razvan 790cf2c
added keep_alive cli option
razvan c2778b7
Merge branch 'main' into feat/olm-deployer
razvan 850a0d0
sleep forever
razvan 99ec5fd
fix lint
razvan 274f0a2
main merge
razvan 2c577ca
Update inline docs.
razvan 1519519
Drop the op_version arg in favor of the csv name.
razvan 57b431e
Update changelog.
razvan 70160ae
fix typos
razvan 00520b4
update readme to mention oci.stackable.tech
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: secret-operator-deployer | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.14.2 | ||
ports: | ||
- containerPort: 80 | ||
tolerations: | ||
- key: keep-out | ||
value: "yes" | ||
operator: Equal | ||
effect: NoSchedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "olm-deployer" | ||
description = "OLM deployment helper." | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
clap.workspace = true | ||
tokio.workspace = true | ||
tracing.workspace = true | ||
stackable-operator.workspace = true | ||
serde.workspace = true | ||
serde_json.workspace = true | ||
serde_yaml.workspace = true | ||
walkdir.workspace = true | ||
|
||
[build-dependencies] | ||
built.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# How to test | ||
|
||
Requirements: | ||
|
||
1. An OpenShift cluster. | ||
2. Checkout the branch `secret-olm-deployer` from the [operators](https://github.com/stackabletech/openshift-certified-operators/tree/secret-olm-deployer) repo. | ||
3. Clone the `stackable-utils` [repo](https://github.com/stackabletech/stackable-utils) | ||
|
||
Install the secret operator using OLM and the `olm-deployer`. From the `stackable-utils` repo, run: | ||
|
||
```bash | ||
$ ./olm/build-bundles.sh -c $HOME/repo/stackable/openshift-certified-operators -r 24.11.0 -o secret -d | ||
adwk67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
... | ||
``` | ||
|
||
The secret op and all it's dependencies should be installed and running in the `stackable-operators` namespace. | ||
|
||
Run the integration tests: | ||
|
||
```bash | ||
$ ./scripts/run-tests --skip-operator secret --test-suite openshift | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
built::write_built_file().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use anyhow::{bail, Result}; | ||
use stackable_operator::kube::{api::DynamicObject, ResourceExt}; | ||
|
||
pub fn data_field_as_mut<'a>( | ||
value: &'a mut serde_json::Value, | ||
pointer: &str, | ||
) -> Result<&'a mut serde_json::Value> { | ||
match value.pointer_mut(pointer) { | ||
Some(field) => Ok(field), | ||
x => bail!("invalid pointer {pointer} for object {x:?}"), | ||
} | ||
} | ||
|
||
pub fn container<'a>( | ||
target: &'a mut DynamicObject, | ||
container_name: &str, | ||
) -> anyhow::Result<&'a mut serde_json::Value> { | ||
let tname = target.name_any(); | ||
let path = "template/spec/containers".split("/"); | ||
match get_or_create(target.data.pointer_mut("/spec").unwrap(), path)? { | ||
serde_json::Value::Array(containers) => { | ||
for c in containers { | ||
if c.is_object() { | ||
if let Some(serde_json::Value::String(name)) = c.get("name") { | ||
if container_name == name { | ||
return Ok(c); | ||
} | ||
} | ||
} else { | ||
anyhow::bail!("container is not a object: {:?}", c); | ||
} | ||
} | ||
anyhow::bail!("container named {container_name} not found"); | ||
} | ||
_ => anyhow::bail!("no containers found in object {tname}"), | ||
} | ||
} | ||
|
||
/// Returns the object nested in `root` by traversing the `path` of nested keys. | ||
/// Creates any missing objects in path. | ||
/// In case of success, the returned value is either the existing object or | ||
/// serde_json::Value::Null. | ||
/// Returns an error if any of the nested objects has a type other than map. | ||
pub fn get_or_create<'a, 'b, I>( | ||
root: &'a mut serde_json::Value, | ||
path: I, | ||
) -> anyhow::Result<&'a mut serde_json::Value> | ||
where | ||
I: IntoIterator<Item = &'b str>, | ||
{ | ||
let mut iter = path.into_iter(); | ||
match iter.next() { | ||
None => Ok(root), | ||
Some(first) => { | ||
let new_root = get_or_insert_default_object(root, first)?; | ||
get_or_create(new_root, iter) | ||
} | ||
} | ||
} | ||
|
||
/// Given a map object create or return the object corresponding to the given `key`. | ||
fn get_or_insert_default_object<'a>( | ||
value: &'a mut serde_json::Value, | ||
key: &str, | ||
) -> anyhow::Result<&'a mut serde_json::Value> { | ||
let map = match value { | ||
serde_json::Value::Object(map) => map, | ||
x @ serde_json::Value::Null => { | ||
*x = serde_json::json!({}); | ||
x.as_object_mut().unwrap() | ||
} | ||
razvan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x => anyhow::bail!("invalid type {x:?}, expected map"), | ||
}; | ||
Ok(map.entry(key).or_insert_with(|| serde_json::Value::Null)) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an accidental left-over?