Skip to content

Commit

Permalink
Merge branch 'main' into release-0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiexin Guo committed May 21, 2022
2 parents 6c08a2c + 3813862 commit 54bacbd
Show file tree
Hide file tree
Showing 21 changed files with 138 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: upload core
run: bash -e ./hack/release/upload_assets.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.TAG }} ${{ env.GOOS }} ${{ env.GOARCH }}
- name: upload plugin
run: aws s3 cp .devstream/ s3://download.devstream.io/${{ env.TAG }}/ --recursive --acl public-read
run: aws s3 cp .devstream/ s3://download.devstream.io/${{ env.TAG }}/ --recursive --acl public-read

# release for darwin-amd64
build-and-release-on-darwin-amd64:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ jobs:
aws eks update-kubeconfig --region ap-southeast-1 --name dtm-test
- name: copy config files
run: cp ./test/e2e/yaml/e2e-*.yaml ./
- name: apply
- name: apply git-ops
run: ./dtm apply -f e2e-config.yaml -y
- name: apply twice
- name: apply twice git-ops
run: ./dtm apply -f e2e-config.yaml -y
- name: apply trello-github
run: ./dtm apply -f e2e-trello-github-config.yaml -y
- name: apply twice trello-github
run: ./dtm apply -f e2e-trello-github-config.yaml -y
- name: check if pod is ready
run: while [[ $(kubectl get pods -l app=dtm-e2e-go -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "pod not ready yet..."; sleep 3; done
timeout-minutes: 10
- name: verify
run: ./dtm verify -f e2e-config.yaml
- name: clean
run: ./dtm delete -f e2e-config.yaml -y

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ ROOT_DIR := $(abspath $(shell cd $(SELF_DIR) && pwd -P))
endif

ifeq ($(origin VERSION), undefined)
VERSION := $(shell git describe --tags --always --match='v*')
# the VERSION is a number, like 0.6.0
# it doesn't contain the prefix v, not v0.6.0, but 0.6.0
VERSION := $(shell git describe --tags --always --match='v*' | cut -c 2-)
endif

ifeq ($(origin PLUGINS_DIR),undefined)
Expand Down
2 changes: 1 addition & 1 deletion cmd/devstream/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var PluginsName string

// List all of plugins name
// List all plugins name
func List(pluginFilter string) {
listPluginsName := strings.Fields(PluginsName)
r, _ := regexp.Compile(pluginFilter)
Expand Down
2 changes: 1 addition & 1 deletion docs/development/creating-a-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ DevStream uses [go plugin](https://pkg.go.dev/plugin) to implement custom DevOps

When you execute a command which calls any of the interfaces(`Create`, `Read`, `Update`, `Delete`), devstream's pluginengine will call the [`plugin.Lookup("DevStreamPlugin")` function](https://github.com/devstream-io/devstream/blob/38307894bbc08f691b2c5015366d9e45cc87970c/internal/pkg/pluginengine/plugin_helper.go#L28) to load the plugin, get the variable `DevStreamPlugin` that implements the ` DevStreamPlugin` interface, and then you can call the corresponding plugin logic functions. This is why it is not recommended to modify the `/cmd/plugin/YOUR-PLUGIN-NAME/main.go` file directly.

Note: The `main()` in `/cmd/plugin/YOUR-PLUGIN-NAME/main.go` file will not executed, it is only used to avoid the goclangci-lint error.
Note: The `main()` in `/cmd/plugin/YOUR-PLUGIN-NAME/main.go` file will not be executed, it is only used to avoid the goclangci-lint error.
2 changes: 1 addition & 1 deletion docs/quickstart_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ For Linux/Macos users:

## 2 Prepare a Config File

Before you start: for an example of DevStream config, see [examples/tools-quickstart.yaml](./examples/tools-quickstart.yaml). Remember to open this configuration file, modify all FULL_UPPER_CASE_STRINGS (like YOUR_GITHUB_USERNAME, for example) in it to your own. Pay attention to the meaning of each item to ensure that it is what you want. For other plugins, checkout the "Plugins" section in our [doc](https://docs.devstream.io) for detailed usage.
Before you start: for an example of DevStream config, see [examples/tools-quickstart.yaml](https://github.com/devstream-io/devstream/blob/main/examples/tools-quickstart.yaml). Remember to open this configuration file, modify all FULL_UPPER_CASE_STRINGS (like YOUR_GITHUB_USERNAME, for example) in it to your own. Pay attention to the meaning of each item to ensure that it is what you want. For other plugins, checkout the "Plugins" section in our [doc](https://docs.devstream.io) for detailed usage.

Download the [examples/quickstart.yaml](https://raw.githubusercontent.com/devstream-io/devstream/main/examples/quickstart.yaml) and [examples/tools-quickstart.yaml](https://raw.githubusercontent.com/devstream-io/devstream/main/examples/tools-quickstart.yaml) to your working directory and rename `quickstart.yaml` to `config.yaml`:

Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## 2 准备一个配置文件

开始之前:这是一个DevStream配置的例子:[examples/tools-quickstart.yaml](../examples/tools-quickstart.yaml)。记得打开这个配置文件,把里面所有的 `FULL_UPPER_CASE_STRINGS`(比如说 `YOUR_GITHUB_USERNAME` )修改成你自己的。注意每一项的含义,并确保它是你要的。对于其他插件,请查看我们的 [文档](https://docs.devstream.io) 中的"插件"部分,以了解详细用法。
开始之前:这是一个DevStream配置的例子:[examples/tools-quickstart.yaml](https://github.com/devstream-io/devstream/blob/main/examples/tools-quickstart.yaml) 。记得打开这个配置文件,把里面所有的 `FULL_UPPER_CASE_STRINGS`(比如说 `YOUR_GITHUB_USERNAME` )修改成你自己的。注意每一项的含义,并确保它是你要的。对于其他插件,请查看我们的 [文档](https://docs.devstream.io) 中的"插件"部分,以了解详细用法。

[examples/quickstart.yaml](https://raw.githubusercontent.com/devstream-io/devstream/main/examples/quickstart.yaml)[examples/tools-quickstart.yaml](https://raw.githubusercontent.com/devstream-io/devstream/main/examples/tools-quickstart.yaml) 文件下载到你到工作目录下,然后重命名`quickstart.yaml``config.yaml`

Expand Down
2 changes: 1 addition & 1 deletion hack/release/auto-release-darwin-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ while getopts "t:" opt; do
done

if [ "${tag}" == "invalid" ]; then
echo "Maybe you forgot to use -t flag. E.g. sh auto-release-darwin-arm64.sh -t v0.6.0"
echo "Maybe you forgot to use -t flag. E.g. sh auto-release-darwin-arm64.sh -t 0.6.0"
exit 1
fi
echo "tag: ${tag}"
Expand Down
46 changes: 46 additions & 0 deletions hack/terraform/bucket-policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
resource "aws_s3_bucket_policy" "policy_iterable" {
bucket = "download.devstream.io"
policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "PublicReadGetObjectOnlyForCloudFlareIps111",
"Effect" : "Deny",
"Principal" : "*",
"Action" : "s3:GetObject",
"Resource" : [
"arn:aws:s3:::download.devstream.io",
"arn:aws:s3:::download.devstream.io/*"
],
"Condition" : {
"NotIpAddress" : {
"aws:SourceIp" : [
"2400:cb00::/32",
"2606:4700::/32",
"2803:f800::/32",
"2405:b500::/32",
"2405:8100::/32",
"2a06:98c0::/29",
"2c0f:f248::/32",
"173.245.48.0/20",
"103.21.244.0/22",
"103.22.200.0/22",
"103.31.4.0/22",
"141.101.64.0/18",
"108.162.192.0/18",
"190.93.240.0/20",
"188.114.96.0/20",
"197.234.240.0/22",
"198.41.128.0/17",
"162.158.0.0/15",
"104.16.0.0/13",
"104.24.0.0/14",
"172.64.0.0/13",
"131.0.72.0/22"
]
}
}
}
]
})
}
2 changes: 2 additions & 0 deletions hack/terraform/devstream-iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ resource "aws_iam_group_policy" "DevStream-Download-Bucket-RW-Policy" {
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject",
"s3:RestoreObject",
"s3:ListBucket",
Expand Down
33 changes: 33 additions & 0 deletions hack/terraform/github-actions-iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,39 @@ resource "aws_iam_user_policy" "githubactions" {
policy = data.aws_iam_policy_document.githubactions.json
}

resource "aws_iam_user_policy" "GitHubActions-Download-Bucket-RW-Policy" {
name = "GitHubActions-Download-Bucket-RW-Policy"
user = aws_iam_user.githubactions.name

policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PermissionForDownloadUploadForTheBucket",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject",
"s3:RestoreObject",
"s3:ListBucket",
"s3:GetBucketPolicy",
"s3:ReplicateObject",
"s3:GetBucketWebsite",
"s3:PutBucketWebsite",
"s3:GetBucketCORS",
],
"Resource": [
"arn:aws:s3:::download.devstream.io",
"arn:aws:s3:::download.devstream.io/*"
]
}
]
})
}

resource "aws_iam_access_key" "githubactions" {
user = aws_iam_user.githubactions.name
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const (

// Backend is used to persist data, it can be local file/etcd/s3/...
type Backend interface {
// Read is used to reads data from persistent storage.
// Read is used to read data from persistent storage.
Read() ([]byte, error)
// Write is used to writes data to persistent storage.
// Write is used to write data to persistent storage.
Write(data []byte) error
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (l *Local) Read() ([]byte, error) {
return data, nil
}

// Write is used to writes the data to local file.
// Write is used to write the data to local file.
func (l *Local) Write(data []byte) error {
l.mu.Lock()
defer l.mu.Unlock()
Expand Down
4 changes: 0 additions & 4 deletions internal/pkg/configloader/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ func validateDependency(tools []Tool) []error {
func validateConfigFile(c *ConfigFile) []error {
errors := make([]error, 0)

if c.VarFile == "" {
errors = append(errors, fmt.Errorf("variables file is empty"))
}

if c.ToolFile == "" {
errors = append(errors, fmt.Errorf("tool file is empty"))
}
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/configloader/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
)

func renderVariables(varFileName string, configFileBytes []byte) ([]byte, error) {
if varFileName == "" {
return configFileBytes, nil
}
// load variables file
variables, err := loadVariablesFilesIntoMap(varFileName)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/pkg/plugin/githubactions/golang/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const (
RegistryHarbor RegistryType = "harbor"
)

// Build is the struct for githubacions job.
// Build is the struct for githubactions job.
type Build struct {
Enable bool
Command string
}

// Test is the struct for githubacions job.
// Test is the struct for githubactions job.
type Test struct {
Enable bool
Command string
Coverage Coverage
}

// Docker is the struct for githubacions job.
// Docker is the struct for githubactions job.
type Docker struct {
Enable bool
Registry Registry
Expand All @@ -35,18 +35,18 @@ type Registry struct {
Repository string
}

// Coverage is the struct for githubacions job.
// Coverage is the struct for githubactions job.
type Coverage struct {
Enable bool
Profile string
Output string
}

// Tag is the struct for githubacions job.
// Tag is the struct for githubactions job.
type Tag struct {
}

// Image is the struct for githubacions job.
// Image is the struct for githubactions job.
type Image struct {
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/pluginengine/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const (
)

// GetChangesForApply takes "State Manager" & "Config" then do some calculate and return a Plan.
// All actions should be execute is included in this Plan.changes.
// All actions should be executed is included in this Plan.changes.
func GetChangesForApply(smgr statemanager.Manager, cfg *configloader.Config) ([]*Change, error) {
return getChanges(smgr, cfg, CommandApply, false)
}

// GetChangesForDelete takes "State Manager" & "Config" then do some calculation and return a Plan to delete all plugins in the Config.
// All actions should be execute is included in this Plan.changes.
// All actions should be executed is included in this Plan.changes.
func GetChangesForDelete(smgr statemanager.Manager, cfg *configloader.Config, isForceDelete bool) ([]*Change, error) {
return getChanges(smgr, cfg, CommandDelete, isForceDelete)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/pluginengine/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func HandleOutputsReferences(smgr statemanager.Manager, options map[string]inter
}

// getToolNamePluginKindAndOutputReferenceKey returns (false, "", "", "") if regex doesn't match
// if match, returns (true, name, instanceID, key)
// if matched, returns (true, name, instanceID, key)
func getToolNamePluginOutputKey(s string) (bool, string, string, string) {
regex := `.*\${{\s*([^.]*)\.([^.]*)\.outputs\.([^.\s]*)\s*}}.*`
r := regexp.MustCompile(regex)
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/yaml/e2e-trello-github-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
varFile: e2e-variables.yaml
toolFile: e2e-trello-github-tools.yaml
state:
backend: local
options:
stateFile: devstream.state
19 changes: 19 additions & 0 deletions test/e2e/yaml/e2e-trello-github-tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tools:
- name: trello
instanceID: default
dependsOn: [ ]
options:
org: [[ githubOrganization ]]
repo: [[ RepoName ]]
kanbanBoardName: [[ kanbanBoardName ]]
- name: trello-github-integ
instanceID: default
dependsOn: [ "trello.default" ]
options:
org: [[ githubOrganization ]]
repo: [[ RepoName ]]
boardId: ${{ trello.default.outputs.boardId }}
todoListId: ${{ trello.default.outputs.todoListId }}
doingListId: ${{ trello.default.outputs.doingListId }}
doneListId: ${{ trello.default.outputs.doneListId }}
branch: main
1 change: 1 addition & 0 deletions test/e2e/yaml/e2e-variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ repoName: dtm-e2e-go
dockerRegistryUserName: dtme2etest
argocdNameSpace: argocd
argocdDeployTimeout: 10m
kanbanBoardName: dtmKanbanTest

0 comments on commit 54bacbd

Please sign in to comment.