Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to postgres add-on #51

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions examples/create-postgres.ts

This file was deleted.

25 changes: 1 addition & 24 deletions src/clusters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VendorPortalApi } from "./configuration";
import { createCluster, createClusterWithLicense, upgradeCluster, pollForStatus } from ".";
import { Addon, Cluster, ClusterPort, StatusError, createAddonObjectStore, createAddonPostgres, exposeClusterPort, pollForAddonStatus } from "./clusters";
import { Addon, Cluster, ClusterPort, StatusError, createAddonObjectStore, exposeClusterPort, pollForAddonStatus } from "./clusters";
import * as mockttp from "mockttp";

describe("ClusterService", () => {
Expand Down Expand Up @@ -226,29 +226,6 @@ describe("Cluster Add-ons", () => {
expect(addon.object_store).toEqual(expectedAddon.addon.object_store);
});

test("should return postgres add-on", async () => {
const clusterId = "1234abcd";
const expectedAddon = {
addon: {
id: "abcd1234",
status: "applied",
postgres: {
uri: "postgres://postgres:1234@test:5432",
version: "16.2",
instance_type: "db.t3.micro",
disk_gib: 200
}
}
};

await mockServer.forPost(`/cluster/${clusterId}/addons/postgres`).thenReply(201, JSON.stringify(expectedAddon));

const addon: Addon = await createAddonPostgres(apiClient, clusterId);
expect(addon.id).toEqual(expectedAddon.addon.id);
expect(addon.status).toEqual(expectedAddon.addon.status);
expect(addon.postgres).toEqual(expectedAddon.addon.postgres);
});

test("should eventually return success with expected status", async () => {
const clusterId = "1234abcd";
const expectedAddon = { id: "1234abcd", status: "ready" };
Expand Down
41 changes: 0 additions & 41 deletions src/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,47 +330,6 @@ export async function createAddonObjectStore(vendorPortalApi: VendorPortalApi, c
return addon;
}

export async function createAddonPostgres(vendorPortalApi: VendorPortalApi, clusterId: string, version?: string, instanceType?: string, diskGib?: number): Promise<Addon> {
const http = await vendorPortalApi.client();

const uri = `${vendorPortalApi.endpoint}/cluster/${clusterId}/addons/postgres`;

const reqBody = {};
if (version) {
reqBody["version"] = version;
}
if (instanceType) {
reqBody["instance_type"] = instanceType;
}
if (diskGib) {
reqBody["disk_gib"] = diskGib;
}
const res = await http.post(uri, JSON.stringify(reqBody));
if (res.message.statusCode != 201) {
let body = "";
try {
body = await res.readBody();
} catch (err) {
// ignore
}
throw new Error(`Failed to queue add-on create: Server responded with ${res.message.statusCode}: ${body}`);
}

const body: any = JSON.parse(await res.readBody());

var addon: Addon = { id: body.addon.id, status: body.addon.status };
if (body.addon.postgres) {
addon.postgres = {
uri: body.addon.postgres.uri,
version: body.addon.postgres.version,
instance_type: body.addon.postgres.instance_type,
disk_gib: body.addon.postgres.disk_gib
};
}

return addon;
}

export async function pollForAddonStatus(vendorPortalApi: VendorPortalApi, clusterId: string, addonId: string, expectedStatus: string, timeout: number = 120, sleeptimeMs: number = 5000): Promise<Addon> {
// get add-ons from the api, look for the status of the id to be ${status}
// if it's not ${status}, sleep for 5 seconds and try again
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { VendorPortalApi } from "./configuration";
export { getApplicationDetails } from "./applications";
export { Channel, createChannel, getChannelDetails, archiveChannel } from "./channels";
export { ClusterVersion, createCluster, createClusterWithLicense, pollForStatus, getKubeconfig, removeCluster, upgradeCluster, getClusterVersions, createAddonObjectStore, createAddonPostgres, pollForAddonStatus, exposeClusterPort } from "./clusters";
export { ClusterVersion, createCluster, createClusterWithLicense, pollForStatus, getKubeconfig, removeCluster, upgradeCluster, getClusterVersions, createAddonObjectStore, pollForAddonStatus, exposeClusterPort } from "./clusters";
export { KubernetesDistribution, archiveCustomer, createCustomer, getUsedKubernetesDistributions } from "./customers";
export { Release, CompatibilityResult, createRelease, createReleaseFromChart, promoteRelease, reportCompatibilityResult } from "./releases";
Loading