|
| 1 | +/* |
| 2 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +you may not use this file except in compliance with the License. |
| 4 | +You may obtain a copy of the License at |
| 5 | +
|
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software |
| 9 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +See the License for the specific language governing permissions and |
| 12 | +limitations under the License. |
| 13 | +*/ |
| 14 | + |
| 15 | +package types |
| 16 | + |
| 17 | +import ( |
| 18 | + "github.com/docker/go-connections/nat" |
| 19 | +) |
| 20 | + |
| 21 | +const ( |
| 22 | + DefaultVanName string = "skupper" |
| 23 | + HostPath string = "/tmp/skupper" |
| 24 | + CertPath = HostPath + "/qpid-dispatch-certs/" |
| 25 | + ConnPath = HostPath + "/connections/" |
| 26 | + ConsoleUsersPath = HostPath + "/console-users/" |
| 27 | + SaslConfigPath = HostPath + "/sasl-config/" |
| 28 | + ServicePath = HostPath + "/services/" |
| 29 | +) |
| 30 | + |
| 31 | +// TransportMode describes how a qdr is intended to be deployed, either interior or edge |
| 32 | +type TransportMode string |
| 33 | + |
| 34 | +const ( |
| 35 | + // TransportModeInterior means the qdr will participate in inter-router protocol exchanges |
| 36 | + TransportModeInterior TransportMode = "interior" |
| 37 | + // TransportModeEdge means that the qdr will connect to interior routers for network access |
| 38 | + TransportModeEdge = "edge" |
| 39 | +) |
| 40 | + |
| 41 | +// Transport constants |
| 42 | +const ( |
| 43 | + TransportDeploymentName string = "skupper-router" |
| 44 | + TransportComponentName string = "router" |
| 45 | + DefaultTransportImage string = "quay.io/interconnectedcloud/qdrouterd" |
| 46 | + TransportContainerName string = "router" |
| 47 | + TransportLivenessPort int32 = 9090 |
| 48 | + TransportEnvConfig string = "QDROUTERD_CONF" |
| 49 | + TransportSaslConfig string = "skupper-sasl-config" |
| 50 | + TransportNetworkName string = "skupper-network" |
| 51 | +) |
| 52 | + |
| 53 | +var TransportPrometheusAnnotations = map[string]string{ |
| 54 | + "prometheus.io/port": "9090", |
| 55 | + "prometheus.io/scrape": "true", |
| 56 | +} |
| 57 | + |
| 58 | +// Controller constants |
| 59 | +const ( |
| 60 | + ControllerDeploymentName string = "skupper-proxy-controller" |
| 61 | + ControllerComponentName string = "controller" |
| 62 | + DefaultControllerImage string = "quay.io/skupper/skupper-docker-controller" |
| 63 | + ControllerContainerName string = "proxy-controller" |
| 64 | + DefaultProxyImage string = "quay.io/skupper/proxy-simple" |
| 65 | + ControllerConfigPath string = "/etc/messaging/" |
| 66 | +) |
| 67 | + |
| 68 | +// Console constants |
| 69 | +const ( |
| 70 | + ConsolePortName string = "console" |
| 71 | + ConsoleServiceName string = "skupper-console" |
| 72 | + ConsoleDefaultServicePort int32 = 8080 |
| 73 | + ConsoleDefaultServiceTargetPort int32 = 8080 |
| 74 | + ConsoleOpenShiftServicePort int32 = 8888 |
| 75 | + ConsoleOpenShiftOauthServicePort int32 = 443 |
| 76 | + ConsoleOpenShiftOuathServiceTargetPort int32 = 8443 |
| 77 | + ConsoleOpenShiftServingCerts string = "skupper-proxy-certs" |
| 78 | +) |
| 79 | + |
| 80 | +type ConsoleAuthMode string |
| 81 | + |
| 82 | +const ( |
| 83 | + ConsoleAuthModeInternal ConsoleAuthMode = "internal" |
| 84 | + ConsoleAuthModeUnsecured = "unsecured" |
| 85 | +) |
| 86 | + |
| 87 | +// Assembly constants |
| 88 | +const ( |
| 89 | + EdgeRole string = "edge" |
| 90 | + EdgeRouteName string = "skupper-edge" |
| 91 | + EdgeListenerPort int32 = 45671 |
| 92 | + InterRouterRole string = "inter-router" |
| 93 | + InterRouterListenerPort int32 = 55671 |
| 94 | + InterRouterRouteName string = "skupper-inter-router" |
| 95 | + InterRouterProfile string = "skupper-internal" |
| 96 | +) |
| 97 | + |
| 98 | +// Controller Service Interface constants |
| 99 | +const ( |
| 100 | + ServiceSyncAddress = "mc/$skupper-service-sync" |
| 101 | + LocalServiceDefsFile = ServicePath + "/local/skupper-services" |
| 102 | + AllServiceDefsFile = ServicePath + "/all/skupper-services" |
| 103 | +) |
| 104 | + |
| 105 | +// TODO: what is possiblity of using types from skupper itself (e.g. no namespace for docker |
| 106 | +// or we change the name to endpoint, etc. |
| 107 | +// VanRouterSpec is the specification of VAN network with router, controller and assembly |
| 108 | +type VanRouterSpec struct { |
| 109 | + Name string `json:"name,omitempty"` |
| 110 | + // Namespace string `json:"namespace,omitempty"` |
| 111 | + AuthMode ConsoleAuthMode `json:"authMode,omitempty"` |
| 112 | + Transport DeploymentSpec `json:"transport,omitempty"` |
| 113 | + Controller DeploymentSpec `json:"controller,omitempty"` |
| 114 | + Assembly AssemblySpec `json:"assembly,omitempty"` |
| 115 | + Users []User `json:"users,omitempty"` |
| 116 | + CertAuthoritys []CertAuthority `json:"certAuthoritys,omitempty"` |
| 117 | + Credentials []Credential `json:"credentials,omitempty"` |
| 118 | +} |
| 119 | + |
| 120 | +// DeploymentSpec for the VAN router or controller components to run within a cluster |
| 121 | +type DeploymentSpec struct { |
| 122 | + Image string `json:"image,omitempty"` |
| 123 | + LivenessPort int32 `json:"livenessPort,omitempty"` |
| 124 | + Labels map[string]string `json:"labels,omitempty"` |
| 125 | + // Annotations map[string]string `json:"annotations,omitempty"` |
| 126 | + EnvVar []string `json:"envVar,omitempty"` |
| 127 | + Ports nat.PortSet `json:"ports,omitempty"` |
| 128 | + Volumes []string `json:"volumes,omitempty"` |
| 129 | + Mounts map[string]string `json:"mounts,omitempty"` |
| 130 | +} |
| 131 | + |
| 132 | +// AssemblySpec for the links and connectors that form the VAN topology |
| 133 | +type AssemblySpec struct { |
| 134 | + Name string `json:"name,omitempty"` |
| 135 | + Mode string `json:"mode,omitempty"` |
| 136 | + Listeners []Listener `json:"listeners,omitempty"` |
| 137 | + InterRouterListeners []Listener `json:"interRouterListeners,omitempty"` |
| 138 | + EdgeListeners []Listener `json:"edgeListeners,omitempty"` |
| 139 | + SslProfiles []SslProfile `json:"sslProfiles,omitempty"` |
| 140 | + Connectors []Connector `json:"connectors,omitempty"` |
| 141 | + InterRouterConnectors []Connector `json:"interRouterConnectors,omitempty"` |
| 142 | + EdgeConnectors []Connector `json:"edgeConnectors,omitempty"` |
| 143 | +} |
| 144 | + |
| 145 | +type Listener struct { |
| 146 | + Name string `json:"name,omitempty"` |
| 147 | + Host string `json:"host,omitempty"` |
| 148 | + Port int32 `json:"port"` |
| 149 | + RouteContainer bool `json:"routeContainer,omitempty"` |
| 150 | + Http bool `json:"http,omitempty"` |
| 151 | + Cost int32 `json:"cost,omitempty"` |
| 152 | + SslProfile string `json:"sslProfile,omitempty"` |
| 153 | + SaslMechanisms string `json:"saslMechanisms,omitempty"` |
| 154 | + AuthenticatePeer bool `json:"authenticatePeer,omitempty"` |
| 155 | + LinkCapacity int32 `json:"linkCapacity,omitempty"` |
| 156 | +} |
| 157 | + |
| 158 | +type SslProfile struct { |
| 159 | + Name string `json:"name,omitempty"` |
| 160 | + Cert string `json:"cert,omitempty"` |
| 161 | + Key string `json:"key,omitempty"` |
| 162 | + CaCert string `json:"caCert,omitempty"` |
| 163 | +} |
| 164 | + |
| 165 | +type ConnectorRole string |
| 166 | + |
| 167 | +const ( |
| 168 | + ConnectorRoleInterRouter ConnectorRole = "inter-router" |
| 169 | + ConnectorRoleEdge = "edge" |
| 170 | +) |
| 171 | + |
| 172 | +type Connector struct { |
| 173 | + Name string `json:"name,omitempty"` |
| 174 | + Role string `json:"role,omitempty"` |
| 175 | + Host string `json:"host"` |
| 176 | + Port string `json:"port"` |
| 177 | + RouteContainer bool `json:"routeContainer,omitempty"` |
| 178 | + Cost int32 `json:"cost,omitempty"` |
| 179 | + VerifyHostname bool `json:"verifyHostname,omitempty"` |
| 180 | + SslProfile string `json:"sslProfile,omitempty"` |
| 181 | + LinkCapacity int32 `json:"linkCapacity,omitempty"` |
| 182 | +} |
| 183 | + |
| 184 | +type Credential struct { |
| 185 | + CA string |
| 186 | + Name string |
| 187 | + Subject string |
| 188 | + Hosts string |
| 189 | + ConnectJson bool |
| 190 | + Post bool |
| 191 | +} |
| 192 | + |
| 193 | +type CertAuthority struct { |
| 194 | + Name string |
| 195 | +} |
| 196 | + |
| 197 | +type User struct { |
| 198 | + Name string |
| 199 | + Password string |
| 200 | +} |
| 201 | + |
| 202 | +type TransportConnectedSites struct { |
| 203 | + Direct int |
| 204 | + Indirect int |
| 205 | + Total int |
| 206 | +} |
| 207 | + |
| 208 | +type ServiceInterface struct { |
| 209 | + Address string `json:"address"` |
| 210 | + Protocol string `json:"protocol"` |
| 211 | + Port int `json:"port"` |
| 212 | + Headless *Headless `json:"headless,omitempty"` |
| 213 | + Targets []ServiceInterfaceTarget `json:"targets"` |
| 214 | + Origin string `json:"origin,omitempty"` |
| 215 | + Alias string `json:"alias,omitempty"` |
| 216 | +} |
| 217 | + |
| 218 | +type ServiceInterfaceTarget struct { |
| 219 | + Name string `json:"name,omitempty"` |
| 220 | + Selector string `json:"selector"` |
| 221 | + TargetPort int `json:"targetPort,omitempty"` |
| 222 | +} |
| 223 | + |
| 224 | +type Headless struct { |
| 225 | + Name string `json:"name"` |
| 226 | + Size int `json:"size"` |
| 227 | + TargetPort int `json:"targetPort,omitempty"` |
| 228 | +} |
| 229 | + |
| 230 | +type ByServiceInterfaceAddress []ServiceInterface |
| 231 | + |
| 232 | +func (a ByServiceInterfaceAddress) Len() int { |
| 233 | + return len(a) |
| 234 | +} |
| 235 | + |
| 236 | +func (a ByServiceInterfaceAddress) Less(i, j int) bool { |
| 237 | + return a[i].Address > a[i].Address |
| 238 | +} |
| 239 | + |
| 240 | +func (a ByServiceInterfaceAddress) Swap(i, j int) { |
| 241 | + a[i], a[j] = a[j], a[i] |
| 242 | +} |
0 commit comments