From 87591519f71684cd1bb2f3e076f713c973a70681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Wed, 8 Jul 2026 11:20:54 +0200 Subject: [PATCH 1/2] initial restructure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- ...container_utils_test.go => lister_test.go} | 0 .../{container_utils.go => local_lister.go} | 30 ------------ pkg/fn/runtime/regclient_lister.go | 49 +++++++++++++++++++ pkg/fn/runtime/runner.go | 14 ++++-- pkg/lib/runneroptions/runneroptions.go | 3 ++ 5 files changed, 62 insertions(+), 34 deletions(-) rename pkg/fn/runtime/{container_utils_test.go => lister_test.go} (100%) rename pkg/fn/runtime/{container_utils.go => local_lister.go} (61%) create mode 100644 pkg/fn/runtime/regclient_lister.go diff --git a/pkg/fn/runtime/container_utils_test.go b/pkg/fn/runtime/lister_test.go similarity index 100% rename from pkg/fn/runtime/container_utils_test.go rename to pkg/fn/runtime/lister_test.go diff --git a/pkg/fn/runtime/container_utils.go b/pkg/fn/runtime/local_lister.go similarity index 61% rename from pkg/fn/runtime/container_utils.go rename to pkg/fn/runtime/local_lister.go index 12f8f58c84..b262b7efc4 100644 --- a/pkg/fn/runtime/container_utils.go +++ b/pkg/fn/runtime/local_lister.go @@ -6,38 +6,8 @@ import ( "fmt" "os/exec" "strings" - - "github.com/regclient/regclient" - regclientref "github.com/regclient/regclient/types/ref" ) -// RegClientLister is a TagLister using the regclient module to list remote OCI tags. -type RegClientLister struct { - client *regclient.RegClient -} - -var _ TagLister = &RegClientLister{} - -func (l *RegClientLister) Name() string { - return "regclient" -} - -func (l *RegClientLister) List(ctx context.Context, image string) ([]string, error) { - ref, err := regclientref.New(image) - if err != nil { - return nil, err - } - - defer func() { _ = l.client.Close(ctx, ref) }() - - tagList, err := l.client.TagList(ctx, ref) - if err != nil { - return nil, err - } - - return tagList.GetTags() -} - // LocalLister is a TagLister using the given CLI tool to list local OCI tags type LocalLister struct { Binary string diff --git a/pkg/fn/runtime/regclient_lister.go b/pkg/fn/runtime/regclient_lister.go new file mode 100644 index 0000000000..cb7369205c --- /dev/null +++ b/pkg/fn/runtime/regclient_lister.go @@ -0,0 +1,49 @@ +// Copyright 2026 The kpt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +import ( + "context" + + "github.com/regclient/regclient" + ref2 "github.com/regclient/regclient/types/ref" +) + +// RegClientLister is a TagLister using the regclient module to list remote OCI tags. +type RegClientLister struct { + Client *regclient.RegClient +} + +var _ TagLister = &RegClientLister{} + +func (l *RegClientLister) Name() string { + return "regclient" +} + +func (l *RegClientLister) List(ctx context.Context, image string) ([]string, error) { + ref, err := ref2.New(image) + if err != nil { + return nil, err + } + + defer func() { _ = l.Client.Close(ctx, ref) }() + + tagList, err := l.Client.TagList(ctx, ref) + if err != nil { + return nil, err + } + + return tagList.GetTags() +} diff --git a/pkg/fn/runtime/runner.go b/pkg/fn/runtime/runner.go index d1a035de9d..60a0c63f32 100644 --- a/pkg/fn/runtime/runner.go +++ b/pkg/fn/runtime/runner.go @@ -60,12 +60,18 @@ func NewRunner( img := opts.ResolveToImage(f.Image) f.Image = img + rcOpts := []regclient.Opt{ + regclient.WithUserAgent(UserAgent), + regclient.WithDockerCreds(), + } + + if opts.TLSConfig != nil { + // TODO + } + listers := []TagLister{ &RegClientLister{ - client: regclient.New( - regclient.WithUserAgent(UserAgent), - regclient.WithDockerCreds(), - ), + Client: regclient.New(rcOpts...), }, } diff --git a/pkg/lib/runneroptions/runneroptions.go b/pkg/lib/runneroptions/runneroptions.go index 17b98e88bd..5ea95739bf 100644 --- a/pkg/lib/runneroptions/runneroptions.go +++ b/pkg/lib/runneroptions/runneroptions.go @@ -16,6 +16,7 @@ package runneroptions import ( + "crypto/tls" "fmt" "net/url" "os" @@ -66,6 +67,8 @@ type RunnerOptions struct { // ImagePrefix determines the prefix ResolveToImage will use when resolving a // partial image reference to a fully qualified image reference ImagePrefix string + + TLSConfig *tls.Config } func (opts *RunnerOptions) InitDefaults(defaultImagePrefix string) { From 2aeee8c17b924328f9f41146676b29631915820c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= Date: Thu, 9 Jul 2026 09:36:46 +0200 Subject: [PATCH 2/2] extra cert option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mózes László Máté --- pkg/fn/runtime/regclient_lister.go | 4 ++-- pkg/fn/runtime/runner.go | 5 +++-- pkg/lib/runneroptions/runneroptions.go | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/fn/runtime/regclient_lister.go b/pkg/fn/runtime/regclient_lister.go index cb7369205c..48e00cdbc1 100644 --- a/pkg/fn/runtime/regclient_lister.go +++ b/pkg/fn/runtime/regclient_lister.go @@ -18,7 +18,7 @@ import ( "context" "github.com/regclient/regclient" - ref2 "github.com/regclient/regclient/types/ref" + regclientref "github.com/regclient/regclient/types/ref" ) // RegClientLister is a TagLister using the regclient module to list remote OCI tags. @@ -33,7 +33,7 @@ func (l *RegClientLister) Name() string { } func (l *RegClientLister) List(ctx context.Context, image string) ([]string, error) { - ref, err := ref2.New(image) + ref, err := regclientref.New(image) if err != nil { return nil, err } diff --git a/pkg/fn/runtime/runner.go b/pkg/fn/runtime/runner.go index 60a0c63f32..32b77d67a7 100644 --- a/pkg/fn/runtime/runner.go +++ b/pkg/fn/runtime/runner.go @@ -35,6 +35,7 @@ import ( "github.com/kptdev/kpt/pkg/lib/runneroptions" "github.com/kptdev/kpt/pkg/printer" "github.com/regclient/regclient" + regclientreg "github.com/regclient/regclient/scheme/reg" "sigs.k8s.io/kustomize/kyaml/filesys" "sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil" "sigs.k8s.io/kustomize/kyaml/kio/kioutil" @@ -65,8 +66,8 @@ func NewRunner( regclient.WithDockerCreds(), } - if opts.TLSConfig != nil { - // TODO + if len(opts.ExtraTlsCerts) != 0 { + regclient.WithRegOpts(regclientreg.WithCerts(opts.ExtraTlsCerts)) } listers := []TagLister{ diff --git a/pkg/lib/runneroptions/runneroptions.go b/pkg/lib/runneroptions/runneroptions.go index 5ea95739bf..6dd2b81fec 100644 --- a/pkg/lib/runneroptions/runneroptions.go +++ b/pkg/lib/runneroptions/runneroptions.go @@ -16,7 +16,6 @@ package runneroptions import ( - "crypto/tls" "fmt" "net/url" "os" @@ -68,7 +67,7 @@ type RunnerOptions struct { // partial image reference to a fully qualified image reference ImagePrefix string - TLSConfig *tls.Config + ExtraTlsCerts [][]byte } func (opts *RunnerOptions) InitDefaults(defaultImagePrefix string) {