@@ -5,22 +5,39 @@ import (
55
66 "github.com/devstream-io/devstream/internal/pkg/configmanager"
77 "github.com/devstream-io/devstream/internal/pkg/plugin/installer/ci"
8+ "github.com/devstream-io/devstream/internal/pkg/plugin/installer/ci/cifile/server"
9+ "github.com/devstream-io/devstream/internal/pkg/plugin/installer/util"
10+ "github.com/devstream-io/devstream/pkg/util/mapz"
11+ "github.com/devstream-io/devstream/pkg/util/validator"
812)
913
1014// validate validates the options provided by the core.
1115func validate (options configmanager.RawOptions ) (configmanager.RawOptions , error ) {
12- opts , err := ci .NewCIOptions ( options )
13- if err != nil {
16+ opts := new ( ci.CIConfig )
17+ if err := util . DecodePlugin ( options , opts ); err != nil {
1418 return nil , err
1519 }
16- // check basic ci error
17- _ , err = ci .Validate (options )
18- if err != nil {
20+ // check struct data
21+ if err := validator .CheckStructError (opts ).Combine (); err != nil {
1922 return nil , err
2023 }
24+
2125 // check repo is valid
22- if ! opts .ProjectRepo .IsGithubRepo () {
23- return nil , fmt .Errorf ("github action only support other repo" )
26+ if opts .ProjectRepo .RepoType != "github" {
27+ return nil , fmt .Errorf ("github action only support github repo" )
2428 }
2529 return options , nil
2630}
31+
32+ func setDefault (options configmanager.RawOptions ) (configmanager.RawOptions , error ) {
33+ opts := new (ci.CIConfig )
34+ if err := util .DecodePlugin (options , opts ); err != nil {
35+ return nil , err
36+ }
37+ // set default value of pipeline location
38+ if opts .Pipeline .ConfigLocation == "" {
39+ opts .Pipeline .ConfigLocation = "https://raw.githubusercontent.com/devstream-io/dtm-pipeline-templates/main/github-actions/workflows/main.yml"
40+ }
41+ opts .CIFileConfig = opts .Pipeline .BuildCIFileConfig (server .CIGithubType , opts .ProjectRepo )
42+ return mapz .DecodeStructToMap (opts )
43+ }
0 commit comments