|
@@ -62,7 +62,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Retrieve full chart data (includes form and values)
|
|
// Retrieve full chart data (includes form and values)
|
|
|
- getChartData = (chart: ChartType) => {
|
|
|
|
|
|
|
+ getChartData = (chart: ChartType, revision: number) => {
|
|
|
let { currentProject } = this.context;
|
|
let { currentProject } = this.context;
|
|
|
let { currentCluster, currentChart } = this.props;
|
|
let { currentCluster, currentChart } = this.props;
|
|
|
|
|
|
|
@@ -77,12 +77,15 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
name: chart.name,
|
|
name: chart.name,
|
|
|
- revision: chart.version,
|
|
|
|
|
|
|
+ revision: revision,
|
|
|
id: currentProject.id,
|
|
id: currentProject.id,
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
let image = res.data?.config?.image?.repository;
|
|
let image = res.data?.config?.image?.repository;
|
|
|
|
|
+ let tag = res.data?.config?.image?.tag.toString();
|
|
|
|
|
+ let newestImage = tag ? image + ":" + tag : image;
|
|
|
|
|
+
|
|
|
if (
|
|
if (
|
|
|
(image === "porterdev/hello-porter-job" ||
|
|
(image === "porterdev/hello-porter-job" ||
|
|
|
image === "public.ecr.aws/o1j4x7p4/hello-porter-job") &&
|
|
image === "public.ecr.aws/o1j4x7p4/hello-porter-job") &&
|
|
@@ -93,7 +96,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
currentChart: res.data,
|
|
currentChart: res.data,
|
|
|
loading: false,
|
|
loading: false,
|
|
|
imageIsPlaceholder: true,
|
|
imageIsPlaceholder: true,
|
|
|
- newestImage: image,
|
|
|
|
|
|
|
+ newestImage: newestImage,
|
|
|
},
|
|
},
|
|
|
() => {
|
|
() => {
|
|
|
this.updateTabs();
|
|
this.updateTabs();
|
|
@@ -101,7 +104,11 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
);
|
|
);
|
|
|
} else {
|
|
} else {
|
|
|
this.setState(
|
|
this.setState(
|
|
|
- { currentChart: res.data, loading: false, newestImage: image },
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ currentChart: res.data,
|
|
|
|
|
+ loading: false,
|
|
|
|
|
+ newestImage: newestImage,
|
|
|
|
|
+ },
|
|
|
() => {
|
|
() => {
|
|
|
this.updateTabs();
|
|
this.updateTabs();
|
|
|
}
|
|
}
|
|
@@ -111,7 +118,8 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
.catch(console.log);
|
|
.catch(console.log);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- refreshChart = () => this.getChartData(this.state.currentChart);
|
|
|
|
|
|
|
+ refreshChart = (revision: number) =>
|
|
|
|
|
+ this.getChartData(this.state.currentChart, revision);
|
|
|
|
|
|
|
|
mergeNewJob = (newJob: any) => {
|
|
mergeNewJob = (newJob: any) => {
|
|
|
let jobs = this.state.jobs;
|
|
let jobs = this.state.jobs;
|
|
@@ -137,9 +145,9 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
let chartVersion = `${chart.chart.metadata.name}-${chart.chart.metadata.version}`;
|
|
let chartVersion = `${chart.chart.metadata.name}-${chart.chart.metadata.version}`;
|
|
|
|
|
|
|
|
let { currentCluster, currentProject } = this.context;
|
|
let { currentCluster, currentProject } = this.context;
|
|
|
- let protocol = process.env.NODE_ENV == "production" ? "wss" : "ws";
|
|
|
|
|
|
|
+ let protocol = window.location.protocol == "https:" ? "wss" : "ws";
|
|
|
let ws = new WebSocket(
|
|
let ws = new WebSocket(
|
|
|
- `${protocol}://${process.env.API_SERVER}/api/projects/${currentProject.id}/k8s/job/status?cluster_id=${currentCluster.id}`
|
|
|
|
|
|
|
+ `${protocol}://${window.location.host}/api/projects/${currentProject.id}/k8s/job/status?cluster_id=${currentCluster.id}`
|
|
|
);
|
|
);
|
|
|
ws.onopen = () => {
|
|
ws.onopen = () => {
|
|
|
console.log("connected to websocket");
|
|
console.log("connected to websocket");
|
|
@@ -181,13 +189,13 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
setupCronJobWebsocket = (chart: ChartType) => {
|
|
setupCronJobWebsocket = (chart: ChartType) => {
|
|
|
- let releaseName = chart.name
|
|
|
|
|
- let releaseNamespace = chart.namespace
|
|
|
|
|
|
|
+ let releaseName = chart.name;
|
|
|
|
|
+ let releaseNamespace = chart.namespace;
|
|
|
|
|
|
|
|
let { currentCluster, currentProject } = this.context;
|
|
let { currentCluster, currentProject } = this.context;
|
|
|
- let protocol = process.env.NODE_ENV == "production" ? "wss" : "ws";
|
|
|
|
|
|
|
+ let protocol = window.location.protocol == "https:" ? "wss" : "ws";
|
|
|
let ws = new WebSocket(
|
|
let ws = new WebSocket(
|
|
|
- `${protocol}://${process.env.API_SERVER}/api/projects/${currentProject.id}/k8s/cronjob/status?cluster_id=${currentCluster.id}`
|
|
|
|
|
|
|
+ `${protocol}://${window.location.host}/api/projects/${currentProject.id}/k8s/cronjob/status?cluster_id=${currentCluster.id}`
|
|
|
);
|
|
);
|
|
|
ws.onopen = () => {
|
|
ws.onopen = () => {
|
|
|
console.log("connected to websocket");
|
|
console.log("connected to websocket");
|
|
@@ -204,20 +212,20 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
this.state.imageIsPlaceholder
|
|
this.state.imageIsPlaceholder
|
|
|
) {
|
|
) {
|
|
|
// filter job belonging to chart
|
|
// filter job belonging to chart
|
|
|
- let relNameAnn = event.Object?.metadata?.annotations["meta.helm.sh/release-name"]
|
|
|
|
|
- let relNamespaceAnn = event.Object?.metadata?.annotations["meta.helm.sh/release-namespace"]
|
|
|
|
|
-
|
|
|
|
|
|
|
+ let relNameAnn =
|
|
|
|
|
+ event.Object?.metadata?.annotations["meta.helm.sh/release-name"];
|
|
|
|
|
+ let relNamespaceAnn =
|
|
|
|
|
+ event.Object?.metadata?.annotations["meta.helm.sh/release-namespace"];
|
|
|
|
|
+
|
|
|
if (
|
|
if (
|
|
|
relNameAnn &&
|
|
relNameAnn &&
|
|
|
relNamespaceAnn &&
|
|
relNamespaceAnn &&
|
|
|
releaseName == relNameAnn &&
|
|
releaseName == relNameAnn &&
|
|
|
releaseNamespace == relNamespaceAnn
|
|
releaseNamespace == relNamespaceAnn
|
|
|
) {
|
|
) {
|
|
|
- console.log("belonged to chart");
|
|
|
|
|
let newestImage =
|
|
let newestImage =
|
|
|
event.Object?.spec?.jobTemplate?.spec?.template?.spec?.containers[0]
|
|
event.Object?.spec?.jobTemplate?.spec?.template?.spec?.containers[0]
|
|
|
?.image;
|
|
?.image;
|
|
|
- console.log("newest image", newestImage)
|
|
|
|
|
if (
|
|
if (
|
|
|
newestImage &&
|
|
newestImage &&
|
|
|
newestImage !== "porterdev/hello-porter-job" &&
|
|
newestImage !== "porterdev/hello-porter-job" &&
|
|
@@ -225,7 +233,6 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job" &&
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job" &&
|
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job:latest"
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job:latest"
|
|
|
) {
|
|
) {
|
|
|
- console.log("setting image placeholder to false");
|
|
|
|
|
this.setState({ newestImage, imageIsPlaceholder: false });
|
|
this.setState({ newestImage, imageIsPlaceholder: false });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -255,15 +262,15 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
let imageUrl = this.state.newestImage;
|
|
let imageUrl = this.state.newestImage;
|
|
|
let tag = null;
|
|
let tag = null;
|
|
|
|
|
|
|
|
- if (imageUrl.includes(":")) {
|
|
|
|
|
- let splits = imageUrl.split(":");
|
|
|
|
|
- imageUrl = splits[0];
|
|
|
|
|
- tag = splits[1];
|
|
|
|
|
- } else if (!tag) {
|
|
|
|
|
- tag = "latest";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if (imageUrl) {
|
|
if (imageUrl) {
|
|
|
|
|
+ if (imageUrl.includes(":")) {
|
|
|
|
|
+ let splits = imageUrl.split(":");
|
|
|
|
|
+ imageUrl = splits[0];
|
|
|
|
|
+ tag = splits[1].toString();
|
|
|
|
|
+ } else if (!tag) {
|
|
|
|
|
+ tag = "latest";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
_.set(values, "image.repository", imageUrl);
|
|
_.set(values, "image.repository", imageUrl);
|
|
|
_.set(values, "image.tag", tag);
|
|
_.set(values, "image.tag", tag);
|
|
|
}
|
|
}
|
|
@@ -281,26 +288,28 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
let imageUrl = this.state.newestImage;
|
|
let imageUrl = this.state.newestImage;
|
|
|
- let tag = null;
|
|
|
|
|
-
|
|
|
|
|
- if (imageUrl.includes(":")) {
|
|
|
|
|
- let splits = imageUrl.split(":");
|
|
|
|
|
- imageUrl = splits[0];
|
|
|
|
|
- tag = splits[1];
|
|
|
|
|
- } else if (!tag) {
|
|
|
|
|
- tag = "latest";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let tag = null as string;
|
|
|
|
|
|
|
|
if (imageUrl) {
|
|
if (imageUrl) {
|
|
|
|
|
+ if (imageUrl.includes(":")) {
|
|
|
|
|
+ let splits = imageUrl.split(":");
|
|
|
|
|
+ imageUrl = splits[0];
|
|
|
|
|
+ tag = splits[1].toString();
|
|
|
|
|
+ } else if (!tag) {
|
|
|
|
|
+ tag = "latest";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
_.set(values, "image.repository", imageUrl);
|
|
_.set(values, "image.repository", imageUrl);
|
|
|
- _.set(values, "image.tag", tag);
|
|
|
|
|
|
|
+ _.set(values, "image.tag", `${tag}`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Weave in preexisting values and convert to yaml
|
|
// Weave in preexisting values and convert to yaml
|
|
|
- conf = yaml.dump({
|
|
|
|
|
- ...(this.state.currentChart.config as Object),
|
|
|
|
|
- ...values,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ conf = yaml.dump(
|
|
|
|
|
+ {
|
|
|
|
|
+ ...(this.state.currentChart.config as Object),
|
|
|
|
|
+ ...values,
|
|
|
|
|
+ }, { forceQuotes: true }
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
api
|
|
api
|
|
@@ -319,12 +328,21 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
this.setState({ saveValuesStatus: "successful" });
|
|
this.setState({ saveValuesStatus: "successful" });
|
|
|
- this.refreshChart();
|
|
|
|
|
|
|
+ this.refreshChart(0);
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
|
|
- this.setState({ saveValuesStatus: "error" });
|
|
|
|
|
- setCurrentError(JSON.stringify(err));
|
|
|
|
|
|
|
+ let parsedErr =
|
|
|
|
|
+ err?.response?.data?.errors && err.response.data.errors[0];
|
|
|
|
|
+
|
|
|
|
|
+ if (parsedErr) {
|
|
|
|
|
+ err = parsedErr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ saveValuesStatus: parsedErr,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ setCurrentError(parsedErr);
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -366,7 +384,6 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job" &&
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job" &&
|
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job:latest"
|
|
newestImage !== "public.ecr.aws/o1j4x7p4/hello-porter-job:latest"
|
|
|
) {
|
|
) {
|
|
|
- console.log("set to false on sorting")
|
|
|
|
|
this.setState({ jobs, newestImage, imageIsPlaceholder: false });
|
|
this.setState({ jobs, newestImage, imageIsPlaceholder: false });
|
|
|
} else {
|
|
} else {
|
|
|
this.setState({ jobs });
|
|
this.setState({ jobs });
|
|
@@ -404,7 +421,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
return (
|
|
return (
|
|
|
<SettingsSection
|
|
<SettingsSection
|
|
|
currentChart={this.state.currentChart}
|
|
currentChart={this.state.currentChart}
|
|
|
- refreshChart={this.refreshChart}
|
|
|
|
|
|
|
+ refreshChart={() => this.refreshChart(0)}
|
|
|
setShowDeleteOverlay={(x: boolean) =>
|
|
setShowDeleteOverlay={(x: boolean) =>
|
|
|
this.setState({ showDeleteOverlay: x })
|
|
this.setState({ showDeleteOverlay: x })
|
|
|
}
|
|
}
|
|
@@ -473,7 +490,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
chart: currentChart.name,
|
|
chart: currentChart.name,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- this.getChartData(currentChart);
|
|
|
|
|
|
|
+ this.getChartData(currentChart, currentChart.version);
|
|
|
this.getJobs(currentChart);
|
|
this.getJobs(currentChart);
|
|
|
this.setupJobWebsocket(currentChart);
|
|
this.setupJobWebsocket(currentChart);
|
|
|
this.setupCronJobWebsocket(currentChart);
|
|
this.setupCronJobWebsocket(currentChart);
|
|
@@ -537,7 +554,7 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
|
|
|
</Title>
|
|
</Title>
|
|
|
<InfoWrapper>
|
|
<InfoWrapper>
|
|
|
<LastDeployed>
|
|
<LastDeployed>
|
|
|
- Run {this.state.jobs.length} times <Dot>•</Dot>Last run
|
|
|
|
|
|
|
+ Run {this.state.jobs.length} times <Dot>•</Dot>Last template update at
|
|
|
{" " + this.readableDate(chart.info.last_deployed)}
|
|
{" " + this.readableDate(chart.info.last_deployed)}
|
|
|
</LastDeployed>
|
|
</LastDeployed>
|
|
|
</InfoWrapper>
|
|
</InfoWrapper>
|