Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #1

Merged
merged 27 commits into from
Nov 11, 2023
Prev Previous commit
Next Next commit
wip
  • Loading branch information
louislam committed Nov 6, 2023
commit d7f4873405882696821edb9ed32feaddfaf0c80c
3 changes: 3 additions & 0 deletions frontend/src/components/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export default defineComponent({
},

service() {
if (!this.jsonObject.services[this.name]) {
return {};
}
return this.jsonObject.services[this.name];
},

Expand Down
35 changes: 25 additions & 10 deletions frontend/src/pages/Compose.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,21 @@ export default {
return;
}

// Check if services is object
if (typeof this.jsonConfig.services !== "object") {
this.$root.toastError("Services must be an object");
this.processing = false;
return;
}

let serviceNameList = Object.keys(this.jsonConfig.services);

// Set the stack name if empty, use the first container name
if (!this.stack.name) {
let serviceName = Object.keys(this.jsonConfig.services)[0];
if (!this.stack.name && serviceNameList.length > 0) {
let serviceName = serviceNameList[0];
let service = this.jsonConfig.services[serviceName];

if (service.container_name) {
if (service && service.container_name) {
this.stack.name = service.container_name;
} else {
this.stack.name = serviceName;
Expand Down Expand Up @@ -472,19 +481,25 @@ export default {
throw doc.errors[0];
}

this.yamlDoc = doc;
console.log(this.yamlDoc);
const config = doc.toJS() ?? {};

this.jsonConfig = doc.toJS() ?? {};
// Check data types
// "services" must be an object
if (!config.services) {
config.services = {};
}

if (!this.jsonConfig.version) {
this.jsonConfig.version = "3.8";
if (Array.isArray(config.services) || typeof config.services !== "object") {
throw new Error("Services must be an object");
}

if (!this.jsonConfig.services) {
this.jsonConfig.services = {};
if (!config.version) {
config.version = "3.8";
}

this.yamlDoc = doc;
this.jsonConfig = config;

clearTimeout(yamlErrorTimeout);
this.yamlError = "";
} catch (e) {
Expand Down