Skip to content

Commit

Permalink
add missing getFloatingIP method
Browse files Browse the repository at this point in the history
  • Loading branch information
[Farbfox] Michael Schiller committed Dec 30, 2021
1 parent 3298a7f commit f57f35f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions dist/deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = /******/ (() => {

imageIdentifier = imageId || options.image.name;
core.info(`debug imageIdentifier: "${imageIdentifier}"`);

res = await fetch(`${config.API}/servers`, {
method: "POST",
headers: {
Expand Down Expand Up @@ -243,6 +243,33 @@ module.exports = /******/ (() => {
return;
}

async function getFloatingIP(id) {
const URI = `${config.API}/floating_ips/${id}`;

try {
res = await fetch(URI, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${options.hcloudToken}`,
"User-Agent": config.USER_AGENT,
},
});
} catch (err) {
core.setFailed(err.message);
}

if (res.status === 200) {
const body = await res.json();
return body.floating_ip.ip;
} else {
core.setFailed(
`When trying to get a floating ip, an error occurred ${res.status}`
);
return;
}
}

async function assignIP() {
const floatingIPId = core.getInput("floating-ip-id");
if (!floatingIPId) {
Expand Down Expand Up @@ -336,7 +363,7 @@ module.exports = /******/ (() => {
assignIP,
getAssignmentProgress,
getImageId,
getFloatingIP,
getFloatingIP
};

/***/
Expand Down
2 changes: 1 addition & 1 deletion lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,5 @@ module.exports = {
assignIP,
getAssignmentProgress,
getImageId,
getFloatingIP,
getFloatingIP
};

0 comments on commit f57f35f

Please sign in to comment.