Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Changing NodePool from Zone to Location (#182)
Browse files Browse the repository at this point in the history
<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
  • Loading branch information
modular-magician authored and rambleraptor committed Jan 31, 2019
1 parent 27e1dad commit 57afbc7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
5 changes: 4 additions & 1 deletion lib/ansible/modules/cloud/google/gcp_container_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@
description:
- The location where the cluster is deployed.
required: true
aliases:
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''

Expand Down Expand Up @@ -622,7 +625,7 @@ def main():
),
),
subnetwork=dict(type='str'),
location=dict(required=True, type='str'),
location=dict(required=True, type='str', aliases=['zone']),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
- The location where the cluster is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''

Expand Down Expand Up @@ -362,7 +364,7 @@


def main():
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['zone'])))
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone'])))

if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
Expand Down
26 changes: 15 additions & 11 deletions lib/ansible/modules/cloud/google/gcp_container_node_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,14 @@
Alternatively, you can add `register: name-of-resource` to a gcp_container_cluster
task and then set this cluster field to "{{ name-of-resource }}"'
required: true
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
extends_documentation_fragment: gcp
'''

Expand All @@ -219,7 +223,7 @@
gcp_container_cluster:
name: "cluster-nodepool"
initial_node_count: 4
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -231,7 +235,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
Expand Down Expand Up @@ -415,9 +419,9 @@
- The cluster this node pool belongs to.
returned: success
type: str
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
returned: success
type: str
'''
Expand Down Expand Up @@ -468,7 +472,7 @@ def main():
),
),
cluster=dict(required=True),
zone=dict(required=True, type='str'),
location=dict(required=True, type='str', aliases=['region', 'zone']),
)
)

Expand Down Expand Up @@ -542,16 +546,16 @@ def fetch_resource(module, link, allow_not_found=True):
def self_link(module):
res = {
'project': module.params['project'],
'zone': module.params['zone'],
'location': module.params['location'],
'cluster': replace_resource_dict(module.params['cluster'], 'name'),
'name': module.params['name'],
}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools/{name}".format(**res)
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools/{name}".format(**res)


def collection(module):
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools".format(**res)


def return_if_object(module, response, allow_not_found=False):
Expand Down
20 changes: 12 additions & 8 deletions lib/ansible/modules/cloud/google/gcp_container_node_pool_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
- requests >= 2.18.4
- google-auth >= 1.3.0
options:
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
required: true
aliases:
- region
- zone
version_added: 2.8
cluster:
description:
- The cluster this node pool belongs to.
Expand All @@ -59,7 +63,7 @@
- name: a node pool facts
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
Expand Down Expand Up @@ -248,9 +252,9 @@
- The cluster this node pool belongs to.
returned: success
type: str
zone:
location:
description:
- The zone where the node pool is deployed.
- The location where the node pool is deployed.
returned: success
type: str
'''
Expand All @@ -267,7 +271,7 @@


def main():
module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str'), cluster=dict(required=True)))
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True)))

if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
Expand All @@ -282,8 +286,8 @@ def main():


def collection(module):
res = {'project': module.params['project'], 'zone': module.params['zone'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools".format(**res)


def fetch_list(module, link):
Expand Down
18 changes: 9 additions & 9 deletions test/integration/targets/gcp_container_node_pool/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
gcp_container_cluster:
name: "cluster-nodepool"
initial_node_count: 4
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -28,7 +28,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -39,7 +39,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -52,7 +52,7 @@
- name: verify that node_pool was created
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -69,7 +69,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -85,7 +85,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -98,7 +98,7 @@
- name: verify that node_pool was deleted
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -115,7 +115,7 @@
name: my-pool
initial_node_count: 4
cluster: "{{ cluster }}"
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand All @@ -132,7 +132,7 @@
gcp_container_cluster:
name: "cluster-nodepool"
initial_node_count: 4
zone: us-central1-a
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
Expand Down

0 comments on commit 57afbc7

Please sign in to comment.