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

fix(errors): throw a useful error for invalid manifest configuration #4452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -50,6 +50,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import retrofit.client.Response;
Expand Down Expand Up @@ -167,6 +168,12 @@ private Supplier<Iterable<Object>> fetchAndParseManifestYaml(Artifact manifestAr
}

private Artifact getManifestArtifact(StageExecution stage, ManifestContext context) {
if (StringUtils.hasText(context.getManifestArtifactId())
&& StringUtils.hasText(context.getManifestArtifactAccount())) {
throw new IllegalArgumentException(
"Artifact account must not be set if referencing an artifact produced by a previous stage.");
}

Artifact manifestArtifact =
Optional.ofNullable(
artifactUtils.getBoundArtifactForStage(
Expand Down
Expand Up @@ -276,6 +276,23 @@ void optionalArtifacts() {
assertThat(result.getOptionalArtifacts()).isEqualTo(optionalArtifacts);
}

@Test
void shouldThrowExceptionWhenArtifactIdAndAccountBothSet() {
StageExecutionImpl stage = new StageExecutionImpl();

DeployManifestContext context =
DeployManifestContext.builder()
.manifestArtifactId("my-manifest-artifact-id")
.manifestArtifactAccount("some-other-account")
.skipExpressionEvaluation(false)
.source(Source.Artifact)
.build();

assertThatThrownBy(() -> manifestEvaluator.evaluate(stage, context))
.isInstanceOf(IllegalArgumentException.class);
verifyNoInteractions(oortService);
}

@Test
void shouldThrowExceptionWhenFailedEvaluatingManifestExpressions() {
StageExecutionImpl stage = new StageExecutionImpl();
Expand Down