Skip to content

Commit

Permalink
omit snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhandamirov committed Mar 5, 2025
1 parent 422352b commit ff3bc7b
Show file tree
Hide file tree
Showing 42 changed files with 374 additions and 602 deletions.
9 changes: 0 additions & 9 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,4 @@ resources:
kind: Replication
path: github.com/open-component-model/ocm-k8s-toolkit/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: ocm.software
group: delivery
kind: Snapshot
path: github.com/open-component-model/ocm-k8s-toolkit/api/v1alpha1
version: v1alpha1
version: "3"
15 changes: 15 additions & 0 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,18 @@ type BlobInfo struct {
// Can be used to determine how to file should be handled when downloaded (memory/disk)
Size int64 `json:"size"`
}

// OCIArtifactInfo contains information on how to locate an OCI Artifact.
type OCIArtifactInfo struct {
// OCI repository name
// +required
Repository string `json:"repository"`

// Manifest digest (required to delete the manifest and prepare OCI artifact for GC)
// +required
Digest string `json:"digest"`

// Blob
// +required
Blob *BlobInfo `json:"blob"`
}
31 changes: 22 additions & 9 deletions api/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"time"

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

Expand Down Expand Up @@ -100,12 +99,6 @@ type ComponentStatus 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.
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`

// Component specifies the concrete version of the component that was
// fetched after based on the semver constraints during the last successful
// reconciliation.
Expand All @@ -117,6 +110,12 @@ type ComponentStatus struct {
// in the order the configuration data was applied.
// +optional
EffectiveOCMConfig []OCMConfiguration `json:"effectiveOCMConfig,omitempty"`

// OCIArtifact references the generated OCI artifact 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.
// +optional
OCIArtifact *OCIArtifactInfo `json:"ociArtifact,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -180,8 +179,22 @@ func (in *Component) GetVerifications() []Verification {
return in.Spec.Verify
}

func (in *Component) GetSnapshotName() string {
return in.Status.SnapshotRef.Name
// GetOCIRepository returns the name of the OCI repository of the OCI artifact in which the component
// descriptors are stored.
func (in *Component) GetOCIRepository() string {
return in.Status.OCIArtifact.Repository
}

// GetManifestDigest returns the manifest digest of the OCI artifact, in which the component descriptors
// are stored.
func (in *Component) GetManifestDigest() string {
return in.Status.OCIArtifact.Digest
}

// GetBlobDigest returns the blob digest of the OCI artifact, in which the component descriptors
// are stored.
func (in *Component) GetBlobDigest() string {
return in.Status.OCIArtifact.Blob.Digest
}

// +kubebuilder:object:root=true
Expand Down
11 changes: 3 additions & 8 deletions api/v1alpha1/configuredresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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 @@ -91,10 +90,10 @@ type ConfiguredResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

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

// +kubebuilder:object:root=true
Expand All @@ -109,10 +108,6 @@ 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
4 changes: 2 additions & 2 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const (

// Finalizers for controllers.
const (
// SnapshotFinalizer is the finalizter that is added to snapshot created by the ocm controllers.
SnapshotFinalizer = "finalizers.ocm.software/snapshot"
// ArtifactFinalizer is the finalizer that is added to an object that handles the lifecycle of an artifact created by the ocm controllers.
ArtifactFinalizer = "finalizers.ocm.software/artifact"
)

// OCI related constants.
Expand Down
14 changes: 5 additions & 9 deletions api/v1alpha1/localizedresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1alpha1
import (
"fmt"

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

Expand Down Expand Up @@ -74,10 +73,6 @@ 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 @@ -96,15 +91,16 @@ type LocalizedResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// The LocalizedResource reports an SnapshotRef which contains the content of the Resource after Localization
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`
// The OCIArtifact contains the information where to find the OCI artifact which contains
// the content of the Resource after Localization
OCIArtifact *OCIArtifactInfo `json:"ociArtifact,omitempty"`

// The LocalizedResource reports a ConfiguredResourceRef which contains a reference to the ConfiguredResource
// that is responsible for generating the SnapshotRef.
// that is responsible for generating the OCI artifact.
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 SnapshotRef.
// and is used to setup the ConfiguredResource responsible for generating the OCI artifact.
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,10 +62,10 @@ type ResourceStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// SnapshotRef points to the Snapshot which represents the output of the
// OCIArtifact points to the OCI artifact which represents the output of the
// last successful Resource sync.
// +optional
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`
OCIArtifact *OCIArtifactInfo `json:"ociArtifact,omitempty"`

// +optional
Resource *ResourceInfo `json:"resource,omitempty"`
Expand Down Expand Up @@ -131,10 +131,6 @@ func (in *Resource) GetEffectiveOCMConfig() []OCMConfiguration {
return in.Status.EffectiveOCMConfig
}

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

// +kubebuilder:object:root=true

// ResourceList contains a list of Resource.
Expand Down
101 changes: 0 additions & 101 deletions api/v1alpha1/snapshot_types.go

This file was deleted.

Loading

0 comments on commit ff3bc7b

Please sign in to comment.