Skip to content

Commit

Permalink
fix: returning data in axios and specifying correct image paramaters
Browse files Browse the repository at this point in the history
  • Loading branch information
NichArchA82 committed Sep 7, 2024
1 parent 9514dc1 commit b1f1708
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion command-handler/src/util/get-hetzner-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import axiosError from "./axios-error-handler.js";
const log = logger();

export default async function getHetznerImages() {
const images = await axios.get(`https://api.hetzner.cloud/v1/images?type=snapshot`, {
const response = await axios.get(`https://api.hetzner.cloud/v1/images?type=snapshot`, {
headers: {
'Authorization': `Bearer ${process.env.HETZNER_API_TOKEN}`
}
Expand All @@ -14,6 +14,8 @@ export default async function getHetznerImages() {
log.error('Failed to get images from hetzner', axiosError(error));
});

const images = response.data.images;

try {
if (!Array.isArray(images)) {
throw new Error('images is not an array');
Expand Down
4 changes: 3 additions & 1 deletion command-handler/src/util/get-latest-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import axiosError from "./axios-error-handler.js";
const log = logger();

export default async function getLatestTag() {
const tags = await axios.get(`https://api.github.com/repos/glueops/packer-cloud-developer-environments/tags`, {
const response = await axios.get(`https://api.github.com/repos/glueops/packer-cloud-developer-environments/tags`, {
})
.catch(error => {
log.error('Failed to get tags from github', axiosError(error));
});

const tags = response.data;

if (tags.length > 0) {
return tags[0].name;
} else {
Expand Down
4 changes: 2 additions & 2 deletions command-handler/src/util/hetzner-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ export default {
app.client.chat.postEphemeral({
channel: `${body.channel.id}`,
user: `${body.user.id}`,
text: `Creating the server with image: ${image} This will take about 4 minutes.`
text: `Creating the server with image: ${image.description} This will take about 4 minutes.`
});

//hetzner api to create the server
try {
await axios.post('https://api.hetzner.cloud/v1/servers',
{
"automount": false,
"image": image,
"image": image.id,
"labels": {
"owner": userEmail
},
Expand Down

0 comments on commit b1f1708

Please sign in to comment.