forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kube-addon-operator.go
71 lines (59 loc) · 1.91 KB
/
kube-addon-operator.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package manifests
import (
"github.com/ghodss/yaml"
"github.com/pkg/errors"
kubeaddon "github.com/coreos/tectonic-config/config/kube-addon"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/rand"
)
// kubeAddonOperator generates the network-operator-*.yml files
type kubeAddonOperator struct {
Config *kubeaddon.OperatorConfig
File *asset.File
}
var _ asset.WritableAsset = (*kubeAddonOperator)(nil)
// Name returns a human friendly name for the operator
func (kao *kubeAddonOperator) Name() string {
return "Kube Addon Operator"
}
// Dependencies returns all of the dependencies directly needed by an
// kubeAddonOperator asset.
func (kao *kubeAddonOperator) Dependencies() []asset.Asset {
return []asset.Asset{
&installconfig.InstallConfig{},
}
}
// Generate generates the network-operator-config.yml and network-operator-manifest.yml files
func (kao *kubeAddonOperator) Generate(dependencies asset.Parents) error {
installConfig := &installconfig.InstallConfig{}
dependencies.Get(installConfig)
kao.Config = &kubeaddon.OperatorConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: kubeaddon.APIVersion,
Kind: kubeaddon.Kind,
},
CloudProvider: tectonicCloudProvider(installConfig.Config.Platform),
RegistryHTTPSecret: rand.String(16),
ClusterConfig: kubeaddon.ClusterConfig{
APIServerURL: getAPIServerURL(installConfig.Config),
},
}
data, err := yaml.Marshal(kao.Config)
if err != nil {
return errors.Wrapf(err, "failed to create %s config from InstallConfig", kao.Name())
}
kao.File = &asset.File{
Filename: "kube-addon-operator-config.yml",
Data: data,
}
return nil
}
// Files returns the files generated by the asset.
func (kao *kubeAddonOperator) Files() []*asset.File {
if kao.File != nil {
return []*asset.File{kao.File}
}
return []*asset.File{}
}