Skip to content

Commit 1d52db0

Browse files
authored
Merge pull request #572 from aFlyBird0/fix-config-varFile
fix(configloader): varFile can be empty
2 parents 79ef320 + 5f14cdb commit 1d52db0

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed

cmd/devstream/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
var PluginsName string
1616

17-
// List all of plugins name
17+
// List all plugins name
1818
func List(pluginFilter string) {
1919
listPluginsName := strings.Fields(PluginsName)
2020
r, _ := regexp.Compile(pluginFilter)

docs/development/creating-a-plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ DevStream uses [go plugin](https://pkg.go.dev/plugin) to implement custom DevOps
5353

5454
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.
5555

56-
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.
56+
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.

internal/pkg/backend/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const (
1818

1919
// Backend is used to persist data, it can be local file/etcd/s3/...
2020
type Backend interface {
21-
// Read is used to reads data from persistent storage.
21+
// Read is used to read data from persistent storage.
2222
Read() ([]byte, error)
23-
// Write is used to writes data to persistent storage.
23+
// Write is used to write data to persistent storage.
2424
Write(data []byte) error
2525
}
2626

internal/pkg/backend/local/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (l *Local) Read() ([]byte, error) {
5252
return data, nil
5353
}
5454

55-
// Write is used to writes the data to local file.
55+
// Write is used to write the data to local file.
5656
func (l *Local) Write(data []byte) error {
5757
l.mu.Lock()
5858
defer l.mu.Unlock()

internal/pkg/configloader/validation.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func validateDependency(tools []Tool) []error {
8282
func validateConfigFile(c *ConfigFile) []error {
8383
errors := make([]error, 0)
8484

85-
if c.VarFile == "" {
86-
errors = append(errors, fmt.Errorf("variables file is empty"))
87-
}
88-
8985
if c.ToolFile == "" {
9086
errors = append(errors, fmt.Errorf("tool file is empty"))
9187
}

internal/pkg/configloader/variables.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
)
1313

1414
func renderVariables(varFileName string, configFileBytes []byte) ([]byte, error) {
15+
if varFileName == "" {
16+
return configFileBytes, nil
17+
}
1518
// load variables file
1619
variables, err := loadVariablesFilesIntoMap(varFileName)
1720
if err != nil {

internal/pkg/plugin/githubactions/golang/jobs.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ const (
99
RegistryHarbor RegistryType = "harbor"
1010
)
1111

12-
// Build is the struct for githubacions job.
12+
// Build is the struct for githubactions job.
1313
type Build struct {
1414
Enable bool
1515
Command string
1616
}
1717

18-
// Test is the struct for githubacions job.
18+
// Test is the struct for githubactions job.
1919
type Test struct {
2020
Enable bool
2121
Command string
2222
Coverage Coverage
2323
}
2424

25-
// Docker is the struct for githubacions job.
25+
// Docker is the struct for githubactions job.
2626
type Docker struct {
2727
Enable bool
2828
Registry Registry
@@ -35,18 +35,18 @@ type Registry struct {
3535
Repository string
3636
}
3737

38-
// Coverage is the struct for githubacions job.
38+
// Coverage is the struct for githubactions job.
3939
type Coverage struct {
4040
Enable bool
4141
Profile string
4242
Output string
4343
}
4444

45-
// Tag is the struct for githubacions job.
45+
// Tag is the struct for githubactions job.
4646
type Tag struct {
4747
}
4848

49-
// Image is the struct for githubacions job.
49+
// Image is the struct for githubactions job.
5050
type Image struct {
5151
}
5252

internal/pkg/pluginengine/change.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ const (
3838
)
3939

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

4646
// GetChangesForDelete takes "State Manager" & "Config" then do some calculation and return a Plan to delete all plugins in the Config.
47-
// All actions should be execute is included in this Plan.changes.
47+
// All actions should be executed is included in this Plan.changes.
4848
func GetChangesForDelete(smgr statemanager.Manager, cfg *configloader.Config, isForceDelete bool) ([]*Change, error) {
4949
return getChanges(smgr, cfg, CommandDelete, isForceDelete)
5050
}

internal/pkg/pluginengine/outputs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func HandleOutputsReferences(smgr statemanager.Manager, options map[string]inter
4343
}
4444

4545
// getToolNamePluginKindAndOutputReferenceKey returns (false, "", "", "") if regex doesn't match
46-
// if match, returns (true, name, instanceID, key)
46+
// if matched, returns (true, name, instanceID, key)
4747
func getToolNamePluginOutputKey(s string) (bool, string, string, string) {
4848
regex := `.*\${{\s*([^.]*)\.([^.]*)\.outputs\.([^.\s]*)\s*}}.*`
4949
r := regexp.MustCompile(regex)

0 commit comments

Comments
 (0)