Edits history of script submission #11011 for ' Run Clusterlint Checks on a Kubernetes Cluster (digitalocean)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Digitalocean = {
      token: string;
    };
    /**
     * Run Clusterlint Checks on a Kubernetes Cluster
     * Clusterlint helps operators conform to Kubernetes best practices around
    resources, security and reliability to avoid common problems while operating
    or upgrading the clusters.
     */
    export async function main(
      auth: Digitalocean,
      cluster_id: string,
      body: {
        include_groups?: string[];
        include_checks?: string[];
        exclude_groups?: string[];
        exclude_checks?: string[];
      },
    ) {
      const url = new URL(
        `https://api.digitalocean.com/v2/kubernetes/clusters/${cluster_id}/clusterlint`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 536 days ago