Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve container credentials retrieval using workflow compute environment #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SubmitContainerTokenRequest implements Cloneable {
/**
* Tower access token required to enable the service
*/
public String towerAccessToken;
public String towerAccessToken;

/**
* Tower refresh token used to refresh the authorization
Expand Down Expand Up @@ -111,9 +111,15 @@ public class SubmitContainerTokenRequest implements Cloneable {

/**
* When {@code true} build requests are carried out in dry-run mode.
* Id of workflow in tower
*/
public Boolean dryRun;

/**
* Id of compute workflow environment in tower
*/
public String towerWorkflowId;

public SubmitContainerTokenRequest copyWith(Map opts) {
try {
final SubmitContainerTokenRequest copy = (SubmitContainerTokenRequest) this.clone();
Expand Down Expand Up @@ -153,6 +159,8 @@ public SubmitContainerTokenRequest copyWith(Map opts) {
copy.format = (String) opts.get("format");
if( opts.containsKey("dryRun") )
copy.dryRun = (Boolean) opts.get("dryRun");
if( opts.containsKey("towerWorkflowId") )
copy.towerWorkflowId = (String) opts.get("towerWorkflowId");
// done
return copy;
}
Expand Down Expand Up @@ -257,7 +265,7 @@ public SubmitContainerTokenRequest withDryRun(Boolean dryRun) {
}

public boolean formatSingularity() {
return "sif".equals(format);
return "sif".equals(format);
}

@Override
Expand All @@ -281,7 +289,7 @@ public String toString() {
", buildContext=" + buildContext +
", type=" + format +
", dryRun=" + dryRun +
", towerWorkflowId=" + towerWorkflowId +
'}';
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class SubmitContainerTokenRequestTest extends Specification {
fingerprint: 'a14',
freeze: true,
format: 'sif',
dryRun: true
dryRun: true,
towerWorkflowId: 'id123'
)

when:
Expand All @@ -61,6 +62,7 @@ class SubmitContainerTokenRequestTest extends Specification {
copy.freeze == req.freeze
copy.format == req.format
copy.dryRun == req.dryRun
copy.towerWorkflowId == req.towerWorkflowId
and:
copy.formatSingularity()

Expand All @@ -82,7 +84,8 @@ class SubmitContainerTokenRequestTest extends Specification {
fingerprint: 'b14',
freeze: false,
format: 'foo',
dryRun: false
dryRun: false,
towerWorkflowId: 'id123'
)
then:
other.towerAccessToken == 'b1'
Expand All @@ -102,8 +105,9 @@ class SubmitContainerTokenRequestTest extends Specification {
other.freeze == false
other.format == 'foo'
other.dryRun == false
other.towerWorkflowId == 'id123'
and:
!other.formatSingularity()
}

}
}