/
ingress.go
82 lines (67 loc) · 1.89 KB
/
ingress.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
72
73
74
75
76
77
78
79
80
81
82
package manifests
import (
"fmt"
"path/filepath"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
ingCfgFilename = filepath.Join(manifestDir, "cluster-ingress-02-config.yml")
)
// Ingress generates the cluster-ingress-*.yml files.
type Ingress struct {
FileList []*asset.File
}
var _ asset.WritableAsset = (*Ingress)(nil)
// Name returns a human friendly name for the asset.
func (*Ingress) Name() string {
return "Ingress Config"
}
// Dependencies returns all of the dependencies directly needed to generate
// the asset.
func (*Ingress) Dependencies() []asset.Asset {
return []asset.Asset{
&installconfig.InstallConfig{},
}
}
// Generate generates the ingress config and its CRD.
func (ing *Ingress) Generate(dependencies asset.Parents) error {
installConfig := &installconfig.InstallConfig{}
dependencies.Get(installConfig)
config := &configv1.Ingress{
TypeMeta: metav1.TypeMeta{
APIVersion: configv1.SchemeGroupVersion.String(),
Kind: "Ingress",
},
ObjectMeta: metav1.ObjectMeta{
Name: "cluster",
// not namespaced
},
Spec: configv1.IngressSpec{
Domain: fmt.Sprintf("apps.%s", installConfig.Config.ClusterDomain()),
},
}
configData, err := yaml.Marshal(config)
if err != nil {
return errors.Wrapf(err, "failed to create %s manifests from InstallConfig", ing.Name())
}
ing.FileList = []*asset.File{
{
Filename: ingCfgFilename,
Data: configData,
},
}
return nil
}
// Files returns the files generated by the asset.
func (ing *Ingress) Files() []*asset.File {
return ing.FileList
}
// Load returns false since this asset is not written to disk by the installer.
func (ing *Ingress) Load(f asset.FileFetcher) (bool, error) {
return false, nil
}