util

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 32 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupIfPresent

func BackupIfPresent(fs afero.Afero, basePath string, logger log.Logger, ui cli.Ui) error

func BailIfPresent

func BailIfPresent(fs afero.Afero, basePath string, logger log.Logger) error

BailIfPresent returns an error if the path is present. Handy to prevent accidentally blowing away directories on the workstation.

func ExcludeKubernetesResource added in v0.47.0

func ExcludeKubernetesResource(fs afero.Afero, basePath string, excludedResource string) error

exclude the provided kubernetes resource file from the kustomization.yaml at basePath, or from bases imported from that.

func ExcludeKubernetesResources added in v0.47.0

func ExcludeKubernetesResources(fs afero.Afero, basePath string, excludedResources []string) error

calls ExcludeKubernetesResource for each excluded resource. Returns after the first error.

func FindOnlySubdir

func FindOnlySubdir(dir string, fs afero.Afero) (string, error)

FindOnlySubdir finds the only subdirectory of a directory.

func GenerateNameFromMetadata added in v0.25.0

func GenerateNameFromMetadata(k8sYaml MinimalK8sYaml, idx int) string

func IsGithubURL

func IsGithubURL(url string) bool

returns true if this parses as a valid Github URL.

func IsK8sYaml added in v0.34.0

func IsK8sYaml(fs *afero.Afero, target string) bool

func IsLegalPath added in v0.34.0

func IsLegalPath(path string) error

IsLegalPath checks if the provided path is a relative path within the current working directory or within the os tempdir. If it is not, it returns an error.

func MaybeSplitMultidocYaml added in v0.28.0

func MaybeSplitMultidocYaml(ctx context.Context, fs afero.Afero, localPath string) error

this function is not perfect, and has known limitations. One of these is that it does not account for `\n---\n` in multiline strings.

func NewKubernetesResource added in v0.28.0

func NewKubernetesResource(in []byte) (*resource.Resource, error)

func RecursiveCopy added in v0.47.0

func RecursiveCopy(fs afero.Afero, sourceDir, destDir string) error

func RecursiveNormalizeCopyKustomize added in v0.47.0

func RecursiveNormalizeCopyKustomize(fs afero.Afero, sourceDir, destDir string) error

RecursiveNormalizeCopyKustomize copies kubernetes yaml from the source directory into the dest directory. `kustomization.yaml` files are skipped. if `kustomization.yaml` contains any bases, those bases are recursively copied into `destDir/<base-name>/`

func ShouldAddFileToBase added in v0.34.0

func ShouldAddFileToBase(fs *afero.Afero, excludedBases []string, targetPath string) bool

func SplitAllKustomize added in v0.47.0

func SplitAllKustomize(fs afero.Afero, path string) error

SplitAllKustomize ensures that all yaml files within the designated directory are split into one resource per file, excepting CRDs if a kustomization yaml existed beforehand, it rewrites the resource list to match the new filenames if not, it creates a kustomization yaml if an existing kustomization yaml referred to other bases, splitAll will be called on those bases as well

func ToGroupVersionKind added in v0.32.0

func ToGroupVersionKind(in gvk.Gvk) schema.GroupVersionKind

func WritePostKustomizeFiles added in v0.33.0

func WritePostKustomizeFiles(debug log.Logger, FS afero.Afero, dest string, postKustomizeFiles []PostKustomizeFile) error

Types

type AssetUploader added in v0.16.0

type AssetUploader interface {
	UploadAssets(target string) error
}

func NewAssetUploader added in v0.16.0

func NewAssetUploader(
	logger log.Logger,
	client *http.Client,
) AssetUploader

type CAType added in v0.26.0

type CAType struct {
	Cert string
	Key  string
}

func MakeCA added in v0.26.0

func MakeCA(caKind string) (CAType, error)

type CertType added in v0.26.0

type CertType struct {
	Cert string
	Key  string
}

func MakeCert added in v0.26.0

func MakeCert(host []string, certKind, CACert, CAKey string) (CertType, error)

type GithubURL

type GithubURL struct {
	Owner  string
	Repo   string
	Ref    string
	Subdir string
	IsBlob bool
}

func ParseGithubURL

func ParseGithubURL(url string, defaultRef string) (GithubURL, error)

func (GithubURL) URL added in v0.30.0

func (g GithubURL) URL() string

type ListK8sYaml added in v0.33.0

type ListK8sYaml struct {
	APIVersion string        `json:"apiVersion" yaml:"apiVersion"`
	Kind       string        `json:"kind" yaml:"kind" hcl:"kind"`
	Items      []interface{} `json:"items" yaml:"items"`
}

type MinimalK8sMetadata added in v0.26.0

type MinimalK8sMetadata struct {
	Name      string `json:"name" yaml:"name" hcl:"name"`
	Namespace string `json:"namespace" yaml:"namespace" hcl:"namespace"`
}

type MinimalK8sYaml added in v0.26.0

type MinimalK8sYaml struct {
	Kind     string             `json:"kind" yaml:"kind" hcl:"kind"`
	Metadata MinimalK8sMetadata `json:"metadata" yaml:"metadata" hcl:"metadata"`
}

type PostKustomizeFile added in v0.33.0

type PostKustomizeFile struct {
	Order   int
	Minimal MinimalK8sYaml
	Full    interface{}
}

type PostKustomizeFileCollection added in v0.33.0

type PostKustomizeFileCollection []PostKustomizeFile

func (PostKustomizeFileCollection) Len added in v0.33.0

func (PostKustomizeFileCollection) Less added in v0.33.0

func (c PostKustomizeFileCollection) Less(i, j int) bool

func (PostKustomizeFileCollection) Swap added in v0.33.0

func (c PostKustomizeFileCollection) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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