Skip to content

Commit

Permalink
Add moar snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
technosophos committed May 22, 2017
1 parent 48edcd9 commit a46bc4a
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 5 deletions.
37 changes: 37 additions & 0 deletions buildsnippets/snippets.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,43 @@ var snippets = map[string]Snippet{
Description: "Create a Helm requirements.yaml",
Body: load("requirements.yaml"),
},

// Template language
"range-list": {
Prefix: "rangeList",
Description: "Loop over a list",
Body: load("range-list.tpl"),
},
"range-map": {
Prefix: "rangeDict",
Description: "Loop over a dict or map",
Body: load("range-map.tpl"),
},
"range-until": {
Prefix: "rangeUntil",
Description: "Loop a fixed number of times.",
Body: load("range-until.tpl"),
},
"if": {
Prefix: "if",
Description: "Create a conditional",
Body: load("if.tpl"),
},
"ifelse": {
Prefix: "ifElse",
Description: "Create a conditional with elseif, else",
Body: load("ifelse.tpl"),
},
"with": {
Prefix: "with",
Description: "Create a with block",
Body: load("with.tpl"),
},
"define": {
Prefix: "define",
Description: "Define a template",
Body: load("define.tpl"),
},
}

func load(loc string) []string {
Expand Down
3 changes: 3 additions & 0 deletions rawsnippets/define.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "${1}" }}
${2}
{{- end -}}
2 changes: 2 additions & 0 deletions rawsnippets/if.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- if ${1:condition} -}}
{{- end -}}
7 changes: 7 additions & 0 deletions rawsnippets/ifelse.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- if ${1:condition} -}}
${2}
{{- elseif ${3:condition2} -}}
${4}
{{- else -}}
${5}
{{- end -}}
3 changes: 3 additions & 0 deletions rawsnippets/range-list.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- range \$i, \$val := ${1:$list} }}
${2}
{{ end -}}
3 changes: 3 additions & 0 deletions rawsnippets/range-map.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- range \$key, \$val := ${1:$dict} }}
${2}
{{ end -}}
3 changes: 3 additions & 0 deletions rawsnippets/range-until.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- range \$i := until ${1:$number} }}
${2}
{{ end -}}
3 changes: 3 additions & 0 deletions rawsnippets/with.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- with ${1:.Values} }}
${2}
{{- end -}}
66 changes: 66 additions & 0 deletions snippets/helm.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,63 @@
],
"description": "Create a Service manifest"
},
"define": {
"prefix": "define",
"body": [
"{{- define \"${1}\" }}",
"${2}",
"{{- end -}}"
],
"description": "Define a template"
},
"if": {
"prefix": "if",
"body": [
"{{- if ${1:condition} -}}",
"{{- end -}}"
],
"description": "Create a conditional"
},
"ifelse": {
"prefix": "ifElse",
"body": [
"{{- if ${1:condition} -}}",
" ${2}",
"{{- elseif ${3:condition2} -}}",
" ${4}",
"{{- else -}}",
" ${5}",
"{{- end -}}"
],
"description": "Create a conditional with elseif, else"
},
"range-list": {
"prefix": "rangeList",
"body": [
"{{- range \\$i, \\$val := ${1:$list} }}",
" ${2}",
"{{ end -}}"
],
"description": "Loop over a list"
},
"range-map": {
"prefix": "rangeDict",
"body": [
"{{- range \\$key, \\$val := ${1:$dict} }}",
" ${2}",
"{{ end -}}"
],
"description": "Loop over a dict or map"
},
"range-until": {
"prefix": "rangeUntil",
"body": [
"{{- range \\$i := until ${1:$number} }}",
" ${2}",
"{{ end -}}"
],
"description": "Loop a fixed number of times."
},
"requirements.yaml": {
"prefix": "requirements.yaml",
"body": [
Expand All @@ -168,5 +225,14 @@
" repository: ${3:https://kubernetes-charts.storage.googleapis.com/}"
],
"description": "Create a Helm requirements.yaml"
},
"with": {
"prefix": "with",
"body": [
"{{- with ${1:.Values} }}",
" ${2}",
"{{- end -}}"
],
"description": "Create a with block"
}
}
10 changes: 5 additions & 5 deletions src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import * as fs from "fs";

export function helmVersion() {
helmExec("version -c", function(code, out, err){
if (code != 0) {
vscode.window.showErrorMessage(err)
return
}
vscode.window.showInformationMessage(out)
if (code != 0) {
vscode.window.showErrorMessage(err)
return
}
vscode.window.showInformationMessage(out)
})
}

Expand Down

0 comments on commit a46bc4a

Please sign in to comment.