patches

package
v0.0.0-...-734a648 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright Contributors to the Open Cluster Management project The content of this file mainly comes from https://github.com/open-cluster-management-io/policy-generator-plugin/blob/main/internal/utils.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeInMemoryKustomizeDir

func InitializeInMemoryKustomizeDir(fSys filesys.FileSystem, schema string) (err error)

Initializes the in-memory file system with base directory and open API schema

func KustomizeManifest

func KustomizeManifest(fSys filesys.FileSystem, kustomizationYAMLFile *KustomizeJSON) (manifests []map[string]interface{}, err error)

Runs Kustomize to apply patches in the in-memory file system

func UnmarshalManifestFile

func UnmarshalManifestFile(manifestPath string) ([]map[string]interface{}, error)

unmarshalManifestFile unmarshals the input object manifest/definition file into a slice in order to account for multiple YAML documents in the same file. If the file cannot be decoded or each document is not a map, an error will be returned.

func VerifyManifestPath

func VerifyManifestPath(baseDirectory, manifestPath string) error

verifyManifestPath verifies that the manifest path is in the directory tree under baseDirectory. An error is returned if it is not or the paths couldn't be properly resolved.

Types

type KustomizeJSON

type KustomizeJSON struct {
	Openapi   `yaml:"openapi"`
	Patches   []Patch  `yaml:"patches"`
	Resources []string `yaml:"resources"`
}

type ManifestPatcher

type ManifestPatcher struct {
	// The manifests to patch.
	Manifests []map[string]interface{}
	// The Kustomize patches to apply on the manifests. Note that modifications are made
	// to the input maps. If this is an issue, provide a deep copy of the patches.
	Patches []map[string]interface{}
}

func (*ManifestPatcher) ApplyPatches

func (m *ManifestPatcher) ApplyPatches(schema string) ([]map[string]interface{}, error)

ApplyPatches applies the Kustomize patches on the input manifests using Kustomize and returns the patched manifests. An error is returned if the patches can't be applied. This should be run after the Validate method.

func (*ManifestPatcher) Validate

func (m *ManifestPatcher) Validate() error

Validate performs basic validatation of the manifests and patches. Any missing values in the patches that can be derived are added to the patches. An error is returned if a manifest or patch is invalid.

type Openapi

type Openapi struct {
	Path string `yaml:"path"`
}

type Patch

type Patch struct {
	Path string `yaml:"path"`
}

type Resources

type Resources []string

Jump to

Keyboard shortcuts

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