arillso.container.fleet_transform_targets filter – Transform Fleet targets from snake_case to camelCase

Note

This filter plugin is part of the arillso.container collection (version 1.0.2).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install arillso.container.

To use it in a playbook, specify: arillso.container.fleet_transform_targets.

New in arillso.container 1.0.0

Synopsis

  • Converts Fleet target configurations from Ansible’s snake_case convention to Fleet API’s camelCase format.

  • Recursively transforms all nested dictionary keys.

  • Handles complex structures including cluster_selector, match_labels, match_expressions, etc.

  • Preserves all values and structure while only changing key names.

Aliases: to_camel_case

Input

This describes the input of the filter, the value before | arillso.container.fleet_transform_targets.

Parameter

Comments

Input

list / elements=dictionary / required

List of target dictionaries with snake_case keys.

Typically contains cluster_selector, cluster_name, cluster_group, etc.

Notes

Note

  • This filter is specifically designed for Fleet GitOps target configurations.

  • Common transformations include cluster_selector -> clusterSelector, match_labels -> matchLabels.

Examples

# Transform Fleet targets in a GitRepo configuration
- name: Apply GitRepo with transformed targets
  kubernetes.core.k8s:
      definition:
          apiVersion: fleet.cattle.io/v1alpha1
          kind: GitRepo
          spec:
              targets: "{{ my_targets | arillso.container.fleet_transform_targets }}"
  vars:
      my_targets:
          - cluster_selector:
                match_labels:
                    environment: production
                    region: us-west

# Result will transform to:
#   targets:
#       - clusterSelector:
#             matchLabels:
#                 environment: production
#                 region: us-west

# Multiple targets with different selectors
- name: Configure multi-cluster deployment
  set_fact:
      transformed_targets: "{{ fleet_targets | arillso.container.fleet_transform_targets }}"
  vars:
      fleet_targets:
          - cluster_selector:
                match_labels:
                    tier: frontend
          - cluster_name: production-cluster
          - cluster_group: staging-group

Return Value

Key

Description

Return value

list / elements=dictionary

List of target dictionaries with camelCase keys suitable for Fleet API.

Returned: always

Authors

  • arillso