Skip to content

fix: broken deno runtime secret injection #946

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

Merged
merged 2 commits into from
Dec 25, 2024
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
24 changes: 12 additions & 12 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude = [
]

[workspace.package]
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
edition = "2021"

[workspace.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/deno/api/example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Policy, t, typegraph } from "jsr:@typegraph/[email protected]";
import { PythonRuntime } from "jsr:@typegraph/[email protected].8/runtimes/python";
import { DenoRuntime } from "jsr:@typegraph/[email protected].8/runtimes/deno";
import { PythonRuntime } from "jsr:@typegraph/[email protected].9/runtimes/python";
import { DenoRuntime } from "jsr:@typegraph/[email protected].9/runtimes/deno";

await typegraph("example", (g) => {
const pub = Policy.public();
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/deno/compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typegate:
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9
restart: always
ports:
- "7890:7890"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/node/compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typegate:
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9
restart: always
ports:
- "7890:7890"
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "MCLI_LOADER_CMD='npm x tsx' meta dev"
},
"dependencies": {
"@typegraph/sdk": "^0.5.0-rc.8"
"@typegraph/sdk": "^0.5.0-rc.9"
},
"devDependencies": {
"tsx": "^3.13.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/templates/python/compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
typegate:
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.8
image: ghcr.io/metatypedev/typegate:v0.5.0-rc.9
restart: always
ports:
- "7890:7890"
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tool.poetry]
name = "example"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
description = ""
authors = []

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
typegraph = "0.5.0-rc.8"
typegraph = "0.5.0-rc.9"

[build-system]
requires = ["poetry-core"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[tool.poetry]
name = "metatype"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
description = ""
authors = []

Expand Down
2 changes: 1 addition & 1 deletion src/pyrt_wit_wire/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyrt_wit_wire"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
description = "Wasm component implementing the PythonRuntime host using wit_wire protocol."
license = "MPL-2.0"
readme = "README.md"
Expand Down
6 changes: 3 additions & 3 deletions src/typegate/src/runtimes/deno/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
allow: () => "ALLOW" as PolicyResolverOutput,
deny: () => "DENY" as PolicyResolverOutput,
pass: () => "PASS" as PolicyResolverOutput,
internal_policy: ({ _: { context } }) => context.provider === "internal" ? "ALLOW" : "DENY" as PolicyResolverOutput,
internal_policy: ({ _: { context } }) => context.provider === "internal" ? "ALLOW" : "PASS" as PolicyResolverOutput,
};

export class DenoRuntime extends Runtime {
Expand Down Expand Up @@ -73,9 +73,9 @@

const secrets: Record<string, string> = {};
for (const m of materializers) {
let secrets = (m.data.secrets as string[]) ?? [];
let matSecrets = (m.data.secrets as string[]) ?? [];
if (m.name === "outjection") {
secrets = m.data.source === "secret"
matSecrets = m.data.source === "secret"

Check warning on line 78 in src/typegate/src/runtimes/deno/deno.ts

View check run for this annotation

Codecov / codecov/patch

src/typegate/src/runtimes/deno/deno.ts#L78

Added line #L78 was not covered by tests
? [...getInjectionValues(m.data)]
: [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/typegate/src/runtimes/wit_wire/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getLogger } from "../../log.ts";

const logger = getLogger(import.meta);

const METATYPE_VERSION = "0.5.0-rc.8";
const METATYPE_VERSION = "0.5.0-rc.9";

export class WitWireMessenger {
static async init(
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typegraph_core"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/core/src/global_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const PREDEFINED_DENO_FUNCTIONS: &[&str] = &["identity", "true"];

thread_local! {
pub static STORE: RefCell<Store> = RefCell::new(Store::new());
pub static SDK_VERSION: String = "0.5.0-rc.8".to_owned();
pub static SDK_VERSION: String = "0.5.0-rc.9".to_owned();
}

fn with_store<T, F: FnOnce(&Store) -> T>(f: F) -> T {
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/deno/deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typegraph/sdk",
"version": "0.5.0-rc.8",
"version": "0.5.0-rc.9",
"publish": {
"exclude": [
"!src/gen",
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "typegraph"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
description = "Declarative API development platform. Build backend components with WASM, Typescript and Python, no matter where and how your (legacy) systems are."
authors = ["Metatype Contributors <[email protected]>"]
license = "MPL-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/python/typegraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from typegraph.policy import Policy # noqa
from typegraph import effects as fx # noqa

version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
2 changes: 1 addition & 1 deletion src/xtask/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xtask"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"
edition = "2021"

# this allows us to exclude the rust files
Expand Down
18 changes: 15 additions & 3 deletions tests/artifacts/artifacts_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ for (const { mode, ...options } of variants) {
...options,
},
async (t) => {
const e = await t.engine("runtimes/deno/deno.py");
const e = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});
const artifacts = e.tg.tg.meta.artifacts;

await t.should("have uploaded artifacts on deploy", async () => {
Expand Down Expand Up @@ -120,7 +124,11 @@ for (const { mode, ...options } of variants) {
...options,
},
async (t) => {
const e = await t.engine("runtimes/deno/deno.py");
const e = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});
const artifacts = e.tg.tg.meta.artifacts;

await t.should("have uploaded artifacts on deploy", async () => {
Expand Down Expand Up @@ -149,7 +157,11 @@ for (const { mode, ...options } of variants) {
...options,
},
async (t) => {
const engine = await t.engine("runtimes/deno/deno.py");
const engine = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});
const artifacts = engine.tg.tg.meta.artifacts;

const enginePartial = await t.engine("runtimes/deno/deno_partial.py");
Expand Down
4 changes: 2 additions & 2 deletions tests/metagen/__snapshots__/metagen_test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.5.0-rc.8";
static MT_VERSION: &str = "0.5.0-rc.9";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down Expand Up @@ -1255,7 +1255,7 @@ impl Router {
}

pub fn init(&self, args: InitArgs) -> Result<InitResponse, InitError> {
static MT_VERSION: &str = "0.5.0-rc.8";
static MT_VERSION: &str = "0.5.0-rc.9";
if args.metatype_version != MT_VERSION {
return Err(InitError::VersionMismatch(MT_VERSION.into()));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/metagen/typegraphs/sample/rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sample_client"
edition = "2021"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"

[dependencies]
metagen-client.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/metagen/typegraphs/sample/rs_upload/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sample_client_upload"
edition = "2021"
version = "0.5.0-rc.8"
version = "0.5.0-rc.9"

[dependencies]
metagen-client.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions tests/runtimes/deno/deno.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def deno(g: Graph):
name="counter",
effect=effects.update(),
),
secrets=deno.import_(
t.struct(),
t.struct({"ok": t.boolean()}),
module="ts/deno.ts",
name="secrets",
secrets=["DENO_SECRET"],
),
min=deno.import_(number_input, t.float(), module="ts/math.ts", name="min"),
max=deno.import_(number_input, t.float(), module="ts/math.ts", name="maxAsync"),
log=deno.import_(
Expand Down
18 changes: 15 additions & 3 deletions tests/runtimes/deno/deno_sync_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ Meta.test(
},
},
async (t) => {
const e = await t.engine("runtimes/deno/deno.py");
const e = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});

await t.should("work on the default worker", async () => {
await gql`
Expand Down Expand Up @@ -128,7 +132,11 @@ Meta.test(
},
},
async (t) => {
const e = await t.engine("runtimes/deno/deno.py");
const e = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});

await t.should("success for allowed network access", async () => {
await gql`
Expand Down Expand Up @@ -368,7 +376,11 @@ Meta.test(
},
},
async (t) => {
const e = await t.engine("runtimes/deno/deno.py");
const e = await t.engine("runtimes/deno/deno.py", {
secrets: {
DENO_SECRET: "deno_secret",
},
});

await t.should("safely fail upon stack overflow", async () => {
await gql`
Expand Down
Loading
Loading