-
Notifications
You must be signed in to change notification settings - Fork 2
/
powershell_option.go
91 lines (65 loc) · 1.67 KB
/
powershell_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
package powershell
import "github.com/simonjanss/go-powershell/internal"
type Option interface {
Apply(*internal.Settings)
}
type withUsernamePassword struct {
username string
password string
}
func WithUsernamePassword(username, password string) Option {
return withUsernamePassword{username, password}
}
func (w withUsernamePassword) Apply(o *internal.Settings) {
o.Username = w.username
o.Password = w.password
}
type useHostName bool
func UseHostName() Option {
return useHostName(true)
}
func (w useHostName) Apply(o *internal.Settings) {
o.UseHostName = bool(w)
}
type withAllowRedirection bool
func WithAllowRedirection() Option {
return withAllowRedirection(true)
}
func (w withAllowRedirection) Apply(o *internal.Settings) {
o.AllowRedirection = bool(w)
}
type withCertificateThumbprint string
func WithCertificateThumbprint(thumbprint string) Option {
return withCertificateThumbprint(thumbprint)
}
func (w withCertificateThumbprint) Apply(o *internal.Settings) {
o.CertificateThumbprint = string(w)
}
type withSSL bool
func WithSSL() Option {
return withSSL(true)
}
func (w withSSL) Apply(o *internal.Settings) {
o.UseSSL = bool(w)
}
type withAuthentication string
func WithAuthentication(auth string) Option {
return withAuthentication(auth)
}
func (w withAuthentication) Apply(o *internal.Settings) {
o.Authentication = string(w)
}
type withPort int
func WithPort(port int) Option {
return withPort(port)
}
func (w withPort) Apply(o *internal.Settings) {
o.Port = int(w)
}
type withNetworkAccess bool
func WithNetworkAccess() Option {
return withNetworkAccess(true)
}
func (w withNetworkAccess) Apply(o *internal.Settings) {
o.NetworkAccess = bool(w)
}