Skip to content

Commit

Permalink
add accessors to scoped metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensel committed Oct 20, 2023
1 parent 00e6eb5 commit f5a02b0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

package clusterless.commons.substrate.aws.cdk.scoped;

import clusterless.commons.naming.Label;
import clusterless.commons.naming.Ref;
import clusterless.commons.naming.Stage;
import clusterless.commons.naming.Version;
import clusterless.commons.substrate.aws.cdk.naming.ArnRefs;
import org.jetbrains.annotations.NotNull;
import software.constructs.Construct;
Expand All @@ -25,6 +28,33 @@ public ScopedConstruct(@NotNull Construct scope, @NotNull String id) {
super(scope, id);
}

/**
* The {@link Stage} of the {@link ScopedApp} that this construct is scoped to.
*
* @return the {@link Stage} of the {@link ScopedApp} that this construct is scoped to.
*/
protected Stage stage() {
return ScopedApp.scopedOf(this).stage();
}

/**
* The name of the {@link ScopedApp} that this construct is scoped to.
*
* @return the name of the {@link ScopedApp} that this construct is scoped to.
*/
protected Label scopedName() {
return ScopedApp.scopedOf(this).name();
}

/**
* The version of the {@link ScopedApp} that this construct is scoped to.
*
* @return the version of the {@link ScopedApp} that this construct is scoped to.
*/
protected Version scopedVersion() {
return ScopedApp.scopedOf(this).version();
}

protected void addArnRefFor(Ref ref, Construct construct, String value, String description) {
ScopedStack.scopedOf(this)
.addArnRef(ref, construct, value, description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,33 @@ public ScopedStack(@NotNull ScopedApp app) {
stage = app.stage();
}

/**
* The {@link Stage} of the {@link ScopedApp} that this construct is scoped to.
*
* @return the {@link Stage} of the {@link ScopedApp} that this construct is scoped to.
*/
public Stage stage() {
return stage;
}

/**
* The name of the {@link ScopedApp} that this construct is scoped to.
*
* @return the name of the {@link ScopedApp} that this construct is scoped to.
*/
protected Label scopedName() {
return ScopedApp.scopedOf(this).name();
}

/**
* The version of the {@link ScopedApp} that this construct is scoped to.
*
* @return the version of the {@link ScopedApp} that this construct is scoped to.
*/
protected Version scopedVersion() {
return ScopedApp.scopedOf(this).version();
}

protected void addNameRefFor(Ref ref, String value, String description) {
addNameRefFor(ref, null, value, description);
}
Expand Down

0 comments on commit f5a02b0

Please sign in to comment.