Skip to content

Instantly share code, notes, and snippets.

@mpvvliet
Created June 25, 2020 07:02
Show Gist options
  • Select an option

  • Save mpvvliet/b6382578581ea76e02af3d97fb4a081d to your computer and use it in GitHub Desktop.

Select an option

Save mpvvliet/b6382578581ea76e02af3d97fb4a081d to your computer and use it in GitHub Desktop.
{
"_version": "1.0.0",
"timestamp": "2019-01-08T17:37:25.846Z[Etc/UTC]",
"nodes": [{
"_type": "ComponentTemplateFunction",
"name": "autosync-component-template",
"handlebarsTemplate": "{\n \"_type\": \"Component\",\n \"checks\": [],\n \"streams\": [],\n \"labels\": \{{#if element.data.labels\}}[\n \{{# join element.data.labels \",\" \}}\n {\n \"_type\": \"Label\",\n \"name\": \"\{{ this \}}\"\n }\n \{{/ join \}}\n ]\{{else\}}[]\{{/if\}},\n \"name\": \"\{{#if element.data.name\}}\{{ element.data.name \}}\{{else\}}\{{ element.externalId \}}\{{/if\}}\",\n\{{#if element.data.description\}}\"description\": \"\{{ element.data.description \}}\",\{{/if\}}\n \"type\" : \{{ getOrCreate \"ComponentType\" element.type.name \"Auto-synced Component\" \}},\n \"version\": \"\{{ element.data.version \}}\",\n \"layer\": \{{ getOrCreate \"Layer\" element.data.layer \"Auto-synced Components\" \}},\n \"domain\": \{{ getOrCreate \"Domain\" element.data.domain \"Auto-synced Domain\" \}},\n \"environments\": [\n \{{ getOrCreate \"Environment\" element.data.environment \"Auto-synced Environment\" \}}\n ]\n}\n",
"parameters": [{
"_type": "Parameter",
"name": "element",
"system": false,
"multiple": false,
"type": "STRUCT_TYPE",
"required": true
}]
},
{
"_type": "RelationTemplateFunction",
"name": "autosync-relation-template",
"handlebarsTemplate": "{\n \"_type\": \"Relation\",\n \"checks\": [],\n \"streams\": [],\n \"labels\": [],\n \"name\": \"\{{ element.sourceExternalId \}} --> \{{ element.targetExternalId \}}\",\n\{{#if element.data.description\}}\"description\": \"\{{ element.data.description \}}\",\{{/if\}}\n \"type\": \{{ getOrCreate \"RelationType\" element.type.name \"Auto-synced Relation\" \}},\n \"dependencyDirection\": \"ONE_WAY\",\n \"source\": \{{ element.sourceId \}},\n \"target\": \{{ element.targetId \}}\n}\n",
"parameters": [{
"_type": "Parameter",
"name": "element",
"system": false,
"multiple": false,
"type": "STRUCT_TYPE",
"required": true
}]
},
{
"_type": "IdExtractorFunction",
"name": "Auto sync component id extractor",
"description": "A generic component id extractor function for topology elements.",
"groovyScript": "element = topologyElement\n\nexternalId = element[\"externalId\"]\ntype = element[\"typeName\"].toLowerCase()\ndata = element[\"data\"]\n\nidentifiers = new HashSet()\n\nif(data.containsKey(\"identifiers\") && data[\"identifiers\"] instanceof List<String>) {\n data[\"identifiers\"].each{ id ->\n identifiers.add(id)\n }\n}\n\nreturn Sts.createId(externalId, identifiers, type)\n",
"parameters": [{
"_type": "Parameter",
"name": "topologyElement",
"system": true,
"multiple": false,
"type": "STRUCT_TYPE",
"required": true
}]
}, {
"_type": "IdExtractorFunction",
"name": "Auto sync relation id extractor",
"description": "A generic relation id extractor function for topology elements.",
"groovyScript": "element = topologyElement\n\nexternalId = element[\"externalId\"]\ntype = element[\"typeName\"].toLowerCase()\n\nreturn Sts.createId(externalId, new HashSet(), type)\n",
"parameters": [{
"_type": "Parameter",
"name": "topologyElement",
"system": true,
"multiple": false,
"type": "STRUCT_TYPE",
"required": true
}]
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment