Skip to content

Commit 3030aea

Browse files
committed
feat: add more logs in the top level of plugins
Signed-off-by: Daniel Hu <[email protected]>
1 parent d172e4c commit 3030aea

Some content is hidden

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

96 files changed

+559
-39
lines changed

internal/pkg/develop/plugin/template/NAME.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var NameGoDirTpl = "internal/pkg/plugin/[[ .Name | dirFormat ]]/"
55
var NameGoMustExistFlag = true
66
var NameGoContentTpl = `package [[ .Name | format ]]
77
8+
const Name = "[[ .Name ]]"
9+
810
// TODO(dtm): Add your logic here.
911
`
1012

internal/pkg/develop/plugin/template/create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ var createGoContentTpl = `package [[ .Name | format ]]
66
77
import (
88
"github.com/devstream-io/devstream/internal/pkg/configmanager"
9+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
910
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
1011
"github.com/devstream-io/devstream/internal/pkg/statemanager"
1112
"github.com/devstream-io/devstream/pkg/util/log"
1213
)
1314
1415
func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
16+
var err error
17+
defer func() {
18+
HandleErrLogsWithPlugin(err, Name)
19+
}()
20+
1521
// Initialize Operator with Operations
1622
operator := &installer.Operator{
1723
PreExecuteOperations: installer.PreExecuteOperations{

internal/pkg/develop/plugin/template/delete.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ var deleteGoContentTpl = `package [[ .Name | format ]]
66
77
import (
88
"github.com/devstream-io/devstream/internal/pkg/configmanager"
9+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
910
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
1011
)
1112
1213
func Delete(options configmanager.RawOptions) (bool, error) {
14+
var err error
15+
defer func() {
16+
HandleErrLogsWithPlugin(err, Name)
17+
}()
18+
1319
// Initialize Operator with Operations
1420
operator := &installer.Operator{
1521
PreExecuteOperations: installer.PreExecuteOperations{
@@ -21,7 +27,7 @@ func Delete(options configmanager.RawOptions) (bool, error) {
2127
}
2228
2329
// Execute all Operations in Operator
24-
_, err := operator.Execute(options)
30+
_, err = operator.Execute(options)
2531
if err != nil {
2632
return false, err
2733
}

internal/pkg/develop/plugin/template/read.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ var readGoContentTpl = `package [[ .Name | format ]]
66
77
import (
88
"github.com/devstream-io/devstream/internal/pkg/configmanager"
9+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
910
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
1011
"github.com/devstream-io/devstream/internal/pkg/statemanager"
1112
"github.com/devstream-io/devstream/pkg/util/log"
1213
)
1314
1415
func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
16+
var err error
17+
defer func() {
18+
HandleErrLogsWithPlugin(err, Name)
19+
}()
20+
1521
// Initialize Operator with Operations
1622
operator := &installer.Operator{
1723
PreExecuteOperations: installer.PreExecuteOperations{

internal/pkg/develop/plugin/template/update.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ var updateGoContentTpl = `package [[ .Name | format ]]
66
77
import (
88
"github.com/devstream-io/devstream/internal/pkg/configmanager"
9+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
910
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
1011
"github.com/devstream-io/devstream/internal/pkg/statemanager"
1112
"github.com/devstream-io/devstream/pkg/util/log"
1213
)
1314
1415
func Update(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
16+
var err error
17+
defer func() {
18+
HandleErrLogsWithPlugin(err, Name)
19+
}()
20+
1521
// Initialize Operator with Operations
1622
operator := &installer.Operator{
1723
PreExecuteOperations: installer.PreExecuteOperations{

internal/pkg/plugin/argocdapp/argocdapp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import (
44
_ "embed"
55
)
66

7+
const Name = "argocdapp"
8+
79
//go:embed tpl/argocd.tpl.yaml
810
var templateFileLoc string

internal/pkg/plugin/argocdapp/create.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ package argocdapp
22

33
import (
44
"github.com/devstream-io/devstream/internal/pkg/configmanager"
5+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
56
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
67
"github.com/devstream-io/devstream/internal/pkg/plugin/installer/kubectl"
78
"github.com/devstream-io/devstream/internal/pkg/statemanager"
89
kubectlUtil "github.com/devstream-io/devstream/pkg/util/kubectl"
910
"github.com/devstream-io/devstream/pkg/util/log"
1011
)
1112

12-
// Create creates an ArgoCD app YAML and applys it.
13+
// Create creates an ArgoCD app YAML and applies it.
1314
func Create(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
15+
var err error
16+
defer func() {
17+
HandleErrLogsWithPlugin(err, Name)
18+
}()
19+
1420
// Initialize Operator with Operations
1521
operator := &installer.Operator{
1622
PreExecuteOperations: installer.PreExecuteOperations{

internal/pkg/plugin/argocdapp/delete.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package argocdapp
22

33
import (
44
"github.com/devstream-io/devstream/internal/pkg/configmanager"
5+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
56
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
67
"github.com/devstream-io/devstream/internal/pkg/plugin/installer/kubectl"
78
kubectlUtil "github.com/devstream-io/devstream/pkg/util/kubectl"
89
)
910

1011
func Delete(options configmanager.RawOptions) (bool, error) {
12+
var err error
13+
defer func() {
14+
HandleErrLogsWithPlugin(err, Name)
15+
}()
16+
1117
// Initialize Operator with Operations
1218
operator := &installer.Operator{
1319
PreExecuteOperations: installer.PreExecuteOperations{
@@ -19,7 +25,7 @@ func Delete(options configmanager.RawOptions) (bool, error) {
1925
}
2026

2127
// Execute all Operations in Operator
22-
_, err := operator.Execute(options)
28+
_, err = operator.Execute(options)
2329
if err != nil {
2430
return false, err
2531
}

internal/pkg/plugin/argocdapp/read.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ package argocdapp
22

33
import (
44
"github.com/devstream-io/devstream/internal/pkg/configmanager"
5+
. "github.com/devstream-io/devstream/internal/pkg/plugin/common"
56
"github.com/devstream-io/devstream/internal/pkg/plugin/installer"
67
"github.com/devstream-io/devstream/internal/pkg/statemanager"
78
)
89

910
func Read(options configmanager.RawOptions) (statemanager.ResourceStatus, error) {
11+
var err error
12+
defer func() {
13+
HandleErrLogsWithPlugin(err, Name)
14+
}()
15+
1016
// Initialize Operator with Operations
1117
operator := &installer.Operator{
1218
PreExecuteOperations: installer.PreExecuteOperations{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
package cigeneric
2+
3+
const Name = "ci-generic"

0 commit comments

Comments
 (0)