Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows tab commands #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ import (
"strings"
)

var funcMap = template.FuncMap{
"escapeWin": func(text string) template.HTML {
text = strings.Replace(text, " ", "` ", -1)
text = strings.Replace(text, "\n", "`r`n", -1)
return template.HTML(text)
},
}

// compile all templates and cache them
var templates = template.Must(template.ParseGlob("./templates/*.html"))
var templates = template.Must(template.New("").Funcs(funcMap).ParseGlob("./templates/*.html"))
nabadger marked this conversation as resolved.
Show resolved Hide resolved

func renderIndex(w http.ResponseWriter, config *Config) {
t, _ := template.ParseFiles("./templates/index.html")
Expand Down
16 changes: 6 additions & 10 deletions templates/windows-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>Copy IDP CA Certificate From URL</h3>
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>

<pre><code>curl --create-dirs -s {{ .IDPCaURI }} -o ${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt</code></pre>
<pre><code>curl --create-dirs -s {{ .IDPCaURI }} -o %USERPROFILE%/.kube/certs/{{ .ClusterName }}/idp-ca.crt</code></pre>
</div>
{{ end }}

Expand All @@ -40,9 +40,7 @@ <h3>Copy IDP CA From Pem</h3>
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>

<pre><code>mkdir -p ${HOME}/.kube/certs/{{ .ClusterName }}/ &amp;&amp; cat &lt;&lt; EOF &gt; ${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt
{{ .IDPCaPem}}
EOF</code></pre>
<pre><code>powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "New-Item %USERPROFILE%/.kube/certs/{{ .ClusterName }}/idp-ca.crt -Force -Value {{ .IDPCaPem | escapeWin }} | Out-Null"</code></pre>
</div>
{{ end }}

Expand All @@ -56,7 +54,7 @@ <h3>Copy Kubernetes CA Certificate From URL</h3>
<button class="btn" style="float: right" data-clipboard-snippet="">
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>
<pre><code>curl --create-dirs -s {{ .K8sCaURI }} -o ${HOME}/.kube/certs/{{ .ClusterName }}/k8s-ca.crt</code></pre>
<pre><code>curl --create-dirs -s {{ .K8sCaURI }} -o %USERPROFILE%/.kube/certs/{{ .ClusterName }}/k8s-ca.crt</code></pre>
</div>
{{ end }}

Expand All @@ -70,9 +68,7 @@ <h3>Copy Kubernetes CA Certificate From PEM</h3>
<button class="btn" style="float:right" data-clipboard-snippet="">
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>
<pre><code>mkdir -p ${HOME}/.kube/certs/{{ .ClusterName }}/ &amp;&amp; cat &lt;&lt; EOF &gt; ${HOME}/.kube/certs/{{ .ClusterName }}/k8s-ca.crt
{{ .K8sCaPem }}
EOF</code></pre>
<pre><code>powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "New-Item %USERPROFILE%/.kube/certs/{{ .ClusterName }}/k8s-ca.crt -Force -Value {{ .K8sCaPem | escapeWin }} | Out-Null"</code></pre>
</div>
{{ end }}

Expand All @@ -85,7 +81,7 @@ <h3>Run configuration commands</h3>
<button class="btn" style="float:right" data-clipboard-snippet="">
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt="">
</button>
<pre><code>kubectl config set-cluster {{ .ClusterName }} --certificate-authority=${HOME}/.kube/certs/{{ .ClusterName}}/k8s-ca.crt --server={{ .K8sMasterURI }}</code></pre>
<pre><code>kubectl config set-cluster {{ .ClusterName }} --certificate-authority=%USERPROFILE%/.kube/certs/{{ .ClusterName}}/k8s-ca.crt --server={{ .K8sMasterURI }}</code></pre>
</div>

<div class="command">
Expand All @@ -94,7 +90,7 @@ <h3>Run configuration commands</h3>
<img class="clippy" width="13" src="{{ .Web_Path_Prefix }}static/clippy.svg" alt=""/>
</button>
<pre><code>kubectl config set-credentials {{ .Username }}-{{ .ClusterName }} --auth-provider=oidc --auth-provider-arg=idp-issuer-url={{ .Issuer }} --auth-provider-arg=client-id={{ .ClientID }} --auth-provider-arg=client-secret={{ .ClientSecret }} --auth-provider-arg=refresh-token={{ .RefreshToken }} --auth-provider-arg=id-token={{ .IDToken }}
{{- if or (.IDPCaURI) (.IDPCaPem) }} --auth-provider-arg=idp-certificate-authority=${HOME}/.kube/certs/{{ .ClusterName }}/idp-ca.crt
{{- if or (.IDPCaURI) (.IDPCaPem) }} --auth-provider-arg=idp-certificate-authority=%USERPROFILE%/.kube/certs/{{ .ClusterName }}/idp-ca.crt
{{- end }}</code></pre>
</div>
<div class="command">
Expand Down