Skip to content

Commit

Permalink
Only install and refresh lxd once
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Apr 11, 2024
1 parent c056d0c commit 77bd26c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 5 additions & 4 deletions dist/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5674,7 +5674,7 @@ function run() {
const juju_channel = core.getInput("juju-channel");
const juju_bundle_channel = core.getInput("juju-bundle-channel");
const juju_crashdump_channel = core.getInput("juju-crashdump-channel");
const lxd_channel = core.getInput("lxd-channel");
const lxd_channel = (provider === "lxd" && ![null, ""].includes(channel)) ? channel : core.getInput("lxd-channel");
const microk8s_group = get_microk8s_group();
let bootstrap_constraints = core.getInput("bootstrap-constraints");
const microk8s_addons = core.getInput("microk8s-addons");
Expand Down Expand Up @@ -5730,10 +5730,9 @@ function run() {
yield exec.exec("mkdir", ["-p", juju_dir]);
let bootstrap_command = `juju bootstrap --debug --verbose ${provider} ${bootstrap_options}`;
if (provider === "lxd") {
if ([null, ""].includes(channel) == false) {
yield snap(`refresh lxd --channel=${channel}`);
}
core.startGroup("Preparing LXD Provider");
group = "lxd";
core.endGroup();
}
else if (provider === "microk8s") {
core.startGroup("Install microk8s");
Expand Down Expand Up @@ -5783,10 +5782,12 @@ function run() {
bootstrap_constraints = `${bootstrap_constraints} allocate-public-ip=true`;
}
else if (credentials_yaml != "") {
core.startGroup(`Preparing Provider ${provider} credentials`);
yield exec.exec("bash", ["-c", `echo "${credentials_yaml}" | base64 -d > ${juju_dir}/credentials.yaml`], options);
if (clouds_yaml != "") {
yield exec.exec("bash", ["-c", `echo "${clouds_yaml}" | base64 -d > ${juju_dir}/clouds.yaml`], options);
}
core.endGroup();
}
else {
core.setFailed(`Custom provider set without credentials: ${provider}`);
Expand Down
11 changes: 7 additions & 4 deletions src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ async function run() {
const juju_channel = core.getInput("juju-channel");
const juju_bundle_channel = core.getInput("juju-bundle-channel");
const juju_crashdump_channel = core.getInput("juju-crashdump-channel")
const lxd_channel = core.getInput("lxd-channel");

const lxd_channel = (provider === "lxd" && ! [null, ""].includes(channel)) ? channel : core.getInput("lxd-channel");

const microk8s_group = get_microk8s_group();
let bootstrap_constraints = core.getInput("bootstrap-constraints");
const microk8s_addons = core.getInput("microk8s-addons")
Expand Down Expand Up @@ -252,10 +254,9 @@ async function run() {
await exec.exec("mkdir", ["-p", juju_dir]);
let bootstrap_command = `juju bootstrap --debug --verbose ${provider} ${bootstrap_options}`
if (provider === "lxd") {
if ([null, ""].includes(channel) == false){
await snap(`refresh lxd --channel=${channel}`);
}
core.startGroup("Preparing LXD Provider");
group = "lxd";
core.endGroup();
} else if (provider === "microk8s") {
core.startGroup("Install microk8s");
if ([null, ""].includes(channel) == false){
Expand Down Expand Up @@ -300,10 +301,12 @@ async function run() {
bootstrap_command = `${bootstrap_command} --bootstrap-series=${os_series} --metadata-source=/tmp/simplestreams --model-default network=test --model-default external-network=external`
bootstrap_constraints = `${bootstrap_constraints} allocate-public-ip=true`
} else if (credentials_yaml != "") {
core.startGroup(`Preparing Provider ${provider} credentials`);
await exec.exec("bash", ["-c", `echo "${credentials_yaml}" | base64 -d > ${juju_dir}/credentials.yaml`], options);
if (clouds_yaml != "" ) {
await exec.exec("bash", ["-c", `echo "${clouds_yaml}" | base64 -d > ${juju_dir}/clouds.yaml`], options);
}
core.endGroup();
} else {
core.setFailed(`Custom provider set without credentials: ${provider}`);
return
Expand Down

0 comments on commit 77bd26c

Please sign in to comment.