Merge pull request #505 from samalba/gitflow-help

Gitflow help
This commit is contained in:
Sam Alba 2021-05-27 00:36:53 -07:00 committed by GitHub
commit 1f29c2f598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 42 deletions

View File

@ -11,7 +11,8 @@ import (
var initCmd = &cobra.Command{
Use: "init",
Args: cobra.MaximumNArgs(1),
Short: "Initialize a new empty workspace",
Args: cobra.NoArgs,
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:
// https://github.com/spf13/viper/issues/233
@ -35,10 +36,12 @@ var initCmd = &cobra.Command{
dir = cwd
}
_, err := state.Init(ctx, dir)
ws, err := state.Init(ctx, dir)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize workspace")
}
lg.Info().Str("path", ws.DaggerDir()).Msg("initialized new empty workspace")
},
}

View File

@ -21,7 +21,7 @@ import (
var listCmd = &cobra.Command{
Use: "list [TARGET] [flags]",
Short: "List for the inputs of an environment",
Short: "List the inputs of an environment",
Args: cobra.MaximumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:

View File

@ -1,6 +1,8 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
@ -8,7 +10,8 @@ import (
)
var newCmd = &cobra.Command{
Use: "new",
Use: "new <NAME>",
Short: "Create a new empty environment",
Args: cobra.ExactArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
// Fix Viper bug for duplicate flags:
@ -29,9 +32,13 @@ var newCmd = &cobra.Command{
Msg("cannot use option -e,--environment for this command")
}
name := args[0]
if _, err := workspace.Create(ctx, name); err != nil {
ws, err := workspace.Create(ctx, name)
if err != nil {
lg.Fatal().Err(err).Msg("failed to create environment")
}
lg.Info().Str("name", name).Msg("created new empty environment")
lg.Info().Str("name", name).Msg(fmt.Sprintf("to add code to the plan, copy or create cue files under: %s", ws.Plan))
},
}

View File

@ -11,33 +11,40 @@ Components:
- [Amazon S3](https://aws.amazon.com/s3/) for hosting
1. Change the current directory to the example deployment plan and create a new deployment
1. Initialize a new workspace
```sh
cd ./simple-s3
dagger new
dagger init
```
2. Configure your AWS credentials
2. Create a new environment
```sh
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
dagger new simple-s3
cp *.cue ./.dagger/env/simple-s3/plan/
```
3. Specify the source code location
3. Configure your AWS credentials
```sh
dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY
```
4. Specify the source code location
```sh
dagger input dir source website
```
4. Deploy!
5. Deploy!
```sh
dagger up
```
5. Check the URL
6. Check the URL
```sh
curl -i $(dagger query url -f text)
@ -56,23 +63,25 @@ Components:
- [Github](https://github.com) for source code hosting
- [React-Todo-App](https://github.com/kabirbaidhya/react-todo-app) by Kabir Baidhya as a sample application.
1. Change the current directory to the example deployment plan
1. Initialize a new workspace
```sh
cd ./react
dagger init
```
2. Create a new deployment from the plan
2. Create a new environment
```sh
dagger new
dagger new react
cp *.cue ./.dagger/env/react/plan/
```
3. Configure the deployment with your Netlify access token.
You can create new tokens from the [Netlify dashboard](https://app.netlify.com/user/applications/personal).
```sh
dagger input text www.account.token MY_TOKEN
dagger input secret www.account.token MY_TOKEN
```
_NOTE: there is a dedicated command for encrypted secret inputs, but it is
@ -95,14 +104,21 @@ This app assumes the following infrastructure is available:
- AWS RDS Instance (MySQL or PostgreSQL)
- AWS ECR repository
1. Create a new deployment from the plan
1. Initialize a new workspace
```sh
cd ./examples/jamstack
dagger new
cd ./jamstack
dagger init
```
2. Edit the inputs
2. Create a new environment
```sh
dagger new jamstack
cp *.cue ./.dagger/env/jamstack/plan/
```
3. Edit the inputs
Edit the file `inputs.yaml` and review all values to match to your infrastructure.
@ -112,7 +128,7 @@ Add the inputs to the deployment:
dagger input yaml "" -f ./inputs.yaml
```
1. Deploy!
4. Deploy!
```sh
dagger up
@ -126,7 +142,7 @@ dagger input dir backend.source ./my/local/backend/code
And the same mechanism applies for every single key in this file.
4. Get the App URL
5. Get the App URL
```sh
dagger query url
@ -144,23 +160,25 @@ Components:
- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning
- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) as kubernetes client
1. Change the current directory to the example deployment plan
1. Initialize a new workspace
```sh
cd ./kubernetes-aws
dagger init
```
2. Create a new deployment from the plan
2. Create a new environment
```sh
dagger new
dagger new kubernetes-aws
cp *.cue ./.dagger/env/kubernetes-aws/plan/
```
3. Configure the deployment with your AWS credentials
```sh
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY
```
4. Deploy!
@ -186,26 +204,28 @@ Components:
- [Amazon Cloudwatch Synthetics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) for hosting the monitoring scripts
- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning
1. Change the current directory to the example deployment plan
1. Initialize a new workspace
```sh
cd ./monitoring
dagger init
```
2. Create a new deployment from the plan
2. Create a new environment
```sh
dagger new
dagger new monitoring
cp *.cue ./.dagger/env/monitoring/plan/
```
3. Configure the deployment with your AWS credentials
2. Configure the deployment with your AWS credentials
```sh
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
```
4. Configure the monitoring parameters
3. Configure the monitoring parameters
```sh
dagger input text website https://MYWEBSITE.TLD
@ -215,7 +235,7 @@ dagger input text website https://MYWEBSITE.TLD
dagger input text email my_email@my_domain.tld
```
5. Deploy!
4. Deploy!
```sh
dagger up
@ -235,23 +255,25 @@ Components:
How to run:
1. Change the current directory to the example deployment plan
1. Initialize a new workspace
```sh
cd ./kubernetes-app
dagger init
```
2. Create a new deployment from the plan
2. Create a new environment
```sh
dagger new
dagger new kubernetes-app
cp *.cue ./.dagger/env/kubernetes-app/plan/
```
3. Configure the deployment with your AWS credentials
```sh
dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY
dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY
dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY
```
4. Configure the EKS cluster to deploy to
@ -265,7 +287,7 @@ dagger input text cluster.clusterName MY_CLUSTER_NAME
5. Load the Helm chart
```sh
dagger input dir helmChart.chart=./kubernetes-app/testdata/mychart
dagger input dir helmChart.chart ./kubernetes-app/testdata/mychart
```
6. Deploy!

View File

@ -268,3 +268,7 @@ func (w *Workspace) Create(ctx context.Context, name string) (*State, error) {
return st, nil
}
func (w *Workspace) DaggerDir() string {
return path.Join(w.Path, daggerDir)
}