From 77edda32634abebb681d2b28135be227fae4cf6f Mon Sep 17 00:00:00 2001 From: Juan Jose Medina Godoy Date: Mon, 26 Feb 2024 10:10:46 +0100 Subject: [PATCH] Support skipping artifacts synchronization --- README.md | 39 ++++++++++ api/config.pb.go | 115 ++++++++++++++++------------- api/config.proto | 3 + cmd/sync.go | 1 + pkg/client/config/config.go | 8 ++ pkg/client/source/common/common.go | 4 +- pkg/syncer/sync.go | 3 +- pkg/syncer/syncer.go | 10 +++ 8 files changed, 129 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 6d1512f..56ef4fb 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Sync chart packages and associated container images between chart repositories + [Sync all charts](#sync-all-helm-charts) + [Sync all charts from specific date](#sync-all-charts-from-specific-date) - [Advanced Usage](#advanced-usage) + + [Skip syncing artifacts](#skip-syncing-artifacts) + [Sync only specific container platforms](#sync-only-specific-container-platforms) + [Sync Helm Charts and Container Images to different registries](#sync-helm-charts-and-container-images-to-different-registries) + [Sync charts between repositories without direct connectivity](#sync-charts-between-repositories-without-direct-connectivity) @@ -75,6 +76,44 @@ charts: - mariadb ``` +### Skip syncing artifacts + +If your chart and docker images include artifacts such as signatures or metadata, they will be synced to the destination repository. If you want to disable this behavior, you can opt out by setting `skipArtifacts` to true: + +```yaml +source: + repo: + kind: OCI + url: http://localhost:8080 +target: + repo: + kind: OCI + url: http://localhost:9090/charts +charts: + - redis + +skipArtifacts: true +``` + +This is especially useful when you filter the container platforms to sync, which would invalidate the signatures. Using `skipArtifacts: true` will prevent syncing the now invalid signatures: + +```yaml +source: + repo: + kind: OCI + url: http://localhost:8080 +target: + repo: + kind: OCI + url: http://localhost:9090/charts +charts: + - redis +skipArtifacts: true +containerPlatforms: + - linux/amd64 +``` + + ### Sync Helm Charts and Container Images to different registries By default, charts-syncer syncs Helm Charts packages and their container images to the same registry specified in the `target.repo.url` property. If you require to configure a different destination registry for the images, this can be configured in the `target.containers.url` property: diff --git a/api/config.pb.go b/api/config.pb.go index 1e976aa..c60a31b 100644 --- a/api/config.pb.go +++ b/api/config.pb.go @@ -92,6 +92,8 @@ type Config struct { ContainerPlatforms []string `protobuf:"bytes,4,rep,name=container_platforms,json=containerPlatforms,proto3" json:"container_platforms,omitempty"` // Opposite of charts property. It indicates the list of charts to skip during sync SkipCharts []string `protobuf:"bytes,5,rep,name=skip_charts,json=skipCharts,proto3" json:"skip_charts,omitempty"` + // Do not sync chart and container artifacts (signatures and metadata) + SkipArtifacts bool `protobuf:"varint,6,opt,name=skip_artifacts,json=skipArtifacts,proto3" json:"skip_artifacts,omitempty"` } func (x *Config) Reset() { @@ -161,6 +163,13 @@ func (x *Config) GetSkipCharts() []string { return nil } +func (x *Config) GetSkipArtifacts() bool { + if x != nil { + return x.SkipArtifacts + } + return false +} + // SourceRepo contains the required information of the source chart repository type Source struct { state protoimpl.MessageState @@ -557,7 +566,7 @@ var File_config_proto protoreflect.FileDescriptor var file_config_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, - 0x61, 0x70, 0x69, 0x22, 0xbc, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, + 0x61, 0x70, 0x69, 0x22, 0xe3, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, @@ -569,57 +578,59 @@ var file_config_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6b, 0x69, 0x70, 0x43, 0x68, 0x61, 0x72, - 0x74, 0x73, 0x22, 0x58, 0x0a, 0x06, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x04, - 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x2f, 0x0a, 0x0a, 0x63, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, - 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x22, 0xb6, 0x01, 0x0a, - 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x04, 0x61, - 0x75, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 0x1a, 0x63, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x41, 0x75, 0x74, - 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x22, 0x58, 0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, - 0x1d, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x2f, - 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, - 0x65, 0x72, 0x73, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x22, - 0xed, 0x01, 0x0a, 0x04, 0x52, 0x65, 0x70, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x04, 0x6b, 0x69, - 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4b, - 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x61, 0x75, 0x74, - 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, - 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, - 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, - 0x2c, 0x0a, 0x10, 0x75, 0x73, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x75, - 0x73, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x30, 0x0a, - 0x14, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x5f, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x64, 0x69, 0x73, - 0x61, 0x62, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, - 0x3e, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2a, - 0x4e, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, - 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x45, 0x4c, 0x4d, 0x10, 0x01, 0x12, 0x0f, - 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x52, 0x54, 0x4d, 0x55, 0x53, 0x45, 0x55, 0x4d, 0x10, 0x02, 0x12, - 0x0a, 0x0a, 0x06, 0x48, 0x41, 0x52, 0x42, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x4f, - 0x43, 0x49, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x10, 0x05, 0x42, - 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x69, - 0x74, 0x6e, 0x61, 0x6d, 0x69, 0x2f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x2d, 0x73, 0x79, 0x6e, - 0x63, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x61, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x73, 0x6b, 0x69, 0x70, + 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x73, 0x22, 0x58, 0x0a, 0x06, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x52, 0x04, 0x72, 0x65, + 0x70, 0x6f, 0x12, 0x2f, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x73, 0x12, 0x31, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, + 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x52, + 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x1a, 0x63, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x22, 0x58, 0x0a, 0x06, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x52, + 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x2f, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x22, 0xed, 0x01, 0x0a, 0x04, 0x52, 0x65, 0x70, 0x6f, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, + 0x6c, 0x12, 0x1d, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, + 0x12, 0x1d, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, + 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61, 0x72, 0x74, + 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x2c, 0x0a, 0x10, 0x75, 0x73, 0x65, 0x5f, 0x63, 0x68, + 0x61, 0x72, 0x74, 0x73, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x75, 0x73, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x73, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x63, 0x68, 0x61, 0x72, 0x74, 0x73, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x12, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, + 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x3e, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x1a, + 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x2a, 0x4e, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, + 0x45, 0x4c, 0x4d, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x52, 0x54, 0x4d, 0x55, + 0x53, 0x45, 0x55, 0x4d, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x48, 0x41, 0x52, 0x42, 0x4f, 0x52, + 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x49, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x4c, + 0x4f, 0x43, 0x41, 0x4c, 0x10, 0x05, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x69, 0x74, 0x6e, 0x61, 0x6d, 0x69, 0x2f, 0x63, 0x68, 0x61, + 0x72, 0x74, 0x73, 0x2d, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, + 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/config.proto b/api/config.proto index ec46a89..4e22101 100644 --- a/api/config.proto +++ b/api/config.proto @@ -13,6 +13,9 @@ message Config { repeated string container_platforms = 4; // Opposite of charts property. It indicates the list of charts to skip during sync repeated string skip_charts = 5; + // Do not sync chart and container artifacts (signatures and metadata) + bool skip_artifacts = 6; + } // SourceRepo contains the required information of the source chart repository diff --git a/cmd/sync.go b/cmd/sync.go index 8d5c63c..d622791 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -106,6 +106,7 @@ func newSyncCmd() *cobra.Command { syncer.WithContainerPlatforms(c.GetContainerPlatforms()), syncer.WithInsecure(rootInsecure), syncer.WithLatestVersionOnly(syncLatestVersionOnly), + syncer.WithSkipArtifacts(c.GetSkipArtifacts()), syncer.WithSkipCharts(c.SkipCharts), syncer.WithUsePlainHTTP(usePlainHTTP), syncer.WithLogger(l), diff --git a/pkg/client/config/config.go b/pkg/client/config/config.go index 76dfd9a..7b07102 100644 --- a/pkg/client/config/config.go +++ b/pkg/client/config/config.go @@ -11,6 +11,7 @@ type Config struct { Logger log.SectionLogger WorkDir string ContainerPlatforms []string + SkipArtifacts bool } // Option is a function that modifies the Config @@ -23,6 +24,13 @@ func WithWorkDir(workdir string) func(*Config) { } } +// WithSkipArtifacts sets the skip artifacts flag +func WithSkipArtifacts(skipArtifacts bool) func(*Config) { + return func(c *Config) { + c.SkipArtifacts = skipArtifacts + } +} + // WithContainerPlatforms sets the container platforms to sync func WithContainerPlatforms(containerPlatforms []string) func(*Config) { return func(c *Config) { diff --git a/pkg/client/source/common/common.go b/pkg/client/source/common/common.go index 23dfdea..466dda5 100644 --- a/pkg/client/source/common/common.go +++ b/pkg/client/source/common/common.go @@ -50,7 +50,9 @@ func (t *Source) Wrap(tgz, destWrap string, opts ...config.Option) (string, erro } defer os.RemoveAll(wrapWorkdir) - outputFile, err := wrap.Chart(tgz, wrap.WithFetchArtifacts(true), + fetchArtifacts := !cfg.SkipArtifacts + + outputFile, err := wrap.Chart(tgz, wrap.WithFetchArtifacts(fetchArtifacts), wrap.WithInsecure(t.insecure), wrap.WithTempDirectory(wrapWorkdir), wrap.WithAuth(t.username, t.password), wrap.WithPlatforms(cfg.ContainerPlatforms), diff --git a/pkg/syncer/sync.go b/pkg/syncer/sync.go index 20233f0..058b9ca 100644 --- a/pkg/syncer/sync.go +++ b/pkg/syncer/sync.go @@ -43,7 +43,8 @@ func (s *Syncer) syncChart(ch *Chart, l log.SectionLogger) error { wrappedChartPath, err := s.cli.src.Wrap(ch.TgzPath, filepath.Join(workdir, "wraps", fmt.Sprintf("%s-%s.wrap.tgz", ch.Name, ch.Version)), - config.WithLogger(l), config.WithWorkDir(workdir), config.WithContainerPlatforms(s.containerPlatforms), + config.WithLogger(l), config.WithWorkDir(workdir), + config.WithContainerPlatforms(s.containerPlatforms), config.WithSkipArtifacts(s.skipArtifacts), ) if err != nil { return errors.Annotatef(err, "unable to move chart %q with charts-syncer", id) diff --git a/pkg/syncer/syncer.go b/pkg/syncer/syncer.go index 577b8ed..97de82b 100644 --- a/pkg/syncer/syncer.go +++ b/pkg/syncer/syncer.go @@ -45,6 +45,9 @@ type Syncer struct { // up re-runs index ChartIndex + // skip syncing artifacts + skipArtifacts bool + // Storage directory for required artifacts workdir string @@ -91,6 +94,13 @@ func WithUsePlainHTTP(enable bool) Option { } } +// WithSkipArtifacts configures the syncer to skip syncing artifacts +func WithSkipArtifacts(skip bool) Option { + return func(s *Syncer) { + s.skipArtifacts = skip + } +} + // WithWorkdir configures the syncer to store artifacts in a specific directory. func WithWorkdir(dir string) Option { return func(s *Syncer) {