Skip to content

Commit

Permalink
make build_sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
pulumi-bot committed Dec 5, 2023
1 parent a1c4aa2 commit 53f4847
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 4 deletions.
71 changes: 71 additions & 0 deletions sdk/go/digitalocean/internal/pulumiUtilities.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sdk/nodejs/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import * as utilities from "./utilities";
*
* const cert = new digitalocean.Certificate("cert", {
* type: "custom",
* privateKey: fs.readFileSync("/Users/myuser/certs/privkey.pem"),
* leafCertificate: fs.readFileSync("/Users/myuser/certs/cert.pem"),
* certificateChain: fs.readFileSync("/Users/myuser/certs/fullchain.pem"),
* privateKey: fs.readFileSync("/Users/myuser/certs/privkey.pem", "utf8"),
* leafCertificate: fs.readFileSync("/Users/myuser/certs/cert.pem", "utf8"),
* certificateChain: fs.readFileSync("/Users/myuser/certs/fullchain.pem", "utf8"),
* });
* ```
* ### Let's Encrypt Certificate
Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/sshKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as utilities from "./utilities";
* import * as fs from "fs";
*
* // Create a new SSH key
* const _default = new digitalocean.SshKey("default", {publicKey: fs.readFileSync("/Users/myuser/.ssh/id_rsa.pub")});
* const _default = new digitalocean.SshKey("default", {publicKey: fs.readFileSync("/Users/myuser/.ssh/id_rsa.pub", "utf8")});
* // Create a new Droplet using the SSH key
* const web = new digitalocean.Droplet("web", {
* image: "ubuntu-18-04-x64",
Expand Down
29 changes: 29 additions & 0 deletions sdk/nodejs/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// *** Do not edit by hand unless you're certain you know what you are doing! ***


import * as runtime from "@pulumi/pulumi/runtime";
import * as pulumi from "@pulumi/pulumi";

export function getEnv(...vars: string[]): string | undefined {
for (const v of vars) {
const value = process.env[v];
Expand Down Expand Up @@ -64,3 +67,29 @@ export function lazyLoad(exports: any, props: string[], loadModule: any) {
});
}
}

export async function callAsync<T>(
tok: string,
props: pulumi.Inputs,
res?: pulumi.Resource,
opts?: {property?: string},
): Promise<T> {
const o: any = runtime.call<T>(tok, props, res);
const value = await o.promise(true /*withUnknowns*/);
const isKnown = await o.isKnown;
const isSecret = await o.isSecret;
const problem: string|undefined =
!isKnown ? "an unknown value"
: isSecret ? "a secret value"
: undefined;
// Ingoring o.resources silently. They are typically non-empty, r.f() calls include r as a dependency.
if (problem) {
throw new Error(`Plain resource method "${tok}" incorrectly returned ${problem}. ` +
"This is an error in the provider, please report this to the provider developer.");
}
// Extract a single property if requested.
if (opts && opts.property) {
return value[opts.property];
}
return value;
}
41 changes: 41 additions & 0 deletions sdk/python/pulumi_digitalocean/_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# *** Do not edit by hand unless you're certain you know what you are doing! ***


import asyncio
import importlib.util
import inspect
import json
Expand All @@ -13,6 +14,7 @@

import pulumi
import pulumi.runtime
from pulumi.runtime.sync_await import _sync_await

from semver import VersionInfo as SemverVersion
from parver import Version as PEP440Version
Expand Down Expand Up @@ -246,5 +248,44 @@ def lifted_func(*args, opts=None, **kwargs):

return (lambda _: lifted_func)


def call_plain(
tok: str,
props: pulumi.Inputs,
res: typing.Optional[pulumi.Resource] = None,
typ: typing.Optional[type] = None,
) -> typing.Any:
"""
Wraps pulumi.runtime.plain to force the output and return it plainly.
"""

output = pulumi.runtime.call(tok, props, res, typ)

# Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency.
result, known, secret, _ = _sync_await(asyncio.ensure_future(_await_output(output)))

problem = None
if not known:
problem = ' an unknown value'
elif secret:
problem = ' a secret value'

if problem:
raise AssertionError(
f"Plain resource method '{tok}' incorrectly returned {problem}. "
+ "This is an error in the provider, please report this to the provider developer."
)

return result


async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]:
return (
await o._future,
await o._is_known,
await o._is_secret,
await o._resources,
)

def get_plugin_download_url():
return None

0 comments on commit 53f4847

Please sign in to comment.