-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the option to use Staging LE issuer for OpenFaaS Ingress
We may want to test that the app will correctly issue a cert but not actually get a prod cert. You are limited to 30 new sub-domains a week with LE. This lets you pass the --staging flag to `arkade install openfaas-ingress --staging` Signed-off-by: Alistair Hey <[email protected]>
- Loading branch information
1 parent
99a1d4f
commit 09b64e3
Showing
2 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,61 @@ import ( | |
) | ||
|
||
func Test_buildYAML_SubsitutesDomainEmailAndIngress(t *testing.T) { | ||
templBytes, _ := buildYAML("openfaas.subdomain.example.com", "[email protected]", "traefik") | ||
templBytes, _ := buildYAML("openfaas.subdomain.example.com", "[email protected]", "traefik", false) | ||
var want = ` | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: openfaas-gateway | ||
namespace: openfaas | ||
annotations: | ||
cert-manager.io/cluster-issuer: letsencrypt-prod | ||
kubernetes.io/ingress.class: traefik | ||
spec: | ||
rules: | ||
- host: openfaas.subdomain.example.com | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: gateway | ||
servicePort: 8080 | ||
path: / | ||
tls: | ||
- hosts: | ||
- openfaas.subdomain.example.com | ||
secretName: openfaas-gateway | ||
--- | ||
apiVersion: cert-manager.io/v1alpha2 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-prod | ||
spec: | ||
acme: | ||
email: [email protected] | ||
server: https://acme-v02.api.letsencrypt.org/directory | ||
privateKeySecretRef: | ||
name: example-issuer-account-key | ||
solvers: | ||
- http01: | ||
ingress: | ||
class: traefik` | ||
|
||
got := string(templBytes) | ||
if want != got { | ||
t.Errorf("suffix, want: %q, got: %q", want, got) | ||
} | ||
} | ||
|
||
var want = ` | ||
func Test_buildYAMLStaging(t *testing.T) { | ||
templBytes, _ := buildYAML("openfaas.subdomain.example.com", "[email protected]", "traefik", true) | ||
var want = ` | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: openfaas-gateway | ||
namespace: openfaas | ||
annotations: | ||
cert-manager.io/cluster-issuer: letsencrypt-prod | ||
cert-manager.io/cluster-issuer: letsencrypt-staging | ||
kubernetes.io/ingress.class: traefik | ||
spec: | ||
rules: | ||
|
@@ -42,18 +81,24 @@ spec: | |
apiVersion: cert-manager.io/v1alpha2 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-prod | ||
name: letsencrypt-staging | ||
spec: | ||
acme: | ||
email: [email protected] | ||
server: https://acme-v02.api.letsencrypt.org/directory | ||
server: https://acme-staging-v02.api.letsencrypt.org/directory | ||
privateKeySecretRef: | ||
name: example-issuer-account-key | ||
solvers: | ||
- http01: | ||
ingress: | ||
class: traefik` | ||
|
||
got := string(templBytes) | ||
if want != got { | ||
t.Errorf("suffix, want: %q, got: %q", want, got) | ||
} | ||
} | ||
|
||
func Test_writeTempFile_writes_to_tmp(t *testing.T) { | ||
var want = "some input string" | ||
tmpLocation, _ := writeTempFile([]byte(want), "tmp_file_name.yaml") | ||
|