exports are created successfully
This commit is contained in:
parent
320e5e9519
commit
1d8db59738
4
main.js
4
main.js
|
@ -1,5 +1,5 @@
|
||||||
import { normalized_config } from "./normalize-config.js";
|
import { normalized_config } from "./normalize-config.js";
|
||||||
import { get_run_details } from "./tfc-api-functions.mjs";
|
import { get_run_details, create_plan_export } from "./tfc-api-functions.mjs";
|
||||||
|
|
||||||
const my_config = await normalized_config;
|
const my_config = await normalized_config;
|
||||||
|
|
||||||
|
@ -28,4 +28,4 @@ const run_details = await get_run_details(my_config.base_url, process.argv.slice
|
||||||
|
|
||||||
const plan_id = run_details.data.data.relationships.plan.data.id;
|
const plan_id = run_details.data.data.relationships.plan.data.id;
|
||||||
|
|
||||||
console.log(plan_id);
|
console.log(await create_plan_export(my_config.base_url, plan_id, my_config.token));
|
|
@ -16,31 +16,42 @@ export const get_run_details = async (base_url, run_id, token) => {
|
||||||
// https://developer.hashicorp.com/terraform/cloud-docs/api-docs/plan-exports#create-a-plan-export
|
// https://developer.hashicorp.com/terraform/cloud-docs/api-docs/plan-exports#create-a-plan-export
|
||||||
// at present, the only type supported in the request body is "plan-exports". The only supported export format is "sentinel-mock-bundle-v0".
|
// at present, the only type supported in the request body is "plan-exports". The only supported export format is "sentinel-mock-bundle-v0".
|
||||||
// As such, I'm going to hard code those portions of the payload
|
// As such, I'm going to hard code those portions of the payload
|
||||||
|
const create_plan_export_axios = axios.create({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const create_plan_export_config = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export const create_plan_export = async (base_url, plan_id, token) => {
|
export const create_plan_export = async (base_url, plan_id, token) => {
|
||||||
|
// This variable name is bad and implies action, but I'm keeping it
|
||||||
|
const create_plan_export_data = {
|
||||||
|
"data": {
|
||||||
|
"type": "plan-exports",
|
||||||
|
"attributes": {
|
||||||
|
"data-type": "sentinel-mock-bundle-v0"
|
||||||
|
},
|
||||||
|
"relationships": {
|
||||||
|
"plan": {
|
||||||
|
"data": {
|
||||||
|
"id": `${plan_id}`,
|
||||||
|
"type": "plans"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
headers: {
|
||||||
|
'Authorization' :`Bearer ${token}`,
|
||||||
|
'Content-Type' : "application/vnd.api+json"
|
||||||
|
}
|
||||||
|
}
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${base_url}/api/v2/plan-exports`,
|
`${base_url}/api/v2/plan-exports`,
|
||||||
{
|
create_plan_export_data,
|
||||||
headers: {
|
config
|
||||||
Authorization :`Bearer ${token}`,
|
|
||||||
'Content-Type' : "application/vnd.api+json"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
|
|
||||||
"data": {
|
|
||||||
"type": "plan-exports",
|
|
||||||
"attributes": {
|
|
||||||
"data-type": "sentinel-mock-bundle-v0"
|
|
||||||
},
|
|
||||||
"relationships": {
|
|
||||||
"plan": {
|
|
||||||
"data": {
|
|
||||||
"id": `${plan_id}`,
|
|
||||||
"type": "plans"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
Loading…
Reference in a new issue