mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 06:00:06 +02:00
feat(portal-api): create Service's before provisioning (#673)
This commit is contained in:
parent
2ce08bbe30
commit
1fe36f0e1b
@ -119,26 +119,21 @@ export const DeploymentGroupList = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const _title = <Title>Deployment groups</Title>;
|
const _title = <Title>Deployment groups</Title>;
|
||||||
|
|
||||||
if (loading) {
|
if (loading && (!deploymentGroups || !deploymentGroups.length)) {
|
||||||
return (
|
return (
|
||||||
<LayoutContainer center>
|
<LayoutContainer center>
|
||||||
{_title}
|
|
||||||
<Loader />
|
<Loader />
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
const _error =
|
||||||
return (
|
error && (!deploymentGroups || !deploymentGroups.length) ? (
|
||||||
<LayoutContainer>
|
|
||||||
{_title}
|
|
||||||
<ErrorMessage
|
<ErrorMessage
|
||||||
title="Ooops!"
|
title="Ooops!"
|
||||||
message="An error occurred while loading your deployment groups."
|
message="An error occurred while loading your deployment groups."
|
||||||
/>
|
/>
|
||||||
</LayoutContainer>
|
) : null;
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const groups = forceArray(deploymentGroups).map(({ slug, name }) => (
|
const groups = forceArray(deploymentGroups).map(({ slug, name }) => (
|
||||||
<Col xs={12} sm={4} md={3} lg={3} key={slug}>
|
<Col xs={12} sm={4} md={3} lg={3} key={slug}>
|
||||||
@ -178,6 +173,7 @@ export const DeploymentGroupList = ({
|
|||||||
return (
|
return (
|
||||||
<LayoutContainer>
|
<LayoutContainer>
|
||||||
{_title}
|
{_title}
|
||||||
|
{_error}
|
||||||
<DGsRows>
|
<DGsRows>
|
||||||
{groups}
|
{groups}
|
||||||
{create}
|
{create}
|
||||||
|
@ -10,10 +10,12 @@ import { Router } from '@mocks/';
|
|||||||
import { NotFound } from '../';
|
import { NotFound } from '../';
|
||||||
|
|
||||||
it('renders <NotFound /> without throwing', () => {
|
it('renders <NotFound /> without throwing', () => {
|
||||||
const tree = renderer.create(
|
const tree = renderer
|
||||||
|
.create(
|
||||||
<Router>
|
<Router>
|
||||||
<NotFound />
|
<NotFound />
|
||||||
</Router>
|
</Router>
|
||||||
).toJSON();
|
)
|
||||||
|
.toJSON();
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -4,10 +4,7 @@ import { Img } from 'normalized-styled-components';
|
|||||||
import remcalc from 'remcalc';
|
import remcalc from 'remcalc';
|
||||||
|
|
||||||
import Logo from '@assets/triton_logo.png';
|
import Logo from '@assets/triton_logo.png';
|
||||||
import {
|
import { Header, HeaderBrand } from 'joyent-ui-toolkit';
|
||||||
Header,
|
|
||||||
HeaderBrand,
|
|
||||||
} from 'joyent-ui-toolkit';
|
|
||||||
|
|
||||||
const StyledLogo = Img.extend`
|
const StyledLogo = Img.extend`
|
||||||
width: ${remcalc(87)};
|
width: ${remcalc(87)};
|
||||||
|
@ -2,8 +2,6 @@ import React from 'react';
|
|||||||
|
|
||||||
import { Header as HeaderComponent } from '@components/navigation';
|
import { Header as HeaderComponent } from '@components/navigation';
|
||||||
|
|
||||||
export const Header = () => (
|
export const Header = () => <HeaderComponent />;
|
||||||
<HeaderComponent />
|
|
||||||
);
|
|
||||||
|
|
||||||
export default Header;
|
export default Header;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
const state = {}
|
const state = {};
|
||||||
|
|
||||||
|
|
||||||
export default state;
|
export default state;
|
@ -1331,6 +1331,58 @@ class Data extends EventEmitter {
|
|||||||
}, handleNewServices);
|
}, handleNewServices);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleConfigServicesCreation = (err) => {
|
||||||
|
if (err) {
|
||||||
|
return handleFailedProvision(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._server.log(['debug'], `-> requesting docker-compose provision for DeploymentGroup ${ctx.currentDeploymentGroup.name}`);
|
||||||
|
|
||||||
|
this._dockerCompose.provision({
|
||||||
|
projectName: ctx.currentDeploymentGroup.name,
|
||||||
|
environment: clientManifest.environment,
|
||||||
|
files: internals.fromKeyValueToDict(clientManifest.files),
|
||||||
|
manifest: ctx.newManifest.raw
|
||||||
|
}, handleProvisionResponse);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createConfigServices = () => {
|
||||||
|
VAsync.forEachParallel({
|
||||||
|
inputs: ctx.config,
|
||||||
|
func: ({ name, slug }, next) => {
|
||||||
|
this.getServices({
|
||||||
|
name,
|
||||||
|
deploymentGroupId: ctx.currentDeploymentGroup.id
|
||||||
|
}, (err, services = []) => {
|
||||||
|
if (!err) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err && !internals.isNotFound(err)) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.createService({
|
||||||
|
deploymentGroupId: ctx.currentDeploymentGroup.id,
|
||||||
|
status: 'PROVISIONING',
|
||||||
|
name,
|
||||||
|
slug
|
||||||
|
}, next);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
return handleFailedProvision(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateDeploymentGroup({
|
||||||
|
id: ctx.currentDeploymentGroup.id,
|
||||||
|
status: 'PROVISIONING',
|
||||||
|
services: result.successes
|
||||||
|
}, handleConfigServicesCreation);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 7. handle new version
|
// 7. handle new version
|
||||||
// 8. call docker-compose to up dg
|
// 8. call docker-compose to up dg
|
||||||
const handleNewVersion = (err, newVersion) => {
|
const handleNewVersion = (err, newVersion) => {
|
||||||
@ -1346,16 +1398,7 @@ class Data extends EventEmitter {
|
|||||||
// CALLBACK
|
// CALLBACK
|
||||||
cb(null, ctx.newVersion);
|
cb(null, ctx.newVersion);
|
||||||
|
|
||||||
setImmediate(() => {
|
setImmediate(createConfigServices);
|
||||||
this._server.log(['debug'], `-> requesting docker-compose provision for DeploymentGroup ${ctx.currentDeploymentGroup.name}`);
|
|
||||||
|
|
||||||
this._dockerCompose.provision({
|
|
||||||
projectName: ctx.currentDeploymentGroup.name,
|
|
||||||
environment: clientManifest.environment,
|
|
||||||
files: internals.fromKeyValueToDict(clientManifest.files),
|
|
||||||
manifest: ctx.newManifest.raw
|
|
||||||
}, handleProvisionResponse);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 6. handle curent scale based on machines in triton
|
// 6. handle curent scale based on machines in triton
|
||||||
|
Loading…
Reference in New Issue
Block a user