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: stackoutput generation and image upload runbooks #2075

Merged
merged 3 commits into from
Dec 13, 2022
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
3 changes: 2 additions & 1 deletion providers/shared/components/runbook/setup.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"Environment" : {},
"Links" : contextLinks,
"TaskParameters" : solution.Task.Parameters,
"Conditions" : solution.Conditions
"Conditions" : solution.Conditions,
"Inputs": runBookInputs
}
]
[#local _context = invokeExtensions(subOccurrence, _context, {}, [], false, "runbook")]
Expand Down
67 changes: 67 additions & 0 deletions providers/shared/deploymentframeworks/default/output.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[#assign CONTRACT_DEFAULT_OUTPUT_TYPE = "contract"]
[#assign INFO_DEFAULT_OUTPUT_TYPE = "info" ]
[#assign STATE_OUTPUT_TYPE = "state" ]
[#assign STACK_OUTPUT_TYPE = "stack"]

[#-- SCRIPT_DEFAULT_OUTPUT_TYPE --]

Expand Down Expand Up @@ -665,6 +666,64 @@
/]
[/#macro]

[#-- Stack Output --]
[#function default_output_stack level="" include=""]
[@setOutputProperties
properties={ "type:file" : { "format" : "json" }}
/]
[@initialiseJsonOutput name="stack_outputs" /]

[@processFlows
level=level
framework=DEFAULT_DEPLOYMENT_FRAMEWORK
flows=getCLOFlows()
/]

[#if getOutputContent("stack_outputs")?has_content ]

[@mergeWithJsonOutput
name="stack_outputs"
content={
"Account" : getActiveLayer(ACCOUNT_LAYER_TYPE).ProviderId,
"Region": getRegion(),
"DeploymentUnit": getCLODeploymentUnit()
}
/]

[#local stackOutputs = []]
[#list getOutputContent("stack_outputs") as k,v]
[#local stackOutputs += [ {"OutputKey": k, "OutputValue": v}]]
[/#list]

[#return
{
"Metadata" : {
"Id" : "state",
"Prepared" : .now?iso_utc,
"RunId" : getCLORunId(),
"RequestReference" : getCLORequestReference(),
"ConfigurationReference" : getCLOConfigurationReference()
},
"Stacks" : [
{
"Outputs": stackOutputs
}
]
}
]
[/#if]
[#return {}]
[/#function]


[#macro stackOutput key value ]
[@mergeWithJsonOutput
name="stack_outputs"
content={
key : value
}
/]
[/#macro]

[#-- Add Output Step mappings for each output --]
[@addGenerationContractStepOutputMapping
Expand Down Expand Up @@ -795,6 +854,14 @@
outputSuffix="state.json"
/]

[@addGenerationContractStepOutputMapping
provider=SHARED_PROVIDER
subset="stack"
outputType=STACK_OUTPUT_TYPE
outputFormat=""
outputSuffix="stack.json"
/]


[#------------------------------------------------------------
-- internal support functions for default output processing --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@

[#macro shared_extension_runbook_image_reference_output_runbook_setup occurrence ]

[#local image = (_context.Links["image"])!{}]
[#if ! image?has_content]
[#local imageLink = (_context.Links["image"])!{}]
[#if ! imageLink?has_content ]
[#return]
[/#if]
[#local image = imageLink.State.Images[_context.Inputs["input:ImageId"]] ]

[#assign _context = mergeObjects(
_context,
{
"TaskParameters" : {
"StackOutputContent" : getJSON(
{
image.State.Resources.image.Id: "__input:Reference__",
formatId(image.State.Resources.image.Id, NAME_ATTRIBUTE_TYPE): "__input:Tag__"
image.Id: "__input:Reference__",
formatId(image.Id, NAME_ATTRIBUTE_TYPE): "__input:Tag__"
}
),
"DeploymentUnit" : getOccurrenceDeploymentUnit(image),
"DeploymentGroup" : getOccurrenceDeploymentGroup(image)
"DeploymentUnit" : getOccurrenceDeploymentUnit(imageLink),
"DeploymentGroup" : getOccurrenceDeploymentGroup(imageLink)
}
}
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@

[#macro shared_extension_runbook_registry_object_filename_runbook_setup occurrence ]

[#local image = (_context.Links["image"])!{}]
[#if ! image?has_content]
[#local imageLink = (_context.Links["image"])!{}]
[#if ! imageLink?has_content ]
[#return]
[/#if]
[#local image = imageLink.State.Images[_context.Inputs["input:ImageId"]] ]

[#assign _context = mergeObjects(
_context,
{
"TaskParameters" : {
"DestinationPath" : {
"Value" : "__output:zip_stage_path:path__/" + (image.State.Resources["image"].ImageFileName)!""
"Value" : "__output:zip_stage_path:path__/" + (image.ImageFileName)!""
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@

[#macro shared_extension_runbook_registry_type_condition_runbook_setup occurrence ]

[#local image = (_context.Links["image"])!{}]
[#if ! image?has_content]
[#local imageLink = (_context.Links["image"])!{}]
[#if ! imageLink?has_content ]
[#return]
[/#if]
[#local image = imageLink.State.Images[_context.Inputs["input:ImageId"]] ]

[#assign _context = mergeObjects(
_context,
{
"Conditions" : {
"registry_type" : {
"Test" : (image.State.Resources["image"].RegistryType)!""
"Test" : image.RegistryType
}
}
}
Expand Down