/
option.go
102 lines (88 loc) · 2.21 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package chartmuseum
import (
"time"
)
type (
// Option allows specifying various settings
Option func(*options)
// options specify optional settings
options struct {
url string
username string
password string
accessToken string
authHeader string
contextPath string
timeout time.Duration
caFile string
certFile string
keyFile string
insecureSkipVerify bool
}
)
// URL specifies the chart repo URL
func URL(url string) Option {
return func(opts *options) {
opts.url = url
}
}
// Username is HTTP basic auth username
func Username(username string) Option {
return func(opts *options) {
opts.username = username
}
}
// Password is HTTP basic auth password
func Password(password string) Option {
return func(opts *options) {
opts.password = password
}
}
// AccessToken is sent in the authorization header
func AccessToken(accessToken string) Option {
return func(opts *options) {
opts.accessToken = accessToken
}
}
// AuthHeader is an alternative header to use for token auth
func AuthHeader(authHeader string) Option {
return func(opts *options) {
opts.authHeader = authHeader
}
}
// ContextPath is the URL prefix for ChartMuseum installation
func ContextPath(contextPath string) Option {
return func(opts *options) {
opts.contextPath = contextPath
}
}
// Timeout specifies the duration (in seconds) before timing out request
func Timeout(timeout int64) Option {
return func(opts *options) {
opts.timeout = time.Duration(timeout) * time.Second
}
}
//CAFile specifies the path of CA bundle
func CAFile(caFile string) Option {
return func(opts *options) {
opts.caFile = caFile
}
}
//CertFile specifies the path of SSL certificate file
func CertFile(certFile string) Option {
return func(opts *options) {
opts.certFile = certFile
}
}
//KeyFile specifies the path of SSL key file
func KeyFile(keyFile string) Option {
return func(opts *options) {
opts.keyFile = keyFile
}
}
//InsecureSkipVerify to indicate if verify the certificate when connecting
func InsecureSkipVerify(insecureSkipVerify bool) Option {
return func(opts *options) {
opts.insecureSkipVerify = insecureSkipVerify
}
}