convert

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package helm provides utilities to aid in the conversion from a Helm chart into an Ansible Playbook Role.

Index

Constants

View Source
const HelmTemplatesDirectory = "templates"

Variables

This section is empty.

Functions

func ConvertControlFlowSyntax

func ConvertControlFlowSyntax(roleDirectory string)

Invokes a custom text/template implementation in order to convert possibly-nested Branch Nodes into the Ansible counterparts. For example, the following Golang template:

{{ if conditional }}
...
{{ end }}

Becomes:

{% if conditional %}
...
{% endif %}

func ConvertDefaultsToSnakeCase

func ConvertDefaultsToSnakeCase(chartClient *helm.HelmChartClient, roleDirectory string) *map[string]string

Convert keys in defaults/main.yaml to snake case, and return a list of the substitutions for use in templates later.

func CopyTemplates

func CopyTemplates(helmChartRootDirectory string, rolesDirectory string) string

Copies Helm Yaml templates to the appropriate Ansible Playbook roles template, post-fixing each YAML file with a ".j2" extension. The path to the ansible playbook templates directory is returned.

func CopyValuesToDefaults

func CopyValuesToDefaults(chartRoot string, roleDirectory string)

Copies the contents of a Helm templates values.yml or values.yaml to the corresponding Ansible Role's defaults/main.yaml.

func InstallAnsibleFilters

func InstallAnsibleFilters(roleDirectory string)

Installs some default Ansible Filters into the generated workspace to aid in the Sprig transition.

func InstallAnsibleTasks

func InstallAnsibleTasks(roleDirectory string)

Installs the Ansible Playbook Role task responsible for invoking the translated templates.

func RemoveValuesReferencesInDefaults

func RemoveValuesReferencesInDefaults(roleDirectory string)

Given an Ansible role directory, correct the defaults/main.yml file for ".Values." references. Although Helm allows self-reference, Ansible Playbook does not support this behavior. Thus, report to the user that the file will need manual inspection/editing after export, and put the appropriate hint in the exported Ansible Playbook.

func RemoveValuesReferencesInTemplates

func RemoveValuesReferencesInTemplates(roleDirectory string)

Remove references to to ".Values." in all templates by replacing with an empty string. Ansible Playbook can directly access defaults defined in defaults/main.yml.

func SuppressWhitespaceTrimmingInTemplates

func SuppressWhitespaceTrimmingInTemplates(roleDirectory string)

Removes Whitespace Trimming calls "{{-" and "-}}" and replaces them with "{{" and "}}" respectively for all templates in an Ansible Role. This is due to the fact that the Go text/template lexer is destructive, and ends up eating this white-space.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL