Skip to content

Commit

Permalink
fix(bootstrap): v9.37.0 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard committed May 18, 2022
1 parent 9773315 commit f216eaa
Show file tree
Hide file tree
Showing 32 changed files with 176 additions and 143 deletions.
28 changes: 27 additions & 1 deletion .circleci/config.yml
@@ -1,6 +1,6 @@
version: 2.1
orbs:
shared: getoutreach/shared@1.60.0
shared: getoutreach/shared@1.64.3

# DEPRECATED: Use the devbase orb instead:
# https://github.com/getoutreach/devbase/tree/main/orbs/shared
Expand Down Expand Up @@ -76,6 +76,25 @@ jobs:
name: Finish Coveralls upload
command: ./scripts/shell-wrapper.sh ci/testing/coveralls-finish.sh

e2e:
executor:
name: shared/testbed-machine
environment:
VAULT_ADDR: https://vault-dev.outreach.cloud
resource_class: large
steps:
- shared/setup_environment:
machine: true
- shared/with_go_cache
- run:
name: Run E2E Tests
command: KUBECONFIG="$HOME/.outreach/kubeconfig.yaml" make e2e | tee ${TEST_RESULTS}/go-test.out
- run:
name: Upload Code Coverage
command: ./scripts/shell-wrapper.sh ci/testing/coveralls.sh e2e
- shared/save_go_cache # We save at the end because binaries are included with this
- shared/upload_test_results # Uploads to CircleCI

release-dryrun:
executor:
name: shared/testbed-docker
Expand Down Expand Up @@ -172,9 +191,16 @@ workflows:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- e2e:
context:
- docker-registry
- ghaccesstoken
- vault-dev
- aws-credentials
- finalize-coverage:
context:
- docker-registry
- ghaccesstoken
requires:
- e2e
- test
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -13,7 +13,9 @@ Please read the [CONTRIBUTING.md](CONTRIBUTING.md) document for guidelines on de
## High-level Overview

<!--- Block(overview) -->

Stencil is a smart templating engine for service/library development aimed to reduce the use of boilerplate code.

Check out our [documentation](https://engineering.outreach.io/stencil/) for more information!

<!--- EndBlock(overview) -->
6 changes: 3 additions & 3 deletions bootstrap.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/content/en/about/what-is-stencil.md
Expand Up @@ -20,9 +20,9 @@ Instead you can write modules for your boilerplate and other "components" of an

Stencil enables this through a few different components:

* [Modules](/stencil/modules/) - The major selling point of stencil, allows you to create module groups of Go templates and other dependencies.
* [Native Extensions](/stencil/modules/native-extensions) - Write code in any language and consume it within your templates.
* [Module Hooks](/stencil/modules/template-module#module-hooks) - Allows modules to write to templates a module owns in a predictable strongly typed fashion, enabling various extension points.
* [Easy Debuggability](/stencil/commands/describe/) - Using the `stencil describe <path>` command you're able to see which module created which file when and where, removing the complexity of who created what.
- [Modules](/stencil/modules/) - The major selling point of stencil, allows you to create module groups of Go templates and other dependencies.
- [Native Extensions](/stencil/modules/native-extensions) - Write code in any language and consume it within your templates.
- [Module Hooks](/stencil/modules/template-module#module-hooks) - Allows modules to write to templates a module owns in a predictable strongly typed fashion, enabling various extension points.
- [Easy Debuggability](/stencil/commands/describe/) - Using the `stencil describe <path>` command you're able to see which module created which file when and where, removing the complexity of who created what.

Curious? Dig into our [Getting Started](/stencil/getting-started/) docs to start creating!
Curious? Dig into our [Getting Started](/stencil/getting-started/) docs to start creating!
4 changes: 2 additions & 2 deletions docs/content/en/commands/stencil.md
Expand Up @@ -25,8 +25,8 @@ DESCRIPTION:
a smart templating engine for service development

COMMANDS:
describe
create
describe
create
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/commands/stencil_create.md
Expand Up @@ -22,11 +22,11 @@ DESCRIPTION:
Commands to create template repositories, or stencil powered repositories

COMMANDS:
templaterepository
templaterepository
help, h Shows a list of commands or help for one command

OPTIONS:
--help, -h show help (default: false)


```
4 changes: 2 additions & 2 deletions docs/content/en/commands/stencil_create_templaterepository.md
Expand Up @@ -13,7 +13,7 @@ menu:

```bash
NAME:
stencil create templaterepository -
stencil create templaterepository -

USAGE:
stencil create templaterepository [command options] create templaterepository <name>
Expand All @@ -23,6 +23,6 @@ DESCRIPTION:

OPTIONS:
--help, -h show help (default: false)


```
4 changes: 2 additions & 2 deletions docs/content/en/commands/stencil_describe.md
Expand Up @@ -13,7 +13,7 @@ menu:

```bash
NAME:
stencil describe -
stencil describe -

USAGE:
stencil describe [command options] [arguments...]
Expand All @@ -23,6 +23,6 @@ DESCRIPTION:

OPTIONS:
--help, -h show help (default: false)


```
1 change: 0 additions & 1 deletion docs/content/en/functions/file.Block.md
Expand Up @@ -25,4 +25,3 @@ Block returns the contents of a given block \#\#\#Block\(name\) Hello\, world\!
{{ file.Block "name" }}
###EndBlock(name)
```

1 change: 0 additions & 1 deletion docs/content/en/functions/file.Create.md
Expand Up @@ -30,4 +30,3 @@ func main() {
{{- stencil.ApplyTemplate "command" | file.SetContents }}
{{- end }}
```

1 change: 0 additions & 1 deletion docs/content/en/functions/file.Delete.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

Delete deletes the current file

1 change: 0 additions & 1 deletion docs/content/en/functions/file.Path.md
Expand Up @@ -15,4 +15,3 @@ Path returns the current path of the file we're writing to\.
```go-text-template
{{ file.Path }}
```

1 change: 0 additions & 1 deletion docs/content/en/functions/file.SetContents.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

SetContents sets the contents of the current file to the provided string\.

1 change: 0 additions & 1 deletion docs/content/en/functions/file.SetPath.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

SetPath changes the path of the current file

1 change: 0 additions & 1 deletion docs/content/en/functions/file.Skip.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

Skip skips the current file

1 change: 0 additions & 1 deletion docs/content/en/functions/file.Static.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

Static marks the current file as static

1 change: 0 additions & 1 deletion docs/content/en/functions/stencil.AddToModuleHook.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

AddToModuleHook adds to a hook in another module

1 change: 0 additions & 1 deletion docs/content/en/functions/stencil.ApplyTemplate.md
Expand Up @@ -26,4 +26,3 @@ func main() {
{{- stencil.ApplyTemplate "command" | file.SetContents }}
```

1 change: 0 additions & 1 deletion docs/content/en/functions/stencil.Arg.md
Expand Up @@ -15,4 +15,3 @@ Arg returns the value of an argument in the service's manifest\.
```go-text-template
{{- stencil.Arg "name" }}
```

1 change: 0 additions & 1 deletion docs/content/en/functions/stencil.Args.md
Expand Up @@ -15,4 +15,3 @@ Args returns all arguments passed to stencil from the service's manifest\. Note:
```go-text-template
{{- (stencil.Args).name }}
```

1 change: 0 additions & 1 deletion docs/content/en/functions/stencil.GetModuleHook.md
Expand Up @@ -11,4 +11,3 @@ menu:
---

GetModuleHook returns a module block in the scope of this module

48 changes: 27 additions & 21 deletions docs/content/en/getting-started/module-quick-start.md
Expand Up @@ -71,13 +71,13 @@ Let's create a template that creates a simple hello world message in Go. We'll s
package main

func main() {
fmt.Println("Hello, world!")
fmt.Println("Hello, world!")
}
{{< /code >}}

## Step 3: Consuming the Module in an Application

Now that we've done that, well how do we use it? This is super easy with the `replacements` map in a [`service.yaml`](/stencil/reference/service.yaml).
Now that we've done that, well how do we use it? This is super easy with the `replacements` map in a [`service.yaml`](/stencil/reference/service.yaml).

Let's quickly create a test application:

Expand All @@ -86,11 +86,11 @@ mkdir testapp; cd testapp
cat > service.yaml <<EOF
name: testapp
modules:

- name: github.com/yourorg/helloworld
replacements:
# Replace ../helloworld with the path to your module.
github.com/yourorg/helloworld: ../helloworld
{{< /code >}}
replacements: # Replace ../helloworld with the path to your module.
github.com/yourorg/helloworld: ../helloworld
{{< /code >}}

Now if we run stencil on the test application, we should see the following:

Expand Down Expand Up @@ -132,25 +132,25 @@ Let's create our own block in the hello.go template from earlier:
package main

func main() {
fmt.Println("Hello, world!")
///Block(additionalMessage)
fmt.Println("Hello, world!")
///Block(additionalMessage)
{{- /* It's important to not indent the file.Block to prevent the indentation from being copied over and.. over again. */ }}
{{ file.Block "additionalMessage" }}
///EndBlock(additionalMessage)
///EndBlock(additionalMessage)
}
{{< /code >}}

If we re-run stencil and look at `hello.go` we should see the following:


{{< code file="hello.go" copy=true >}}
package main

func main() {
fmt.Println("Hello, world!")
///Block(additionalMessage)
fmt.Println("Hello, world!")
///Block(additionalMessage)

///EndBlock(additionalMessage)

///EndBlock(additionalMessage)
}
{{< /code >}}

Expand All @@ -161,23 +161,30 @@ If we add contents to the block and re-run stencil they'll be persisted across t
One of the powerful parts of stencil is the ability to create an arbitrary number of files with a single template. This is done with the [`file.Create`](/stencil/functions/file.create) function. Let's create a `greeter.go.tpl` template in the `templates/` directory that'll create `<greeting>.go` based on the `greetings` argument.

{{< code file="greeter.go.tpl" copy=true >}}

# This is important! We don't want to create a greeter.go file

{{- $_ := file.Skip "Generates multiple files" }}
{{- define "greeter" -}}
{{- $greeting := .greeting }}
package main

func main() {
fmt.Println("$greeting, world!")
fmt.Println("$greeting, world!")
}

{{- end -}}

{{- range $_, $greeting := stencil.Arg "greetings" }}

# Create a new $greeting.go file

{{- file.Create (printf "%s.go" $greeting) 0600 now }}

# We'll render the template greeter with $greeting as the values being passed to it

# Once we've done that we'll use the output to set the contents of the file we just created.

{{- stencil.ApplyTemplate "greeter" $greeting | file.SetContents }}
{{- end }}
{{< /code >}}
Expand All @@ -190,14 +197,13 @@ Now let's modify the `manifest.yaml` to accept the argument `greetings`:

{{< code file="manifest.yaml" copy=true >}}
arguments:
greetings:
description: A list of greetings to use
type: list
require: true
default: ["hello", "goodbye"]
greetings:
description: A list of greetings to use
type: list
require: true
default: ["hello", "goodbye"]
{{< /code >}}


If we run stencil on the test application, we should see the following:

```bash
Expand Down Expand Up @@ -236,4 +242,4 @@ func main() {

## Reflection

We've created a module, used it in a test application via the `replacements` map in the `service.yaml` and used a block. Optionally we've also created multiple files with a template. This is just the beginning of what you can do with modules. Modules have a rich amount of [functions](/stencil/functions/) available to them. Check out the [reference](/stencil/reference/) for more information about modules and how to use them.
We've created a module, used it in a test application via the `replacements` map in the `service.yaml` and used a block. Optionally we've also created multiple files with a template. This is just the beginning of what you can do with modules. Modules have a rich amount of [functions](/stencil/functions/) available to them. Check out the [reference](/stencil/reference/) for more information about modules and how to use them.

0 comments on commit f216eaa

Please sign in to comment.