complete (but untested) create_plan_export function
This commit is contained in:
parent
dddeebd133
commit
320e5e9519
1
main.js
1
main.js
|
@ -3,6 +3,7 @@ import { get_run_details } from "./tfc-api-functions.mjs";
|
|||
|
||||
const my_config = await normalized_config;
|
||||
|
||||
// TODO: Split all this run verification clutter out into a separate module
|
||||
// verify that a run_id was provided to the program
|
||||
const runid_provided = run_id => {
|
||||
return (run_id ? true : false);
|
||||
|
|
|
@ -11,3 +11,36 @@ export const get_run_details = async (base_url, run_id, token) => {
|
|||
);
|
||||
return response;
|
||||
};
|
||||
|
||||
// This will use the TFC API to 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".
|
||||
// As such, I'm going to hard code those portions of the payload
|
||||
export const create_plan_export = async (base_url, plan_id, token) => {
|
||||
const response = await axios.post(
|
||||
`${base_url}/api/v2/plan-exports`,
|
||||
{
|
||||
headers: {
|
||||
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