Commit 24c4809a authored by Christopher Harm's avatar Christopher Harm

Adding swagger-ui ingress and setup of /etc/hosts file

parent 284cb9a5
Pipeline #90915 passed with stages
in 58 seconds
......@@ -28,6 +28,7 @@ import (
"git.psu.edu/k8s/devtool/environment"
"github.com/fatih/color"
"github.com/goodhosts/hostsfile"
"github.com/markbates/pkger"
"github.com/spf13/cobra"
"github.com/spf13/viper"
......@@ -247,6 +248,8 @@ func start() {
environment.RunRequired(true, "minikube", "addons", "enable", "ingress")
}
setupHostsFile()
}
func helmVersion2() bool {
......@@ -421,9 +424,16 @@ func checkIfSwaggerUiInstalled() {
}
if helmVersion2() {
environment.RunRequired(true, "helm", "install", "--name", "swagger-ui", "cm/swagger-ui")
environment.RunRequired(true, "helm", "install",
"--name", "swagger-ui",
"--set", "ingress.enabled=true",
"--set", "ingress.hosts={kubernetes.local}",
"--set", "ingress.path=/swagger-ui", "cm/swagger-ui")
} else {
environment.RunRequired(true, "helm", "install", "swagger-ui", "cm/swagger-ui")
environment.RunRequired(true, "helm", "install", "swagger-ui", "cm/swagger-ui",
"--set", "ingress.enabled=true",
"--set", "ingress.hosts={kubernetes.local,localhost}",
"--set", "ingress.path=/swagger-ui")
}
}
}
......@@ -463,8 +473,12 @@ func checkIfNginxIngressInstalled() {
}
func helmReleaseInstalled(releaseName string) bool {
helmReleases := environment.RunAndGetOutputRequired("helm", "ls", "--all", "--short")
var helmReleases []string
if helmVersion2() {
helmReleases = environment.RunAndGetOutputRequired("helm", "ls", "--all", "--short")
} else {
helmReleases = environment.RunAndGetOutputRequired("helm", "ls", "--all", "--all-namespaces", "--short")
}
installed := false
for _, r := range helmReleases {
......@@ -496,3 +510,30 @@ func readPkgedFile(path string) (string, error) {
return string(bytes), nil
}
func setupHostsFile() error {
hostsfile, err := hostsfile.NewHosts()
if err != nil {
return err
}
var ip string
if minikubeProvider() {
output := environment.RunAndGetOutputRequired("minikube", "ip")
ip = output[0]
} else if kindProvider() {
ip = "127.0.0.1"
}
if !hostsfile.Has(ip, "kubernetes.local") {
if hostsfile.HasHostname("kubernetes.local") {
color.Red("host ip address has changed. Please clean up your /etc/hosts file")
return fmt.Errorf("host ip address has changed. Please clean up your /etc/hosts file")
}
color.Red("ACTION REQUIRED: Please modify your /etc/hosts file!")
color.New(color.FgRed).Printf("\tRun: 'echo \"%s kubernetes.local\" | sudo tee -a /etc/hosts'\n", ip)
}
return nil
}
......@@ -69,3 +69,17 @@ func RunAndGetOutputRequired(name string, args ...string) []string {
}
return output
}
func RunWithStdin(name string, args ...string) error {
cmd := exec.Command(name, args...)
cmd.Env = os.Environ()
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
return err
}
......@@ -6,16 +6,30 @@ require (
git.psu.edu/swe-golang/buildversion v0.1.0
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/fatih/color v1.7.0
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/goodhosts/hostsfile v0.0.1
github.com/google/uuid v1.1.1
github.com/kr/pretty v0.2.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/manifoldco/promptui v0.3.2
github.com/markbates/pkger v0.15.0
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.7 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.9 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/nicksnyder/go-i18n v1.10.0 // indirect
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.3.2
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/lint v0.0.0-20200130185559-910be7a94367 // indirect
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20200203215610-ab391d50b528 // indirect
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c // indirect
gopkg.in/yaml.v2 v2.2.7
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.8
)
This diff is collapsed.
This diff is collapsed.
......@@ -13,4 +13,8 @@ controller:
operator: Equal
effect: NoSchedule
daemonset:
useHostPort: true
\ No newline at end of file
useHostPort: true
config:
enable-opentracing: "true"
zipkin-collector-host: "oc-collector.monitoring"
use-forwarded-headers: "true"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment