Skip to content

Commit 0f2a93a

Browse files
authored
refactor: splitting github actions plugin into different ones accordi… (#184)
* refactor: splitting github actions plugin into different ones according to languages * fixing lint
1 parent cbd8625 commit 0f2a93a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1167
-542
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ help: ## Display this help.
1010
build: fmt vet ## Build dtm & plugins locally.
1111
go mod tidy
1212
mkdir -p .devstream
13-
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/githubactions-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/
13+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/githubactions-golang-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/golang
14+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/githubactions-python-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/python
15+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/githubactions-nodejs-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/nodejs
1416
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/trello-github-integ-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/trellogithub/
1517
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/argocd-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/argocd/
1618
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o .devstream/argocdapp-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/argocdapp/

build/package/build_linux_amd64.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export GOOS=linux
66
export GOARCH=amd64
77
export VERSION
88
go build -trimpath -gcflags="all=-N -l" -o output/dtm-${GOOS}-${GOARCH} ./cmd/devstream/
9-
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/githubactions-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/
9+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/githubactions-golang-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/golang
10+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/githubactions-python-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/python
11+
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/githubactions-nodejs-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/githubactions/nodejs
1012
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/trello-github-integ-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/trellogithub/
1113
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/argocd-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/argocd/
1214
go build -buildmode=plugin -trimpath -gcflags="all=-N -l" -o output/argocdapp-${GOOS}-${GOARCH}_${VERSION}.so ./cmd/argocdapp/
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@ package main
22

33
import (
44
"github.com/merico-dev/stream/internal/pkg/log"
5-
"github.com/merico-dev/stream/internal/pkg/plugin/githubactions"
5+
"github.com/merico-dev/stream/internal/pkg/plugin/githubactions/golang"
66
)
77

88
// NAME is the name of this DevStream plugin.
9-
const NAME = "githubactions"
9+
const NAME = "githubactions-golang"
1010

1111
// Plugin is the type used by DevStream core. It's a string.
1212
type Plugin string
1313

1414
// Install implements the installation of some GitHub Actions workflows.
1515
func (p Plugin) Install(options *map[string]interface{}) (bool, error) {
16-
return githubactions.Install(options)
16+
return golang.Install(options)
1717
}
1818

1919
// Reinstall implements the installation of some GitHub Actions workflows.
2020
func (p Plugin) Reinstall(options *map[string]interface{}) (bool, error) {
21-
return githubactions.Reinstall(options)
21+
return golang.Reinstall(options)
2222
}
2323

2424
// Uninstall implements the installation of some GitHub Actions workflows.
2525
func (p Plugin) Uninstall(options *map[string]interface{}) (bool, error) {
26-
return githubactions.Uninstall(options)
26+
return golang.Uninstall(options)
2727
}
2828

2929
// IsHealthy implements the healthy check of GitHub Actions workflows.
3030
func (p Plugin) IsHealthy(options *map[string]interface{}) (bool, error) {
31-
return githubactions.IsHealthy(options)
31+
return golang.IsHealthy(options)
3232
}
3333

3434
// DevStreamPlugin is the exported variable used by the DevStream core.

cmd/githubactions/nodejs/main.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"github.com/merico-dev/stream/internal/pkg/log"
5+
"github.com/merico-dev/stream/internal/pkg/plugin/githubactions/nodejs"
6+
)
7+
8+
// NAME is the name of this DevStream plugin.
9+
const NAME = "githubactions-nodejs"
10+
11+
// Plugin is the type used by DevStream core. It's a string.
12+
type Plugin string
13+
14+
// Install implements the installation of some GitHub Actions workflows.
15+
func (p Plugin) Install(options *map[string]interface{}) (bool, error) {
16+
return nodejs.Install(options)
17+
}
18+
19+
// Reinstall implements the installation of some GitHub Actions workflows.
20+
func (p Plugin) Reinstall(options *map[string]interface{}) (bool, error) {
21+
return nodejs.Reinstall(options)
22+
}
23+
24+
// Uninstall implements the installation of some GitHub Actions workflows.
25+
func (p Plugin) Uninstall(options *map[string]interface{}) (bool, error) {
26+
return nodejs.Uninstall(options)
27+
}
28+
29+
// IsHealthy implements the healthy check of GitHub Actions workflows.
30+
func (p Plugin) IsHealthy(options *map[string]interface{}) (bool, error) {
31+
return nodejs.IsHealthy(options)
32+
}
33+
34+
// DevStreamPlugin is the exported variable used by the DevStream core.
35+
var DevStreamPlugin Plugin
36+
37+
func main() {
38+
log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", NAME, DevStreamPlugin)
39+
}

cmd/githubactions/python/main.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
"github.com/merico-dev/stream/internal/pkg/log"
5+
"github.com/merico-dev/stream/internal/pkg/plugin/githubactions/python"
6+
)
7+
8+
// NAME is the name of this DevStream plugin.
9+
const NAME = "githubactions-python"
10+
11+
// Plugin is the type used by DevStream core. It's a string.
12+
type Plugin string
13+
14+
// Install implements the installation of some GitHub Actions workflows.
15+
func (p Plugin) Install(options *map[string]interface{}) (bool, error) {
16+
return python.Install(options)
17+
}
18+
19+
// Reinstall implements the installation of some GitHub Actions workflows.
20+
func (p Plugin) Reinstall(options *map[string]interface{}) (bool, error) {
21+
return python.Reinstall(options)
22+
}
23+
24+
// Uninstall implements the installation of some GitHub Actions workflows.
25+
func (p Plugin) Uninstall(options *map[string]interface{}) (bool, error) {
26+
return python.Uninstall(options)
27+
}
28+
29+
// IsHealthy implements the healthy check of GitHub Actions workflows.
30+
func (p Plugin) IsHealthy(options *map[string]interface{}) (bool, error) {
31+
return python.IsHealthy(options)
32+
}
33+
34+
// DevStreamPlugin is the exported variable used by the DevStream core.
35+
var DevStreamPlugin Plugin
36+
37+
func main() {
38+
log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", NAME, DevStreamPlugin)
39+
}

examples/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tools:
1212
image_repo: ironcore864/golang-demo
1313
- name: golang-demo-app
1414
plugin:
15-
kind: githubactions
15+
kind: githubactions-golang
1616
version: 0.0.2
1717
options:
1818
owner: ironcore864
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package githubactions
2+
3+
import "fmt"
4+
5+
func GetLanguage(l *Language) string {
6+
return fmt.Sprintf("%s-%s", l.Name, l.Version)
7+
}

0 commit comments

Comments
 (0)