yamlmerge

command module
v0.0.0-...-53c3e3c Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 10 Imported by: 0

README

YAMLMerge

Takes an arbitrary number of yaml files, extracts $path from each, and merges these into a template at a new $path

Configuration

Create a new file config.yaml with the following:

  • template String. The template to merge keys into
  • crds List. The yaml files you wish to extract from

The structure for crds is an object as such:

  • mergeAt The yaml path in the template you wish to merge to
  • mergeFrom The yaml path in the remote file you need to extract
  • fileUrl The URL to the remote file
  • version The version to load

Example:

template: ./xrd/definition.yaml
crds:
  - mergeAt: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.aws.properties.cluster.properties
    mergeFrom: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.atProvider.properties
    fileUrl: "https://raw.githubusercontent.com/upbound/provider-aws/{{ .Version }}/package/crds/eks.aws.upbound.io_clusters.yaml"
    version: v0.43.0
  - mergeAt: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.aws.properties.vpc.properties
    mergeFrom: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.atProvider.properties
    fileUrl: "https://raw.githubusercontent.com/upbound/provider-aws/{{ .Version }}/package/crds/ec2.aws.upbound.io_vpcs.yaml"
    version: v0.43.0
  - mergeAt: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.azure.properties.cluster.properties
    mergeFrom: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.atProvider.properties
    fileUrl: "https://raw.githubusercontent.com/upbound/provider-azure/{{ .Version }}/package/crds/containerservice.azure.upbound.io_kubernetesclusters.yaml"
    version: v0.38.0
  - mergeAt: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.gcp.properties.cluster.properties
    mergeFrom: .spec.versions[0].schema.openAPIV3Schema.properties.status.properties.atProvider.properties
    fileUrl: "https://raw.githubusercontent.com/upbound/provider-gcp//{{ .Version }}/package/crds/container.gcp.upbound.io_clusters.yaml"
    version: v0.38.0

Results in the structure:

status:
  type: object
  properties:
    azure:
      type: object
      properties:
        cluster:
        type: object
        properties:
            ...
    aws:
      type: object
      properties:
        cluster:
        type: object
        properties:
            ...
        vpc:
        type: object
        properties:
            ...
    gcp:
      type: object
      properties:
        cluster:
        type: object
        properties:
            ...

TODO: recursive merge

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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