This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 560
/
config.go
113 lines (94 loc) · 2.2 KB
/
config.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
103
104
105
106
107
108
109
110
111
112
113
package release39
import (
"crypto/rsa"
"crypto/x509"
"math/big"
"net"
"sync"
"github.com/Azure/acs-engine/pkg/openshift/filesystem"
)
// Config represents an OpenShift configuration
type Config struct {
ExternalMasterHostname string
serial serial
cas map[string]CertAndKey
AuthSecret string
EncSecret string
Master *Master
Bootstrap KubeConfig
ClusterUsername string
ClusterPassword string
EnableAADAuthentication bool
AzureConfig AzureConfig
}
// AzureConfig represents the azure.conf configuration
type AzureConfig struct {
TenantID string
SubscriptionID string
AADClientID string
AADClientSecret string
ResourceGroup string
Location string
SecurityGroupName string
PrimaryAvailabilitySetName string
}
// Master represents an OpenShift master configuration
type Master struct {
Hostname string
IPs []net.IP
Port int16
certs map[string]CertAndKey
etcdcerts map[string]CertAndKey
kubeconfigs map[string]KubeConfig
}
// CertAndKey is a certificate and key
type CertAndKey struct {
cert *x509.Certificate
key *rsa.PrivateKey
}
type serial struct {
m sync.Mutex
i int64
}
func (s *serial) Get() *big.Int {
s.m.Lock()
defer s.m.Unlock()
s.i++
return big.NewInt(s.i)
}
// WriteMaster writes the config files for a Master node to a Filesystem.
func (c *Config) WriteMaster(fs filesystem.Writer) error {
err := c.WriteMasterCerts(fs)
if err != nil {
return err
}
err = c.WriteMasterKeypair(fs)
if err != nil {
return err
}
err = c.WriteMasterKubeConfigs(fs)
if err != nil {
return err
}
err = c.WriteMasterFiles(fs)
if err != nil {
return err
}
err = c.WriteBootstrapCerts(fs)
if err != nil {
return err
}
return c.WriteNodeFiles(fs)
}
// WriteNode writes the config files for bootstrapping a node to a Filesystem.
func (c *Config) WriteNode(fs filesystem.Writer) error {
err := c.WriteBootstrapCerts(fs)
if err != nil {
return err
}
err = c.WriteBootstrapKubeConfig(fs)
if err != nil {
return err
}
return c.WriteNodeFiles(fs)
}