config

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Overview

Package config contains logic for parsing config.

Index

Constants

View Source
const (
	SecretK8sCorev1BasicAuthUsernameKey = "username"
	SecretK8sCorev1BasicAuthPasswordKey = "password"

	SecretK8sCoreV1SSHAuthPrivateKey = "ssh-privatekey"
	SecretSSHAuthKnownHosts          = "ssh-knownhosts" // not part of k8s

	SecretRegistryHostnameKey   = "hostname"
	SecretRegistryBearerToken   = "token"
	SecretRegistryIdentityToken = "identity-token"

	SecretGithubAPIToken = "token"
)
View Source
const (
	EntireDirPath = "."
)

Variables

View Source
var (
	DefaultLegalPaths = []string{
		"{LICENSE,LICENCE,License,Licence}{,.md,.txt,.rst}",
		"{COPYRIGHT,Copyright}{,.md,.txt,.rst}",
		"{NOTICE,Notice}{,.md,.txt,.rst}",
	}
)

Functions

func NewConfigFromFiles added in v0.37.0

func NewConfigFromFiles(paths []string) (Config, []Secret, []ConfigMap, error)

Types

type Config

type Config struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`

	MinimumRequiredVersion string `json:"minimumRequiredVersion"`

	Directories []Directory `json:"directories,omitempty"`
}

func NewConfigFromBytes

func NewConfigFromBytes(bs []byte) (Config, error)

func (Config) AsBytes added in v0.37.0

func (c Config) AsBytes() ([]byte, error)

func (Config) Lock added in v0.37.0

func (c Config) Lock(lockConfig LockConfig) error

func (Config) Subset added in v0.37.0

func (c Config) Subset(paths []string) (Config, error)

func (Config) UseDirectory added in v0.37.0

func (c Config) UseDirectory(path, dirPath string) error

func (Config) Validate

func (c Config) Validate() error

type ConfigMap added in v0.37.0

type ConfigMap struct {
	APIVersion string
	Kind       string

	Metadata GenericMetadata
	Data     map[string]string
}

type Directory added in v0.37.0

type Directory struct {
	Path     string              `json:"path"`
	Contents []DirectoryContents `json:"contents,omitempty"`

	Permissions *os.FileMode `json:"permissions,omitempty"`
}

func (Directory) Validate added in v0.37.0

func (c Directory) Validate() error

type DirectoryContents added in v0.37.0

type DirectoryContents struct {
	Path string `json:"path"`
	Lazy bool   `json:"lazy,omitempty"`

	Git           *DirectoryContentsGit           `json:"git,omitempty"`
	Hg            *DirectoryContentsHg            `json:"hg,omitempty"`
	HTTP          *DirectoryContentsHTTP          `json:"http,omitempty"`
	Image         *DirectoryContentsImage         `json:"image,omitempty"`
	ImgpkgBundle  *DirectoryContentsImgpkgBundle  `json:"imgpkgBundle,omitempty"`
	GithubRelease *DirectoryContentsGithubRelease `json:"githubRelease,omitempty"`
	HelmChart     *DirectoryContentsHelmChart     `json:"helmChart,omitempty"`
	Manual        *DirectoryContentsManual        `json:"manual,omitempty"`
	Directory     *DirectoryContentsDirectory     `json:"directory,omitempty"`
	Inline        *DirectoryContentsInline        `json:"inline,omitempty"`

	IncludePaths []string `json:"includePaths,omitempty"`
	ExcludePaths []string `json:"excludePaths,omitempty"`
	IgnorePaths  []string `json:"ignorePaths,omitempty"`

	// By default LICENSE/LICENCE/NOTICE/COPYRIGHT files are kept
	LegalPaths *[]string `json:"legalPaths,omitempty"`

	NewRootPath string `json:"newRootPath,omitempty"`

	Permissions *os.FileMode `json:"permissions,omitempty"`
}

func (DirectoryContents) IsEntireDir added in v0.37.0

func (c DirectoryContents) IsEntireDir() bool

func (DirectoryContents) LegalPathsWithDefaults added in v0.37.0

func (c DirectoryContents) LegalPathsWithDefaults() []string

func (DirectoryContents) Lock added in v0.37.0

func (c DirectoryContents) Lock(lockConfig LockDirectoryContents) error

func (DirectoryContents) Validate added in v0.37.0

func (c DirectoryContents) Validate() error

type DirectoryContentsDirectory added in v0.37.0

type DirectoryContentsDirectory struct {
	Path string `json:"path"`
}

type DirectoryContentsGit added in v0.37.0

type DirectoryContentsGit struct {
	URL          string                            `json:"url,omitempty"`
	Ref          string                            `json:"ref,omitempty"`
	RefSelection *ctlver.VersionSelection          `json:"refSelection,omitempty"`
	Verification *DirectoryContentsGitVerification `json:"verification,omitempty"`
	// Secret may include one or more keys: ssh-privatekey, ssh-knownhosts
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`
	// +optional
	LFSSkipSmudge          bool `json:"lfsSkipSmudge,omitempty"`
	DangerousSkipTLSVerify bool `json:"dangerousSkipTLSVerify,omitempty"`
	SkipInitSubmodules     bool `json:"skipInitSubmodules,omitempty"`
	Depth                  int  `json:"depth,omitempty"`
	ForceHTTPBasicAuth     bool `json:"forceHTTPBasicAuth,omitempty"`
}

func (*DirectoryContentsGit) Lock added in v0.37.0

type DirectoryContentsGitVerification added in v0.37.0

type DirectoryContentsGitVerification struct {
	PublicKeysSecretRef *DirectoryContentsLocalRef `json:"publicKeysSecretRef,omitempty"`
}

type DirectoryContentsGithubRelease added in v0.37.0

type DirectoryContentsGithubRelease struct {
	Slug         string                   `json:"slug"` // e.g. organization/repository
	Tag          string                   `json:"tag"`
	TagSelection *ctlver.VersionSelection `json:"tagSelection,omitempty"`
	Latest       bool                     `json:"latest,omitempty"`
	URL          string                   `json:"url,omitempty"`

	Checksums                     map[string]string `json:"checksums,omitempty"`
	DisableAutoChecksumValidation bool              `json:"disableAutoChecksumValidation,omitempty"`

	AssetNames    []string                        `json:"assetNames,omitempty"`
	UnpackArchive *DirectoryContentsUnpackArchive `json:"unpackArchive,omitempty"`

	// Secret may include one key: token
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`

	// +optional
	HTTP *DirectoryContentsHTTP `json:"http,omitempty"`
}

func (*DirectoryContentsGithubRelease) Lock added in v0.37.0

type DirectoryContentsHTTP added in v0.37.0

type DirectoryContentsHTTP struct {
	// URL can point to one of following formats: text, tgz, zip
	URL string `json:"url,omitempty"`
	// +optional
	SHA256 string `json:"sha256,omitempty"`
	// Secret may include one or more keys: username, password
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`
	// +optional
	DisableUnpack bool `json:"disableUnpack,omitempty"`
}

func (*DirectoryContentsHTTP) Lock added in v0.37.0

type DirectoryContentsHelmChart added in v0.37.0

type DirectoryContentsHelmChart struct {
	// Example: stable/redis
	Name string `json:"name,omitempty"`
	// +optional
	Version    string                          `json:"version,omitempty"`
	Repository *DirectoryContentsHelmChartRepo `json:"repository,omitempty"`

	// +optional
	HelmVersion string `json:"helmVersion,omitempty"`
}

func (*DirectoryContentsHelmChart) Lock added in v0.37.0

type DirectoryContentsHelmChartRepo added in v0.37.0

type DirectoryContentsHelmChartRepo struct {
	URL string `json:"url,omitempty"`
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`
}

type DirectoryContentsHg added in v0.37.0

type DirectoryContentsHg struct {
	URL    string `json:"url,omitempty"`
	Ref    string `json:"ref,omitempty"`
	Evolve bool   `json:"evolve,omitempty"`
	// Secret may include one or more keys: ssh-privatekey, ssh-knownhosts
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`
}

func (*DirectoryContentsHg) Lock added in v0.37.0

func (c *DirectoryContentsHg) Lock(lockConfig *LockDirectoryContentsHg) error

type DirectoryContentsHgVerification added in v0.37.0

type DirectoryContentsHgVerification struct {
	PublicKeysSecretRef *DirectoryContentsLocalRef `json:"publicKeysSecretRef,omitempty"`
}

type DirectoryContentsImage added in v0.37.0

type DirectoryContentsImage struct {
	// Example: username/app1-config:v0.1.0
	URL string `json:"url,omitempty"`

	TagSelection *ctlver.VersionSelection `json:"tagSelection,omitempty"`

	// Secret may include one or more keys: username, password, token.
	// By default anonymous access is used for authentication.
	// TODO support docker config formatted secret
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`

	ResponseHeaderTimeout  int  `json:"responseHeaderTimeout,omitempty"`
	DangerousSkipTLSVerify bool `json:"dangerousSkipTLSVerify,omitempty"`
	// contains filtered or unexported fields
}

func (*DirectoryContentsImage) Lock added in v0.37.0

func (DirectoryContentsImage) PreresolvedTag added in v0.37.0

func (c DirectoryContentsImage) PreresolvedTag() string

type DirectoryContentsImgpkgBundle added in v0.37.0

type DirectoryContentsImgpkgBundle struct {
	// Example: username/app1-config:v0.1.0
	Image string `json:"image,omitempty"`

	TagSelection *ctlver.VersionSelection `json:"tagSelection,omitempty"`

	// Secret may include one or more keys: username, password, token.
	// By default anonymous access is used for authentication.
	// TODO support docker config formatted secret
	// +optional
	SecretRef *DirectoryContentsLocalRef `json:"secretRef,omitempty"`

	ResponseHeaderTimeout  int  `json:"responseHeaderTimeout,omitempty"`
	DangerousSkipTLSVerify bool `json:"dangerousSkipTLSVerify,omitempty"`
	Recursive              bool `json:"recursive,omitempty"`
	// contains filtered or unexported fields
}

func (*DirectoryContentsImgpkgBundle) Lock added in v0.37.0

func (DirectoryContentsImgpkgBundle) PreresolvedTag added in v0.37.0

func (c DirectoryContentsImgpkgBundle) PreresolvedTag() string

type DirectoryContentsInline added in v0.37.0

type DirectoryContentsInline struct {
	Paths     map[string]string               `json:"paths,omitempty"`
	PathsFrom []DirectoryContentsInlineSource `json:"pathsFrom,omitempty"`
}

type DirectoryContentsInlineSource added in v0.37.0

type DirectoryContentsInlineSource struct {
	SecretRef    *DirectoryContentsInlineSourceRef `json:"secretRef,omitempty"`
	ConfigMapRef *DirectoryContentsInlineSourceRef `json:"configMapRef,omitempty"`
}

type DirectoryContentsInlineSourceRef added in v0.37.0

type DirectoryContentsInlineSourceRef struct {
	DirectoryPath             string `json:"directoryPath,omitempty"`
	DirectoryContentsLocalRef `json:",inline"`
}

type DirectoryContentsLocalRef added in v0.37.0

type DirectoryContentsLocalRef struct {
	Name string `json:"name,omitempty"`
}

type DirectoryContentsManual added in v0.37.0

type DirectoryContentsManual struct{}

type DirectoryContentsUnpackArchive added in v0.37.0

type DirectoryContentsUnpackArchive struct {
	Path string `json:"path"`
}

type GenericMetadata added in v0.37.0

type GenericMetadata struct {
	Name string
}

type LockConfig

type LockConfig struct {
	APIVersion  string          `json:"apiVersion"`
	Kind        string          `json:"kind"`
	Directories []LockDirectory `json:"directories"`
}

LockConfig outputs a vendir.lock with shas for reproducible vendir-ing.

func NewLockConfig

func NewLockConfig() LockConfig

func NewLockConfigFromBytes added in v0.37.0

func NewLockConfigFromBytes(bs []byte) (LockConfig, error)

func NewLockConfigFromFile added in v0.37.0

func NewLockConfigFromFile(path string) (LockConfig, error)

func (*LockConfig) AppendContents added in v0.38.0

func (c *LockConfig) AppendContents(path string, appendCon LockDirectoryContents) bool

func (LockConfig) AsBytes added in v0.3.0

func (c LockConfig) AsBytes() ([]byte, error)

func (LockConfig) FindContents added in v0.37.0

func (c LockConfig) FindContents(dirPath, conPath string) (LockDirectoryContents, error)

func (LockConfig) FindDirectory added in v0.37.0

func (c LockConfig) FindDirectory(dirPath string) (LockDirectory, error)

func (*LockConfig) Merge added in v0.37.0

func (c *LockConfig) Merge(other LockConfig) error

func (*LockConfig) ReplaceContents added in v0.38.0

func (c *LockConfig) ReplaceContents(path string, replaceCon LockDirectoryContents) bool

func (LockConfig) Validate added in v0.37.0

func (c LockConfig) Validate() error

func (LockConfig) WriteToFile

func (c LockConfig) WriteToFile(path string) error

type LockDirectory added in v0.37.0

type LockDirectory struct {
	Path     string                  `json:"path"`
	Contents []LockDirectoryContents `json:"contents"`
}

func (LockDirectory) FindContents added in v0.37.0

func (d LockDirectory) FindContents(conPath string) (LockDirectoryContents, error)

type LockDirectoryContents added in v0.37.0

type LockDirectoryContents struct {
	Path         string `json:"path"`
	ConfigDigest string `json:"configDigest,omitempty"`

	Git           *LockDirectoryContentsGit           `json:"git,omitempty"`
	Hg            *LockDirectoryContentsHg            `json:"hg,omitempty"`
	HTTP          *LockDirectoryContentsHTTP          `json:"http,omitempty"`
	Image         *LockDirectoryContentsImage         `json:"image,omitempty"`
	ImgpkgBundle  *LockDirectoryContentsImgpkgBundle  `json:"imgpkgBundle,omitempty"`
	GithubRelease *LockDirectoryContentsGithubRelease `json:"githubRelease,omitempty"`
	HelmChart     *LockDirectoryContentsHelmChart     `json:"helmChart,omitempty"`
	Manual        *LockDirectoryContentsManual        `json:"manual,omitempty"`
	Directory     *LockDirectoryContentsDirectory     `json:"directory,omitempty"`
	Inline        *LockDirectoryContentsInline        `json:"inline,omitempty"`
}

type LockDirectoryContentsDirectory added in v0.37.0

type LockDirectoryContentsDirectory struct{}

type LockDirectoryContentsGit added in v0.37.0

type LockDirectoryContentsGit struct {
	SHA         string   `json:"sha"`
	Tags        []string `json:"tags,omitempty"`
	CommitTitle string   `json:"commitTitle"`
}

type LockDirectoryContentsGithubRelease added in v0.37.0

type LockDirectoryContentsGithubRelease struct {
	URL string `json:"url"`
	Tag string `json:"tag,omitempty"`
}

type LockDirectoryContentsHTTP added in v0.37.0

type LockDirectoryContentsHTTP struct{}

type LockDirectoryContentsHelmChart added in v0.37.0

type LockDirectoryContentsHelmChart struct {
	Version    string `json:"version"`
	AppVersion string `json:"appVersion"`
}

type LockDirectoryContentsHg added in v0.37.0

type LockDirectoryContentsHg struct {
	SHA            string   `json:"sha"`
	Tags           []string `json:"tags,omitempty"`
	ChangeSetTitle string   `json:"changeSetTitle"`
}

type LockDirectoryContentsImage added in v0.37.0

type LockDirectoryContentsImage struct {
	URL string `json:"url"`
	Tag string `json:"tag,omitempty"`
}

type LockDirectoryContentsImgpkgBundle added in v0.37.0

type LockDirectoryContentsImgpkgBundle struct {
	Image string `json:"image"`
	Tag   string `json:"tag,omitempty"`
}

type LockDirectoryContentsInline added in v0.37.0

type LockDirectoryContentsInline struct{}

type LockDirectoryContentsManual added in v0.37.0

type LockDirectoryContentsManual struct{}

type Secret added in v0.37.0

type Secret struct {
	APIVersion string
	Kind       string

	Metadata GenericMetadata
	Type     string
	Data     map[string][]byte
}

func (Secret) ToRegistryAuthSecrets added in v0.37.0

func (s Secret) ToRegistryAuthSecrets() ([]Secret, error)

ToRegistryAuthSecrets splits secret into multiple secrets if secret of type dockerconfigjson; otherwise returns same secret.

Jump to

Keyboard shortcuts

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