|
@@ -85,7 +85,7 @@ const WebService = {
|
|
|
generateUrlForExternalTraffic: false,
|
|
generateUrlForExternalTraffic: false,
|
|
|
customDomain: '',
|
|
customDomain: '',
|
|
|
}),
|
|
}),
|
|
|
- serialize: async (service: WebService) => {
|
|
|
|
|
|
|
+ serialize: (service: WebService) => {
|
|
|
const autoscaling = service.autoscalingOn ? {
|
|
const autoscaling = service.autoscalingOn ? {
|
|
|
autoscaling: {
|
|
autoscaling: {
|
|
|
enabled: true,
|
|
enabled: true,
|
|
@@ -171,10 +171,13 @@ export const Service = {
|
|
|
isWeb: (service: Service): service is WebService => service.type === 'web',
|
|
isWeb: (service: Service): service is WebService => service.type === 'web',
|
|
|
isWorker: (service: Service): service is WorkerService => service.type === 'worker',
|
|
isWorker: (service: Service): service is WorkerService => service.type === 'worker',
|
|
|
isJob: (service: Service): service is JobService => service.type === 'job',
|
|
isJob: (service: Service): service is JobService => service.type === 'job',
|
|
|
- handleWebIngress: async (service: WebService, stackName: string, projectId?: number, clusterId?: number) => {
|
|
|
|
|
|
|
+ handleWebIngress: (service: WebService, stackName: string, projectId?: number, clusterId?: number) => {
|
|
|
if (projectId == null || clusterId == null) {
|
|
if (projectId == null || clusterId == null) {
|
|
|
throw new Error('Project ID and Cluster ID must be provided to handle web ingress');
|
|
throw new Error('Project ID and Cluster ID must be provided to handle web ingress');
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!service.generateUrlForExternalTraffic) {
|
|
|
|
|
+ return {}
|
|
|
|
|
+ }
|
|
|
const ingress: Ingress = {
|
|
const ingress: Ingress = {
|
|
|
enabled: true,
|
|
enabled: true,
|
|
|
hosts: [],
|
|
hosts: [],
|
|
@@ -185,21 +188,22 @@ export const Service = {
|
|
|
ingress.hosts.push(service.customDomain);
|
|
ingress.hosts.push(service.customDomain);
|
|
|
ingress.custom_domain = true;
|
|
ingress.custom_domain = true;
|
|
|
} else {
|
|
} else {
|
|
|
- const res = await api
|
|
|
|
|
- .createSubdomain(
|
|
|
|
|
- "<token>",
|
|
|
|
|
- {},
|
|
|
|
|
- {
|
|
|
|
|
- id: projectId,
|
|
|
|
|
- cluster_id: clusterId,
|
|
|
|
|
- release_name: stackName,
|
|
|
|
|
- namespace: `porter-stack-${stackName}`,
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- if (res == null || res.data == null || res.data.external_url == null) {
|
|
|
|
|
- throw new Error('Failed to create subdomain for web service');
|
|
|
|
|
- }
|
|
|
|
|
- ingress.porter_hosts.push(res.data.external_url)
|
|
|
|
|
|
|
+ // const res = await api
|
|
|
|
|
+ // .createSubdomain(
|
|
|
|
|
+ // "<token>",
|
|
|
|
|
+ // {},
|
|
|
|
|
+ // {
|
|
|
|
|
+ // id: projectId,
|
|
|
|
|
+ // cluster_id: clusterId,
|
|
|
|
|
+ // release_name: stackName,
|
|
|
|
|
+ // namespace: `porter-stack-${stackName}`,
|
|
|
|
|
+ // }
|
|
|
|
|
+ // )
|
|
|
|
|
+ // if (res == null || res.data == null || res.data.external_url == null) {
|
|
|
|
|
+ // throw new Error('Failed to create subdomain for web service');
|
|
|
|
|
+ // }
|
|
|
|
|
+ // ingress.porter_hosts.push(res.data.external_url)
|
|
|
|
|
+ throw new Error('Generating external URLs without custom subdomains not yet supported!');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return ingress;
|
|
return ingress;
|