-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ec232b
commit 9514dc1
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import axios from "axios" | ||
import logger from "./logger.js" | ||
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`, { | ||
headers: { | ||
'Authorization': `Bearer ${process.env.HETZNER_API_TOKEN}` | ||
} | ||
}) | ||
.catch(error => { | ||
log.error('Failed to get images from hetzner', axiosError(error)); | ||
}); | ||
|
||
try { | ||
if (!Array.isArray(images)) { | ||
throw new Error('images is not an array'); | ||
} | ||
} catch (error) { | ||
log.error({message: error.message, stack: error.stack}); | ||
return null; | ||
} | ||
|
||
return images; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import axios from "axios" | ||
import logger from "./logger.js" | ||
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`, { | ||
}) | ||
.catch(error => { | ||
log.error('Failed to get tags from github', axiosError(error)); | ||
}); | ||
|
||
if (tags.length > 0) { | ||
return tags[0].name; | ||
} else { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters