Skip to content

Commit 2a83a21

Browse files
committed
wip
1 parent 09609e1 commit 2a83a21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1787
-1489
lines changed

api/v1alpha1/common_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ type ResourceInfo struct {
116116

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

122121
// Tag/Version of the blob

api/v1alpha1/component_types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ type ComponentStatus struct {
106106
// +optional
107107
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`
108108

109-
// TODO: Remove
110-
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`
111-
112109
// Component specifies the concrete version of the component that was
113110
// fetched after based on the semver constraints during the last successful
114111
// reconciliation.

api/v1alpha1/condition_types.go

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ limitations under the License.
1717
package v1alpha1
1818

1919
const (
20-
// SecretFetchFailedReason is used when the controller failed to fetch its secrets.
21-
SecretFetchFailedReason = "SecretFetchFailed"
22-
2320
// ConfigFetchFailedReason is used when the controller failed to fetch its configs.
2421
ConfigFetchFailedReason = "ConfigFetchFailed"
2522

26-
// VerificationsInvalidReason is used when the controller failed to gather the verification information.
27-
VerificationsInvalidReason = "VerificationsInvalid"
28-
2923
// ConfigureContextFailedReason is used when the controller failed to create an authenticated context.
3024
ConfigureContextFailedReason = "ConfigureContextFailed"
3125

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

35-
// RepositorySpecInvalidReason is used when the referenced repository spec cannot be unmarshaled and therefore is
29+
// RepositorySpecInvalidReason is used when the referenced repository spec cannot be unmarshalled and therefore is
3630
// invalid.
3731
RepositorySpecInvalidReason = "RepositorySpecInvalid"
3832

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

45-
// ComponentIsNotReadyReason is used when the referenced component is not Ready yet.
39+
// ReplicationFailedReason is used when the referenced component is not Ready yet.
4640
ReplicationFailedReason = "ReplicationFailed"
4741

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

60-
// StorageReconcileFailedReason is used when there was a problem reconciling the artifact storage.
61-
StorageReconcileFailedReason = "StorageReconcileFailed"
62-
63-
// ReconcileArtifactFailedReason is used when we fail in creating an Artifact.
64-
ReconcileArtifactFailedReason = "ReconcileArtifactFailed"
65-
6654
// MarshalFailedReason is used when we fail to marshal a struct.
6755
MarshalFailedReason = "MarshalFailed"
6856

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

72-
// CreateOCIRepositoryFailedReason is used when we fail to create a OCI repository.
60+
// CreateOCIRepositoryFailedReason is used when we fail to create an OCI repository.
7361
CreateOCIRepositoryFailedReason = "CreateOCIRepositoryFailed"
7462

63+
// OCIRepositoryExistsFailedReason is used when we fail to check the existence of an OCI repository.
64+
OCIRepositoryExistsFailedReason = "OCIRepositoryExistsFailed"
65+
7566
// CreateSnapshotFailedReason is used when we fail to create a snapshot.
7667
CreateSnapshotFailedReason = "CreateSnapshotFailed"
7768

78-
// GetArtifactFailedReason is used when we fail in getting an Artifact.
79-
GetArtifactFailedReason = "GetArtifactFailed"
80-
8169
// GetSnapshotFailedReason is used when we fail in getting a Snapshot.
8270
GetSnapshotFailedReason = "GetSnapshotFailed"
8371

72+
// SnapshotReadyFailedReason is used when the snapshot is not ready.
73+
SnapshotReadyFailedReason = "SnapshotReadyFailed"
74+
75+
// PushSnapshotFailedReason is used when we fail to push a snapshot.
76+
PushSnapshotFailedReason = "PushSnapshotFailed"
77+
8478
// ResolveResourceFailedReason is used when we fail in resolving a resource.
8579
ResolveResourceFailedReason = "ResolveResourceFailed"
8680

@@ -96,18 +90,6 @@ const (
9690
// GetResourceFailedReason is used when we fail to get the resource.
9791
GetResourceFailedReason = "GetResourceFailed"
9892

99-
// PushSnapshotFailedReason is used when we fail to push a snapshot.
100-
PushSnapshotFailedReason = "PushSnapshotFailed"
101-
102-
// FetchSnapshotFailedReason is used when we fail to fetch a snapshot.
103-
FetchSnapshotFailedReason = "FetchSnapshotFailed"
104-
105-
// DeleteSnapshotFailedReason is used when we fail to delete a snapshot.
106-
DeleteSnapshotFailedReason = "DeleteSnapshotFailed"
107-
108-
// GetComponentForArtifactFailedReason is used when we fail in getting a component for an artifact.
109-
GetComponentForArtifactFailedReason = "GetComponentForArtifactFailed"
110-
11193
// GetComponentForSnapshotFailedReason is used when we fail in getting a component for a snapshot.
11294
GetComponentForSnapshotFailedReason = "GetComponentForSnapshotFailed"
11395

@@ -120,14 +102,17 @@ const (
120102
// ConfigurationFailedReason is used when a resource was not able to be configured.
121103
ConfigurationFailedReason = "ConfigurationFailed"
122104

123-
// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an artifact.
105+
// CreateTGZFailedReason is used when a TGZ creation failed.
106+
CreateTGZFailedReason = "CreateTGZFailed"
107+
108+
// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an snapshot.
124109
LocalizationRuleGenerationFailedReason = "LocalizationRuleGenerationFailed"
125110

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

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

api/v1alpha1/configuredresource_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

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

24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
)
2627

@@ -90,15 +91,10 @@ type ConfiguredResourceStatus struct {
9091
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
9192
Conditions []metav1.Condition `json:"conditions,omitempty"`
9293

93-
// The configuration reconcile loop generates an artifact, which contains the
94+
// The configuration reconcile loop generates a snapshot, which contains the
9495
// ConfiguredResourceSpec.Target ConfigurationReference after configuration.
95-
// It is filled once the Artifact is created and the configuration completed.
96-
ArtifactRef *ObjectKey `json:"artifactRef,omitempty"`
97-
98-
// Digest contains a technical identifier for the artifact. This technical identifier
99-
// can be used to track changes on the ArtifactRef as it is a combination of the origin
100-
// ConfiguredResourceSpec.Config applied to the ConfiguredResourceSpec.Target.
101-
Digest string `json:"digest,omitempty"`
96+
// It is filled once the Snapshot is created and the configuration completed.
97+
SnapshotRef corev1.LocalObjectReference `json:"snapshotRef,omitempty"`
10298
}
10399

104100
// +kubebuilder:object:root=true
@@ -113,6 +109,10 @@ type ConfiguredResource struct {
113109
Status ConfiguredResourceStatus `json:"status,omitempty"`
114110
}
115111

112+
func (in *ConfiguredResource) GetSnapshotName() string {
113+
return in.Status.SnapshotRef.Name
114+
}
115+
116116
// +kubebuilder:object:root=true
117117

118118
// ConfiguredResourceList contains a list of ConfiguredResource.

api/v1alpha1/constants.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const (
2424
OCMConfigKey = ".ocmconfig"
2525
// OCMLabelDowngradable defines the secret.
2626
OCMLabelDowngradable = "ocm.software/ocm-k8s-toolkit/downgradable"
27-
// OCMComponentDescriptorList defines the file name of the component descriptor list exposed as artifact by the
28-
// component controller.
29-
OCMComponentDescriptorList = "component-descriptor-list.yaml"
3027
)
3128

3229
// Log levels.
@@ -37,16 +34,11 @@ const (
3734

3835
// Finalizers for controllers.
3936
const (
40-
// TODO: Remove ArtifactFinalizer.
41-
42-
// ArtifactFinalizer is the finalizer that is added to artifacts created by the ocm controllers.
43-
ArtifactFinalizer = "finalizers.ocm.software/artifact"
44-
4537
// SnapshotFinalizer is the finalizter that is added to snapshot created by the ocm controllers.
4638
SnapshotFinalizer = "finalizers.ocm.software/snapshot"
4739
)
4840

49-
// External CRDs.
41+
// OCI Schema.
5042
const (
51-
ArtifactCrd = "https://github.com/openfluxcd/artifact/releases/download/v0.1.1/openfluxcd.ocm.software_artifacts.yaml"
43+
OCISchemaVersion = 2
5244
)

api/v1alpha1/localizedresource_types.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v1alpha1
33
import (
44
"fmt"
55

6+
corev1 "k8s.io/api/core/v1"
67
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
78
)
89

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

77+
func (in *LocalizedResource) GetSnapshotName() string {
78+
return in.Status.SnapshotRef.Name
79+
}
80+
7681
type LocalizedResourceSpec struct {
7782
// Target that is to be localized
7883
Target ConfigurationReference `json:"target"`
@@ -91,15 +96,15 @@ type LocalizedResourceStatus struct {
9196
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
9297
Conditions []metav1.Condition `json:"conditions,omitempty"`
9398

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

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

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

105110
// A unique digest of the combination of the config and target resources applied through a LocalizationStrategy

api/v1alpha1/resource_types.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,11 @@ type ResourceStatus struct {
6262
// +optional
6363
Conditions []metav1.Condition `json:"conditions,omitempty"`
6464

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

71-
// TODO: Remove
72-
ArtifactRef corev1.LocalObjectReference `json:"artifactRef,omitempty"`
73-
7470
// +optional
7571
Resource *ResourceInfo `json:"resource,omitempty"`
7672

api/v1alpha1/snapshot_types.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package v1alpha1
22

33
import (
4+
"fmt"
5+
46
"sigs.k8s.io/controller-runtime/pkg/client"
57

68
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -12,8 +14,6 @@ type SnapshotWriter interface {
1214
client.Object
1315
GetSnapshotName() string
1416
GetKind() string
15-
GetNamespace() string
16-
GetName() string
1717
}
1818

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

2929
// Blob
3030
// +required
31-
Blob BlobInfo `json:"blob"`
31+
Blob *BlobInfo `json:"blob"`
3232

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

43-
// Digest is calculated by the caching layer.
44-
// +optional
45-
LastReconciledDigest string `json:"digest,omitempty"`
46-
47-
// Tag defines the explicit tag that was used to create the related snapshot and cache entry.
48-
// +optional
49-
LastReconciledTag string `json:"tag,omitempty"`
50-
5143
// ObservedGeneration is the last reconciled generation.
5244
// +optional
5345
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
5446
}
5547

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

6053
return metadata
6154
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 8 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)