Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- templates/cloud_router

GoogleCloudPlatform#47
  • Loading branch information
bohdanyurov-gl committed May 24, 2019
1 parent f523a5c commit 590e5ad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
16 changes: 10 additions & 6 deletions dm/templates/cloud_router/cloud_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
def generate_config(context):
""" Entry point for the deployment resources. """

name = context.properties.get('name', context.env['name'])
properties = context.properties
name = properties.get('name', context.env['name'])
project_id = properties.get('project', context.env['project'])

resources = [
{
'name': context.env['name'],
'type': 'compute.v1.router',
'type': 'gcp-types/compute-v1:routers',
'properties':
{
'name':
Expand All @@ -32,11 +34,13 @@ def generate_config(context):
},
'network':
generate_network_url(
context,
project_id,
context.properties['network']
),
'region':
context.properties['region']
context.properties['region'],
'project':
project_id
}
}
]
Expand Down Expand Up @@ -64,10 +68,10 @@ def generate_config(context):
}


def generate_network_url(context, network):
def generate_network_url(project_id, network):
"""Format the resource name as a resource URI."""

return 'projects/{}/global/networks/{}'.format(
context.env['project'],
project_id,
network
)
10 changes: 8 additions & 2 deletions dm/templates/cloud_router/cloud_router.py.schema
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
info:
title: Cloud Router
author: Sourced Group Inc.
version: 1.0.0
description: |
Deploys a Cloud Router.

Expand All @@ -34,10 +35,15 @@ required:
properties:
name:
type: string
description: The name of Cloud Router the resource.
description: The name of this Cloud Router. Resource name would be used if omitted.
project:
type: string
description: |
The project ID of the project containing the Cloud Router instance. The
Google apps domain is prefixed if applicable.
network:
type: string
description: The name of the network to which the Cloud Router belongs.
description: The name of the network to which the Cloud Router belongs (without project prefix).
region:
type: string
description: The URI of the region where the Cloud Router resides.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
network: asd
region: us-east1
asn: 65001
foo: bar
5 changes: 5 additions & 0 deletions dm/templates/cloud_router/tests/schemas/valid_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
network: asd
region: us-east1
asn: 65001
name: foo
project: foo

0 comments on commit 590e5ad

Please sign in to comment.