Skip to content

Commit

Permalink
Add support for organization in pulumi stack init
Browse files Browse the repository at this point in the history
Added a feature to the Pulumi stack initialization to include organization details. This is implemented by introducing 'organization' as an option in both the 'StackInitOptions' struct and the Pulumi stack specification. Accordingly, the 'stack_init' function syncs the stack name with the present organization when initiating a new stack. Also, updated Pulumi Kubernetes job image to version 1.0.26. This feature enhances stack management in organizations by enabling namespace differentiation.
  • Loading branch information
jan-br committed Oct 19, 2023
1 parent 2faa31f commit 28a4eaf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pulumi-cli/src/lib.rs
Expand Up @@ -25,7 +25,12 @@ impl PulumiCLI {

pub async fn stack_init(&self, options: StackInitOptions) -> ExitStatus {
let mut command = Command::new("pulumi");
command.arg("stack").arg("init").arg(options.stack);
let combined_stack = if let Some(organization) = options.organization {
format!("{}/{}", organization, options.stack)
} else {
options.stack
};
command.arg("stack").arg("init").arg(combined_stack);

self.spawn(command).await
}
Expand Down Expand Up @@ -172,6 +177,7 @@ pub struct CancelOptions {
}
pub struct StackInitOptions {
pub stack: String,
pub organization: Option<String>,
}

pub struct DestroyOptions {
Expand Down
1 change: 1 addition & 0 deletions pulumi-operator-kubernetes-job/src/pulumi_execution.rs
Expand Up @@ -157,6 +157,7 @@ impl PulumiExecution {
pulumi
.stack_init(StackInitOptions {
stack: stack_name.clone(),
organization: pulumi_stack.spec.organization.clone()
})
.await;

Expand Down
1 change: 1 addition & 0 deletions pulumi-operator-kubernetes/src/stack/crd.rs
Expand Up @@ -25,6 +25,7 @@ pub struct StackSpec {
pub extra_volumes: Option<Vec<Volume>>,
pub main_container: Option<MainContainerOverride>,
pub main_pod: Option<MainPodOverride>,
pub organization: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
Expand Down
2 changes: 1 addition & 1 deletion pulumi-operator-kubernetes/src/stack/service.rs
Expand Up @@ -59,7 +59,7 @@ impl KubernetesPulumiStackService {

let mut main_container: Container = serde_json::from_value(json!({
"name": "pulumi",
"image": "ghcr.io/stromee/pulumi-operator/pulumi-operator-kubernetes-job:1.0.25",
"image": "ghcr.io/stromee/pulumi-operator/pulumi-operator-kubernetes-job:1.0.26",
"env": [{
"name": "PULUMI_STACK",
"value": name
Expand Down

0 comments on commit 28a4eaf

Please sign in to comment.