Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Rename to programs, clean a few things up
Browse files Browse the repository at this point in the history
  • Loading branch information
cnunciato committed Nov 29, 2023
1 parent 245c66e commit 331ecca
Show file tree
Hide file tree
Showing 143 changed files with 181 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests
name: Run example programs
on:
schedule:
- cron: "0 8 * * *"
Expand Down Expand Up @@ -74,4 +74,4 @@ jobs:
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}

- name: Run the tests
run: make test-examples
run: make test-programs
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ yarn-error.log
themes/default/theme
themes/default/assets
themes/default/layouts
themes/default/static/examples
themes/default/static/programs
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ new-learn-topic:
new-template:
./scripts/content/new-template.sh

test-examples:
./scripts/test-examples.sh preview
test-programs:
./scripts/test-programs.sh preview
2 changes: 2 additions & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -o errexit -o pipefail

git clean -fdX

yarn cache clean
hugo mod clean

Expand Down
8 changes: 4 additions & 4 deletions scripts/test-examples.sh → scripts/test-programs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -euo pipefail
pulumi whoami -v

# Delete build/test artifacts.
git clean -fdX themes/default/static/examples
git clean -fdX themes/default/static/programs

pushd themes/default/static/examples
pushd themes/default/static/programs
for dir in */; do
project="$(basename $dir)"

Expand All @@ -29,9 +29,9 @@ pushd themes/default/static/examples
# https://github.com/pulumi/pulumi-awsx/issues/820
if [[ "$project" == "awsx-vpc-fargate-service-java" ]]; then
continue
elif [[ "$project" == "load-balanced-fargate-ecr-java" ]]; then
elif [[ "$project" == "awsx-load-balanced-fargate-ecr-java" ]]; then
continue
elif [[ "$project" == "load-balanced-fargate-nginx-java" ]]; then
elif [[ "$project" == "awsx-load-balanced-fargate-nginx-java" ]]; then
continue
fi

Expand Down
7 changes: 4 additions & 3 deletions themes/default/content/docs/clouds/aws/guides/ecr.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ To create a new ECR repository, allocate an instance of the `awsx.ecr.Repository
{{% choosable language "javascript" %}}

```javascript
"use strict";
const awsx = require("@pulumi/awsx");

const repo = new awsx.ecr.Repository("repo");
Expand Down Expand Up @@ -262,7 +263,7 @@ entirely from code. This lets you version and deploy container changes easily al

In the following example, creating an `Image` resource will build an image from the "./app" directory (relative to our project and containing Dockerfile), and publish it to our ECR repository provisioned above.

{{< example path="awsx-ecr-image" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-ecr-image" >}}

As we run `pulumi up`, we will see Docker build output in the Pulumi CLI display. If there is an error, it'll
be printed in the diagnostics section, but otherwise the resulting image name is printed:
Expand Down Expand Up @@ -311,7 +312,7 @@ defaults to `latest`). The container instances require IAM permissions which are

To use your private repository from an ECS task definition, reference it like so:

{{< example path="load-balanced-fargate-ecr" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-load-balanced-fargate-ecr" >}}

For information about ECS, refer to the [Pulumi Crosswalk for AWS ECS documentation](/docs/clouds/aws/guides/ecs/). For
information about consuming ECR images from ECS services specifically, see
Expand All @@ -321,7 +322,7 @@ information about consuming ECR images from ECS services specifically, see

To use your private repository from a Kubernetes service, such as one using EKS, reference it like so:

{{< example path="awsx-ecr-eks-deployment-service" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-ecr-eks-deployment-service" >}}

For information about EKS, refer to the [Pulumi Crosswalk for AWS EKS documentation](/docs/clouds/aws/guides/eks/).

Expand Down
6 changes: 3 additions & 3 deletions themes/default/content/docs/clouds/aws/guides/ecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ providing full control over the underlying EC2 machine resources that power your
To run a Docker container in ECS using default network and cluster settings, use the `awsx.ecs.FargateService`
class. Since we need to access this container over port 80 using a stable address, we will use a load balancer.

{{< example path="load-balanced-fargate-nginx" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-load-balanced-fargate-nginx" >}}

After deploying this program, `pulumi stack output url` can be used to access the Url output property. We can then access our NGINX web server behind our load balancer via curl:

Expand Down Expand Up @@ -83,7 +83,7 @@ To create an ECS service inside of a VPC, we will first create or use an existin
described in [Pulumi Crosswalk for AWS VPC](/docs/clouds/aws/guides/vpc/). Then we pass the subnets
from that VPC into the network configuration argument for our cluster:

{{< example path="awsx-vpc-fargate-service" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-vpc-fargate-service" >}}

When using a custom VPC, you will also need to specify your own security groups if you need to allow ingress or egress.

Expand Down Expand Up @@ -115,7 +115,7 @@ it separately ahead of time. This makes it very easy to use private registration
For example, specifying a `path` will run a `docker build` in that path, push the result up to the ECR repository that specified in the first argument, and then pass
the private ECR repository path to the container:

{{< example path="load-balanced-fargate-ecr" languages="javascript,typescript,python,go,csharp,java,yaml" >}}
{{< example-program path="awsx-load-balanced-fargate-ecr" >}}

For more information about using ECR, refer to [Pulumi Crosswalk for AWS ECR](/docs/clouds/aws/guides/ecr/).

Expand Down
44 changes: 44 additions & 0 deletions themes/default/layouts/shortcodes/example-program-snippet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- $path := .Get "path" -}}
{{- $language := .Get "language" -}}
{{- $from := .Get "from" -}}
{{- $to := .Get "to" -}}
{{- $program := "" -}}
{{- $depfile := "" -}}
{{- $deplang := "" -}}
{{- if eq $language "javascript" -}}
{{- $program = "index.js" -}}
{{- $depfile = "package.json" -}}
{{- $deplang = "json" -}}
{{- else if eq $language "typescript" -}}
{{- $program = "index.ts" -}}
{{- $depfile = "package.json" -}}
{{- $deplang = "json" -}}
{{- else if eq $language "python" -}}
{{- $program = "__main__.py" -}}
{{- $depfile = "requirements.txt" -}}
{{- $deplang = "plain" -}}
{{- else if eq $language "go" -}}
{{- $program = "main.go" -}}
{{- $depfile = "go.mod" -}}
{{- $deplang = "bash" -}}
{{- else if eq $language "csharp" -}}
{{- $program = "Program.cs" -}}
{{- $depfile = printf "%s.csproj" (printf "%s-%s" $path $language) -}}
{{- $deplang = "xml" -}}
{{- else if eq $language "java" -}}
{{- $program = "src/main/java/myproject/App.java" -}}
{{- $depfile = "pom.xml" -}}
{{- $deplang = "xml" -}}
{{- else if eq $language "yaml" -}}
{{- $program = "Pulumi.yaml" -}}
{{- end -}}
{{- $file := readFile (path.Join "static" "programs" (printf "%s-%s" $path $language) $program) -}}
{{- if and (ne $from "") (ne $to "") -}}
{{- $lines := split $file "\n" -}}
{{- $toEnd := after (sub (int $from) 1) $lines -}}
{{- $lineCount := add (sub (int $to) (int $from)) 1 -}}
{{- $toTo := first $lineCount $toEnd -}}
{{- delimit $toTo "\n" -}}
{{- else -}}
{{- $file -}}
{{- end -}}
54 changes: 54 additions & 0 deletions themes/default/layouts/shortcodes/example-program.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ $path := .Get "path" }}
{{ $languages := default "javascript,typescript,python,go,csharp,java,yaml" (.Get "languages") }}
{{ $folder := path.Join "static" "programs" }}

<div>
<pulumi-chooser type="language" options="{{ $languages }}"></pulumi-chooser>
</div>

{{ range $i, $language := split $languages "," }}
<div class="w-full">
<pulumi-choosable type="language" values="{{ $language }}">
<div>
{{ $program := "" }}
{{ $depfile := "" }}
{{ $deplang := "" }}
{{ if eq $language "javascript" }}
{{ $program = "index.js" }}
{{ $depfile = "package.json" }}
{{ $deplang = "json" }}
{{ else if eq $language "typescript" }}
{{ $program = "index.ts" }}
{{ $depfile = "package.json" }}
{{ $deplang = "json" }}
{{ else if eq $language "python" }}
{{ $program = "__main__.py" }}
{{ $depfile = "requirements.txt" }}
{{ $deplang = "plain" }}
{{ else if eq $language "go" }}
{{ $program = "main.go" }}
{{ $depfile = "go.mod" }}
{{ $deplang = "bash" }}
{{ else if eq $language "csharp" }}
{{ $program = "Program.cs" }}
{{ $depfile = printf "%s.csproj" (printf "%s-%s" $path $language) }}
{{ $deplang = "xml" }}
{{ else if eq $language "java" }}
{{ $program = "src/main/java/myproject/App.java" }}
{{ $depfile = "pom.xml" }}
{{ $deplang = "xml" }}
{{ else if eq $language "yaml" }}
{{ $program = "Pulumi.yaml" }}
{{ end }}
{{ if ne $program "" }}
{{ $root := slice "static" "programs" (printf "%s-%s" $path $language) }}
{{ $code := readFile (path.Join $root $program) }}
{{ $info := os.Stat (path.Join $root) }}
<div data-program-path="{{ $path }}" data-program-language="{{ $language }}" data-program-file="{{ $program }}" data-program-depfile="{{ $depfile }}">
{{ highlight $code $language }}
</div>
{{ end }}
</div>
</pulumi-choosable>
</div>
{{ end }}
34 changes: 1 addition & 33 deletions themes/default/layouts/shortcodes/example.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
{{ $path := .Get "path" }}
{{ $languages := .Get "languages" }}

<div>
<pulumi-chooser type="language" options="{{ $languages }}"></pulumi-chooser>
<pulumi-choosable type="language" values="{{ .Get 0 }}">{{ .Inner }}</pulumi-choosable>
</div>

{{ range $i, $language := split $languages "," }}
<div class="w-full">
<pulumi-choosable type="language" values="{{ $language }}">
<div>
{{ $program := "" }}
{{ if eq $language "javascript" }}
{{ $program = "index.js" }}
{{ else if eq $language "typescript" }}
{{ $program = "index.ts" }}
{{ else if eq $language "python" }}
{{ $program = "__main__.py" }}
{{ else if eq $language "go" }}
{{ $program = "main.go" }}
{{ else if eq $language "csharp" }}
{{ $program = "Program.cs" }}
{{ else if eq $language "java" }}
{{ $program = "src/main/java/myproject/App.java" }}
{{ else if eq $language "yaml" }}
{{ $program = "Pulumi.yaml" }}
{{ end }}
{{ if ne $program "" }}
{{ $code := readFile (path.Join "static" "examples" (printf "%s-%s" $path $language) $program) }}
{{ highlight $code $language }}
{{ end }}
</div>
</pulumi-choosable>
</div>
{{ end }}
3 changes: 3 additions & 0 deletions themes/default/layouts/shortcodes/examples.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
<pulumi-examples>{{ .Inner }}</pulumi-examples>
</div>
13 changes: 0 additions & 13 deletions themes/default/layouts/shortcodes/snippet.html

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions themes/default/static/examples/awsx-ecr-image-go/Pulumi.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ maven-status
target/

# Nested .gitignores.
**/.gitignore
/**/.gitignore
!.gitignore

# Lockfiles.
go.sum
package-lock.json
yarn.lock


# Stack config files.
Pulumi.*.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-ecr-eks-deployment-service-csharp
runtime: dotnet
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
name: awsx-ecr-eks-deployment-service-java
runtime: java
description: A minimal AWS Java Pulumi program
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ runtime:
name: python
options:
virtualenv: venv
description: A Python program to deploy a Kubernetes cluster on AWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-ecr-image-csharp
runtime: dotnet
2 changes: 2 additions & 0 deletions themes/default/static/programs/awsx-ecr-image-go/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-ecr-image-go
runtime: go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: awsx-ecr-image-java
runtime: java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ runtime:
name: nodejs
options:
typescript: false
description: A minimal AWS JavaScript Pulumi program
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ runtime:
name: python
options:
virtualenv: venv
description: A minimal AWS Python Pulumi program
Loading

0 comments on commit 331ecca

Please sign in to comment.