Skip to content

Commit

Permalink
feat: When we skip an env or cluster then ignore config
Browse files Browse the repository at this point in the history
When we skipped and env or a cluster, will continued to process the
config files regardless. This was so that dependancies between different
clusters could be managed correctly for skipped clusters.

But we in practise we don't support dependancies between clusters
correctly anyway. So this can be simplified.
  • Loading branch information
Brian May authored and brianmay committed Apr 8, 2024
1 parent e0aebc6 commit 6f7a161
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,9 @@ async fn do_task(
let (skipped_list, todo) = generate_todo(args, list_release_names, &mut helm_repos)?;

let mut skipped = InstallationSet::new();
for (show_skipped, item) in skipped_list {
for item in skipped_list {
skipped.add(&item);
if show_skipped {
output.send(Message::SkippedJob(item)).await;
}
output.send(Message::SkippedJob(item)).await;
}

let jobs: Jobs = (task, todo);
Expand Down Expand Up @@ -396,7 +394,7 @@ impl<'a> Iterator for HelmIter<'a> {
}
}

type SkippedResult = (bool, Arc<Installation>);
type SkippedResult = Arc<Installation>;

#[allow(clippy::cognitive_complexity)]
fn generate_todo(
Expand All @@ -408,7 +406,7 @@ fn generate_todo(
let envs = Env::list_all_env(&vdir)
.with_context(|| format!("Cannot list envs from vdir {}", vdir.display()))?;
let mut todo: Vec<Arc<Installation>> = Vec::new();
let mut skipped: Vec<(bool, Arc<Installation>)> = Vec::new();
let mut skipped: Vec<SkippedResult> = Vec::new();
let mut seen = InstallationSet::default();
let mut next_id: InstallationId = 0;

Expand All @@ -429,6 +427,11 @@ fn generate_todo(
continue;
}

if args.env != "*" && args.env != env_name {
trace!("Skipping env {}", env.name);
continue;
}

trace!("Processing env {}", env.name);

let all_clusters = env
Expand All @@ -444,6 +447,11 @@ fn generate_todo(
continue;
}

if !args.cluster.is_empty() && !args.cluster.contains(&cluster_name) {
trace!("Skipping cluster {}", cluster.name);
continue;
}

trace!("Processing cluster {}", cluster.name);

let all_releases = cluster.list_all_releases().with_context(|| {
Expand All @@ -462,18 +470,11 @@ fn generate_todo(
AutoState::All => false,
};

// We don't show skipped entries to the user if the env was skipped or the cluster was skipped
let hide_skip = env.config.locked
|| (args.env != "*" && args.env != env_name)
|| (!args.cluster.is_empty() && !args.cluster.contains(&cluster_name))
|| cluster.config.locked;

// We also do skip entries if the install is to be skipped, these will be shown
let skip = (!list_release_names.is_empty()
&& !list_release_names.contains(&install.name))
|| install.config.locked
|| auto_skip
|| hide_skip;
|| auto_skip;

let installation =
create_installation(&env, &cluster, install, next_id, helm_repos);
Expand All @@ -492,7 +493,7 @@ fn generate_todo(
// Note: skipped installs count towards dependency requirements
let installation = Arc::new(installation);
if skip {
skipped.push((!hide_skip, installation));
skipped.push(installation);
} else {
todo.push(installation);
}
Expand Down

0 comments on commit 6f7a161

Please sign in to comment.