Skip to content

Commit

Permalink
add exclude property to extensible models so that they may be optiona…
Browse files Browse the repository at this point in the history
…lly be ignored during a deployment
  • Loading branch information
cwensel committed Jul 11, 2023
1 parent dd27062 commit affe34f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
)
@JsonTypeIdResolver(ExtensibleResolver.class)
public abstract class Extensible extends Model {

String type;
boolean exclude = false;

public Extensible() {
type = resolveType(this);
Expand Down Expand Up @@ -56,6 +56,13 @@ public String type() {
return type;
}

/**
* @return true if this object should be excluded when creating constructs
*/
public boolean exclude() {
return exclude;
}

public Class<? extends Model> modelType() {
return resolveModel(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ private void constructManagedStacks(ManagedProject managedProject, Deployable de
throw new IllegalStateException(message);
}

if (arc.exclude()) {
LOG.info("excluding arc type: {}", arc.type());
continue;
}

// construct a stack for every arc
ArcStack stack = new ArcStack(configurations, managedProject, deployable, arc);

Expand All @@ -128,6 +133,7 @@ private void constructManagedStacks(ManagedProject managedProject, Deployable de

stack.applyArcWorkloadComponent(construct);
}

}

private void constructIndependentStacks(ManagedProject managedProject, Deployable deployable, ModelType[] isolatable) {
Expand Down Expand Up @@ -164,6 +170,12 @@ private void constructGroupedStack(ManagedProject managedProject, Deployable dep
private static void construct(ComponentContext context, Map<Extensible, ComponentService<ComponentContext, Model, Component>> containers) {
containers.entrySet().stream().filter(e -> e.getValue() != null).forEach(e -> {
Extensible extensible = e.getKey();

if (extensible.exclude()) {
LOG.info("excluding {} type: {}", extensible.label(), extensible.type());
return;
}

ComponentService<ComponentContext, Model, Component> modelComponentService = e.getValue();
LOG.info("creating {} construct: {}", extensible.label(), extensible.type());
modelComponentService.create(context, extensible);
Expand Down

0 comments on commit affe34f

Please sign in to comment.