Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port controller to new pkg/runtime API #165

Merged
merged 6 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/fluxcd/image-reflector-controller/api
go 1.16

require (
github.com/fluxcd/pkg/apis/meta v0.10.0
github.com/fluxcd/pkg/apis/meta v0.11.0-rc.1
k8s.io/apimachinery v0.21.3
sigs.k8s.io/controller-runtime v0.9.5
)
8 changes: 3 additions & 5 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMi
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fluxcd/pkg/apis/meta v0.10.0 h1:N7wVGHC1cyPdT87hrDC7UwCwRwnZdQM46PBSLjG2rlE=
github.com/fluxcd/pkg/apis/meta v0.10.0/go.mod h1:CW9X9ijMTpNe7BwnokiUOrLl/h13miwVr/3abEQLbKE=
github.com/fluxcd/pkg/apis/meta v0.11.0-rc.1 h1:RHHrztAFv9wmjM+Pk7Svt1UdD+1SdnQSp76MWFiM7Hg=
github.com/fluxcd/pkg/apis/meta v0.11.0-rc.1/go.mod h1:yUblM2vg+X8TE3A2VvJfdhkGmg+uqBlSPkLk7dxi0UM=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
Expand Down Expand Up @@ -159,7 +159,6 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down Expand Up @@ -510,7 +509,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down Expand Up @@ -677,7 +675,7 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
k8s.io/api v0.21.3 h1:cblWILbLO8ar+Fj6xdDGr603HRsf8Wu9E9rngJeprZQ=
k8s.io/api v0.21.3/go.mod h1:hUgeYHUbBp23Ue4qdX9tR8/ANi/g3ehylAqDn9NWVOg=
k8s.io/apiextensions-apiserver v0.21.3/go.mod h1:kl6dap3Gd45+21Jnh6utCx8Z2xxLm8LGDkprcd+KbsE=
k8s.io/apimachinery v0.21.1/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY=
k8s.io/apimachinery v0.21.2/go.mod h1:CdTY8fU/BlvAbJ2z/8kBwimGki5Zp8/fbVuLY8gJumM=
k8s.io/apimachinery v0.21.3 h1:3Ju4nvjCngxxMYby0BimUk+pQHPOQp3eCGChk5kfVII=
k8s.io/apimachinery v0.21.3/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI=
k8s.io/apiserver v0.21.3/go.mod h1:eDPWlZG6/cCCMj/JBcEpDoK+I+6i3r9GsChYBHSbAzU=
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha1/imagepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ func (p *ImagePolicy) GetStatusConditions() *[]metav1.Condition {
return &p.Status.Conditions
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImagePolicyReadiness(p *ImagePolicy, status metav1.ConditionStatus, reason, message string) {
p.Status.ObservedGeneration = p.ObjectMeta.Generation
meta.SetResourceCondition(p, meta.ReadyCondition, status, reason, message)
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="LatestImage",type=string,JSONPath=`.status.latestImage`
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha1/imagerepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ type ImageRepositoryStatus struct {
meta.ReconcileRequestStatus `json:",inline"`
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImageRepositoryReadiness(ir *ImageRepository, status metav1.ConditionStatus, reason, message string) {
ir.Status.ObservedGeneration = ir.ObjectMeta.Generation
meta.SetResourceCondition(ir, meta.ReadyCondition, status, reason, message)
}

// GetStatusConditions returns a pointer to the Status.Conditions slice
func (in *ImageRepository) GetStatusConditions() *[]metav1.Condition {
return &in.Status.Conditions
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha2/imagepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ func (p *ImagePolicy) GetStatusConditions() *[]metav1.Condition {
return &p.Status.Conditions
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImagePolicyReadiness(p *ImagePolicy, status metav1.ConditionStatus, reason, message string) {
p.Status.ObservedGeneration = p.ObjectMeta.Generation
meta.SetResourceCondition(p, meta.ReadyCondition, status, reason, message)
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="LatestImage",type=string,JSONPath=`.status.latestImage`
Expand Down
6 changes: 0 additions & 6 deletions api/v1alpha2/imagerepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ type ImageRepositoryStatus struct {
meta.ReconcileRequestStatus `json:",inline"`
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImageRepositoryReadiness(ir *ImageRepository, status metav1.ConditionStatus, reason, message string) {
ir.Status.ObservedGeneration = ir.ObjectMeta.Generation
meta.SetResourceCondition(ir, meta.ReadyCondition, status, reason, message)
}

// GetStatusConditions returns a pointer to the Status.Conditions slice
func (in *ImageRepository) GetStatusConditions() *[]metav1.Condition {
return &in.Status.Conditions
Expand Down
19 changes: 13 additions & 6 deletions api/v1beta1/imagepolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,21 @@ type ImagePolicyStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

func (p *ImagePolicy) GetStatusConditions() *[]metav1.Condition {
return &p.Status.Conditions
// GetConditions returns the slice of status conditions for the object.
func (in ImagePolicy) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the slice of status conditions for the object.
func (in *ImagePolicy) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImagePolicyReadiness(p *ImagePolicy, status metav1.ConditionStatus, reason, message string) {
p.Status.ObservedGeneration = p.ObjectMeta.Generation
meta.SetResourceCondition(p, meta.ReadyCondition, status, reason, message)
// GetStatusConditions returns a pointer to the slice of status
// conditions. Deprecated: use GetConditions (and possibly
// SetConditions) instead.
func (p *ImagePolicy) GetStatusConditions() *[]metav1.Condition {
return &p.Status.Conditions
}

// +kubebuilder:storageversion
Expand Down
15 changes: 10 additions & 5 deletions api/v1beta1/imagerepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,18 @@ type ImageRepositoryStatus struct {
meta.ReconcileRequestStatus `json:",inline"`
}

// SetImageRepositoryReadiness sets the ready condition with the given status, reason and message.
func SetImageRepositoryReadiness(ir *ImageRepository, status metav1.ConditionStatus, reason, message string) {
ir.Status.ObservedGeneration = ir.ObjectMeta.Generation
meta.SetResourceCondition(ir, meta.ReadyCondition, status, reason, message)
// GetConditions returns the slice of status conditions for the object.
func (in ImageRepository) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// GetStatusConditions returns a pointer to the Status.Conditions slice
// SetConditions sets the slice of status conditions for the object.
func (in *ImageRepository) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetStatusConditions returns a pointer to the Status.Conditions
// slice. Deprecated: use GetConditions (then SetConditions) instead.
func (in *ImageRepository) GetStatusConditions() *[]metav1.Condition {
return &in.Status.Conditions
}
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/image.toolkit.fluxcd.io_imagepolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
description: ImageRepositoryRef points at the object specifying the image being scanned
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -186,7 +186,7 @@ spec:
description: ImageRepositoryRef points at the object specifying the image being scanned
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -322,10 +322,10 @@ spec:
description: ImageRepositoryRef points at the object specifying the image being scanned
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
namespace:
description: Namespace of the referent, when not specified it acts as LocalObjectReference
description: Namespace of the referent, when not specified it acts as LocalObjectReference.
type: string
required:
- name
Expand Down
18 changes: 9 additions & 9 deletions config/crd/bases/image.toolkit.fluxcd.io_imagerepositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
description: "CertSecretRef can be given the name of a secret containing either or both of \n - a PEM-encoded client certificate (`certFile`) and private key (`keyFile`); - a PEM-encoded CA certificate (`caFile`) \n and whichever are supplied, will be used for connecting to the registry. The client cert and key are useful if you are authenticating with a certificate; the CA cert is useful if you are using a self-signed server certificate."
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand All @@ -58,7 +58,7 @@ spec:
description: SecretRef can be given the name of a secret containing credentials to use for the image registry. The secret should be created with `kubectl create secret docker-registry`, or the equivalent.
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -120,7 +120,7 @@ spec:
type: object
type: array
lastHandledReconcileAt:
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change can be detected.
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change of the annotation value can be detected.
type: string
lastScanResult:
description: LastScanResult contains the number of fetched tags.
Expand Down Expand Up @@ -170,7 +170,7 @@ spec:
description: "CertSecretRef can be given the name of a secret containing either or both of \n - a PEM-encoded client certificate (`certFile`) and private key (`keyFile`); - a PEM-encoded CA certificate (`caFile`) \n and whichever are supplied, will be used for connecting to the registry. The client cert and key are useful if you are authenticating with a certificate; the CA cert is useful if you are using a self-signed server certificate."
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand All @@ -185,7 +185,7 @@ spec:
description: SecretRef can be given the name of a secret containing credentials to use for the image registry. The secret should be created with `kubectl create secret docker-registry`, or the equivalent.
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -247,7 +247,7 @@ spec:
type: object
type: array
lastHandledReconcileAt:
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change can be detected.
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change of the annotation value can be detected.
type: string
lastScanResult:
description: LastScanResult contains the number of fetched tags.
Expand Down Expand Up @@ -310,7 +310,7 @@ spec:
description: "CertSecretRef can be given the name of a secret containing either or both of \n - a PEM-encoded client certificate (`certFile`) and private key (`keyFile`); - a PEM-encoded CA certificate (`caFile`) \n and whichever are supplied, will be used for connecting to the registry. The client cert and key are useful if you are authenticating with a certificate; the CA cert is useful if you are using a self-signed server certificate."
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand All @@ -325,7 +325,7 @@ spec:
description: SecretRef can be given the name of a secret containing credentials to use for the image registry. The secret should be created with `kubectl create secret docker-registry`, or the equivalent.
properties:
name:
description: Name of the referent
description: Name of the referent.
type: string
required:
- name
Expand Down Expand Up @@ -387,7 +387,7 @@ spec:
type: object
type: array
lastHandledReconcileAt:
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change can be detected.
description: LastHandledReconcileAt holds the value of the most recent reconcile request value, so a change of the annotation value can be detected.
type: string
lastScanResult:
description: LastScanResult contains the number of fetched tags.
Expand Down
Loading