Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frewilhelm committed Feb 14, 2025
1 parent db59c21 commit ac6759c
Show file tree
Hide file tree
Showing 55 changed files with 1,888 additions and 1,430 deletions.
1 change: 0 additions & 1 deletion api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ type ResourceInfo struct {

type BlobInfo struct {
// Digest is the digest of the blob in the form of '<algorithm>:<checksum>'.
// +kubebuilder:validation:Pattern="^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
Digest string `json:"digest"`

// Tag/Version of the blob
Expand Down
3 changes: 0 additions & 3 deletions api/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ type ComponentStatus struct {
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// TODO: Remove
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`

// Component specifies the concrete version of the component that was
// fetched after based on the semver constraints during the last successful
// reconciliation.
Expand Down
51 changes: 18 additions & 33 deletions api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@ limitations under the License.
package v1alpha1

const (
// SecretFetchFailedReason is used when the controller failed to fetch its secrets.
SecretFetchFailedReason = "SecretFetchFailed"

// ConfigFetchFailedReason is used when the controller failed to fetch its configs.
ConfigFetchFailedReason = "ConfigFetchFailed"

// VerificationsInvalidReason is used when the controller failed to gather the verification information.
VerificationsInvalidReason = "VerificationsInvalid"

// ConfigureContextFailedReason is used when the controller failed to create an authenticated context.
ConfigureContextFailedReason = "ConfigureContextFailed"

// CheckVersionFailedReason is used when the controller failed to check for new versions.
CheckVersionFailedReason = "CheckVersionFailed"

// RepositorySpecInvalidReason is used when the referenced repository spec cannot be unmarshaled and therefore is
// RepositorySpecInvalidReason is used when the referenced repository spec cannot be unmarshalled and therefore is
// invalid.
RepositorySpecInvalidReason = "RepositorySpecInvalid"

Expand All @@ -42,7 +36,7 @@ const (
// ComponentIsNotReadyReason is used when the referenced component is not Ready yet.
ComponentIsNotReadyReason = "ComponentIsNotReady"

// ComponentIsNotReadyReason is used when the referenced component is not Ready yet.
// ReplicationFailedReason is used when the referenced component is not Ready yet.
ReplicationFailedReason = "ReplicationFailed"

// VerificationFailedReason is used when the signature verification of a component failed.
Expand All @@ -57,30 +51,33 @@ const (
// GetComponentVersionFailedReason is used when the component cannot be fetched.
GetComponentVersionFailedReason = "GetComponentVersionFailed"

// StorageReconcileFailedReason is used when there was a problem reconciling the artifact storage.
StorageReconcileFailedReason = "StorageReconcileFailed"

// ReconcileArtifactFailedReason is used when we fail in creating an Artifact.
ReconcileArtifactFailedReason = "ReconcileArtifactFailed"

// MarshalFailedReason is used when we fail to marshal a struct.
MarshalFailedReason = "MarshalFailed"

// TGZCreationFailedReason is used when we fail to create a tar-gzip.
TGZCreationFailedReason = "TGZCreationFailed"

// CreateOCIRepositoryNameFailedReason is used when we fail to create an OCI repository name.
CreateOCIRepositoryNameFailedReason = "CreateOCIRepositoryNameFailed"

// CreateOCIRepositoryFailedReason is used when we fail to create a OCI repository.
// CreateOCIRepositoryFailedReason is used when we fail to create an OCI repository.
CreateOCIRepositoryFailedReason = "CreateOCIRepositoryFailed"

// OCIRepositoryExistsFailedReason is used when we fail to check the existence of an OCI repository.
OCIRepositoryExistsFailedReason = "OCIRepositoryExistsFailed"

// CreateSnapshotFailedReason is used when we fail to create a snapshot.
CreateSnapshotFailedReason = "CreateSnapshotFailed"

// GetArtifactFailedReason is used when we fail in getting an Artifact.
GetArtifactFailedReason = "GetArtifactFailed"

// GetSnapshotFailedReason is used when we fail in getting a Snapshot.
GetSnapshotFailedReason = "GetSnapshotFailed"

// SnapshotReadyFailedReason is used when the snapshot is not ready.
SnapshotReadyFailedReason = "SnapshotReadyFailed"

// PushSnapshotFailedReason is used when we fail to push a snapshot.
PushSnapshotFailedReason = "PushSnapshotFailed"

// ResolveResourceFailedReason is used when we fail in resolving a resource.
ResolveResourceFailedReason = "ResolveResourceFailed"

Expand All @@ -96,18 +93,6 @@ const (
// GetResourceFailedReason is used when we fail to get the resource.
GetResourceFailedReason = "GetResourceFailed"

// PushSnapshotFailedReason is used when we fail to push a snapshot.
PushSnapshotFailedReason = "PushSnapshotFailed"

// FetchSnapshotFailedReason is used when we fail to fetch a snapshot.
FetchSnapshotFailedReason = "FetchSnapshotFailed"

// DeleteSnapshotFailedReason is used when we fail to delete a snapshot.
DeleteSnapshotFailedReason = "DeleteSnapshotFailed"

// GetComponentForArtifactFailedReason is used when we fail in getting a component for an artifact.
GetComponentForArtifactFailedReason = "GetComponentForArtifactFailed"

// GetComponentForSnapshotFailedReason is used when we fail in getting a component for a snapshot.
GetComponentForSnapshotFailedReason = "GetComponentForSnapshotFailed"

Expand All @@ -120,14 +105,14 @@ const (
// ConfigurationFailedReason is used when a resource was not able to be configured.
ConfigurationFailedReason = "ConfigurationFailed"

// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an artifact.
// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an snapshot.
LocalizationRuleGenerationFailedReason = "LocalizationRuleGenerationFailed"

// LocalizationIsNotReadyReason is used when a controller is waiting to get the localization result.
LocalizationIsNotReadyReason = "LocalizationIsNotReady"

// UniqueIDGenerationFailedReason is used when the controller failed to generate a unique identifier for a pending artifact.
// This can happen if the artifact is based on multiple other sources but these sources could not be used
// UniqueIDGenerationFailedReason is used when the controller failed to generate a unique identifier for a pending snapshot.
// This can happen if the snapshot is based on multiple other sources but these sources could not be used
// to determine a unique identifier.
UniqueIDGenerationFailedReason = "UniqueIDGenerationFailed"

Expand Down
15 changes: 10 additions & 5 deletions api/v1alpha1/configuredresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/fluxcd/pkg/apis/meta"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -90,13 +91,13 @@ type ConfiguredResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// The configuration reconcile loop generates an artifact, which contains the
// The configuration reconcile loop generates a snapshot, which contains the
// ConfiguredResourceSpec.Target ConfigurationReference after configuration.
// It is filled once the Artifact is created and the configuration completed.
ArtifactRef *ObjectKey `json:"artifactRef,omitempty"`
// It is filled once the Snapshot is created and the configuration completed.
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// Digest contains a technical identifier for the artifact. This technical identifier
// can be used to track changes on the ArtifactRef as it is a combination of the origin
// Digest contains a technical identifier for the snapshot. This technical identifier
// can be used to track changes on the SnapshotRef as it is a combination of the origin
// ConfiguredResourceSpec.Config applied to the ConfiguredResourceSpec.Target.
Digest string `json:"digest,omitempty"`
}
Expand All @@ -113,6 +114,10 @@ type ConfiguredResource struct {
Status ConfiguredResourceStatus `json:"status,omitempty"`
}

func (in *ConfiguredResource) GetSnapshotName() string {
return in.Status.SnapshotRef.Name
}

// +kubebuilder:object:root=true

// ConfiguredResourceList contains a list of ConfiguredResource.
Expand Down
12 changes: 2 additions & 10 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const (
OCMConfigKey = ".ocmconfig"
// OCMLabelDowngradable defines the secret.
OCMLabelDowngradable = "ocm.software/ocm-k8s-toolkit/downgradable"
// OCMComponentDescriptorList defines the file name of the component descriptor list exposed as artifact by the
// component controller.
OCMComponentDescriptorList = "component-descriptor-list.yaml"
)

// Log levels.
Expand All @@ -37,16 +34,11 @@ const (

// Finalizers for controllers.
const (
// TODO: Remove ArtifactFinalizer.

// ArtifactFinalizer is the finalizer that is added to artifacts created by the ocm controllers.
ArtifactFinalizer = "finalizers.ocm.software/artifact"

// SnapshotFinalizer is the finalizter that is added to snapshot created by the ocm controllers.
SnapshotFinalizer = "finalizers.ocm.software/snapshot"
)

// External CRDs.
// OCI Schema.
const (
ArtifactCrd = "https://github.com/openfluxcd/artifact/releases/download/v0.1.1/openfluxcd.ocm.software_artifacts.yaml"
OCISchemaVersion = 2
)
13 changes: 9 additions & 4 deletions api/v1alpha1/localizedresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1alpha1
import (
"fmt"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -73,6 +74,10 @@ func (in *LocalizedResource) SetTarget(v *ConfigurationReference) {
v.DeepCopyInto(&in.Spec.Target)
}

func (in *LocalizedResource) GetSnapshotName() string {
return in.Status.SnapshotRef.Name
}

type LocalizedResourceSpec struct {
// Target that is to be localized
Target ConfigurationReference `json:"target"`
Expand All @@ -91,15 +96,15 @@ type LocalizedResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// The LocalizedResource reports an ArtifactRef which contains the content of the Resource after Localization
ArtifactRef *ObjectKey `json:"artifactRef,omitempty"`
// The LocalizedResource reports an SnapshotRef which contains the content of the Resource after Localization
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// The LocalizedResource reports a ConfiguredResourceRef which contains a reference to the ConfiguredResource
// that is responsible for generating the ArtifactRef.
// that is responsible for generating the SnapshotRef.
ConfiguredResourceRef *ObjectKey `json:"configuredResourceRef,omitempty"`

// ConfigRef is a reference to the Configuration that was generated by the Localization process
// and is used to setup the ConfiguredResource responsible for generating the ArtifactRef.
// and is used to setup the ConfiguredResource responsible for generating the SnapshotRef.
ConfigRef *ObjectKey `json:"configRef,omitempty"`

// A unique digest of the combination of the config and target resources applied through a LocalizationStrategy
Expand Down
8 changes: 2 additions & 6 deletions api/v1alpha1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,11 @@ type ResourceStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// SnapshotRef references the generated snapshot containing a list of
// component descriptors. This list can be used by other controllers to
// avoid re-downloading (and potentially also re-verifying) the components.
// SnapshotRef points to the Snapshot which represents the output of the
// last successful Resource sync.
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// TODO: Remove
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`

// +optional
Resource *ResourceInfo `json:"resource,omitempty"`

Expand Down
17 changes: 5 additions & 12 deletions api/v1alpha1/snapshot_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1alpha1

import (
"fmt"

"sigs.k8s.io/controller-runtime/pkg/client"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -12,8 +14,6 @@ type SnapshotWriter interface {
client.Object
GetSnapshotName() string
GetKind() string
GetNamespace() string
GetName() string
}

// SnapshotSpec defines the desired state of Snapshot.
Expand All @@ -28,7 +28,7 @@ type SnapshotSpec struct {

// Blob
// +required
Blob BlobInfo `json:"blob"`
Blob *BlobInfo `json:"blob"`

// Suspend stops all operations on this object.
// +optional
Expand All @@ -40,22 +40,15 @@ type SnapshotStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Digest is calculated by the caching layer.
// +optional
LastReconciledDigest string `json:"digest,omitempty"`

// Tag defines the explicit tag that was used to create the related snapshot and cache entry.
// +optional
LastReconciledTag string `json:"tag,omitempty"`

// ObservedGeneration is the last reconciled generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

func (in *Snapshot) GetVID() map[string]string {
vid := fmt.Sprintf("%s:%s", in.GetNamespace(), in.GetName())
metadata := make(map[string]string)
metadata[GroupVersion.Group+"/snapshot_digest"] = in.Status.LastReconciledDigest
metadata[GroupVersion.Group+"/snapshot_version"] = vid

return metadata
}
Expand Down
22 changes: 8 additions & 14 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ac6759c

Please sign in to comment.