Last active
May 14, 2021 10:14
-
-
Save DazWilkin/80b54ff6c73412954b655d5fa0652e60 to your computer and use it in GitHub Desktop.
Cloud Deployment Manager & Kubernetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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