Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save udoyen/9faa34a4499df28f948d45441dd84655 to your computer and use it in GitHub Desktop.
Save udoyen/9faa34a4499df28f948d45441dd84655 to your computer and use it in GitHub Desktop.
Cloud Deployment Manager & Kubernetes
def GenerateConfig(context):
"""Generate YAML resource configuration."""
endpoints = {
'-v1': 'api/v1',
'-v1beta1-apps': 'apis/apps/v1beta1',
'-v1beta1-extensions': 'apis/extensions/v1beta1'
}
resources = []
outputs = []
for type_suffix, endpoint in endpoints.iteritems():
resources.append({
'name': 'kubernetes' + type_suffix,
'type': 'deploymentmanager.v2beta.typeProvider',
'properties': {
'options': {
'validationOptions': {
'schemaValidation': 'IGNORE_WITH_WARNINGS'
},
'inputMappings': [{
'fieldName': 'name',
'location': 'PATH',
'methodMatch': '^(GET|DELETE|PUT)$',
'value': '$.ifNull('
'$.resource.properties.metadata.name, '
'$.resource.name)'
}, {
'fieldName': 'metadata.name',
'location': 'BODY',
'methodMatch': '^(PUT|POST)$',
'value': '$.ifNull('
'$.resource.properties.metadata.name, '
'$.resource.name)'
}, {
'fieldName': 'Authorization',
'location': 'HEADER',
'value': '$.concat("Bearer ",'
'$.googleOauth2AccessToken())'
}]
},
'descriptorUrl':
''.join([
'https://' + context.properties['endpoint'] + '/swaggerapi/',
endpoint
])
}
})
return {'resources': resources}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment