-
Notifications
You must be signed in to change notification settings - Fork 88
/
midstream.go
49 lines (43 loc) · 1.56 KB
/
midstream.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
package midstream
import (
kotsv1beta1 "github.com/replicatedhq/kots/kotskinds/apis/kots/v1beta1"
"github.com/replicatedhq/kots/pkg/base"
"github.com/replicatedhq/kots/pkg/docker/registry"
"github.com/replicatedhq/kots/pkg/k8sdoc"
corev1 "k8s.io/api/core/v1"
kustomizetypes "sigs.k8s.io/kustomize/api/types"
)
type Midstream struct {
Kustomization *kustomizetypes.Kustomization
Base *base.Base
DocForPatches []k8sdoc.K8sDoc
AppPullSecret *corev1.Secret
AdminConsolePullSecret *corev1.Secret
IdentitySpec *kotsv1beta1.Identity
IdentityConfig *kotsv1beta1.IdentityConfig
}
func CreateMidstream(b *base.Base, images []kustomizetypes.Image, objects []k8sdoc.K8sDoc, pullSecrets *registry.ImagePullSecrets, identitySpec *kotsv1beta1.Identity, identityConfig *kotsv1beta1.IdentityConfig) (*Midstream, error) {
kustomization := kustomizetypes.Kustomization{
TypeMeta: kustomizetypes.TypeMeta{
APIVersion: "kustomize.config.k8s.io/v1beta1",
Kind: "Kustomization",
},
Bases: []string{},
Resources: []string{},
Patches: []kustomizetypes.Patch{},
PatchesStrategicMerge: []kustomizetypes.PatchStrategicMerge{},
Images: images,
}
m := Midstream{
Kustomization: &kustomization,
Base: b,
DocForPatches: objects,
IdentitySpec: identitySpec,
IdentityConfig: identityConfig,
}
if pullSecrets != nil {
m.AppPullSecret = pullSecrets.AppSecret
m.AdminConsolePullSecret = &pullSecrets.AdminConsoleSecret
}
return &m, nil
}