Documentation
¶
Index ¶
- Constants
- Variables
- func IsValid(c *HydrosConfig) (string, bool)
- type ConfigSpec
- type EcrPolicySync
- type EcrPolicySyncSpec
- type Function
- type GitHubRepo
- type HydrosConfig
- type ImageBuilder
- type ImageList
- type ImageRepoMatch
- type ImageTagToPin
- type InPlaceConfig
- type LabelSelector
- type LabelSelectorOperator
- type LabelSelectorRequirement
- type ManifestSync
- type ManifestSyncSpec
- type ManifestSyncStatus
- type Metadata
- type NonTerminalError
- type PinnedImage
- type RepoMatchType
- type S3AssetsList
- type S3NonTerminalError
- type Strategy
- type TerminalError
Constants ¶
const ( // TermErr classified as an error that needs to stop the program TermErr TerminalError = "Hit Terminal Error: " // NonTermErr classified as an error that we can ignore NonTermErr NonTerminalError = "Hit Non Terminal Error: " )
const ( // ManifestSyncKind is the kind for ManifestSync resources. ManifestSyncKind = "ManifestSync" // SourceCommitStrategy indicates the source image should have a tag // equal to the source commit tag. SourceCommitStrategy Strategy = "sourceCommit" // MutableTagStrategy means you should pin to whatever image has that commit. MutableTagStrategy Strategy = "mutableTag" // UnknownStrategy indicates unknown tag matching strategy. UnknownStrategy Strategy = "unknown" // LatestTagPrefix means you should look for the most recent image // which has that tag as a prefix. LatestTagPrefix Strategy = "latestTagPrefix" // IncludeRepo is the enum value indicating a repo list is an include list. IncludeRepo RepoMatchType = "include" // ExcludeRepo is the enum value indicating a repo list is an exclude list. ExcludeRepo RepoMatchType = "exclude" )
const ( // Group for MLP tasks. // TODO(jeremy): we should change this Group = "mlp.primer.ai" // Version for tasks. Version = "v1alpha1" )
const (
// EcrPolicySyncKind is the kind for EcrPolicySync resources.
EcrPolicySyncKind = "EcrPolicySync"
)
Variables ¶
var EcrPolicySyncGVK = schema.GroupVersionKind{ Group: Group, Version: Version, Kind: EcrPolicySyncKind, }
EcrPolicySyncGVK is the GVK for EcrPolicySync.
Functions ¶
func IsValid ¶
func IsValid(c *HydrosConfig) (string, bool)
IsValid returns true if the config is valid. For invalid config the string will be a message of validation errors
Types ¶
type ConfigSpec ¶
type ConfigSpec struct {
// InPlaceConfigs configure hydrations that are done in-place. This means the hydrated configurations
// are checked back into the repository
InPlaceConfigs []InPlaceConfig `yaml:"inPlaceConfigs"`
}
type EcrPolicySync ¶
type EcrPolicySync struct {
APIVersion string `yaml:"apiVersion" yamltags:"required"`
Kind string `yaml:"kind" yamltags:"required"`
Metadata Metadata `yaml:"metadata,omitempty"`
Spec EcrPolicySyncSpec `yaml:"spec,omitempty"`
}
EcrPolicySync continually ensures a set of ECR repos exists and has the specified policy
type EcrPolicySyncSpec ¶
type EcrPolicySyncSpec struct {
// Policy is the JSON representation of the policy to apply
Policy string `yaml:"policy,omitempty"`
// ImageRegistry is the registry in which to apply it.
ImageRegistry string `yaml:"imageRegistry,omitempty"`
// ImageRepos is a list of repos to apply the changes to.
ImageRepos []string `yaml:"imageRepos,omitempty"`
}
EcrPolicySyncSpec spec for the resource to sync ECR policies.
type Function ¶
type Function struct {
// RepoKey can be source or dest and indicates whether the functions are sourced from the source
// or dest repo.
RepoKey string `yaml:"repoKey,omitempty"`
// Paths is the path to the YAML files or directories to apply.
Paths []string `yaml:"paths,omitempty"`
}
Function is a list of functions to apply
type GitHubRepo ¶
type GitHubRepo struct {
// Org that owns the repo.
Org string `yaml:"org,omitempty"`
Repo string `yaml:"repo,omitempty"`
Branch string `yaml:"branch,omitempty"`
}
GitHubRepo represents a GitHub repo.
func (*GitHubRepo) IsValid ¶
func (r *GitHubRepo) IsValid() error
IsValid checks if this is a valid resource.
type HydrosConfig ¶
type HydrosConfig struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata Metadata `yaml:"metadata"`
Spec ConfigSpec `yaml:"spec"`
}
HydrosConfig is hydros GitHub App configuration. This is the configuration that should be checked into a repository to configure hydros on that repository
type ImageBuilder ¶
type ImageBuilder struct {
// Enabled is a boolean indicating whether the image builder is enabled or not
Enabled bool `yaml:"enabled,omitempty"`
// Registry is the registry to use with the images.
Registry string `yaml:"registry,omitempty"`
}
ImageBuilder configures the image builder.
type ImageList ¶
type ImageList struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata Metadata `yaml:"metadata,omitempty"`
Images []string `yaml:"images,omitempty"`
}
ImageList is a list of images
type ImageRepoMatch ¶
type ImageRepoMatch struct {
Repos []string `yaml:"repos,omitempty"`
// RepoMatchType indicates whether this is an include or exclude list.
Type RepoMatchType `yaml:"type,omitempty"`
}
ImageRepoMatch describes how to match repos.
type ImageTagToPin ¶
type ImageTagToPin struct {
// Tags of the images to look for to pin.
Tags []string `yaml:"tags,omitempty"`
// Strategy is an enum indicating how the image should be pinned.
Strategy Strategy `yaml:"strategy,omitempty"`
// ImageRepoMatch describes the image repos to match
// If nil all repos are matched.
ImageRepoMatch *ImageRepoMatch `yaml:"imageRepoMatch,omitempty"`
}
ImageTagToPin describes an image tag to pin.
type InPlaceConfig ¶
type InPlaceConfig struct {
// BaseBranch is the branch to use as the base for the hydration.
// This will be the branch that is checked out and updated by Hydros
BaseBranch string `yaml:"baseBranch"`
// PRBranch is the branch hydros will use to prepare the changes
PRBranch string `yaml:"prBranch"`
// AutoMerge determines whether Hydros should try to automatically merge the PR.
// If AutoMerge is true then Hydros will try to enable GitHub AutoMerge on the PR if it is available
// or it will try to merge the PR if it is immediately mergeable.
AutoMerge bool `yaml:"autoMerge"`
// Paths is the relative paths of the directories to search for KRMFunctions
// If this is blank then the entire repo will be search.
Paths []string `yaml:"paths"`
}
type LabelSelector ¶
type LabelSelector struct {
// matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
// map is equivalent to an element of matchExpressions, whose key field is "key", the
// operator is "In", and the values array contains only "value". The requirements are ANDed.
// +optional
MatchLabels map[string]string `json:"matchLabels,omitempty" yaml:"matchLabels,omitempty"`
// MatchExpressions is a list of label selector requirements. The requirements are ANDed.
// +optional
MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty" yaml:"matchExpressions,omitempty"`
}
LabelSelector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects. +structType=atomic
N.B. Based on https://github.com/kubernetes/apimachinery/blob/460d10991a520527026863efae34f49f89c2f4e1/pkg/apis/meta/v1/types.go#L1096 We copy the struct so we can add YAML annotations
func (*LabelSelector) ToK8s ¶
func (s *LabelSelector) ToK8s() (*meta.LabelSelector, error)
ToK8s converts it to a K8s Label selector. This indirection is necessary because we need to change how the LabelSelector is serialized to YAML by adding YAML tags.
type LabelSelectorOperator ¶
type LabelSelectorOperator string
LabelSelectorOperator is the set of operators that can be used in a selector requirement.
const ( // LabelSelectorOpIn is the in operator LabelSelectorOpIn LabelSelectorOperator = "In" // LabelSelectorOpNotIn is the not in operator LabelSelectorOpNotIn LabelSelectorOperator = "NotIn" // LabelSelectorOpExists is the exists operator LabelSelectorOpExists LabelSelectorOperator = "Exists" // LabelSelectorOpDoesNotExist is the does not exist operator LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist" )
type LabelSelectorRequirement ¶
type LabelSelectorRequirement struct {
// key is the label key that the selector applies to.
// +patchMergeKey=key
// +patchStrategy=merge
Key string `json:"key" yaml:"key" patchStrategy:"merge" patchMergeKey:"key"`
// operator represents a key's relationship to a set of values.
// Valid operators are In, NotIn, Exists and DoesNotExist.
Operator LabelSelectorOperator `json:"operator" yaml:"operator"`
// values is an array of string values. If the operator is In or NotIn,
// the values array must be non-empty. If the operator is Exists or DoesNotExist,
// the values array must be empty. This array is replaced during a strategic
// merge patch.
// +optional
Values []string `json:"values,omitempty" yaml:"values,omitempty"`
}
LabelSelectorRequirement is a selector that contains values, a key, and an operator that relates the key and values.
type ManifestSync ¶
type ManifestSync struct {
APIVersion string `yaml:"apiVersion" yamltags:"required"`
Kind string `yaml:"kind" yamltags:"required"`
Metadata Metadata `yaml:"metadata,omitempty"`
Spec ManifestSyncSpec `yaml:"spec,omitempty"`
Status ManifestSyncStatus `yaml:"status,omitempty"`
}
ManifestSync continually syncs unhyrated manifests to a hydrated repo. As part of that images are replaced with the latest images.
func (*ManifestSync) IsValid ¶
func (m *ManifestSync) IsValid() error
IsValid verifies this is a fully valid manifest
type ManifestSyncSpec ¶
type ManifestSyncSpec struct {
SourceRepo GitHubRepo `yaml:"sourceRepo,omitempty"`
// ForkRepo is the repo into which the hydrated manifests will be pushed
ForkRepo GitHubRepo `yaml:"forkRepo,omitempty"`
// DestRepo is the repo into which a PR will be created to merge hydrated
// manifests from the ForkRepo
DestRepo GitHubRepo `yaml:"destRepo,omitempty"`
// SourcePath is relative to root of SourceRepo. It is the director
// to search for manifests to hydrate
SourcePath string `yaml:"sourcePath,omitempty"`
// Selector selects which kustomizations to be used by matching kustomize labels.
Selector *LabelSelector `yaml:"selector,omitempty"`
// Only kustomizations which include these annotations as commonAnnotations will be hydrated.
// Deprecated; selector should be used instead.
MatchAnnotations map[string]string `yaml:"matchAnnotations,omitempty"`
// DestPath is the directory in the destination repo where hydrated manifests should be emitted.
// This directory will be deleted and recreated for each PR to ensure pruned resources are removed
DestPath string `yaml:"destPath,omitempty"`
// ImageTagsToPin is a list of image tags whose images should be pinned.
// It is a replacement for ImageTags.
ImageTagsToPin []ImageTagToPin `yaml:"imageTagsToPin,omitempty"`
// ImageRegistries is a list of image registries. Only images in these registries with one of
// the ImageTags labeled above is eligible for replacement.
ImageRegistries []string `yaml:"imageRegistries,omitempty"`
// ImageBuilder configures the image building.
ImageBuilder *ImageBuilder `yaml:"imageBuilder,omitempty"`
// ExcludeDirs is a list of paths relative to the repo root exclude. This is typically directories that
// store templates. These directories will not be considered at all; e.g.
// 1. Manifests are not eligible for image replacement
// 2. Manifests are not eligible for hydration
// If you need to #1 but not #2 use MatchAnnotations to exclude a kustomization from hydration but not image
// replacement.
ExcludeDirs []string `yaml:"excludeDirs,omitempty"`
// PrLabels is a list of labels to add to the PR.
PrLabels []string `yaml:"prLabels,omitempty"`
// Functions is a list of kustomize functions to apply to the hydrated manifests
Functions []Function `yaml:"functions,omitempty"`
}
ManifestSyncSpec is the spec for ManifestSync.
type ManifestSyncStatus ¶
type ManifestSyncStatus struct {
SourceURL string `yaml:"sourceUrl,omitempty"`
SourceCommit string `yaml:"sourceCommit,omitempty"`
PinnedImages []PinnedImage `yaml:"pinnedImages,omitempty"`
}
ManifestSyncStatus is the status for ManifestSync resources.
type Metadata ¶
type Metadata struct {
Name string `yaml:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
Labels map[string]string `yaml:"labels"`
Annotations map[string]string `yaml:"annotations,omitempty"`
// ResourceVersion is used for optimistic concurrency.
// Ref: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
// This should be treated as an opaque value by clients.
ResourceVersion string `yaml:"resourceVersion,omitempty"`
}
Metadata holds an optional name of the project.
type NonTerminalError ¶
type NonTerminalError string
NonTerminalError error that we can safely ignore
func (NonTerminalError) Error ¶
func (e NonTerminalError) Error() string
type PinnedImage ¶
type PinnedImage struct {
Image string `yaml:"image,omitempty"`
NewImage string `yaml:"newImage,omitempty"`
}
PinnedImage represents the mapping of an image to the value it should be pinned to.
type RepoMatchType ¶
type RepoMatchType string
RepoMatchType is an enum for how repo matching rules should be applied.
type S3AssetsList ¶
type S3AssetsList struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata Metadata `yaml:"metadata,omitempty"`
S3Assets []string `yaml:"s3assets,omitempty"`
}
S3AssetsList is a list of s3 paths
type S3NonTerminalError ¶
type S3NonTerminalError string
S3NonTerminalError a non terminal s3 error
const ( // ErrS3IsADirectory a non terminal error for a directory that already exists ErrS3IsADirectory S3NonTerminalError = "is a directory" // ErrS3AssetAlreadyDownloaded a non terminal for an already downloaded s3 asset ErrS3AssetAlreadyDownloaded S3NonTerminalError = "Asset already downloaded" )
func (S3NonTerminalError) Error ¶
func (e S3NonTerminalError) Error() string
func (S3NonTerminalError) Unwrap ¶
func (e S3NonTerminalError) Unwrap() error
Unwrap func to unwrap a wrapped err