Skip to content

Commit

Permalink
fix: Adding ignore flag to ingredient - If set, failed ingredient wil…
Browse files Browse the repository at this point in the history
…l not fail a build (#165)
  • Loading branch information
whilke authored Jun 18, 2020
1 parent 540ea27 commit ba2a616
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ An ingredient block describes an instance of an ingredient to deploy. It has a l
properties:
type: string
condition: variable
ignoreErrors: bool
source: string
tokens: {string: variable}
parameters: {string: variable}
Expand All @@ -90,6 +91,7 @@ dependsOn: [string]
|----------|----------|------------|
|type|yes|name of ingredient to deploy (check ingredient docs for name)|
|condition|no|optional condition check that will skip this ingredient if it returns false|
|ignoreErrors|no|If true, any errors from the ingredient will be logged, but not stop other ingredients from running. Will also not fail the deployment|
|source|depends on ingredient|source file/option for some ingredients|
|tokens|depends on ingredient|Token values typically used to update configuration files when deployed. Check ingredient docs for token options|
|parameters|depends on ingredient|check ingredient docs for parameter options|
Expand All @@ -115,6 +117,7 @@ recipe:
custom-script:
properties:
type: "@azbake/ingredient-script"
ignoreErrors: true
source: ./script.ts
parameters:
name: "[coreutils.create_storage_name('wpoctest1')]"
Expand Down
1 change: 1 addition & 0 deletions core/src/bake-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface IIngredientProperties {
type: string,
source: BakeVariable,
condition?: BakeVariable,
ignoreErrors?: boolean
parameters: Map<string,BakeVariable>,
tokens: Map<string,BakeVariable>,
alerts: Map<string,BakeVariable>
Expand Down
27 changes: 22 additions & 5 deletions system/src/bake-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ export class BakeRunner {
}
}
catch (e) {
this._logger.error("Error running condition check for " + ingredientName + " => " + e);
foundErrors = true;
const shouldIgnoreErrors: boolean = ingredient.properties.ignoreErrors || false
if (shouldIgnoreErrors) {
this._logger.log(red("Error running condition check for " + ingredientName + " => " + e));
this._logger.log("ignoring above error and continuing")
} else {
this._logger.error("Error running condition check for " + ingredientName + " => " + e);
foundErrors = true
}

finished.push(ingredientName)
continue
}
Expand All @@ -75,9 +82,19 @@ export class BakeRunner {
if (exec) {

let promise = exec.Execute().then(() => { return ingredientName }).catch((err) => {
this._logger.error(err)
foundErrors = true
return ingredientName

const shouldIgnoreErrors: boolean = ingredient.properties.ignoreErrors || false

if (shouldIgnoreErrors) {
this._logger.log(red(err))
this._logger.log("ignoring above error and continuing")
}
else {
this._logger.error(err)
foundErrors = true
}

return ingredientName
})

executing.push(promise)
Expand Down

0 comments on commit ba2a616

Please sign in to comment.