Skip to content

Commit 8bc36bc

Browse files
authored
Merge pull request #913 from fluxcd/oci-copy-layer
[OCIRepository] Optimise OCI artifacts reconciliation
2 parents 9c6dc33 + 3f7d463 commit 8bc36bc

File tree

6 files changed

+298
-172
lines changed

6 files changed

+298
-172
lines changed

api/v1beta2/ocirepository_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const (
4545
// AzureOCIProvider provides support for OCI authentication using a Azure Service Principal,
4646
// Managed Identity or Shared Key.
4747
AzureOCIProvider string = "azure"
48+
49+
// OCILayerExtract defines the operation type for extracting the content from an OCI artifact layer.
50+
OCILayerExtract = "extract"
51+
52+
// OCILayerCopy defines the operation type for copying the content from an OCI artifact layer.
53+
OCILayerCopy = "copy"
4854
)
4955

5056
// OCIRepositorySpec defines the desired state of OCIRepository
@@ -156,6 +162,14 @@ type OCILayerSelector struct {
156162
// first layer matching this type is selected.
157163
// +optional
158164
MediaType string `json:"mediaType,omitempty"`
165+
166+
// Operation specifies how the selected layer should be processed.
167+
// By default, the layer compressed content is extracted to storage.
168+
// When the operation is set to 'copy', the layer compressed content
169+
// is persisted to storage as it is.
170+
// +kubebuilder:validation:Enum=extract;copy
171+
// +optional
172+
Operation string `json:"operation,omitempty"`
159173
}
160174

161175
// OCIRepositoryVerification verifies the authenticity of an OCI Artifact
@@ -231,6 +245,15 @@ func (in *OCIRepository) GetLayerMediaType() string {
231245
return in.Spec.LayerSelector.MediaType
232246
}
233247

248+
// GetLayerOperation returns the layer selector operation (defaults to extract).
249+
func (in *OCIRepository) GetLayerOperation() string {
250+
if in.Spec.LayerSelector == nil || in.Spec.LayerSelector.Operation == "" {
251+
return OCILayerExtract
252+
}
253+
254+
return in.Spec.LayerSelector.Operation
255+
}
256+
234257
// +genclient
235258
// +genclient:Namespaced
236259
// +kubebuilder:storageversion

config/crd/bases/source.toolkit.fluxcd.io_ocirepositories.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ spec:
9090
which should be extracted from the OCI Artifact. The first layer
9191
matching this type is selected.
9292
type: string
93+
operation:
94+
description: Operation specifies how the selected layer should
95+
be processed. By default, the layer compressed content is extracted
96+
to storage. When the operation is set to 'copy', the layer compressed
97+
content is persisted to storage as it is.
98+
enum:
99+
- extract
100+
- copy
101+
type: string
93102
type: object
94103
provider:
95104
default: generic

0 commit comments

Comments
 (0)