Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (c buildConfig) clientOptions() ([]fn.Option, error) {
if c.Builder == builders.Host {
o = append(o,
fn.WithBuilder(oci.NewBuilder(builders.Host, c.Verbose)),
fn.WithPusher(oci.NewPusher(c.RegistryInsecure, false, c.Verbose)))
fn.WithPusher(oci.NewPusher(c.RegistryInsecure, false, c.Verbose, newTransport(c.RegistryInsecure))))
} else if c.Builder == builders.Pack {
o = append(o,
fn.WithBuilder(pack.NewBuilder(
Expand Down
18 changes: 8 additions & 10 deletions pkg/oci/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package oci

import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -32,15 +31,21 @@ type Pusher struct {

updates chan v1.Update
done chan bool

transport http.RoundTripper
}

func NewPusher(insecure, anon, verbose bool) *Pusher {
func NewPusher(insecure, anon, verbose bool, t http.RoundTripper) *Pusher {
if t == nil {
t = remote.DefaultTransport
}
return &Pusher{
Insecure: insecure,
Anonymous: anon,
Verbose: verbose,
updates: make(chan v1.Update, 10),
done: make(chan bool, 1),
transport: t,
}
}

Expand Down Expand Up @@ -124,14 +129,7 @@ func (p *Pusher) writeIndex(ctx context.Context, ref name.Reference, ii v1.Image
oo := []remote.Option{
remote.WithContext(ctx),
remote.WithProgress(p.updates),
}

if p.Insecure {
t := remote.DefaultTransport.(*http.Transport).Clone()
t.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
oo = append(oo, remote.WithTransport(t))
remote.WithTransport(p.transport),
}

if !p.Anonymous {
Expand Down
4 changes: 2 additions & 2 deletions pkg/oci/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestPusher_Push(t *testing.T) {
// Create and push a function
client := fn.New(
fn.WithBuilder(NewBuilder("", false)),
fn.WithPusher(NewPusher(insecure, anon, verbose)))
fn.WithPusher(NewPusher(insecure, anon, verbose, nil)))

f := fn.Function{Root: root, Runtime: "go", Name: "f", Registry: l.Addr().String() + "/funcs"}

Expand Down Expand Up @@ -127,7 +127,7 @@ func TestPusher_BasicAuth(t *testing.T) {
// initialized with an OCI builder and pusher.
client := fn.New(
fn.WithBuilder(NewBuilder("", verbose)),
fn.WithPusher(NewPusher(false, false, verbose)))
fn.WithPusher(NewPusher(false, false, verbose, nil)))

// Function
// Built and tagged to push to the mock registry
Expand Down
Loading