-
Notifications
You must be signed in to change notification settings - Fork 2
/
pipeline_syntax.go
39 lines (29 loc) · 1018 Bytes
/
pipeline_syntax.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package gocd
import (
"strings"
"github.com/nikhilsbhat/gocd-sdk-go/pkg/plugin"
)
func (conf *client) ValidatePipelineSyntax(pluginCfg plugin.Plugin, pipelines []string, fetchVersionFromServer bool) (bool, error) {
if err := pluginCfg.SetType(pipelines); err != nil {
return false, err
}
if fetchVersionFromServer {
conf.logger.Info("since fetch version from server is enabled, fetching the plugin version from GoCD server")
pluginsInfo, err := conf.GetPluginsInfo()
if err != nil {
return false, err
}
for _, pluginInfo := range pluginsInfo.Plugins {
if strings.Contains(pluginInfo.ID, pluginCfg.GetType()) {
pluginVersion := pluginInfo.About["version"].(string)
pluginCfg.SetVersion(pluginVersion)
conf.logger.Infof("identified the plugin as '%s' and the version installed in GoCD is '%s'",
pluginCfg.GetType(), pluginCfg.GetVersion())
}
}
}
if _, err := pluginCfg.Download(); err != nil {
return false, err
}
return pluginCfg.ValidatePlugin(pipelines)
}