//native
type Digitalocean = {
token: string;
};
/**
* Fetch Clusterlint Diagnostics for a Kubernetes Cluster
* To request clusterlint diagnostics for your cluster, send a GET request to
`/v2/kubernetes/clusters/$K8S_CLUSTER_ID/clusterlint`. If the `run_id` query
parameter is provided, then the diagnostics for the specific run is fetched.
By default, the latest results are shown.
To find out how to address clusterlint feedback, please refer to
[the clusterlint check documentation](https://github.com/digitalocean/clusterlint/blob/master/checks.md).
*/
export async function main(
auth: Digitalocean,
cluster_id: string,
run_id: string | undefined,
) {
const url = new URL(
`https://api.digitalocean.com/v2/kubernetes/clusters/${cluster_id}/clusterlint`,
);
for (const [k, v] of [["run_id", run_id]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago