Skip to content

Commit 3b027df

Browse files
authored
feat: add insecure flag for push command (#129)
Signed-off-by: chlins <[email protected]>
1 parent 426fea3 commit 3b027df

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

cmd/push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func init() {
5151
flags := pushCmd.Flags()
5252
flags.IntVar(&pushConfig.Concurrency, "concurrency", pushConfig.Concurrency, "specify the number of concurrent push operations")
5353
flags.BoolVar(&pushConfig.PlainHTTP, "plain-http", false, "use plain HTTP instead of HTTPS")
54+
flags.BoolVar(&pushConfig.Insecure, "insecure", false, "turning on this flag will disable TLS verification")
5455
flags.BoolVar(&pushConfig.Nydusify, "nydusify", false, "[EXPERIMENTAL] nydusify the model artifact")
5556
flags.MarkHidden("nydusify")
5657

pkg/backend/push.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ package backend
1919
import (
2020
"bytes"
2121
"context"
22+
"crypto/tls"
2223
"encoding/json"
2324
"fmt"
25+
"net/http"
2426

2527
internalpb "github.com/CloudNativeAI/modctl/internal/pb"
2628
"github.com/CloudNativeAI/modctl/pkg/config"
@@ -59,10 +61,17 @@ func (b *backend) Push(ctx context.Context, target string, cfg *config.Push) err
5961
return fmt.Errorf("failed to create credential store: %w", err)
6062
}
6163

64+
httpClient := &http.Client{
65+
Transport: retry.NewTransport(&http.Transport{
66+
TLSClientConfig: &tls.Config{
67+
InsecureSkipVerify: cfg.Insecure,
68+
},
69+
}),
70+
}
6271
dst.Client = &auth.Client{
6372
Cache: auth.NewCache(),
6473
Credential: credentials.Credential(credStore),
65-
Client: retry.DefaultClient,
74+
Client: httpClient,
6675
}
6776

6877
if cfg.PlainHTTP {

pkg/config/push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
type Push struct {
2727
Concurrency int
2828
PlainHTTP bool
29+
Insecure bool
2930
Nydusify bool
3031
}
3132

0 commit comments

Comments
 (0)