Skip to content

Commit

Permalink
omit snapshot 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhandamirov committed Mar 6, 2025
1 parent c094a6b commit 8ab05b5
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 376 deletions.
10 changes: 5 additions & 5 deletions api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const (
// MarshalFailedReason is used when we fail to marshal a struct.
MarshalFailedReason = "MarshalFailed"

// YamlToJsonDecodeFailedReason is used when we fail to decode yaml to json.
YamlToJsonDecodeFailedReason = "YamlToJsonDecodeFailed"
// YamlToJSONDecodeFailedReason is used when we fail to decode yaml to json.
YamlToJSONDecodeFailedReason = "YamlToJsonDecodeFailed"

// CreateOCIRepositoryNameFailedReason is used when we fail to create an OCI repository name.
CreateOCIRepositoryNameFailedReason = "CreateOCIRepositoryNameFailed"
Expand Down Expand Up @@ -105,14 +105,14 @@ const (
// CreateTGZFailedReason is used when a TGZ creation failed.
CreateTGZFailedReason = "CreateTGZFailed"

// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an snapshot.
// LocalizationRuleGenerationFailedReason is used when the controller failed to localize an OCI artifact.
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 snapshot.
// This can happen if the snapshot 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 OCI artifact.
// This can happen if the OCI artifact is based on multiple other sources but these sources could not be used
// to determine a unique identifier.
UniqueIDGenerationFailedReason = "UniqueIDGenerationFailed"

Expand Down
22 changes: 22 additions & 0 deletions api/v1alpha1/configuredresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ func (in *ConfiguredResource) SetTarget(v *ConfigurationReference) {
v.DeepCopyInto(&in.Spec.Target)
}

func (in *ConfiguredResource) GetOCIArtifact() *OCIArtifactInfo {
return in.Status.OCIArtifact
}

// GetOCIRepository returns the name of the OCI repository of the OCI artifact in which the component
// descriptors are stored.
func (in *ConfiguredResource) 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 *ConfiguredResource) 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 *ConfiguredResource) GetBlobDigest() string {
return in.Status.OCIArtifact.Blob.Digest
}

// ConfiguredResourceStatus defines the observed state of ConfiguredResource.
type ConfiguredResourceStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
22 changes: 22 additions & 0 deletions api/v1alpha1/localizedresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ func (in *LocalizedResource) SetTarget(v *ConfigurationReference) {
v.DeepCopyInto(&in.Spec.Target)
}

func (in *LocalizedResource) GetOCIArtifact() *OCIArtifactInfo {
return in.Status.OCIArtifact
}

// GetOCIRepository returns the name of the OCI repository of the OCI artifact in which the component
// descriptors are stored.
func (in *LocalizedResource) 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 *LocalizedResource) 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 *LocalizedResource) GetBlobDigest() string {
return in.Status.OCIArtifact.Blob.Digest
}

type LocalizedResourceSpec struct {
// Target that is to be localized
Target ConfigurationReference `json:"target"`
Expand Down
17 changes: 2 additions & 15 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ import (
"github.com/open-component-model/ocm-k8s-toolkit/internal/controller/ocmrepository"
"github.com/open-component-model/ocm-k8s-toolkit/internal/controller/replication"
"github.com/open-component-model/ocm-k8s-toolkit/internal/controller/resource"
"github.com/open-component-model/ocm-k8s-toolkit/internal/controller/snapshot"
snapshotRegistry "github.com/open-component-model/ocm-k8s-toolkit/pkg/ociartifact"
"github.com/open-component-model/ocm-k8s-toolkit/pkg/ociartifact"
"github.com/open-component-model/ocm-k8s-toolkit/pkg/ocm"
)

Expand Down Expand Up @@ -162,7 +161,7 @@ func main() {
os.Exit(1)
}

registry, err := snapshotRegistry.NewRegistry(registryAddr)
registry, err := ociartifact.NewRegistry(registryAddr)
registry.PlainHTTP = true
if err != nil {
setupLog.Error(err, "unable to initialize registry object")
Expand Down Expand Up @@ -235,18 +234,6 @@ func main() {
os.Exit(1)
}

if err = (&snapshot.Reconciler{
BaseReconciler: &ocm.BaseReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
EventRecorder: eventsRecorder,
},
Registry: registry,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Snapshot")
os.Exit(1)
}

// +kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
154 changes: 0 additions & 154 deletions config/crd/bases/delivery.ocm.software_snapshots.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ resources:
- bases/delivery.ocm.software_localizedresources.yaml
- bases/delivery.ocm.software_configuredresources.yaml
- bases/delivery.ocm.software_resourceconfigs.yaml
- bases/delivery.ocm.software_snapshots.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patches:
# patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
# +kubebuilder:scaffold:crdkustomizewebhookpatch
Expand Down
2 changes: 0 additions & 2 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ resources:
# default, aiding admins in cluster management. Those roles are
# not used by the Project itself. You can comment the following lines
# if you do not want those helpers be installed with your Project.
- snapshot_editor_role.yaml
- snapshot_viewer_role.yaml
- replication_editor_role.yaml
- replication_viewer_role.yaml
- configuredresource_editor_role.yaml
Expand Down
3 changes: 0 additions & 3 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ rules:
- ocmrepositories
- replications
- resources
- snapshots
verbs:
- create
- delete
Expand All @@ -53,7 +52,6 @@ rules:
- localizedresources/finalizers
- ocmrepositories/finalizers
- replications/finalizers
- snapshots/finalizers
verbs:
- update
- apiGroups:
Expand All @@ -65,7 +63,6 @@ rules:
- ocmrepositories/status
- replications/status
- resources/status
- snapshots/status
verbs:
- get
- patch
Expand Down
27 changes: 0 additions & 27 deletions config/rbac/snapshot_editor_role.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions config/rbac/snapshot_viewer_role.yaml

This file was deleted.

1 change: 0 additions & 1 deletion config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ resources:
- delivery_v1alpha1_component.yaml
- delivery_v1alpha1_resource.yaml
- delivery_v1alpha1_replication.yaml
- delivery_v1alpha1_snapshot.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
1 change: 1 addition & 0 deletions internal/controller/component/component_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (r *Reconciler) reconcileExists(ctx context.Context, component *v1alpha1.Co
}

logger.Info("component is being deleted and cannot be used", "name", component.Name)

return ctrl.Result{Requeue: true}, nil
}

Expand Down
Loading

0 comments on commit 8ab05b5

Please sign in to comment.