Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ tasks:
- create:
name: test-scaler
namespace: test
scale_target_ref_kind: ReplicaSet
scale_target_ref_name: test
min_replicas: 2
max_replicas: 5
spec_scale_target_ref_kind: ReplicaSet
spec_scale_target_ref_name: test
spec_min_replicas: 2
spec_max_replicas: 5
# target_cpu_utilization_percentage: 50
name: Create replica set
8 changes: 4 additions & 4 deletions openshift/ansiblegen/examples/k8s_v1_persistent_volume.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ admin: yes
tasks:
- create:
name: mypv
capacity:
spec_capacity:
storage: '1Gi'
access_modes:
spec_access_modes:
- ReadWriteOnce
persistent_volume_reclaim_policy: Recycle
host_path_path: /tmp/test_volume
spec_persistent_volume_reclaim_policy: Recycle
spec_host_path_path: /tmp/test_volume
name: Create persitent volume
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ tasks:
- create:
name: mypvc
namespace: demo_project
access_modes:
spec_access_modes:
- ReadWriteOnce
resources_requests:
spec_resources_requests:
storage: 1Gi
name: Create persitent volume claim
26 changes: 13 additions & 13 deletions openshift/ansiblegen/examples/k8s_v1_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@ tasks:
- create:
name: myservice
namespace: k8s-project
selector:
spec_selector:
app: django
ports:
spec_ports:
- port: 8765
target_port: 8000
name: http-port
type: ClusterIP
spec_type: ClusterIP
name: Create service

- patch:
name: myservice
namespace: k8s-project
selector:
spec_selector:
app: django
env: production
ports:
spec_ports:
- port: 8765
target_port: 8010
name: http-port
- port: 8788
target_port: 8080
name: socket-port
type: ClusterIP
spec_type: ClusterIP
name: Patch service

- create:
name: myservice01
namespace: k8s-project
selector:
spec_selector:
app_name: service_testing
app_env: production
ports:
spec_ports:
- port: 8888
target_port: 8010
name: http
type: ClusterIP
spec_type: ClusterIP
name: Create service

- patch:
name: myservice01
namespace: k8s-project
ports:
spec_ports:
- port: 9443
target_port: 9443
name: https
Expand All @@ -58,15 +58,15 @@ tasks:
- replace:
name: myservice01
namespace: k8s-project
selector:
spec_selector:
app_name: web_site
app_env: testing
ports:
spec_ports:
- port: 9999
target_port: 9999
name: https
- port: 8080
target_port: 8080
name: http
type: NodePort
spec_type: NodePort
name: Repace service
4 changes: 2 additions & 2 deletions openshift/ansiblegen/examples/k8s_v1beta1_replica_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ tasks:
- create:
name: myreplicaset
namespace: test
replicas: 3
spec_replicas: 3
# spec_selector_match_labels:
# name: myreplicaset
# spec_selector_match_expressions:
# - {key: name, operator: In, values: [myreplicaset]}
spec_template_metadata_labels:
name: myreplicaset
containers:
spec_template_spec_containers:
- name: myreplicaset
image: openshift/origin-ruby-sample:v1.0
name: Create replica set
8 changes: 4 additions & 4 deletions openshift/ansiblegen/examples/k8s_v1beta1_stateful_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ tasks:
labels:
name: test
namespace: test
service_name: test
replicas: 3
spec_service_name: test
spec_replicas: 3
spec_template_metadata_labels:
name: test
spec_template_metadata_name: test
termination_grace_period_seconds: 10
containers:
spec_template_spec_termination_grace_period_seconds: 10
spec_template_spec_containers:
- name: test
image: openshift/origin-ruby-sample:v1.0
name: Create stateful set
22 changes: 11 additions & 11 deletions openshift/ansiblegen/examples/openshift_v1_deployment_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ tasks:
namespace: k8s-project
spec_template_metadata_labels:
name: frontend
containers:
spec_template_spec_containers:
- name: helloworld
image: openshift/origin-ruby-sample
ports:
- container_port: 8080
protocol: TCP
name: http-port
replicas: 5
selector:
spec_replicas: 5
spec_selector:
name: frontend
triggers:
spec_triggers:
- type: ConfigChange
- type: ImageChange
image_change_params:
Expand All @@ -35,32 +35,32 @@ tasks:
namespace: k8s-project
spec_template_metadata_labels:
name: frontend
containers:
spec_template_spec_containers:
- name: helloworld
image: "openshift/origin-ruby-sample:v1.0"
ports:
- container_port: 9000
protocol: UDP
name: udp-port
replicas: 3
spec_replicas: 3
name: Patch deployment config

- replace:
name: frontend
namespace: k8s-project
spec_template_metadata_labels:
name: frontend_app
containers:
spec_template_spec_containers:
- name: helloworld
image: openshift/origin-ruby-sample:v2
ports:
- container_port: 8888
protocol: TCP
name: http-port
replicas: 2
selector:
spec_replicas: 2
spec_selector:
name: frontend_app
triggers:
spec_triggers:
- type: ConfigChange
- type: ImageChange
image_change_params:
Expand All @@ -70,7 +70,7 @@ tasks:
_from:
kind: ImageStreamTag
name: "origin-ruby-sample:v2"
strategy_type: Rolling
spec_strategy_type: Rolling
name: Replace deployment config

- remove:
Expand Down
20 changes: 10 additions & 10 deletions openshift/ansiblegen/examples/openshift_v1_route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ tasks:
- create:
name: myroute
namespace: k8s-project
host: www.example.com
spec_host: www.example.com
spec_to_kind: Service
spec_to_name: service-name
tls_termination: edge
tls_key: |-
spec_tls_termination: edge
spec_tls_key: |-
-----BEGIN PRIVATE KEY-----
key_file_contents
-----END PRIVATE KEY-----
tls_certificate: |-
spec_tls_certificate: |-
-----BEGIN CERTIFICATE-----
certificate contents
-----END CERTIFICATE-----
tls_ca_certificate: |-
spec_tls_ca_certificate: |-
-----BEGIN CERTIFICATE-----
ca_certificate_contents
-----END CERTIFICATE-----
Expand All @@ -29,20 +29,20 @@ tasks:
- patch:
name: myroute
namespace: k8s-project
host: www.example.com
tls_termination: reencrypt
spec_host: www.example.com
spec_tls_termination: reencrypt
spec_to_kind: Service
spec_to_name: other-service-name
name: Patch route

- replace:
name: myroute
namespace: k8s-project
host: www.example.com
path: /foo/bar/baz.html
spec_host: www.example.com
spec_path: /foo/bar/baz.html
spec_to_kind: Service
spec_to_name: whimsy-name
tls_termination: edge
spec_tls_termination: edge
name: Replace route

- remove:
Expand Down
4 changes: 0 additions & 4 deletions openshift/helper/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,6 @@ def add_meta(prop_name, prop_prefix, prop_alt_prefix):
if prop_alt_prefix != prop_prefix:
if prop_alt_prefix:
args[prop_prefix + prop_name]['aliases'] = [prop_alt_prefix + prop_name]
elif prop_prefix:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than removing these branches entirely, it might be better to just add a check that ensures it's not creating an alias that conflicts with a top level key.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may even just entail keeping a set of all names + aliases that have been used and checking that everything we're setting is unique.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this make sense. Will consider this option too

args[prop_prefix + prop_name]['aliases'] = [prop_name]
prop_paths = copy.copy(path) # copy path from outer scope
prop_paths.append('metadata')
prop_paths.append(prop_name)
Expand Down Expand Up @@ -705,8 +703,6 @@ def add_meta(prop_name, prop_prefix, prop_alt_prefix):
# Use the alternate prefix to construct a human-friendly alias
if arg_alt_prefix and arg_prefix != arg_alt_prefix:
args[arg_prefix + prop]['aliases'] = [arg_alt_prefix + prop]
elif arg_prefix:
args[arg_prefix + prop]['aliases'] = [prop]

if prop == 'type':
choices = self.__convert_params_to_choices(properties)
Expand Down