Graduate v1alpha2 API to v1beta1

This does the following:

 - copies the type definitions from v1alpha2 to v1beta1
 - changes the "stored" version to v1beta1
 - gives the CRD a conversion strategy of None, meaning just rewrite the version
 - switches the controller to use v1beta1
 - moves the generated documentation to v1beta1

This effectively rebadges the v1alpha2 version of this part of the
image API to v1beta1. The v1alpha2 version is left in place; there are
no conversion issues, as with v1alpha1->v1alpha2. The CRD specifies
that converting between v1alpha2 and v1beta1 just means changing the
version (i.e., the schema and semantics are the same).

Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
Michael Bridgen 2021-06-24 14:44:10 +01:00
parent c1533ea757
commit 5b9631327f
17 changed files with 887 additions and 60 deletions

View File

@ -79,7 +79,7 @@ manifests: controller-gen
# Generate API reference documentation
api-docs: gen-crd-api-reference-docs
$(API_REF_GEN) -api-dir=./api/v1alpha2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/image-automation.md
$(API_REF_GEN) -api-dir=./api/v1beta1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/image-automation.md
# Run go mod tidy
tidy:

View File

@ -7,4 +7,7 @@ resources:
- group: image
kind: ImageUpdateAutomation
version: v1alpha2
- group: image
kind: ImageUpdateAutomation
version: v1beta1
version: "2"

View File

@ -119,7 +119,6 @@ func SetImageUpdateAutomationReadiness(auto *ImageUpdateAutomation, status metav
meta.SetResourceCondition(auto, meta.ReadyCondition, status, reason, message)
}
//+kubebuilder:storageversion
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Last run",type=string,JSONPath=`.status.lastAutomationRunTime`

26
api/v1beta1/doc.go Normal file
View File

@ -0,0 +1,26 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1beta1 contains API types for the image API group, version
// v1beta1. The types here are concerned with automated updates to
// git, based on metadata from OCI image registries gathered by the
// image-reflector-controller. v1alpha2 did some rearrangement from
// v1alpha1 to make room for future enhancements; v1beta1 does not
// change the schema from v1alpha2.
//
// +kubebuilder:object:generate=true
// +groupName=image.toolkit.fluxcd.io
package v1beta1

90
api/v1beta1/git.go Normal file
View File

@ -0,0 +1,90 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
)
type GitSpec struct {
// Checkout gives the parameters for cloning the git repository,
// ready to make changes. If not present, the `spec.ref` field from the
// referenced `GitRepository` or its default will be used.
// +optional
Checkout *GitCheckoutSpec `json:"checkout,omitempty"`
// Commit specifies how to commit to the git repository.
// +required
Commit CommitSpec `json:"commit"`
// Push specifies how and where to push commits made by the
// automation. If missing, commits are pushed (back) to
// `.spec.checkout.branch` or its default.
// +optional
Push *PushSpec `json:"push,omitempty"`
}
type GitCheckoutSpec struct {
// Reference gives a branch, tag or commit to clone from the Git
// repository.
// +required
Reference sourcev1.GitRepositoryRef `json:"ref"`
}
// CommitSpec specifies how to commit changes to the git repository
type CommitSpec struct {
// Author gives the email and optionally the name to use as the
// author of commits.
// +required
Author CommitUser `json:"author"`
// SigningKey provides the option to sign commits with a GPG key
// +optional
SigningKey *SigningKey `json:"signingKey,omitempty"`
// MessageTemplate provides a template for the commit message,
// into which will be interpolated the details of the change made.
// +optional
MessageTemplate string `json:"messageTemplate,omitempty"`
}
type CommitUser struct {
// Name gives the name to provide when making a commit.
// +optional
Name string `json:"name,omitempty"`
// Email gives the email to provide when making a commit.
// +required
Email string `json:"email"`
}
// SigningKey references a Kubernetes secret that contains a GPG keypair
type SigningKey struct {
// SecretRef holds the name to a secret that contains a 'git.asc' key
// corresponding to the ASCII Armored file containing the GPG signing
// keypair as the value. It must be in the same namespace as the
// ImageUpdateAutomation.
// +required
SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
}
// PushSpec specifies how and where to push commits.
type PushSpec struct {
// Branch specifies that commits should be pushed to the branch
// named. The branch is created using `.spec.checkout.branch` as the
// starting point, if it doesn't already exist.
// +required
Branch string `json:"branch"`
}

View File

@ -0,0 +1,33 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)
var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "image.toolkit.fluxcd.io", Version: "v1beta1"}
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

View File

@ -0,0 +1,151 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fluxcd/pkg/apis/meta"
)
const ImageUpdateAutomationKind = "ImageUpdateAutomation"
// ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation
type ImageUpdateAutomationSpec struct {
// SourceRef refers to the resource giving access details
// to a git repository.
// +required
SourceRef SourceReference `json:"sourceRef"`
// GitSpec contains all the git-specific definitions. This is
// technically optional, but in practice mandatory until there are
// other kinds of source allowed.
// +optional
GitSpec *GitSpec `json:"git,omitempty"`
// Interval gives an lower bound for how often the automation
// run should be attempted.
// +required
Interval metav1.Duration `json:"interval"`
// Update gives the specification for how to update the files in
// the repository. This can be left empty, to use the default
// value.
// +kubebuilder:default={"strategy":"Setters"}
Update *UpdateStrategy `json:"update,omitempty"`
// Suspend tells the controller to not run this automation, until
// it is unset (or set to false). Defaults to false.
// +optional
Suspend bool `json:"suspend,omitempty"`
}
// UpdateStrategyName is the type for names that go in
// .update.strategy. NB the value in the const immediately below.
// +kubebuilder:validation:Enum=Setters
type UpdateStrategyName string
const (
// UpdateStrategySetters is the name of the update strategy that
// uses kyaml setters. NB the value in the enum annotation for the
// type, above.
UpdateStrategySetters UpdateStrategyName = "Setters"
)
// UpdateStrategy is a union of the various strategies for updating
// the Git repository. Parameters for each strategy (if any) can be
// inlined here.
type UpdateStrategy struct {
// Strategy names the strategy to be used.
// +required
// +kubebuilder:default=Setters
Strategy UpdateStrategyName `json:"strategy"`
// Path to the directory containing the manifests to be updated.
// Defaults to 'None', which translates to the root path
// of the GitRepositoryRef.
// +optional
Path string `json:"path,omitempty"`
}
// ImageUpdateAutomationStatus defines the observed state of ImageUpdateAutomation
type ImageUpdateAutomationStatus struct {
// LastAutomationRunTime records the last time the controller ran
// this automation through to completion (even if no updates were
// made).
// +optional
LastAutomationRunTime *metav1.Time `json:"lastAutomationRunTime,omitempty"`
// LastPushCommit records the SHA1 of the last commit made by the
// controller, for this automation object
// +optional
LastPushCommit string `json:"lastPushCommit,omitempty"`
// LastPushTime records the time of the last pushed change.
// +optional
LastPushTime *metav1.Time `json:"lastPushTime,omitempty"`
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
meta.ReconcileRequestStatus `json:",inline"`
}
const (
// GitNotAvailableReason is used for ConditionReady when the
// automation run cannot proceed because the git repository is
// missing or cannot be cloned.
GitNotAvailableReason = "GitRepositoryNotAvailable"
// NoStrategyReason is used for ConditionReady when the automation
// run cannot proceed because there is no update strategy given in
// the spec.
NoStrategyReason = "MissingUpdateStrategy"
)
// SetImageUpdateAutomationReadiness sets the ready condition with the given status, reason and message.
func SetImageUpdateAutomationReadiness(auto *ImageUpdateAutomation, status metav1.ConditionStatus, reason, message string) {
auto.Status.ObservedGeneration = auto.ObjectMeta.Generation
meta.SetResourceCondition(auto, meta.ReadyCondition, status, reason, message)
}
//+kubebuilder:storageversion
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Last run",type=string,JSONPath=`.status.lastAutomationRunTime`
// ImageUpdateAutomation is the Schema for the imageupdateautomations API
type ImageUpdateAutomation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ImageUpdateAutomationSpec `json:"spec,omitempty"`
Status ImageUpdateAutomationStatus `json:"status,omitempty"`
}
func (auto *ImageUpdateAutomation) GetStatusConditions() *[]metav1.Condition {
return &auto.Status.Conditions
}
//+kubebuilder:object:root=true
// ImageUpdateAutomationList contains a list of ImageUpdateAutomation
type ImageUpdateAutomationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ImageUpdateAutomation `json:"items"`
}
func init() {
SchemeBuilder.Register(&ImageUpdateAutomation{}, &ImageUpdateAutomationList{})
}

35
api/v1beta1/reference.go Normal file
View File

@ -0,0 +1,35 @@
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
// SourceReference contains enough information to let you locate the
// typed, referenced source object.
type SourceReference struct {
// API version of the referent
// +optional
APIVersion string `json:"apiVersion,omitempty"`
// Kind of the referent
// +kubebuilder:validation:Enum=GitRepository
// +kubebuilder:default=GitRepository
// +required
Kind string `json:"kind"`
// Name of the referent
// +required
Name string `json:"name"`
}

View File

@ -0,0 +1,282 @@
// +build !ignore_autogenerated
/*
Copyright 2020 The Flux authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by controller-gen. DO NOT EDIT.
package v1beta1
import (
"k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CommitSpec) DeepCopyInto(out *CommitSpec) {
*out = *in
out.Author = in.Author
if in.SigningKey != nil {
in, out := &in.SigningKey, &out.SigningKey
*out = new(SigningKey)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommitSpec.
func (in *CommitSpec) DeepCopy() *CommitSpec {
if in == nil {
return nil
}
out := new(CommitSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CommitUser) DeepCopyInto(out *CommitUser) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommitUser.
func (in *CommitUser) DeepCopy() *CommitUser {
if in == nil {
return nil
}
out := new(CommitUser)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitCheckoutSpec) DeepCopyInto(out *GitCheckoutSpec) {
*out = *in
out.Reference = in.Reference
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitCheckoutSpec.
func (in *GitCheckoutSpec) DeepCopy() *GitCheckoutSpec {
if in == nil {
return nil
}
out := new(GitCheckoutSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitSpec) DeepCopyInto(out *GitSpec) {
*out = *in
if in.Checkout != nil {
in, out := &in.Checkout, &out.Checkout
*out = new(GitCheckoutSpec)
**out = **in
}
in.Commit.DeepCopyInto(&out.Commit)
if in.Push != nil {
in, out := &in.Push, &out.Push
*out = new(PushSpec)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitSpec.
func (in *GitSpec) DeepCopy() *GitSpec {
if in == nil {
return nil
}
out := new(GitSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImageUpdateAutomation) DeepCopyInto(out *ImageUpdateAutomation) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageUpdateAutomation.
func (in *ImageUpdateAutomation) DeepCopy() *ImageUpdateAutomation {
if in == nil {
return nil
}
out := new(ImageUpdateAutomation)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ImageUpdateAutomation) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImageUpdateAutomationList) DeepCopyInto(out *ImageUpdateAutomationList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ImageUpdateAutomation, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageUpdateAutomationList.
func (in *ImageUpdateAutomationList) DeepCopy() *ImageUpdateAutomationList {
if in == nil {
return nil
}
out := new(ImageUpdateAutomationList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ImageUpdateAutomationList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImageUpdateAutomationSpec) DeepCopyInto(out *ImageUpdateAutomationSpec) {
*out = *in
out.SourceRef = in.SourceRef
if in.GitSpec != nil {
in, out := &in.GitSpec, &out.GitSpec
*out = new(GitSpec)
(*in).DeepCopyInto(*out)
}
out.Interval = in.Interval
if in.Update != nil {
in, out := &in.Update, &out.Update
*out = new(UpdateStrategy)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageUpdateAutomationSpec.
func (in *ImageUpdateAutomationSpec) DeepCopy() *ImageUpdateAutomationSpec {
if in == nil {
return nil
}
out := new(ImageUpdateAutomationSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImageUpdateAutomationStatus) DeepCopyInto(out *ImageUpdateAutomationStatus) {
*out = *in
if in.LastAutomationRunTime != nil {
in, out := &in.LastAutomationRunTime, &out.LastAutomationRunTime
*out = (*in).DeepCopy()
}
if in.LastPushTime != nil {
in, out := &in.LastPushTime, &out.LastPushTime
*out = (*in).DeepCopy()
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]v1.Condition, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
out.ReconcileRequestStatus = in.ReconcileRequestStatus
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageUpdateAutomationStatus.
func (in *ImageUpdateAutomationStatus) DeepCopy() *ImageUpdateAutomationStatus {
if in == nil {
return nil
}
out := new(ImageUpdateAutomationStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PushSpec) DeepCopyInto(out *PushSpec) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PushSpec.
func (in *PushSpec) DeepCopy() *PushSpec {
if in == nil {
return nil
}
out := new(PushSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SigningKey) DeepCopyInto(out *SigningKey) {
*out = *in
out.SecretRef = in.SecretRef
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SigningKey.
func (in *SigningKey) DeepCopy() *SigningKey {
if in == nil {
return nil
}
out := new(SigningKey)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SourceReference) DeepCopyInto(out *SourceReference) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceReference.
func (in *SourceReference) DeepCopy() *SourceReference {
if in == nil {
return nil
}
out := new(SourceReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) {
*out = *in
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateStrategy.
func (in *UpdateStrategy) DeepCopy() *UpdateStrategy {
if in == nil {
return nil
}
out := new(UpdateStrategy)
in.DeepCopyInto(out)
return out
}

View File

@ -394,6 +394,213 @@ spec:
type: object
type: object
served: true
storage: false
subresources:
status: {}
- additionalPrinterColumns:
- jsonPath: .status.lastAutomationRunTime
name: Last run
type: string
name: v1beta1
schema:
openAPIV3Schema:
description: ImageUpdateAutomation is the Schema for the imageupdateautomations API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation
properties:
git:
description: GitSpec contains all the git-specific definitions. This is technically optional, but in practice mandatory until there are other kinds of source allowed.
properties:
checkout:
description: Checkout gives the parameters for cloning the git repository, ready to make changes. If not present, the `spec.ref` field from the referenced `GitRepository` or its default will be used.
properties:
ref:
description: Reference gives a branch, tag or commit to clone from the Git repository.
properties:
branch:
default: master
description: The Git branch to checkout, defaults to master.
type: string
commit:
description: The Git commit SHA to checkout, if specified Tag filters will be ignored.
type: string
semver:
description: The Git tag semver expression, takes precedence over Tag.
type: string
tag:
description: The Git tag to checkout, takes precedence over Branch.
type: string
type: object
required:
- ref
type: object
commit:
description: Commit specifies how to commit to the git repository.
properties:
author:
description: Author gives the email and optionally the name to use as the author of commits.
properties:
email:
description: Email gives the email to provide when making a commit.
type: string
name:
description: Name gives the name to provide when making a commit.
type: string
required:
- email
type: object
messageTemplate:
description: MessageTemplate provides a template for the commit message, into which will be interpolated the details of the change made.
type: string
signingKey:
description: SigningKey provides the option to sign commits with a GPG key
properties:
secretRef:
description: SecretRef holds the name to a secret that contains a 'git.asc' key corresponding to the ASCII Armored file containing the GPG signing keypair as the value. It must be in the same namespace as the ImageUpdateAutomation.
properties:
name:
description: Name of the referent
type: string
required:
- name
type: object
type: object
required:
- author
type: object
push:
description: Push specifies how and where to push commits made by the automation. If missing, commits are pushed (back) to `.spec.checkout.branch` or its default.
properties:
branch:
description: Branch specifies that commits should be pushed to the branch named. The branch is created using `.spec.checkout.branch` as the starting point, if it doesn't already exist.
type: string
required:
- branch
type: object
required:
- commit
type: object
interval:
description: Interval gives an lower bound for how often the automation run should be attempted.
type: string
sourceRef:
description: SourceRef refers to the resource giving access details to a git repository.
properties:
apiVersion:
description: API version of the referent
type: string
kind:
default: GitRepository
description: Kind of the referent
enum:
- GitRepository
type: string
name:
description: Name of the referent
type: string
required:
- kind
- name
type: object
suspend:
description: Suspend tells the controller to not run this automation, until it is unset (or set to false). Defaults to false.
type: boolean
update:
default:
strategy: Setters
description: Update gives the specification for how to update the files in the repository. This can be left empty, to use the default value.
properties:
path:
description: Path to the directory containing the manifests to be updated. Defaults to 'None', which translates to the root path of the GitRepositoryRef.
type: string
strategy:
default: Setters
description: Strategy names the strategy to be used.
enum:
- Setters
type: string
required:
- strategy
type: object
required:
- interval
- sourceRef
type: object
status:
description: ImageUpdateAutomationStatus defines the observed state of ImageUpdateAutomation
properties:
conditions:
items:
description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating details about the transition. This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
lastAutomationRunTime:
description: LastAutomationRunTime records the last time the controller ran this automation through to completion (even if no updates were made).
format: date-time
type: string
lastHandledReconcileAt:
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change can be detected.
type: string
lastPushCommit:
description: LastPushCommit records the SHA1 of the last commit made by the controller, for this automation object
type: string
lastPushTime:
description: LastPushTime records the time of the last pushed change.
format: date-time
type: string
observedGeneration:
format: int64
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}

View File

@ -62,7 +62,7 @@ import (
"github.com/fluxcd/source-controller/pkg/git"
gitstrat "github.com/fluxcd/source-controller/pkg/git/strategy"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha2"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
"github.com/fluxcd/image-automation-controller/pkg/update"
)

View File

@ -33,7 +33,7 @@ import (
imagev1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha2"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha2"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
// +kubebuilder:scaffold:imports
)

View File

@ -54,7 +54,7 @@ import (
"github.com/fluxcd/pkg/ssh"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha2"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
"github.com/fluxcd/image-automation-controller/pkg/test"
"github.com/fluxcd/image-automation-controller/pkg/update"
)

View File

@ -2,22 +2,23 @@
<p>Packages:</p>
<ul class="simple">
<li>
<a href="#image.toolkit.fluxcd.io%2fv1alpha2">image.toolkit.fluxcd.io/v1alpha2</a>
<a href="#image.toolkit.fluxcd.io%2fv1beta1">image.toolkit.fluxcd.io/v1beta1</a>
</li>
</ul>
<h2 id="image.toolkit.fluxcd.io/v1alpha2">image.toolkit.fluxcd.io/v1alpha2</h2>
<p>Package v1alpha2 contains API types for the image v1alpha2 API
group. The types here are concerned with automated updates to git,
based on metadata from OCI image registries gathered by the
image-reflector-controller. There is some rearrangement from
v1alpha1 to make room for future enhancements.</p>
<h2 id="image.toolkit.fluxcd.io/v1beta1">image.toolkit.fluxcd.io/v1beta1</h2>
<p>Package v1beta1 contains API types for the image API group, version
v1beta1. The types here are concerned with automated updates to
git, based on metadata from OCI image registries gathered by the
image-reflector-controller. v1alpha2 did some rearrangement from
v1alpha1 to make room for future enhancements; v1beta1 does not
change the schema from v1alpha2.</p>
Resource Types:
<ul class="simple"></ul>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.CommitSpec">CommitSpec
<h3 id="image.toolkit.fluxcd.io/v1beta1.CommitSpec">CommitSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitSpec">GitSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.GitSpec">GitSpec</a>)
</p>
<p>CommitSpec specifies how to commit changes to the git repository</p>
<div class="md-typeset__scrollwrap">
@ -34,7 +35,7 @@ Resource Types:
<td>
<code>author</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.CommitUser">
<a href="#image.toolkit.fluxcd.io/v1beta1.CommitUser">
CommitUser
</a>
</em>
@ -48,7 +49,7 @@ author of commits.</p>
<td>
<code>signingKey</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.SigningKey">
<a href="#image.toolkit.fluxcd.io/v1beta1.SigningKey">
SigningKey
</a>
</em>
@ -75,11 +76,11 @@ into which will be interpolated the details of the change made.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.CommitUser">CommitUser
<h3 id="image.toolkit.fluxcd.io/v1beta1.CommitUser">CommitUser
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.CommitSpec">CommitSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.CommitSpec">CommitSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
@ -118,11 +119,11 @@ string
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.GitCheckoutSpec">GitCheckoutSpec
<h3 id="image.toolkit.fluxcd.io/v1beta1.GitCheckoutSpec">GitCheckoutSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitSpec">GitSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.GitSpec">GitSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
@ -152,11 +153,11 @@ repository.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.GitSpec">GitSpec
<h3 id="image.toolkit.fluxcd.io/v1beta1.GitSpec">GitSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
@ -172,7 +173,7 @@ repository.</p>
<td>
<code>checkout</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitCheckoutSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.GitCheckoutSpec">
GitCheckoutSpec
</a>
</em>
@ -188,7 +189,7 @@ referenced <code>GitRepository</code> or its default will be used.</p>
<td>
<code>commit</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.CommitSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.CommitSpec">
CommitSpec
</a>
</em>
@ -201,7 +202,7 @@ CommitSpec
<td>
<code>push</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.PushSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.PushSpec">
PushSpec
</a>
</em>
@ -217,7 +218,7 @@ automation. If missing, commits are pushed (back) to
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomation">ImageUpdateAutomation
<h3 id="image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomation">ImageUpdateAutomation
</h3>
<p>ImageUpdateAutomation is the Schema for the imageupdateautomations API</p>
<div class="md-typeset__scrollwrap">
@ -248,7 +249,7 @@ Refer to the Kubernetes API documentation for the fields of the
<td>
<code>spec</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationSpec">
ImageUpdateAutomationSpec
</a>
</em>
@ -261,7 +262,7 @@ ImageUpdateAutomationSpec
<td>
<code>sourceRef</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.SourceReference">
<a href="#image.toolkit.fluxcd.io/v1beta1.SourceReference">
SourceReference
</a>
</em>
@ -275,7 +276,7 @@ to a git repository.</p>
<td>
<code>git</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.GitSpec">
GitSpec
</a>
</em>
@ -305,7 +306,7 @@ run should be attempted.</p>
<td>
<code>update</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.UpdateStrategy">
<a href="#image.toolkit.fluxcd.io/v1beta1.UpdateStrategy">
UpdateStrategy
</a>
</em>
@ -336,7 +337,7 @@ it is unset (or set to false). Defaults to false.</p>
<td>
<code>status</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationStatus">
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationStatus">
ImageUpdateAutomationStatus
</a>
</em>
@ -348,11 +349,11 @@ ImageUpdateAutomationStatus
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec
<h3 id="image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomation">ImageUpdateAutomation</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomation">ImageUpdateAutomation</a>)
</p>
<p>ImageUpdateAutomationSpec defines the desired state of ImageUpdateAutomation</p>
<div class="md-typeset__scrollwrap">
@ -369,7 +370,7 @@ ImageUpdateAutomationStatus
<td>
<code>sourceRef</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.SourceReference">
<a href="#image.toolkit.fluxcd.io/v1beta1.SourceReference">
SourceReference
</a>
</em>
@ -383,7 +384,7 @@ to a git repository.</p>
<td>
<code>git</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitSpec">
<a href="#image.toolkit.fluxcd.io/v1beta1.GitSpec">
GitSpec
</a>
</em>
@ -413,7 +414,7 @@ run should be attempted.</p>
<td>
<code>update</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.UpdateStrategy">
<a href="#image.toolkit.fluxcd.io/v1beta1.UpdateStrategy">
UpdateStrategy
</a>
</em>
@ -441,11 +442,11 @@ it is unset (or set to false). Defaults to false.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationStatus">ImageUpdateAutomationStatus
<h3 id="image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationStatus">ImageUpdateAutomationStatus
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomation">ImageUpdateAutomation</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomation">ImageUpdateAutomation</a>)
</p>
<p>ImageUpdateAutomationStatus defines the observed state of ImageUpdateAutomation</p>
<div class="md-typeset__scrollwrap">
@ -544,11 +545,11 @@ github.com/fluxcd/pkg/apis/meta.ReconcileRequestStatus
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.PushSpec">PushSpec
<h3 id="image.toolkit.fluxcd.io/v1beta1.PushSpec">PushSpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.GitSpec">GitSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.GitSpec">GitSpec</a>)
</p>
<p>PushSpec specifies how and where to push commits.</p>
<div class="md-typeset__scrollwrap">
@ -578,11 +579,11 @@ starting point, if it doesn&rsquo;t already exist.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.SigningKey">SigningKey
<h3 id="image.toolkit.fluxcd.io/v1beta1.SigningKey">SigningKey
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.CommitSpec">CommitSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.CommitSpec">CommitSpec</a>)
</p>
<p>SigningKey references a Kubernetes secret that contains a GPG keypair</p>
<div class="md-typeset__scrollwrap">
@ -615,11 +616,11 @@ ImageUpdateAutomation.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.SourceReference">SourceReference
<h3 id="image.toolkit.fluxcd.io/v1beta1.SourceReference">SourceReference
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
</p>
<p>SourceReference contains enough information to let you locate the
typed, referenced source object.</p>
@ -671,11 +672,11 @@ string
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.UpdateStrategy">UpdateStrategy
<h3 id="image.toolkit.fluxcd.io/v1beta1.UpdateStrategy">UpdateStrategy
</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.ImageUpdateAutomationSpec">ImageUpdateAutomationSpec</a>)
</p>
<p>UpdateStrategy is a union of the various strategies for updating
the Git repository. Parameters for each strategy (if any) can be
@ -694,7 +695,7 @@ inlined here.</p>
<td>
<code>strategy</code><br>
<em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.UpdateStrategyName">
<a href="#image.toolkit.fluxcd.io/v1beta1.UpdateStrategyName">
UpdateStrategyName
</a>
</em>
@ -721,11 +722,11 @@ of the GitRepositoryRef.</p>
</table>
</div>
</div>
<h3 id="image.toolkit.fluxcd.io/v1alpha2.UpdateStrategyName">UpdateStrategyName
<h3 id="image.toolkit.fluxcd.io/v1beta1.UpdateStrategyName">UpdateStrategyName
(<code>string</code> alias)</h3>
<p>
(<em>Appears on:</em>
<a href="#image.toolkit.fluxcd.io/v1alpha2.UpdateStrategy">UpdateStrategy</a>)
<a href="#image.toolkit.fluxcd.io/v1beta1.UpdateStrategy">UpdateStrategy</a>)
</p>
<p>UpdateStrategyName is the type for names that go in
.update.strategy. NB the value in the const immediately below.</p>

View File

@ -38,9 +38,9 @@ import (
"github.com/fluxcd/pkg/runtime/probes"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha2"
"github.com/fluxcd/image-automation-controller/controllers"
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
// +kubebuilder:scaffold:imports
"github.com/fluxcd/image-automation-controller/controllers"
)
const controllerName = "image-automation-controller"

View File

@ -31,7 +31,7 @@ import (
"sigs.k8s.io/kustomize/kyaml/setters2"
"sigs.k8s.io/kustomize/kyaml/yaml"
imagev1alpha1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha2"
imagev1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha2"
)
const (
@ -52,7 +52,7 @@ func init() {
// UpdateWithSetters takes all YAML files from `inpath`, updates any
// that contain an "in scope" image policy marker, and writes files it
// updated (and only those files) back to `outpath`.
func UpdateWithSetters(tracelog logr.Logger, inpath, outpath string, policies []imagev1alpha1_reflect.ImagePolicy) (Result, error) {
func UpdateWithSetters(tracelog logr.Logger, inpath, outpath string, policies []imagev1_reflect.ImagePolicy) (Result, error) {
// the OpenAPI schema is a package variable in kyaml/openapi. In
// lieu of being able to isolate invocations (per
// https://github.com/kubernetes-sigs/kustomize/issues/3058), I

View File

@ -30,7 +30,7 @@ import (
"sigs.k8s.io/kustomize/kyaml/yaml"
"github.com/fluxcd/image-automation-controller/pkg/test"
imagev1alpha1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha2"
imagev1_reflect "github.com/fluxcd/image-reflector-controller/api/v1alpha2"
)
func TestUpdate(t *testing.T) {
@ -41,13 +41,13 @@ func TestUpdate(t *testing.T) {
var _ = Describe("Update image via kyaml setters2", func() {
var (
policies = []imagev1alpha1_reflect.ImagePolicy{
policies = []imagev1_reflect.ImagePolicy{
{
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
Namespace: "automation-ns",
Name: "policy",
},
Status: imagev1alpha1_reflect.ImagePolicyStatus{
Status: imagev1_reflect.ImagePolicyStatus{
LatestImage: "index.repo.fake/updated:v1.0.1",
},
},
@ -56,7 +56,7 @@ var _ = Describe("Update image via kyaml setters2", func() {
Namespace: "automation-ns",
Name: "unchanged",
},
Status: imagev1alpha1_reflect.ImagePolicyStatus{
Status: imagev1_reflect.ImagePolicyStatus{
LatestImage: "image:v1.0.0",
},
},
@ -68,13 +68,13 @@ var _ = Describe("Update image via kyaml setters2", func() {
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(tmp)
policies := []imagev1alpha1_reflect.ImagePolicy{
policies := []imagev1_reflect.ImagePolicy{
{
ObjectMeta: metav1.ObjectMeta{ // name matches marker used in testdata/setters/{original,expected}
Namespace: "automation-ns",
Name: "policy",
},
Status: imagev1alpha1_reflect.ImagePolicyStatus{
Status: imagev1_reflect.ImagePolicyStatus{
LatestImage: "index.repo.fake/updated:v1.0.1",
},
},
@ -83,7 +83,7 @@ var _ = Describe("Update image via kyaml setters2", func() {
Namespace: "automation-ns",
Name: "unchanged",
},
Status: imagev1alpha1_reflect.ImagePolicyStatus{
Status: imagev1_reflect.ImagePolicyStatus{
LatestImage: "image:v1.0.0",
},
},