-
Notifications
You must be signed in to change notification settings - Fork 114
/
jenkins_config.go
36 lines (32 loc) · 1.15 KB
/
jenkins_config.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
package lighthouse
import (
"fmt"
"k8s.io/apimachinery/pkg/labels"
)
// JenkinsConfig is config for the Jenkins controller.
type JenkinsConfig struct {
Controller `json:",inline"`
// LabelSelectorString compiles into LabelSelector at load time.
// If set, this option needs to match --label-selector used by
// the desired jenkins-operator. This option is considered
// invalid when provided with a single jenkins-operator config.
//
// For label selector syntax, see below:
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
LabelSelectorString string `json:"label_selector,omitempty"`
// LabelSelector is used so different jenkins-operator replicas
// can use their own configuration.
LabelSelector labels.Selector `json:"-"`
}
// Parse initializes and validates the Config
func (c *JenkinsConfig) Parse() error {
if err := c.Controller.Parse(); err != nil {
return fmt.Errorf("validating jenkins_operators config: %v", err)
}
sel, err := labels.Parse(c.LabelSelectorString)
if err != nil {
return fmt.Errorf("invalid jenkins_operators.label_selector option: %v", err)
}
c.LabelSelector = sel
return nil
}