Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit f67de9e

Browse files
committed
Move token into secret for cert-manager
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
1 parent c77ef3a commit f67de9e

File tree

6 files changed

+31
-44
lines changed

6 files changed

+31
-44
lines changed

init.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ enable_oauth: false
128128
### your OpenFaaS Cloud.
129129
tls: true
130130
tls_config:
131-
132131
email: "email@domain"
133132

134133
# issuer_type: "prod"
@@ -148,4 +147,3 @@ tls_config:
148147

149148
### DigitalOcean
150149
dns_service: digitalocean
151-
digitalocean_access_token: ""

pkg/tls/tls.go

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,27 @@ import (
1212

1313
// TLSTemplate TLS configuration
1414
type TLSTemplate struct {
15-
RootDomain string
16-
Email string
17-
DNSService string
18-
ProjectID string
19-
IssuerType string
20-
Region string
21-
AccessKeyID string
22-
DigitalOceanAccessToken string
15+
RootDomain string
16+
Email string
17+
DNSService string
18+
ProjectID string
19+
IssuerType string
20+
Region string
21+
AccessKeyID string
2322
}
2423

25-
var tlsTemplatesPath = "templates/k8s/tls/"
26-
2724
// Apply executes the plan
2825
func Apply(plan types.Plan) error {
2926

3027
tlsTemplatesList, _ := listTLSTemplates()
3128
tlsTemplate := TLSTemplate{
32-
RootDomain: plan.RootDomain,
33-
Email: plan.TLSConfig.Email,
34-
DNSService: plan.TLSConfig.DNSService,
35-
ProjectID: plan.TLSConfig.ProjectID,
36-
IssuerType: plan.TLSConfig.IssuerType,
37-
Region: plan.TLSConfig.Region,
38-
AccessKeyID: plan.TLSConfig.AccessKeyID,
39-
DigitalOceanAccessToken: plan.TLSConfig.DigitalOceanAccessToken,
29+
RootDomain: plan.RootDomain,
30+
Email: plan.TLSConfig.Email,
31+
DNSService: plan.TLSConfig.DNSService,
32+
ProjectID: plan.TLSConfig.ProjectID,
33+
IssuerType: plan.TLSConfig.IssuerType,
34+
Region: plan.TLSConfig.Region,
35+
AccessKeyID: plan.TLSConfig.AccessKeyID,
4036
}
4137

4238
for _, template := range tlsTemplatesList {
@@ -55,23 +51,17 @@ func Apply(plan types.Plan) error {
5551
}
5652

5753
func listTLSTemplates() ([]string, error) {
58-
file, err := os.Open(tlsTemplatesPath)
5954

60-
if err != nil {
61-
log.Fatalf("failed opening directory: %s, %s", tlsTemplatesPath, err)
62-
return nil, err
63-
}
64-
defer file.Close()
65-
66-
list, _ := file.Readdirnames(0)
67-
if err != nil {
68-
log.Fatalf("failed reading filenames in directory %s, %s", tlsTemplatesPath, err)
69-
return nil, err
70-
}
71-
return list, nil
55+
return []string{
56+
"issuer-prod.yml",
57+
"issuer-staging.yml",
58+
"wildcard-domain-cert.yml",
59+
"auth-domain-cert.yml",
60+
}, nil
7261
}
7362

7463
func generateTemplate(fileName string, tlsTemplate TLSTemplate) (string, error) {
64+
tlsTemplatesPath := "templates/k8s/tls/"
7565

7666
data, err := ioutil.ReadFile(tlsTemplatesPath + fileName)
7767
if err != nil {

pkg/types/types.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ type S3 struct {
7070
}
7171

7272
type TLSConfig struct {
73-
Email string `yaml:"email"`
74-
DNSService string `yaml:"dns_service"`
75-
ProjectID string `yaml:"project_id"`
76-
IssuerType string `yaml:"issuer_type"`
77-
Region string `yaml:"region"`
78-
AccessKeyID string `yaml:"access_key_id"`
79-
DigitalOceanAccessToken string `yaml:"digitalocean_access_token"`
73+
Email string `yaml:"email"`
74+
DNSService string `yaml:"dns_service"`
75+
ProjectID string `yaml:"project_id"`
76+
IssuerType string `yaml:"issuer_type"`
77+
Region string `yaml:"region"`
78+
AccessKeyID string `yaml:"access_key_id"`
8079
}

scripts/reset.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
helm delete --purge cert-manager nginxingress openfaas cloud-minio
44

55
kubectl delete certificates --all -n openfaas
6+
kubectl delete clusterissuer letsencrypt-prod letsencrypt-staging
67

7-
kubectl delete ns openfaas openfaas-fn
8-
kubectl delete ns cert-manager
8+
kubectl delete ns openfaas openfaas-fn cert-manager
99

1010
kubectl delete crd sealedsecrets.bitnami.com
1111
kubectl delete \

templates/k8s/tls/issuer-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ spec:
2828
{{else if eq .DNSService "digitalocean" }}
2929
tokenSecretRef:
3030
name: digitalocean-dns
31-
key: "{{.DigitalOceanAccessToken}}"
31+
key: access-token
3232
{{ end }}

templates/k8s/tls/issuer-staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ spec:
2828
{{else if eq .DNSService "digitalocean" }}
2929
tokenSecretRef:
3030
name: digitalocean-dns
31-
key: "{{.DigitalOceanAccessToken}}"
31+
key: access-token
3232
{{ end }}

0 commit comments

Comments
 (0)