@reyemtech/pulumi-rackspace-spot 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cmd/install-plugin.js +19 -0
- package/cmd/provider/auth.d.ts +15 -0
- package/cmd/provider/auth.js +77 -0
- package/cmd/provider/auth.js.map +1 -0
- package/cmd/provider/client.d.ts +17 -0
- package/cmd/provider/client.js +75 -0
- package/cmd/provider/client.js.map +1 -0
- package/cmd/provider/functions/getCloudspace.d.ts +14 -0
- package/cmd/provider/functions/getCloudspace.js +18 -0
- package/cmd/provider/functions/getCloudspace.js.map +1 -0
- package/cmd/provider/functions/getKubeconfig.d.ts +10 -0
- package/cmd/provider/functions/getKubeconfig.js +26 -0
- package/cmd/provider/functions/getKubeconfig.js.map +1 -0
- package/cmd/provider/functions/getRegions.d.ts +10 -0
- package/cmd/provider/functions/getRegions.js +16 -0
- package/cmd/provider/functions/getRegions.js.map +1 -0
- package/cmd/provider/functions/getServerClasses.d.ts +17 -0
- package/cmd/provider/functions/getServerClasses.js +24 -0
- package/cmd/provider/functions/getServerClasses.js.map +1 -0
- package/cmd/provider/index.d.ts +1 -0
- package/cmd/provider/index.js +53 -0
- package/cmd/provider/index.js.map +1 -0
- package/cmd/provider/provider.d.ts +20 -0
- package/cmd/provider/provider.js +257 -0
- package/cmd/provider/provider.js.map +1 -0
- package/cmd/provider/resources/cloudspace.d.ts +33 -0
- package/cmd/provider/resources/cloudspace.js +114 -0
- package/cmd/provider/resources/cloudspace.js.map +1 -0
- package/cmd/provider/resources/ondemandnodepool.d.ts +35 -0
- package/cmd/provider/resources/ondemandnodepool.js +100 -0
- package/cmd/provider/resources/ondemandnodepool.js.map +1 -0
- package/cmd/provider/resources/spotnodepool.d.ts +40 -0
- package/cmd/provider/resources/spotnodepool.js +141 -0
- package/cmd/provider/resources/spotnodepool.js.map +1 -0
- package/cmd/pulumi-resource-rackspace-spot.js +2 -0
- package/package.json +11 -2
- package/cloudspace.ts +0 -29
- package/getCloudspace.ts +0 -23
- package/getKubeconfig.ts +0 -19
- package/getRegions.ts +0 -19
- package/getServerClasses.ts +0 -28
- package/index.ts +0 -10
- package/ondemandnodepool.ts +0 -33
- package/provider.ts +0 -11
- package/spotnodepool.ts +0 -37
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall hook — symlinks the provider binary so Pulumi can find it on $PATH.
|
|
4
|
+
* Creates: /usr/local/bin/pulumi-resource-rackspace-spot -> this package's cmd/pulumi-resource-rackspace-spot.js
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const src = path.join(__dirname, "pulumi-resource-rackspace-spot.js");
|
|
10
|
+
const dest = "/usr/local/bin/pulumi-resource-rackspace-spot";
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
if (fs.existsSync(dest)) fs.unlinkSync(dest);
|
|
14
|
+
fs.symlinkSync(src, dest);
|
|
15
|
+
console.log(`pulumi-rackspace-spot: linked provider to ${dest}`);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// Non-fatal — CI environments may not have /usr/local/bin write access
|
|
18
|
+
console.warn(`pulumi-rackspace-spot: could not link provider to ${dest} (${e.code}). Add ${path.dirname(src)} to PATH manually.`);
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TokenResult {
|
|
2
|
+
idToken: string;
|
|
3
|
+
orgId: string;
|
|
4
|
+
namespace: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class SpotAuth {
|
|
7
|
+
private readonly refreshToken;
|
|
8
|
+
private readonly apiBase;
|
|
9
|
+
private cache;
|
|
10
|
+
constructor(refreshToken: string, apiBase?: string);
|
|
11
|
+
getToken(): Promise<TokenResult>;
|
|
12
|
+
private discoverTokenEndpoint;
|
|
13
|
+
private exchangeToken;
|
|
14
|
+
private decodeJwtPayload;
|
|
15
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpotAuth = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Rackspace Spot OIDC issuer. Discovered via .well-known/openid-configuration.
|
|
6
|
+
* This is the public Auth0 tenant for Rackspace Spot — present in every JWT they issue.
|
|
7
|
+
*/
|
|
8
|
+
const OIDC_ISSUER = "https://login.spot.rackspace.com";
|
|
9
|
+
/**
|
|
10
|
+
* Rackspace Spot Auth0 client ID (audience). This is a public OIDC value present
|
|
11
|
+
* in every JWT's `aud` claim — not a secret. OIDC discovery doesn't expose
|
|
12
|
+
* per-application client IDs, so this must be hardcoded.
|
|
13
|
+
*/
|
|
14
|
+
const OIDC_CLIENT_ID = "mwG3lUMV8KyeMqHe4fJ5Bb3nM1vBvRNa";
|
|
15
|
+
class SpotAuth {
|
|
16
|
+
refreshToken;
|
|
17
|
+
apiBase;
|
|
18
|
+
cache = null;
|
|
19
|
+
constructor(refreshToken, apiBase = "https://spot.rackspace.com") {
|
|
20
|
+
this.refreshToken = refreshToken;
|
|
21
|
+
this.apiBase = apiBase.replace(/\/$/, "");
|
|
22
|
+
}
|
|
23
|
+
async getToken() {
|
|
24
|
+
const nowSec = Math.floor(Date.now() / 1000);
|
|
25
|
+
if (this.cache !== null && nowSec < this.cache.expiresAt) {
|
|
26
|
+
return this.cache.result;
|
|
27
|
+
}
|
|
28
|
+
const idToken = await this.exchangeToken();
|
|
29
|
+
const payload = this.decodeJwtPayload(idToken);
|
|
30
|
+
const orgId = payload.org_id;
|
|
31
|
+
const namespace = orgId.toLowerCase().replace(/_/g, "-");
|
|
32
|
+
const result = { idToken, orgId, namespace };
|
|
33
|
+
this.cache = { result, expiresAt: payload.exp - 60 };
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Private helpers
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
async discoverTokenEndpoint() {
|
|
40
|
+
// Use OIDC discovery to find the token endpoint — unauthenticated and resilient
|
|
41
|
+
// to domain changes. Only the clientId is hardcoded (OIDC discovery doesn't
|
|
42
|
+
// expose per-application client IDs).
|
|
43
|
+
const res = await fetch(`${OIDC_ISSUER}/.well-known/openid-configuration`);
|
|
44
|
+
if (!res.ok) {
|
|
45
|
+
throw new Error(`OIDC discovery failed (HTTP ${res.status}): ${OIDC_ISSUER}`);
|
|
46
|
+
}
|
|
47
|
+
const config = await res.json();
|
|
48
|
+
return config.token_endpoint;
|
|
49
|
+
}
|
|
50
|
+
async exchangeToken() {
|
|
51
|
+
const tokenEndpoint = await this.discoverTokenEndpoint();
|
|
52
|
+
const res = await fetch(tokenEndpoint, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
55
|
+
body: new URLSearchParams({
|
|
56
|
+
grant_type: "refresh_token",
|
|
57
|
+
client_id: OIDC_CLIENT_ID,
|
|
58
|
+
refresh_token: this.refreshToken,
|
|
59
|
+
}).toString(),
|
|
60
|
+
});
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
throw new Error(`Token exchange failed (HTTP ${res.status}) against ${tokenEndpoint}`);
|
|
63
|
+
}
|
|
64
|
+
const data = await res.json();
|
|
65
|
+
return data.id_token;
|
|
66
|
+
}
|
|
67
|
+
decodeJwtPayload(jwt) {
|
|
68
|
+
const parts = jwt.split(".");
|
|
69
|
+
if (parts.length !== 3) {
|
|
70
|
+
throw new Error("Invalid JWT: expected 3 segments");
|
|
71
|
+
}
|
|
72
|
+
const raw = Buffer.from(parts[1], "base64").toString("utf-8");
|
|
73
|
+
return JSON.parse(raw);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.SpotAuth = SpotAuth;
|
|
77
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
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CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAe,CAAC;IACvC,CAAC;CACF;AA1ED,4BA0EC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type K8sResource = Record<string, any>;
|
|
2
|
+
export declare class SpotClient {
|
|
3
|
+
private readonly baseUrl;
|
|
4
|
+
private readonly namespace;
|
|
5
|
+
private readonly headers;
|
|
6
|
+
constructor(baseUrl: string, namespace: string, token: string);
|
|
7
|
+
private namespacedUrl;
|
|
8
|
+
private clusterUrl;
|
|
9
|
+
private request;
|
|
10
|
+
get(resource: string, name: string): Promise<K8sResource>;
|
|
11
|
+
list(resource: string): Promise<K8sResource[]>;
|
|
12
|
+
create(resource: string, body: K8sResource): Promise<K8sResource>;
|
|
13
|
+
update(resource: string, name: string, body: K8sResource): Promise<K8sResource>;
|
|
14
|
+
remove(resource: string, name: string): Promise<void>;
|
|
15
|
+
getClusterScoped(resource: string, name?: string): Promise<K8sResource>;
|
|
16
|
+
listClusterScoped(resource: string): Promise<K8sResource[]>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpotClient = void 0;
|
|
4
|
+
const API_GROUP = "ngpc.rxt.io/v1";
|
|
5
|
+
class SpotClient {
|
|
6
|
+
baseUrl;
|
|
7
|
+
namespace;
|
|
8
|
+
headers;
|
|
9
|
+
constructor(baseUrl, namespace, token) {
|
|
10
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
11
|
+
this.namespace = namespace;
|
|
12
|
+
this.headers = {
|
|
13
|
+
Authorization: `Bearer ${token}`,
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
// Namespaced path: /apis/ngpc.rxt.io/v1/namespaces/{namespace}/{resource}/{name}
|
|
18
|
+
namespacedUrl(resource, name) {
|
|
19
|
+
const base = `${this.baseUrl}/apis/${API_GROUP}/namespaces/${this.namespace}/${resource}`;
|
|
20
|
+
return name ? `${base}/${name}` : base;
|
|
21
|
+
}
|
|
22
|
+
// Cluster-scoped path: /apis/ngpc.rxt.io/v1/{resource}/{name}
|
|
23
|
+
clusterUrl(resource, name) {
|
|
24
|
+
const base = `${this.baseUrl}/apis/${API_GROUP}/${resource}`;
|
|
25
|
+
return name ? `${base}/${name}` : base;
|
|
26
|
+
}
|
|
27
|
+
async request(url, opts = {}) {
|
|
28
|
+
const res = await fetch(url, {
|
|
29
|
+
...opts,
|
|
30
|
+
headers: { ...this.headers, ...opts.headers },
|
|
31
|
+
});
|
|
32
|
+
const text = await res.text();
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw new Error(`Spot API error ${res.status}: ${text}`);
|
|
35
|
+
}
|
|
36
|
+
return text;
|
|
37
|
+
}
|
|
38
|
+
async get(resource, name) {
|
|
39
|
+
const text = await this.request(this.namespacedUrl(resource, name), { method: "GET" });
|
|
40
|
+
return JSON.parse(text);
|
|
41
|
+
}
|
|
42
|
+
async list(resource) {
|
|
43
|
+
const text = await this.request(this.namespacedUrl(resource), { method: "GET" });
|
|
44
|
+
const body = JSON.parse(text);
|
|
45
|
+
return body.items;
|
|
46
|
+
}
|
|
47
|
+
async create(resource, body) {
|
|
48
|
+
const text = await this.request(this.namespacedUrl(resource), {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify(body),
|
|
51
|
+
});
|
|
52
|
+
return JSON.parse(text);
|
|
53
|
+
}
|
|
54
|
+
async update(resource, name, body) {
|
|
55
|
+
const text = await this.request(this.namespacedUrl(resource, name), {
|
|
56
|
+
method: "PUT",
|
|
57
|
+
body: JSON.stringify(body),
|
|
58
|
+
});
|
|
59
|
+
return JSON.parse(text);
|
|
60
|
+
}
|
|
61
|
+
async remove(resource, name) {
|
|
62
|
+
await this.request(this.namespacedUrl(resource, name), { method: "DELETE" });
|
|
63
|
+
}
|
|
64
|
+
async getClusterScoped(resource, name) {
|
|
65
|
+
const text = await this.request(this.clusterUrl(resource, name), { method: "GET" });
|
|
66
|
+
return JSON.parse(text);
|
|
67
|
+
}
|
|
68
|
+
async listClusterScoped(resource) {
|
|
69
|
+
const text = await this.request(this.clusterUrl(resource), { method: "GET" });
|
|
70
|
+
const body = JSON.parse(text);
|
|
71
|
+
return body.items;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.SpotClient = SpotClient;
|
|
75
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":";;;AAEA,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC,MAAa,UAAU;IACJ,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,OAAO,CAAyB;IAEjD,YAAY,OAAe,EAAE,SAAiB,EAAE,KAAa;QAC3D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG;YACb,aAAa,EAAE,UAAU,KAAK,EAAE;YAChC,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;IAED,iFAAiF;IACzE,aAAa,CAAC,QAAgB,EAAE,IAAa;QACnD,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,SAAS,SAAS,eAAe,IAAI,CAAC,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1F,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,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QACtC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,KAAsB,CAAC;IACrC,CAAC;CACF;AA/ED,gCA+EC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SpotClient } from "../client";
|
|
2
|
+
export declare function getCloudspace(client: SpotClient, inputs: {
|
|
3
|
+
name: string;
|
|
4
|
+
}): Promise<{
|
|
5
|
+
outputs: {
|
|
6
|
+
name: any;
|
|
7
|
+
region: any;
|
|
8
|
+
kubernetesVersion: any;
|
|
9
|
+
cni: any;
|
|
10
|
+
haControlPlane: any;
|
|
11
|
+
apiServerEndpoint: any;
|
|
12
|
+
phase: any;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCloudspace = getCloudspace;
|
|
4
|
+
async function getCloudspace(client, inputs) {
|
|
5
|
+
const cs = await client.get("cloudspaces", inputs.name);
|
|
6
|
+
return {
|
|
7
|
+
outputs: {
|
|
8
|
+
name: cs.metadata.name,
|
|
9
|
+
region: cs.spec.region,
|
|
10
|
+
kubernetesVersion: cs.spec.kubernetesVersion,
|
|
11
|
+
cni: cs.spec.cni,
|
|
12
|
+
haControlPlane: cs.spec.HAControlPlane ?? cs.spec.haControlPlane ?? false,
|
|
13
|
+
apiServerEndpoint: cs.status?.APIServerEndpoint ?? cs.status?.apiServerEndpoint ?? "",
|
|
14
|
+
phase: cs.status?.phase ?? "",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=getCloudspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCloudspace.js","sourceRoot":"","sources":["../../functions/getCloudspace.ts"],"names":[],"mappings":";;AAEA,sCAaC;AAbM,KAAK,UAAU,aAAa,CAAC,MAAkB,EAAE,MAAwB;IAC9E,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO;QACL,OAAO,EAAE;YACP,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI;YACtB,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM;YACtB,iBAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB;YAC5C,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG;YAChB,cAAc,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,IAAI,CAAC,cAAc,IAAI,KAAK;YACzE,iBAAiB,EAAE,EAAE,CAAC,MAAM,EAAE,iBAAiB,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,IAAI,EAAE;YACrF,KAAK,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;SAC9B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKubeconfig = getKubeconfig;
|
|
4
|
+
async function getKubeconfig(client, token, inputs) {
|
|
5
|
+
const cs = await client.get("cloudspaces", inputs.cloudspaceName);
|
|
6
|
+
// K8s CRD uses PascalCase field names
|
|
7
|
+
const endpoint = cs.status?.APIServerEndpoint ?? cs.status?.apiServerEndpoint;
|
|
8
|
+
if (!endpoint)
|
|
9
|
+
throw new Error(`Cloudspace ${inputs.cloudspaceName} has no API endpoint yet`);
|
|
10
|
+
const raw = JSON.stringify({
|
|
11
|
+
apiVersion: "v1",
|
|
12
|
+
kind: "Config",
|
|
13
|
+
clusters: [{
|
|
14
|
+
cluster: { server: `https://${endpoint}`, "insecure-skip-tls-verify": true },
|
|
15
|
+
name: inputs.cloudspaceName,
|
|
16
|
+
}],
|
|
17
|
+
contexts: [{
|
|
18
|
+
context: { cluster: inputs.cloudspaceName, namespace: "default", user: "spot-user" },
|
|
19
|
+
name: inputs.cloudspaceName,
|
|
20
|
+
}],
|
|
21
|
+
"current-context": inputs.cloudspaceName,
|
|
22
|
+
users: [{ name: "spot-user", user: { token } }],
|
|
23
|
+
});
|
|
24
|
+
return { outputs: { raw, host: `https://${endpoint}`, clusterName: inputs.cloudspaceName } };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=getKubeconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKubeconfig.js","sourceRoot":"","sources":["../../functions/getKubeconfig.ts"],"names":[],"mappings":";;AAEA,sCAsBC;AAtBM,KAAK,UAAU,aAAa,CAAC,MAAkB,EAAE,KAAa,EAAE,MAAkC;IACvG,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAClE,sCAAsC;IACtC,MAAM,QAAQ,GAAG,EAAE,CAAC,MAAM,EAAE,iBAAiB,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAC9E,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,MAAM,CAAC,cAAc,0BAA0B,CAAC,CAAC;IAE9F,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QACzB,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC;gBACT,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,QAAQ,EAAE,EAAE,0BAA0B,EAAE,IAAI,EAAE;gBAC5E,IAAI,EAAE,MAAM,CAAC,cAAc;aAC5B,CAAC;QACF,QAAQ,EAAE,CAAC;gBACT,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;gBACpF,IAAI,EAAE,MAAM,CAAC,cAAc;aAC5B,CAAC;QACF,iBAAiB,EAAE,MAAM,CAAC,cAAc;QACxC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegions = getRegions;
|
|
4
|
+
async function getRegions(client) {
|
|
5
|
+
const items = await client.listClusterScoped("regions");
|
|
6
|
+
return {
|
|
7
|
+
outputs: {
|
|
8
|
+
regions: items.map((r) => ({
|
|
9
|
+
name: r.metadata.name,
|
|
10
|
+
country: r.spec?.country ?? "",
|
|
11
|
+
description: r.spec?.description ?? "",
|
|
12
|
+
})),
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getRegions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRegions.js","sourceRoot":"","sources":["../../functions/getRegions.ts"],"names":[],"mappings":";;AAEA,gCAWC;AAXM,KAAK,UAAU,UAAU,CAAC,MAAkB;IACjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACxD,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;gBAC9B,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI;gBACrB,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;gBAC9B,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE;aACvC,CAAC,CAAC;SACJ;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SpotClient } from "../client";
|
|
2
|
+
export declare function getServerClasses(client: SpotClient, inputs?: {
|
|
3
|
+
region?: string;
|
|
4
|
+
}): Promise<{
|
|
5
|
+
outputs: {
|
|
6
|
+
serverClasses: {
|
|
7
|
+
name: any;
|
|
8
|
+
region: any;
|
|
9
|
+
category: any;
|
|
10
|
+
cpu: any;
|
|
11
|
+
memory: any;
|
|
12
|
+
flavorType: any;
|
|
13
|
+
available: any;
|
|
14
|
+
capacity: any;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServerClasses = getServerClasses;
|
|
4
|
+
async function getServerClasses(client, inputs) {
|
|
5
|
+
const items = await client.listClusterScoped("serverclasses");
|
|
6
|
+
const filtered = inputs?.region
|
|
7
|
+
? items.filter((sc) => sc.spec?.region === inputs.region)
|
|
8
|
+
: items;
|
|
9
|
+
return {
|
|
10
|
+
outputs: {
|
|
11
|
+
serverClasses: filtered.map((sc) => ({
|
|
12
|
+
name: sc.metadata.name,
|
|
13
|
+
region: sc.spec?.region ?? "",
|
|
14
|
+
category: sc.spec?.category ?? "",
|
|
15
|
+
cpu: sc.spec?.resources?.cpu ?? "",
|
|
16
|
+
memory: sc.spec?.resources?.memory ?? "",
|
|
17
|
+
flavorType: sc.spec?.flavorType ?? "",
|
|
18
|
+
available: sc.status?.available ?? 0,
|
|
19
|
+
capacity: sc.status?.capacity ?? 0,
|
|
20
|
+
})),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=getServerClasses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getServerClasses.js","sourceRoot":"","sources":["../../functions/getServerClasses.ts"],"names":[],"mappings":";;AAEA,4CAmBC;AAnBM,KAAK,UAAU,gBAAgB,CAAC,MAAkB,EAAE,MAA4B;IACrF,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,MAAM,EAAE,MAAM;QAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC;QAC9D,CAAC,CAAC,KAAK,CAAC;IACV,OAAO;QACL,OAAO,EAAE;YACP,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI;gBACtB,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE;gBAC7B,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE;gBACjC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE;gBAClC,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,IAAI,EAAE;gBACxC,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE;gBACrC,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC;gBACpC,QAAQ,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,IAAI,CAAC;aACnC,CAAC,CAAC;SACJ;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const pulumi = __importStar(require("@pulumi/pulumi"));
|
|
37
|
+
const fs_1 = require("fs");
|
|
38
|
+
const path_1 = require("path");
|
|
39
|
+
const provider_1 = require("./provider");
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
41
|
+
const pkg = require("../package.json");
|
|
42
|
+
function main(args) {
|
|
43
|
+
// At runtime __dirname is provider/bin/ (compiled output).
|
|
44
|
+
// schema.json sits one level up at the provider root, and package.json
|
|
45
|
+
// is at the repo root (two levels up from bin/).
|
|
46
|
+
const schema = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, "..", "schema.json"), "utf-8");
|
|
47
|
+
return pulumi.provider.main(new provider_1.RackspaceSpotProvider(pkg.version, schema), args);
|
|
48
|
+
}
|
|
49
|
+
main(process.argv.slice(2)).catch((err) => {
|
|
50
|
+
console.error(err);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AACzC,2BAAkC;AAClC,+BAA+B;AAC/B,yCAAmD;AAEnD,8DAA8D;AAC9D,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAE9D,SAAS,IAAI,CAAC,IAAc;IAC1B,2DAA2D;IAC3D,uEAAuE;IACvE,iDAAiD;IACjD,MAAM,MAAM,GAAG,IAAA,iBAAY,EAAC,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;IAE9E,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,gCAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AACpF,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACxC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as provider from "@pulumi/pulumi/provider";
|
|
2
|
+
export declare class RackspaceSpotProvider implements provider.Provider {
|
|
3
|
+
readonly version: string;
|
|
4
|
+
readonly schema: string;
|
|
5
|
+
private refreshToken;
|
|
6
|
+
constructor(version: string, schema: string);
|
|
7
|
+
checkConfig(urn: string, _olds: any, news: any): Promise<provider.CheckResult>;
|
|
8
|
+
diffConfig(_id: string, _urn: string, _olds: any, news: any): Promise<provider.DiffResult>;
|
|
9
|
+
configure(news: any): Promise<void>;
|
|
10
|
+
private ensureClient;
|
|
11
|
+
/** Read refreshToken from ~/.spot_config (created by `spotctl configure`). */
|
|
12
|
+
private readSpotConfig;
|
|
13
|
+
check(urn: string, _olds: any, news: any): Promise<provider.CheckResult>;
|
|
14
|
+
diff(id: string, urn: string, olds: any, news: any): Promise<provider.DiffResult>;
|
|
15
|
+
create(urn: string, inputs: any): Promise<provider.CreateResult>;
|
|
16
|
+
read(id: string, urn: string, props?: any): Promise<provider.ReadResult>;
|
|
17
|
+
update(id: string, urn: string, olds: any, news: any): Promise<provider.UpdateResult>;
|
|
18
|
+
delete(id: string, urn: string, _props: any): Promise<void>;
|
|
19
|
+
invoke(token: string, inputs: any): Promise<provider.InvokeResult>;
|
|
20
|
+
}
|