Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from shykes/demo-tweaks
Browse files Browse the repository at this point in the history
Rename dagger.yaml to cloak.yaml
  • Loading branch information
sipsma authored Aug 4, 2022
2 parents 55e7801 + c0d45d4 commit cecd88e
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 14 deletions.
8 changes: 4 additions & 4 deletions DEMO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a demo meant for external users. They are assumed to have general knowle
- `go build ./cmd/cloak`
- `ln -sf "$(pwd)/cloak" /usr/local/bin`
3. Ensure that packages are already cached so that you don't have to wait a long time at the first command for various yarn packages to download
- TODO: add a command for doing this (`cloak import -c dagger.yaml`?)
- TODO: add a command for doing this (`cloak import -c cloak.yaml`?)
4. Export `NETLIFY_AUTH_TOKEN` env

## 1. Background
Expand All @@ -30,7 +30,7 @@ This is a demo meant for external users. They are assumed to have general knowle
Run:

```console
cloak query -c examples/todoapp/go/dagger.yaml --op Deploy --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN"
cloak query -c examples/todoapp/go/cloak.yaml --op Deploy --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN"
```

1. Click on the output URL, show the TODOApp.
Expand Down Expand Up @@ -72,7 +72,7 @@ cloak query -c examples/todoapp/go/dagger.yaml --op Deploy --local-dir src=examp
1. Run same command as before:

```console
cloak query -c examples/todoapp/go/dagger.yaml --op Deploy --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN"
cloak query -c examples/todoapp/go/cloak.yaml --op Deploy --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN"
```

1. Click on the output URL, show the TODOApp at the new URL.
Expand All @@ -86,7 +86,7 @@ Dream goal is something like:

1. User starts with empty directory. Creates `schema.graphql` either from scratch or from a template.
1. User fills out actions they'd like to implement in `schema.graphql` in addition to declaring which other actions they want to use in their implementation (aka their dependencies)
- (This assumes we have migrated `dagger.yaml` to be directives in `schema.graphql`)
- (This assumes we have migrated `cloak.yaml` to be directives in `schema.graphql`)
- Declaring dependencies could be optional too, can have whole universe imported by default if not declared or similar DX sugar.
1. User runs a command that reads `schema.graphql` and outputs to a local directory all dependency schemas, client stubs for calling the dependencies and implementation stubs that the user can fill out to implement their action.
1. User fills in implementations.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ EOF
Yarn build:

```console
cloak query -c examples/yarn/dagger.yaml --local-dir source=examples/todoapp/app --set name=build
cloak query -c examples/yarn/cloak.yaml --local-dir source=examples/todoapp/app --set name=build
```

TODOApp deploy:

```console
cloak query -c examples/todoapp/ts/dagger.yaml --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN" <<'EOF'
cloak query -c examples/todoapp/ts/cloak.yaml --local-dir src=examples/todoapp/app --secret token="$NETLIFY_AUTH_TOKEN" <<'EOF'
query Build($src: FS!, $token: String!) {
todoapp{deploy(src: $src, token: $token){url}}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ Say we are creating a new Typescript package called `foo` that will have a singl
1. Open `schema.graphql`, replace the existing `build`, `test` and `deploy` fields under `Query` with one field per action you want to implement
- This is where the schema for the actions in your package is configured. Feel free to add more complex output/input types as needed
- If you want `foo` to just have a single action `bar`, you just need a field for `bar` (with appropriate input and output types).
1. Open up `dagger.yaml`
1. Open up `cloak.yaml`
- This is where you declare your own package in addition to dependencies of your package. Declaring packages here makes them available to be called by your action implementation in addition to telling cloak how to build them.
- Packages are declared by specifying how they are built. Currently, we just use Dockerfiles for everything, but in theory this should be much more flexible.
- Replacing the existing `yarn` key under `actions` with `foo`; similarly change `examples/yarn/Dockerfile` to `examples/foo/Dockerfile`
Expand Down Expand Up @@ -122,7 +122,7 @@ Say we are creating a new Go package called `foo` that will have a single action
1. Open `schema.graphql`, replace the existing `build` field under `Query` with one field per action you want to implement
- This is where the schema for the actions in your package is configured. Feel free to add more complex output/input types as needed
- If you want `foo` to just have a single action `bar`, you just need a field for `bar` (with appropriate input and output types).
1. Open up `dagger.yaml`
1. Open up `cloak.yaml`
- This is where you declare your own package in addition to dependencies of your package. Declaring packages here makes them available to be called by your action implementation in addition to telling cloak how to build them.
- Packages are declared by specifying how they are built. Currently, we just use Dockerfiles for everything, but in theory this should be much more flexible.
- Replacing the existing `alpine` key under `actions` with `foo`; similarly change `examples/alpine/Dockerfile` to `examples/foo/Dockerfile`
Expand All @@ -131,7 +131,7 @@ Say we are creating a new Go package called `foo` that will have a single action
1. Setup client stub configuration for each of your dependencies
- Open `main.go`, remove the imports, remove the `Resolver` struct and method, and comment out the lines of code in the `main` func.
- `cloak generate --output-dir gen`
- This will parse your `dagger.yaml` and export `schema.graphql` and `operation.graphql` into a subdir under `gen/` for each of your dependencies (plus `core`)
- This will parse your `cloak.yaml` and export `schema.graphql` and `operation.graphql` into a subdir under `gen/` for each of your dependencies (plus `core`)
- For each of the dependencies
- Create a file `gen/<pkgname>/genqclient.yaml` based on `../alpinegen/core/genqlient.yaml`, replacing the word `core` with `<pkgname>`
- Add a `//go:generate` directive to the top of `main.go` in the form:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/cloak/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
)

func init() {
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./dagger.yaml", "config file")
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "./cloak.yaml", "config file")
rootCmd.AddCommand(
queryCmd,
generateCmd,
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloak/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func Query(cmd *cobra.Command, args []string) {

// Use the provided query file if specified
// Otherwise, if stdin is a pipe or other non-tty thing, read from it.
// Finally, default to reading from operations.graphql next to dagger.yaml
// Finally, default to reading from operations.graphql next to cloak.yaml
isTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
if queryFile == "" && isTerminal {
queryFile = filepath.Join(filepath.Dir(configFile), "operations.graphql")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/queries/dagger.yaml → examples/queries/cloak.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
actions:
# alpine:
# local: ../..
# dockerfile: examples/alpine/Dockerfile
alpine:
local: ../..
dockerfile: examples/alpine/Dockerfile
# yarn:
# local: ../..
# dockerfile: examples/yarn/Dockerfile
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/todoapp/ts/cloak.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
actions:
alpine:
local: ../../..
dockerfile: examples/alpine/Dockerfile
yarn:
local: ../../..
dockerfile: examples/yarn/Dockerfile
netlify:
local: ../../..
dockerfile: examples/netlify/ts/Dockerfile
todoapp:
local: ../../..
dockerfile: examples/todoapp/ts/Dockerfile
File renamed without changes.

0 comments on commit cecd88e

Please sign in to comment.