Skip to content

Commit cf8cd4c

Browse files
author
Yifan Gu
committed
*: Fix golint.
1 parent 533c601 commit cf8cd4c

File tree

7 files changed

+76
-15
lines changed

7 files changed

+76
-15
lines changed

pkg/asset/installconfig/stock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Stock interface {
3232
Platform() asset.Asset
3333
}
3434

35-
// StockImpl is the
35+
// StockImpl implements the Stock interface for installconfig and user inputs.
3636
type StockImpl struct {
3737
installConfig asset.Asset
3838
clusterID asset.Asset

pkg/asset/tls/certkey.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ type CertKey struct {
4040

4141
var _ asset.Asset = (*CertKey)(nil)
4242

43+
// Dependencies returns the dependency of the the cert/key pair, which includes
44+
// the parent CA, and install config if it depends on the install config for
45+
// DNS names, etc.
4346
func (c *CertKey) Dependencies() []asset.Asset {
4447
parents := []asset.Asset{c.ParentCA}
4548

@@ -51,6 +54,7 @@ func (c *CertKey) Dependencies() []asset.Asset {
5154
return parents
5255
}
5356

57+
// Generate generates the cert/key pair based on its dependencies.
5458
func (c *CertKey) Generate(parents map[asset.Asset]*asset.State) (*asset.State, error) {
5559
cfg := &CertCfg{
5660
Subject: c.Subject,

pkg/asset/tls/helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
"github.com/openshift/installer/pkg/types"
1111
)
1212

13+
const (
14+
tlsDir = "tls"
15+
)
16+
1317
func assetFilePath(rootDir, filename string) string {
1418
return filepath.Join(rootDir, tlsDir, filename)
1519
}

pkg/asset/tls/keypair.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ type KeyPair struct {
1616

1717
var _ asset.Asset = (*KeyPair)(nil)
1818

19+
// Dependencies returns the dependency of an rsa private / public key pair.
1920
func (k *KeyPair) Dependencies() []asset.Asset {
2021
return []asset.Asset{}
2122
}
2223

24+
// Generate generates the rsa private / public key pair.
2325
func (k *KeyPair) Generate(map[asset.Asset]*asset.State) (*asset.State, error) {
2426
key, err := PrivateKey()
2527
if err != nil {

pkg/asset/tls/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ type RootCA struct {
1616

1717
var _ asset.Asset = (*CertKey)(nil)
1818

19+
// Dependencies returns the dependency of the root-ca, which is empty.
1920
func (c *RootCA) Dependencies() []asset.Asset {
2021
return []asset.Asset{}
2122
}
2223

24+
// Generate generates the root-ca key and cert pair.
2325
func (c *RootCA) Generate(parents map[asset.Asset]*asset.State) (*asset.State, error) {
2426
cfg := &CertCfg{
2527
Subject: pkix.Name{CommonName: "root-ca", OrganizationalUnit: []string{"openshift"}},

pkg/asset/tls/stock.go

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,41 @@ import (
88
"github.com/openshift/installer/pkg/asset/installconfig"
99
)
1010

11+
// Stock is the stock of TLS assets that can be generated.
1112
type Stock interface {
13+
// RootCA is the asset that generates the root-ca key/cert pair.
1214
RootCA() asset.Asset
15+
// KubeCA is the asset that generates the kube-ca key/cert pair.
1316
KubeCA() asset.Asset
17+
// EtcdCA is the asset that generates the etcd-ca key/cert pair.
1418
EtcdCA() asset.Asset
19+
// AggregatorCA is the asset that generates the aggregator-ca key/cert pair.
1520
AggregatorCA() asset.Asset
21+
// ServiceServingCA is the asset that generates the service-serving-ca key/cert pair.
1622
ServiceServingCA() asset.Asset
23+
// EtcdClientCertKey is the asset that generates the etcd client key/cert pair.
1724
EtcdClientCertKey() asset.Asset
25+
// AdminCertKey is the asset that generates the admin key/cert pair.
1826
AdminCertKey() asset.Asset
27+
// IngressCertKey is the asset that generates the ingress key/cert pair.
1928
IngressCertKey() asset.Asset
29+
// APIServerCertKey is the asset that generates the API server key/cert pair.
2030
APIServerCertKey() asset.Asset
31+
// OpenshiftAPIServerCertKey is the asset that generates the Openshift API server key/cert pair.
2132
OpenshiftAPIServerCertKey() asset.Asset
33+
// APIServerProxyCertKey is the asset that generates the API server proxy key/cert pair.
2234
APIServerProxyCertKey() asset.Asset
35+
// KubeletCertKey is the asset that generates the kubelet key/cert pair.
2336
KubeletCertKey() asset.Asset
37+
// TNCCertKey is the asset that generates the TNC key/cert pair.
2438
TNCCertKey() asset.Asset
39+
// ClusterAPIServerCertKey is the asset that generates the cluster API server key/cert pair.
2540
ClusterAPIServerCertKey() asset.Asset
41+
// ServiceAccountKeyPair is the asset that generates the service-account public/private key pair.
2642
ServiceAccountKeyPair() asset.Asset
2743
}
2844

45+
// StockImpl implements the Stock interface for tls assets.
2946
type StockImpl struct {
3047
rootCA asset.Asset
3148
kubeCA asset.Asset
@@ -46,6 +63,7 @@ type StockImpl struct {
4663

4764
var _ Stock = (*StockImpl)(nil)
4865

66+
// EstablishStock establishes the stock of assets in the specified directory.
4967
func (s *StockImpl) EstablishStock(rootDir string, stock installconfig.Stock) {
5068
s.rootCA = &RootCA{rootDir: rootDir}
5169
s.kubeCA = &CertKey{
@@ -233,18 +251,47 @@ func (s *StockImpl) EstablishStock(rootDir string, stock installconfig.Stock) {
233251
}
234252
}
235253

236-
func (s *StockImpl) RootCA() asset.Asset { return s.rootCA }
237-
func (s *StockImpl) KubeCA() asset.Asset { return s.kubeCA }
238-
func (s *StockImpl) EtcdCA() asset.Asset { return s.etcdCA }
239-
func (s *StockImpl) AggregatorCA() asset.Asset { return s.aggregatorCA }
240-
func (s *StockImpl) ServiceServingCA() asset.Asset { return s.serviceServingCA }
241-
func (s *StockImpl) EtcdClientCertKey() asset.Asset { return s.etcdClientCertKey }
242-
func (s *StockImpl) AdminCertKey() asset.Asset { return s.adminCertKey }
243-
func (s *StockImpl) IngressCertKey() asset.Asset { return s.ingressCertKey }
244-
func (s *StockImpl) APIServerCertKey() asset.Asset { return s.apiServerCertKey }
254+
// RootCA is the asset that generates the root-ca key/cert pair.
255+
func (s *StockImpl) RootCA() asset.Asset { return s.rootCA }
256+
257+
// KubeCA is the asset that generates the kube-ca key/cert pair.
258+
func (s *StockImpl) KubeCA() asset.Asset { return s.kubeCA }
259+
260+
// EtcdCA is the asset that generates the etcd-ca key/cert pair.
261+
func (s *StockImpl) EtcdCA() asset.Asset { return s.etcdCA }
262+
263+
// AggregatorCA is the asset that generates the aggregator-ca key/cert pair.
264+
func (s *StockImpl) AggregatorCA() asset.Asset { return s.aggregatorCA }
265+
266+
// ServiceServingCA is the asset that generates the service-serving-ca key/cert pair.
267+
func (s *StockImpl) ServiceServingCA() asset.Asset { return s.serviceServingCA }
268+
269+
// EtcdClientCertKey is the asset that generates the etcd client key/cert pair.
270+
func (s *StockImpl) EtcdClientCertKey() asset.Asset { return s.etcdClientCertKey }
271+
272+
// AdminCertKey is the asset that generates the admin key/cert pair.
273+
func (s *StockImpl) AdminCertKey() asset.Asset { return s.adminCertKey }
274+
275+
// IngressCertKey is the asset that generates the ingress key/cert pair.
276+
func (s *StockImpl) IngressCertKey() asset.Asset { return s.ingressCertKey }
277+
278+
// APIServerCertKey is the asset that generates the API server key/cert pair.
279+
func (s *StockImpl) APIServerCertKey() asset.Asset { return s.apiServerCertKey }
280+
281+
// OpenshiftAPIServerCertKey is the asset that generates the Openshift API server key/cert pair.
245282
func (s *StockImpl) OpenshiftAPIServerCertKey() asset.Asset { return s.openshiftAPIServerCertKey }
246-
func (s *StockImpl) APIServerProxyCertKey() asset.Asset { return s.apiServerProxyCertKey }
247-
func (s *StockImpl) KubeletCertKey() asset.Asset { return s.kubeletCertKey }
248-
func (s *StockImpl) TNCCertKey() asset.Asset { return s.tncCertKey }
249-
func (s *StockImpl) ClusterAPIServerCertKey() asset.Asset { return s.clusterAPIServerCertKey }
250-
func (s *StockImpl) ServiceAccountKeyPair() asset.Asset { return s.serviceAccountKeyPair }
283+
284+
// APIServerProxyCertKey is the asset that generates the API server proxy key/cert pair.
285+
func (s *StockImpl) APIServerProxyCertKey() asset.Asset { return s.apiServerProxyCertKey }
286+
287+
// KubeletCertKey is the asset that generates the kubelet key/cert pair.
288+
func (s *StockImpl) KubeletCertKey() asset.Asset { return s.kubeletCertKey }
289+
290+
// TNCCertKey is the asset that generates the TNC key/cert pair.
291+
func (s *StockImpl) TNCCertKey() asset.Asset { return s.tncCertKey }
292+
293+
// ClusterAPIServerCertKey is the asset that generates the cluster API server key/cert pair.
294+
func (s *StockImpl) ClusterAPIServerCertKey() asset.Asset { return s.clusterAPIServerCertKey }
295+
296+
// ServiceAccountKeyPair is the asset that generates the service-account public/private key pair.
297+
func (s *StockImpl) ServiceAccountKeyPair() asset.Asset { return s.serviceAccountKeyPair }

pkg/asset/tls/tls.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func GenerateRootCA(key *rsa.PrivateKey, cfg *CertCfg) (*x509.Certificate, error
185185
return cert, nil
186186
}
187187

188+
// GenerateSignedCert generates a signed certificate.
188189
func GenerateSignedCert(cfg *CertCfg,
189190
csr *x509.CertificateRequest,
190191
key *rsa.PrivateKey,
@@ -197,6 +198,7 @@ func GenerateSignedCert(cfg *CertCfg,
197198
return cert, nil
198199
}
199200

201+
// GenerateRootCertKey generates a root key/cert pair.
200202
func GenerateRootCertKey(cfg *CertCfg) (*rsa.PrivateKey, *x509.Certificate, error) {
201203
key, err := PrivateKey()
202204
if err != nil {

0 commit comments

Comments
 (0)