diff --git a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/handler/PipelineTemplateErrorHandler.kt b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/handler/PipelineTemplateErrorHandler.kt index 1a19328a3ce..ce1afdf7698 100644 --- a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/handler/PipelineTemplateErrorHandler.kt +++ b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/handler/PipelineTemplateErrorHandler.kt @@ -31,7 +31,6 @@ class PipelineTemplateErrorHandler : Handler { if (context.getErrors().hasErrors(context.getRequest().plan)) { context.getProcessedOutput().putAll(context.getErrors().toResponse()) - context.getProcessedOutput().put("mptRequestId", context.getRequestId()) } } diff --git a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/validator/V1TemplateConfigurationSchemaValidator.java b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/validator/V1TemplateConfigurationSchemaValidator.java index 7cbae746d2a..49568cb7065 100644 --- a/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/validator/V1TemplateConfigurationSchemaValidator.java +++ b/orca-pipelinetemplate/src/main/java/com/netflix/spinnaker/orca/pipelinetemplate/v1schema/validator/V1TemplateConfigurationSchemaValidator.java @@ -67,8 +67,6 @@ public void validate(VersionedSchema configuration, Errors errors, SchemaValidat .withSeverity(Severity.WARN)); } }); - - // TODO rz - validate required variables are set and of the correct type } private static String location(String location) { diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-child.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-child.yml new file mode 100644 index 00000000000..cdf8823e294 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-child.yml @@ -0,0 +1,13 @@ +schema: "1" +id: child-template +source: example-root.yml # Indicates that this template inherits from the root-template +metadata: + name: Child template + description: A child template +stages: +- id: waitChild1 + type: wait + dependsOn: + - wait1 # Depending on a stage from the root-template + config: + waitTime: "{{ waitTime }}" # Using a variable from the root-template diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-config.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-config.yml new file mode 100644 index 00000000000..43b139efc3d --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-config.yml @@ -0,0 +1,27 @@ +schema: "1" +pipeline: + application: myApp + name: My super awesome pipeline + template: + source: example-template.yml + variables: + waitTime: 20 + childWaitTime: 15 +configuration: + notifications: + - address: example@example.com + level: pipeline + name: email0 + type: email + when: + - pipeline.failed + triggers: [] +stages: +- id: finalWait + type: wait + dependsOn: + - waitChild1 + - waitChild2 + config: + waitTime: 10 + diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-expected.json b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-expected.json new file mode 100644 index 00000000000..24fa5c105c2 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-expected.json @@ -0,0 +1,51 @@ +{ + "keepWaitingPipelines": false, + "limitConcurrent": true, + "application": "myApp", + "name": "My super awesome pipeline", + "stages": [ + { + "requisiteStageRefIds": [], + "name": "wait1", + "id": null, + "refId": "wait1", + "type": "wait", + "waitTime": 20 + }, + { + "requisiteStageRefIds": ["wait1"], + "id": null, + "name": "waitChild2", + "refId": "waitChild2", + "type": "wait", + "waitTime": 15 + }, + { + "requisiteStageRefIds": ["wait1"], + "id": null, + "name": "waitChild1", + "refId": "waitChild1", + "type": "wait", + "waitTime": 20 + }, + { + "requisiteStageRefIds": ["waitChild2", "waitChild1"], + "id": null, + "name": "finalWait", + "refId": "finalWait", + "type": "wait", + "waitTime": 10 + } + ], + "id": "unknown", + "notifications": [ + { + "address": "example@example.com", + "level": "pipeline", + "name": "email0", + "when": ["pipeline.failed"], + "type": "email" + } + ], + "parameterConfig": [] +} diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-root.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-root.yml new file mode 100644 index 00000000000..eb3dce161c2 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-root.yml @@ -0,0 +1,14 @@ +schema: "1" # Schema must match for all +id: root-template +metadata: + name: Simple wait template + description: Extendable root template +variables: # Variables available to all that inherit +- name: waitTime + description: The time a wait stage should pause + type: int +stages: # Stages available to all that inherit +- id: wait1 + type: wait + config: + waitTime: "{{ waitTime }}" # Variables can be used anywhere diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-template.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-template.yml new file mode 100644 index 00000000000..907dbffdf16 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/example-template.yml @@ -0,0 +1,16 @@ +schema: "1" +id: child-2-template +source: example-child.yml +variables: +- name: childWaitTime + description: pause time for another wait +metadata: + name: A Second Child template + description: A second child template +stages: +- id: waitChild2 + type: wait + dependsOn: + - wait1 + config: + waitTime: "{{ childWaitTime }}" diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-config.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-config.yml new file mode 100644 index 00000000000..e2c87d799a0 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-config.yml @@ -0,0 +1,20 @@ +schema: "1" +pipeline: + application: myApp + name: My super awesome pipeline + template: + source: exampleCombined-template.yml + variables: + waitTime: 20 + childWaitTime: 15 +configuration: + notifications: + - address: example@example.com + level: pipeline + name: email0 + type: email + when: + - pipeline.failed + triggers: [] + + diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-expected.json b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-expected.json new file mode 100644 index 00000000000..24fa5c105c2 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-expected.json @@ -0,0 +1,51 @@ +{ + "keepWaitingPipelines": false, + "limitConcurrent": true, + "application": "myApp", + "name": "My super awesome pipeline", + "stages": [ + { + "requisiteStageRefIds": [], + "name": "wait1", + "id": null, + "refId": "wait1", + "type": "wait", + "waitTime": 20 + }, + { + "requisiteStageRefIds": ["wait1"], + "id": null, + "name": "waitChild2", + "refId": "waitChild2", + "type": "wait", + "waitTime": 15 + }, + { + "requisiteStageRefIds": ["wait1"], + "id": null, + "name": "waitChild1", + "refId": "waitChild1", + "type": "wait", + "waitTime": 20 + }, + { + "requisiteStageRefIds": ["waitChild2", "waitChild1"], + "id": null, + "name": "finalWait", + "refId": "finalWait", + "type": "wait", + "waitTime": 10 + } + ], + "id": "unknown", + "notifications": [ + { + "address": "example@example.com", + "level": "pipeline", + "name": "email0", + "when": ["pipeline.failed"], + "type": "email" + } + ], + "parameterConfig": [] +} diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-template.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-template.yml new file mode 100644 index 00000000000..ee575968f50 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/exampleCombined-template.yml @@ -0,0 +1,35 @@ +schema: "1" +id: combined-template +metadata: + name: Less simple wait template + description: A template with many waits +variables: +- name: waitTime + description: The time a wait stage should pause + type: int +- name: childWaitTime + description: pause time for another wait +stages: +- id: wait1 + type: wait + config: + waitTime: "{{ waitTime }}" +- id: waitChild1 + type: wait + dependsOn: + - wait1 + config: + waitTime: "{{ waitTime }}" +- id: waitChild2 + type: wait + dependsOn: + - wait1 + config: + waitTime: "{{ childWaitTime }}" +- id: finalWait + type: wait + dependsOn: + - waitChild1 + - waitChild2 + config: + waitTime: 10 diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-config.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-config.yml new file mode 100644 index 00000000000..10b9ace27f5 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-config.yml @@ -0,0 +1,11 @@ +--- +schema: "1" +pipeline: + application: orca +stages: +- id: wait2 + type: wait + config: + waitTime: "{{ waitTime }}" + dependsOn: + - wait1 diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-expected.json b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-expected.json new file mode 100644 index 00000000000..a0c85afb6a3 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-expected.json @@ -0,0 +1,9 @@ +{ + "errors": [ + { + "severity": "FATAL", + "cause": "The template being used has marked itself as protected", + "message": "Modification of the stage graph (adding, removing, editing) is disallowed" + } + ] +} diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-template.yml b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-template.yml new file mode 100644 index 00000000000..f63a7ee6865 --- /dev/null +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/protect-template.yml @@ -0,0 +1,13 @@ +--- +schema: "1" +id: simple +protect: true +metadata: + name: Barebones + description: The simplest template possible. +stages: +- id: wait1 + type: wait + config: + waitTime: "{{ waitTime }}" + diff --git a/orca-pipelinetemplate/src/test/resources/integration/v1schema/unsupportedVersion-expected.json b/orca-pipelinetemplate/src/test/resources/integration/v1schema/unsupportedVersion-expected.json index 78c4fd11291..83c9dcb8a4f 100644 --- a/orca-pipelinetemplate/src/test/resources/integration/v1schema/unsupportedVersion-expected.json +++ b/orca-pipelinetemplate/src/test/resources/integration/v1schema/unsupportedVersion-expected.json @@ -2,7 +2,7 @@ "errors": [ { "severity": "FATAL", - "message": "config schema version is unsupported: expected '1', got '0.1'" + "message": "unexpected schema version '0.1'" } ] }