diff --git a/pkg/getter/ocigetter.go b/pkg/getter/ocigetter.go index d8fd53862..3f85b9862 100644 --- a/pkg/getter/ocigetter.go +++ b/pkg/getter/ocigetter.go @@ -58,10 +58,19 @@ func (g *OCIGetter) get(href string) (*bytes.Buffer, error) { } // NewOCIGetter constructs a valid http/https client as a Getter -func NewOCIGetter(options ...Option) (Getter, error) { - var client OCIGetter +func NewOCIGetter(ops ...Option) (Getter, error) { + registryClient, err := registry.NewClient() + if err != nil { + return nil, err + } - for _, opt := range options { + client := OCIGetter{ + opts: options{ + registryClient: registryClient, + }, + } + + for _, opt := range ops { opt(&client.opts) } diff --git a/pkg/getter/ocigetter_test.go b/pkg/getter/ocigetter_test.go new file mode 100644 index 000000000..fc548b7a6 --- /dev/null +++ b/pkg/getter/ocigetter_test.go @@ -0,0 +1,30 @@ +/* +Copyright The Helm 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 getter + +import ( + "testing" +) + +func TestNewOCIGetter(t *testing.T) { + testfn := func(ops *options) { + if ops.registryClient == nil { + t.Fatalf("the OCIGetter's registryClient should not be null") + } + } + + NewOCIGetter(testfn) +}