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

feat: add kstatus conforment status updates #284

Merged
merged 8 commits into from
Nov 14, 2023
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
15 changes: 14 additions & 1 deletion api/v1alpha1/componentversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package v1alpha1

import (
"fmt"
"time"

"github.com/fluxcd/pkg/apis/meta"
Expand Down Expand Up @@ -145,11 +146,23 @@ type ComponentVersionStatus struct {
// +optional
ReconciledVersion string `json:"reconciledVersion,omitempty"`

// Verified is a boolean indicating whether all of the specified signatures have been verified and are valid.
// Verified is a boolean indicating whether all the specified signatures have been verified and are valid.
// +optional
Verified bool `json:"verified,omitempty"`
}

func (in *ComponentVersion) GetVID() map[string]string {
Skarlso marked this conversation as resolved.
Show resolved Hide resolved
vid := fmt.Sprintf("%s:%s", in.Status.ComponentDescriptor.Name, in.Status.ReconciledVersion)
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/component_version"] = vid

return metadata
}

func (in *ComponentVersion) SetObservedGeneration(v int64) {
in.Status.ObservedGeneration = v
}

// GetComponentName returns the name of the component
func (in *ComponentVersion) GetComponentName() string {
return in.Spec.Component
Expand Down
29 changes: 28 additions & 1 deletion api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
// ConvertComponentDescriptorFailedReason is used when the Component Descriptor cannot be converted.
ConvertComponentDescriptorFailedReason = "ConvertComponentDescriptorFailed"

// NameGenerationFailedReason is used when the componentn name could not be generated.
// NameGenerationFailedReason is used when the component name could not be generated.
NameGenerationFailedReason = "NameGenerationFailed"

// CreateOrUpdateComponentDescriptorFailedReason is used when the Component Descriptor cannot be created or updated on the resource.
Expand All @@ -44,6 +44,12 @@ const (
// ComponentDescriptorNotFoundReason is used when the component descriptor cannot be found.
ComponentDescriptorNotFoundReason = "ComponentDescriptorNotFound"

// ComponentVersionNotFoundReason is used when the component version cannot be found.
ComponentVersionNotFoundReason = "ComponentVersionNotFound"

// ComponentVersionNotReadyReason is used when the component version is not ready.
ComponentVersionNotReadyReason = "ComponentVersionNotReady"
phoban01 marked this conversation as resolved.
Show resolved Hide resolved

// CreateOrUpdateSnapshotFailedReason is used when the snapshot cannot be created or updated.
CreateOrUpdateSnapshotFailedReason = "CreateOrUpdateSnapshotFailed"

Expand All @@ -55,4 +61,25 @@ const (

// CreateRepositoryNameReason is used when the generating a new repository name fails.
CreateRepositoryNameReason = "CreateRepositoryNameFailed"

// ConfigRefNotReadyWithErrorReason is used when configuration reference is not ready yet with an error.
ConfigRefNotReadyWithErrorReason = "ConfigRefNotReadyWithError"

// ConfigRefNotReadyReason is used when configuration ref is not ready yet and there was no error.
ConfigRefNotReadyReason = "ConfigRefNotReady"

// SourceRefNotReadyWithErrorReason is used when the source ref is not ready and there was an error.
SourceRefNotReadyWithErrorReason = "SourceRefNotReadyWithError"

// SourceRefNotReadyReason is used when the source ref is not ready and there was no error.
SourceRefNotReadyReason = "SourceRefNotReady"

// PatchStrategicMergeSourceRefNotReadyWithErrorReason is used when source ref for patch strategic merge is not ready and there was an error.
PatchStrategicMergeSourceRefNotReadyWithErrorReason = "PatchStrategicMergeSourceRefNotReadyWithError"

// PatchStrategicMergeSourceRefNotReadyReason is used when source ref for patch strategic merge is not ready and there was no error.
PatchStrategicMergeSourceRefNotReadyReason = "PatchStrategicMergeSourceRefNotReady"

// SnapshotNameEmptyReason is used for a failure to generate a snapshot name.
SnapshotNameEmptyReason = "SnapshotNameEmpty"
)
11 changes: 11 additions & 0 deletions api/v1alpha1/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ type Configuration struct {
Status MutationStatus `json:"status,omitempty"`
}

func (in *Configuration) GetVID() map[string]string {
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/configuration_digest"] = in.Status.LatestSnapshotDigest

return metadata
}

func (in *Configuration) SetObservedGeneration(v int64) {
in.Status.ObservedGeneration = v
}

// GetConditions returns the conditions of the Configuration.
func (in *Configuration) GetConditions() []metav1.Condition {
return in.Status.Conditions
Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/localization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ type Localization struct {
Status MutationStatus `json:"status,omitempty"`
}

func (in *Localization) GetVID() map[string]string {
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/localization_digest"] = in.Status.LatestSnapshotDigest

return metadata
}

func (in *Localization) SetObservedGeneration(v int64) {
in.Status.ObservedGeneration = v
}

// GetConditions returns the conditions of the Localization.
func (in *Localization) GetConditions() []metav1.Condition {
return in.Status.Conditions
Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ type Resource struct {
Status ResourceStatus `json:"status,omitempty"`
}

func (in *Resource) GetVID() map[string]string {
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/resource_version"] = in.Status.LastAppliedResourceVersion

return metadata
}

func (in *Resource) SetObservedGeneration(v int64) {
in.Status.ObservedGeneration = v
}

// GetConditions returns the conditions of the Resource.
func (in *Resource) GetConditions() []metav1.Condition {
return in.Status.Conditions
Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/snapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ type SnapshotStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

func (in *Snapshot) GetVID() map[string]string {
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/snapshot_digest"] = in.Status.LastReconciledDigest

return metadata
}

func (in *Snapshot) SetObservedGeneration(v int64) {
in.Status.ObservedGeneration = v
}

// GetComponentVersion returns the component version for the snapshot
func (in Snapshot) GetComponentVersion() string {
return in.Spec.Identity[ComponentVersionKey]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ spec:
of the latest reconciled ComponentVersion.
type: string
verified:
description: Verified is a boolean indicating whether all of the specified
description: Verified is a boolean indicating whether all the specified
signatures have been verified and are valid.
type: boolean
type: object
Expand Down
Loading
Loading