Skip to content
Permalink
Browse files

Added validation that email and domain were set for openfaas-ingress

Initially when this was implemented there was no check that a user
had set the email and domain. This could lead to users installing
the ingress with invalid domain and email for cert-manager.

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
  • Loading branch information...
Waterdrips authored and alexellis committed Nov 5, 2019
1 parent 8982f32 commit 05186062577456ac47e9c8a0a6c7385d301fe3cb
Showing with 14 additions and 6 deletions.
  1. +14 −6 pkg/cmd/openfaas_ingress_app.go
@@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
@@ -27,10 +28,18 @@ func makeInstallOpenFaaSIngress() *cobra.Command {
SilenceUsage: true,
}

openfaasIngress.Flags().StringP("domain", "d", "openfaas.example.com", "Custom Ingress Domain")
openfaasIngress.Flags().StringP("email", "e", "openfaas@example.com", "Letsencrypt Email")
openfaasIngress.Flags().StringP("domain", "d", "", "Custom Ingress Domain")
openfaasIngress.Flags().StringP("email", "e", "", "Letsencrypt Email")

openfaasIngress.RunE = func(command *cobra.Command, args []string) error {

email, _ := command.Flags().GetString("email")
domain, _ := command.Flags().GetString("domain")

if email == "" || domain == "" {
return errors.New("both --email and --domain flags should be set and not empty, please set these values")
}

kubeConfigPath := getDefaultKubeconfig()

if command.Flags().Changed("kubeconfig") {
@@ -39,9 +48,6 @@ func makeInstallOpenFaaSIngress() *cobra.Command {

fmt.Printf("Using kubeconfig: %s\n", kubeConfigPath)

email, _ := command.Flags().GetString("email")
domain, _ := command.Flags().GetString("domain")

yamlBytes, templateErr := buildYaml(domain, email)
if templateErr != nil {
log.Print("Unable to install the application. Could not build the templated yaml file for the resources")
@@ -78,9 +84,11 @@ func makeInstallOpenFaaSIngress() *cobra.Command {
# Ingress to your domain has been installed for OpenFaaS
# to see the ingress record run
kubectl get -n openfaas ingress openfaas-gateway
# Check the cert-manager logs with:
kubectl logs -n cert-manager deploy/cert-manager
# A cert-manager ClusterIssuer has been installed into the default
# namespace - to see the resource run
kubectl describe ClusterIssuer letsencrypt-prod

0 comments on commit 0518606

Please sign in to comment.
You can’t perform that action at this time.