github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/application/applications/apigateway/crds/host.go (about) 1 package crds 2 3 type HostConfig struct { 4 Name string 5 Namespace string 6 Email string 7 AcmeProvider string 8 TLSSecret string 9 PrivateKeySecret string 10 Hostname string 11 InsecureAction string 12 } 13 type Metadata struct { 14 Name string `yaml:"name"` 15 Namespace string `yaml:"namespace,omitempty"` 16 } 17 type PrivateKeySecret struct { 18 Name string `yaml:"name,omitempty"` 19 } 20 type AcmeProvider struct { 21 Authority string `yaml:"authority,omitempty"` 22 Email string `yaml:"email,omitempty"` 23 PrivateKeySecret *PrivateKeySecret `yaml:"privateKeySecret,omitempty"` 24 } 25 26 type TLSSecret struct { 27 Name string `yaml:"name,omitempty"` 28 } 29 type HostSpec struct { 30 Hostname string `yaml:"hostname"` 31 AcmeProvider *AcmeProvider `yaml:"acmeProvider,omitempty"` 32 TLSSecret *TLSSecret `yaml:"tlsSecret,omitempty"` 33 } 34 type Insecure struct { 35 Action string `yaml:"action,omitempty"` 36 AdditionalPort string `yaml:"additionalPort,omitempty"` 37 } 38 39 type RequestPolicy struct { 40 Insecure *Insecure `yaml:"insecure,omitempty"` 41 } 42 43 type Host struct { 44 APIVersion string `yaml:"apiVersion"` 45 Kind string `yaml:"kind"` 46 Metadata *Metadata `yaml:"metadata"` 47 Spec *HostSpec `yaml:"spec"` 48 RequestPolicy *RequestPolicy `yaml:"requestPolicy,omitempty"` 49 } 50 51 func GetHostFromConfig(conf *HostConfig) *Host { 52 53 var metadata *Metadata 54 if conf.Namespace != "" { 55 metadata = &Metadata{ 56 Name: conf.Name, 57 Namespace: conf.Namespace, 58 } 59 } else { 60 metadata = &Metadata{ 61 Name: conf.Name, 62 } 63 } 64 65 var tlsSecret *TLSSecret 66 if conf.TLSSecret != "" { 67 tlsSecret = &TLSSecret{ 68 Name: conf.TLSSecret, 69 } 70 } 71 72 var acmeProvider *AcmeProvider 73 if conf.AcmeProvider != "" { 74 acmeProvider = &AcmeProvider{ 75 Authority: conf.AcmeProvider, 76 Email: conf.Email, 77 // PrivateKeySecret: &PrivateKeySecret{ 78 // Name: conf.PrivateKeySecret, 79 // }, 80 } 81 } 82 83 var requestPolicy *RequestPolicy 84 if conf.InsecureAction != "" { 85 requestPolicy = &RequestPolicy{ 86 Insecure: &Insecure{ 87 Action: conf.InsecureAction, 88 }, 89 } 90 } 91 92 return &Host{ 93 APIVersion: "getambassador.io/v2", 94 Kind: "Host", 95 Metadata: metadata, 96 Spec: &HostSpec{ 97 Hostname: conf.Hostname, 98 AcmeProvider: acmeProvider, 99 TLSSecret: tlsSecret, 100 }, 101 RequestPolicy: requestPolicy, 102 } 103 }