Compare commits
No commits in common. "e98d64f39c2ca05f43c7237733179671dcdd7522" and "b2ebc5a621dcaf966cf16e7b45e1c69e4a8ee683" have entirely different histories.
e98d64f39c
...
b2ebc5a621
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,9 +1,7 @@
|
||||||
.cache
|
.cache
|
||||||
zig-cache
|
zig-cache
|
||||||
codegen/models/*.zig
|
src/codegen/models/*.zig
|
||||||
codegen/codegen
|
src/codegen/codegen
|
||||||
*.tgz
|
*.tgz
|
||||||
service_manifest.zig
|
service_manifest.zig
|
||||||
demo
|
demo
|
||||||
src/models/
|
|
||||||
smithy/zig-out/
|
|
||||||
|
|
36
README.md
36
README.md
|
@ -1,17 +1,23 @@
|
||||||
# AWS SDK for Zig
|
# AWS SDK for Zig
|
||||||
|
|
||||||
Ok, so it's not actually an SDK (yet). Right now the SDK should support
|
Ok, so it's not actually an SDK (yet). Right now this is SDK supports sts
|
||||||
any "query-based" operation and probably EC2, though this isn't tested yet.
|
get-caller-identity action only. Why? Because it's one of the easiest to
|
||||||
Total service count should be around 18 services supported. If you use an
|
support, so I started there. From here, the next major step is to codegen
|
||||||
unsupported service, you'll get a compile error.
|
the types necessary to support the various services. Currently this code is
|
||||||
|
dynamically generating the sts types so we are somewhat codegen ready, but
|
||||||
|
current comptime limitations might trip us up. The advantage of comptime is
|
||||||
|
that only types actually used would be generated vs the whole surface area
|
||||||
|
of AWS. That said, with most of the heavy lifting now coded, the addition
|
||||||
|
of the request/response types, even if all of them are added, should not
|
||||||
|
balloon the size beyond "reasonable". Of course this still needs to be be seen.
|
||||||
|
|
||||||
This is my first serious zig effort, so please issue a PR if the code isn't
|
This is my first serious zig effort, so please issue a PR if the code isn't
|
||||||
"ziggy" or if there's a better way.
|
"ziggy" or if there's a better way.
|
||||||
|
|
||||||
This is designed to be built statically using the `aws_c_*` libraries, so
|
This is designed to be built statically using the `aws_c_*` libraries, so
|
||||||
we inherit a lot of the goodness of the work going on there. Current
|
we inherit a lot of the goodness of the work going on there. Implementing
|
||||||
executable size is 10.3M, about half of which is due to the SSL library.
|
get-caller-identity with all dependencies statically linked gives us a stripped
|
||||||
This is for x86_linux (which is all that's tested at the moment).
|
executable size of 5.3M for x86_linux (which is all that's tested at the moment).
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
|
@ -25,15 +31,12 @@ I'm also hoping/expecting AWS to factor out that library sometime in
|
||||||
the future.
|
the future.
|
||||||
|
|
||||||
Once that's done, you'll have an alpine image with all dependencies ready
|
Once that's done, you'll have an alpine image with all dependencies ready
|
||||||
to go and zig master installed. There are some build-related things still
|
to go and zig 0.7.1 installed. The build.zig currently relies on
|
||||||
broken in 0.8.0 and hopefully 0.8.1 will address those and we can be on
|
[this PR to allow stripping -static](https://github.com/ziglang/zig/pull/8248),
|
||||||
a standard release.
|
so either:
|
||||||
|
|
||||||
* `zig build` should work. It will build the code generation project, run
|
* Modify build.zig, then strip (or not) after the fact
|
||||||
the code generation, then build the main project with the generated code.
|
* Install make and use the included Makefile
|
||||||
* Install make and use the included Makefile. Going this path should be fine
|
|
||||||
with zig 0.8.0 release, but code generation has not been added to the
|
|
||||||
Makefile yet (ever?), so you'll be on your own for that.
|
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
|
@ -93,7 +96,7 @@ TODO List:
|
||||||
* ✓ Implement codegen for services with xml structures (using Smithy models)
|
* ✓ Implement codegen for services with xml structures (using Smithy models)
|
||||||
* ✓ Implement codegen for others (using Smithy models)
|
* ✓ Implement codegen for others (using Smithy models)
|
||||||
* Switch to aws-c-cal upstream once [PR for full static musl build support is merged](https://github.com/awslabs/aws-c-cal/pull/89) (see Dockerfile)
|
* Switch to aws-c-cal upstream once [PR for full static musl build support is merged](https://github.com/awslabs/aws-c-cal/pull/89) (see Dockerfile)
|
||||||
* Move to compiler on tagged release (hopefully 0.8.1)
|
* Remove compiler 0.7.1 shims when 0.8.0 is released
|
||||||
(new 2021-05-29. I will proceed in this order unless I get other requests)
|
(new 2021-05-29. I will proceed in this order unless I get other requests)
|
||||||
* ✓ Implement [AWS query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-query-protocol.html). This is the protocol in use by sts.getcalleridentity. Total service count 18
|
* ✓ Implement [AWS query protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-query-protocol.html). This is the protocol in use by sts.getcalleridentity. Total service count 18
|
||||||
* Implement [AWS Json 1.0 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_0-protocol.html). Includes dynamodb. Total service count 18
|
* Implement [AWS Json 1.0 protocol](https://awslabs.github.io/smithy/1.0/spec/aws/aws-json-1_0-protocol.html). Includes dynamodb. Total service count 18
|
||||||
|
@ -103,6 +106,7 @@ TODO List:
|
||||||
|
|
||||||
Compiler wishlist/watchlist:
|
Compiler wishlist/watchlist:
|
||||||
|
|
||||||
|
* Fix the weirdness we see with comptime type generation (see aws.zig around line 135)
|
||||||
* ~~[Allow declarations for comptime type generation](https://github.com/ziglang/zig/issues/6709)~~
|
* ~~[Allow declarations for comptime type generation](https://github.com/ziglang/zig/issues/6709)~~
|
||||||
|
|
||||||
This is no longer as important. The primary issue was in the return value, but
|
This is no longer as important. The primary issue was in the return value, but
|
||||||
|
|
77
build.zig
77
build.zig
|
@ -1,8 +1,7 @@
|
||||||
const std = @import("std");
|
// const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
|
||||||
const Builder = @import("std").build.Builder;
|
const Builder = @import("std").build.Builder;
|
||||||
|
|
||||||
pub fn build(b: *Builder) !void {
|
pub fn build(b: *Builder) void {
|
||||||
// Standard target options allows the person running `zig build` to choose
|
// Standard target options allows the person running `zig build` to choose
|
||||||
// what target to build for. Here we do not override the defaults, which
|
// what target to build for. Here we do not override the defaults, which
|
||||||
// means any target is allowed, and the default is native. Other options
|
// means any target is allowed, and the default is native. Other options
|
||||||
|
@ -14,45 +13,20 @@ pub fn build(b: *Builder) !void {
|
||||||
const mode = b.standardReleaseOptions();
|
const mode = b.standardReleaseOptions();
|
||||||
const exe = b.addExecutable("demo", "src/main.zig");
|
const exe = b.addExecutable("demo", "src/main.zig");
|
||||||
|
|
||||||
// https://github.com/ziglang/zig/issues/855
|
// TODO: Generate src/models.zig
|
||||||
exe.addPackagePath("smithy", "smithy/src/smithy.zig");
|
|
||||||
|
|
||||||
// TODO: Support > linux
|
|
||||||
// TODO: Get a better cache in place
|
|
||||||
if (std.builtin.os.tag == .linux) {
|
|
||||||
const codegen = b.step("gen", "Generate zig service code from smithy models");
|
|
||||||
codegen.dependOn(&b.addSystemCommand(&.{ "/bin/sh", "-c", "cd codegen && zig build" }).step);
|
|
||||||
codegen.dependOn(&b.addSystemCommand(&.{
|
|
||||||
"/bin/sh", "-c",
|
|
||||||
\\ mkdir -p src/models/ && \
|
|
||||||
\\ [ -f src/models/service_manifest.zig ] || \
|
|
||||||
\\ ( cd codegen/models && ../codegen *.json && mv *.zig ../../src/models )
|
|
||||||
}).step);
|
|
||||||
b.getInstallStep().dependOn(codegen);
|
|
||||||
}
|
|
||||||
|
|
||||||
exe.addCSourceFile("src/bitfield-workaround.c", &[_][]const u8{"-std=c99"});
|
exe.addCSourceFile("src/bitfield-workaround.c", &[_][]const u8{"-std=c99"});
|
||||||
const c_include_dirs = .{
|
exe.addIncludeDir("./src/");
|
||||||
"./src/",
|
exe.addIncludeDir("/usr/local/include");
|
||||||
"/usr/local/include",
|
exe.addObjectFile("/usr/local/lib64/libs2n.a");
|
||||||
};
|
exe.addObjectFile("/usr/local/lib64/libcrypto.a");
|
||||||
inline for (c_include_dirs) |dir|
|
exe.addObjectFile("/usr/local/lib64/libssl.a");
|
||||||
exe.addIncludeDir(dir);
|
exe.addObjectFile("/usr/local/lib64/libaws-c-auth.a");
|
||||||
|
exe.addObjectFile("/usr/local/lib64/libaws-c-cal.a");
|
||||||
const dependent_objects = .{
|
exe.addObjectFile("/usr/local/lib64/libaws-c-common.a");
|
||||||
"/usr/local/lib64/libs2n.a",
|
exe.addObjectFile("/usr/local/lib64/libaws-c-compression.a");
|
||||||
"/usr/local/lib64/libcrypto.a",
|
exe.addObjectFile("/usr/local/lib64/libaws-c-http.a");
|
||||||
"/usr/local/lib64/libssl.a",
|
exe.addObjectFile("/usr/local/lib64/libaws-c-io.a");
|
||||||
"/usr/local/lib64/libaws-c-auth.a",
|
|
||||||
"/usr/local/lib64/libaws-c-cal.a",
|
|
||||||
"/usr/local/lib64/libaws-c-common.a",
|
|
||||||
"/usr/local/lib64/libaws-c-compression.a",
|
|
||||||
"/usr/local/lib64/libaws-c-http.a",
|
|
||||||
"/usr/local/lib64/libaws-c-io.a",
|
|
||||||
};
|
|
||||||
inline for (dependent_objects) |obj|
|
|
||||||
exe.addObjectFile(obj);
|
|
||||||
|
|
||||||
exe.linkSystemLibrary("c");
|
exe.linkSystemLibrary("c");
|
||||||
exe.setTarget(target);
|
exe.setTarget(target);
|
||||||
exe.setBuildMode(mode);
|
exe.setBuildMode(mode);
|
||||||
|
@ -62,14 +36,9 @@ pub fn build(b: *Builder) !void {
|
||||||
// https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.113+05b5e49bc.tar.xz
|
// https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.113+05b5e49bc.tar.xz
|
||||||
// exe.override_dest_dir = .{ .Custom = ".." };
|
// exe.override_dest_dir = .{ .Custom = ".." };
|
||||||
exe.override_dest_dir = .{ .custom = ".." };
|
exe.override_dest_dir = .{ .custom = ".." };
|
||||||
|
|
||||||
// Static linkage flag was nonfunctional until 2b2efa24d0855
|
|
||||||
// Did not notice this until 2021-06-28, and that nightly is:
|
|
||||||
// https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.321+15a030ef3.tar.xz
|
|
||||||
exe.linkage = .static;
|
exe.linkage = .static;
|
||||||
|
|
||||||
const is_strip = b.option(bool, "strip", "strip exe") orelse true;
|
exe.strip = true;
|
||||||
exe.strip = !is_strip;
|
|
||||||
exe.install();
|
exe.install();
|
||||||
|
|
||||||
const run_cmd = exe.run();
|
const run_cmd = exe.run();
|
||||||
|
@ -80,20 +49,4 @@ pub fn build(b: *Builder) !void {
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
|
||||||
var build_dir = try std.fs.openDirAbsolute(b.build_root, .{});
|
|
||||||
defer build_dir.close();
|
|
||||||
var src_dir = try build_dir.openDir("src", .{ .iterate = true });
|
|
||||||
defer src_dir.close();
|
|
||||||
var iterator = src_dir.iterate();
|
|
||||||
while (try iterator.next()) |entry| {
|
|
||||||
if (std.mem.endsWith(u8, entry.name, ".zig")) {
|
|
||||||
const name = try std.fmt.allocPrint(b.allocator, "src/{s}", .{entry.name});
|
|
||||||
defer b.allocator.free(name);
|
|
||||||
const t = b.addTest(name);
|
|
||||||
t.setBuildMode(mode);
|
|
||||||
test_step.dependOn(&t.step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) !void {
|
|
||||||
// Standard target options allows the person running `zig build` to choose
|
|
||||||
// what target to build for. Here we do not override the defaults, which
|
|
||||||
// means any target is allowed, and the default is native. Other options
|
|
||||||
// for restricting supported target set are available.
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
|
|
||||||
// Standard release options allow the person running `zig build` to select
|
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
|
||||||
const mode = b.standardReleaseOptions();
|
|
||||||
|
|
||||||
const exe = b.addExecutable("codegen", "src/main.zig");
|
|
||||||
exe.addPackagePath("smithy", "../smithy/src/smithy.zig");
|
|
||||||
exe.setTarget(target);
|
|
||||||
exe.setBuildMode(mode);
|
|
||||||
// This line works as of c5d412268
|
|
||||||
// Earliest nightly is 05b5e49bc on 2021-06-12
|
|
||||||
// https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.113+05b5e49bc.tar.xz
|
|
||||||
// exe.override_dest_dir = .{ .Custom = ".." };
|
|
||||||
exe.override_dest_dir = .{ .custom = ".." };
|
|
||||||
|
|
||||||
// Static linkage flag was nonfunctional until 2b2efa24d0855
|
|
||||||
// Did not notice this until 2021-06-28, and that nightly is:
|
|
||||||
// https://ziglang.org/builds/zig-linux-x86_64-0.9.0-dev.321+15a030ef3.tar.xz
|
|
||||||
exe.linkage = .static;
|
|
||||||
|
|
||||||
const is_strip = b.option(bool, "strip", "strip exe") orelse true;
|
|
||||||
exe.strip = !is_strip;
|
|
||||||
exe.install();
|
|
||||||
|
|
||||||
const run_cmd = exe.run();
|
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
|
||||||
if (b.args) |args| {
|
|
||||||
run_cmd.addArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
const run_step = b.step("run", "Run the app");
|
|
||||||
run_step.dependOn(&run_cmd.step);
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
|
||||||
var build_dir = try std.fs.openDirAbsolute(b.build_root, .{});
|
|
||||||
defer build_dir.close();
|
|
||||||
var src_dir = try build_dir.openDir("src", .{ .iterate = true });
|
|
||||||
defer src_dir.close();
|
|
||||||
var iterator = src_dir.iterate();
|
|
||||||
while (try iterator.next()) |entry| {
|
|
||||||
if (std.mem.endsWith(u8, entry.name, ".zig") and
|
|
||||||
!std.mem.eql(u8, entry.name, "main.zig"))
|
|
||||||
{
|
|
||||||
const name = try std.fmt.allocPrint(b.allocator, "src/{s}", .{entry.name});
|
|
||||||
defer b.allocator.free(name);
|
|
||||||
const t = b.addTest(name);
|
|
||||||
t.setBuildMode(mode);
|
|
||||||
test_step.dependOn(&t.step);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,213 +0,0 @@
|
||||||
const smithy = @import("smithy.zig");
|
|
||||||
|
|
||||||
pub const sts: struct {
|
|
||||||
version: []const u8 = "2011-06-15",
|
|
||||||
sdk_id: []const u8 = "STS",
|
|
||||||
arn_namespace: []const u8 = "sts",
|
|
||||||
endpoint_prefix: []const u8 = "sts",
|
|
||||||
sigv4_name: []const u8 = "sts",
|
|
||||||
aws_protocol: smithy.AwsProtocol = smithy.AwsProtocol.query,
|
|
||||||
assume_role: struct {
|
|
||||||
action_name: []const u8 = "AssumeRole",
|
|
||||||
Request: type = struct {
|
|
||||||
role_session_name: []const u8,
|
|
||||||
transitive_tag_keys: ?[][]const u8 = null,
|
|
||||||
serial_number: ?[]const u8 = null,
|
|
||||||
token_code: ?[]const u8 = null,
|
|
||||||
tags: ?[]struct {
|
|
||||||
value: []const u8,
|
|
||||||
key: []const u8,
|
|
||||||
} = null,
|
|
||||||
policy_arns: ?[]struct {
|
|
||||||
arn: ?[]const u8 = null,
|
|
||||||
} = null,
|
|
||||||
role_arn: []const u8,
|
|
||||||
source_identity: ?[]const u8 = null,
|
|
||||||
duration_seconds: ?i64 = null,
|
|
||||||
policy: ?[]const u8 = null,
|
|
||||||
external_id: ?[]const u8 = null,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
credentials: struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
secret_access_key: []const u8,
|
|
||||||
session_token: []const u8,
|
|
||||||
expiration: i64,
|
|
||||||
},
|
|
||||||
source_identity: []const u8,
|
|
||||||
assumed_role_user: struct {
|
|
||||||
assumed_role_id: []const u8,
|
|
||||||
arn: []const u8,
|
|
||||||
},
|
|
||||||
packed_policy_size: i64,
|
|
||||||
},
|
|
||||||
ServiceError: type = error{
|
|
||||||
ExpiredToken,
|
|
||||||
MalformedPolicyDocument,
|
|
||||||
PackedPolicyTooLarge,
|
|
||||||
RegionDisabled,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
assume_role_with_saml: struct {
|
|
||||||
action_name: []const u8 = "AssumeRoleWithSAML",
|
|
||||||
Request: type = struct {
|
|
||||||
policy_arns: ?[]struct {
|
|
||||||
arn: ?[]const u8 = null,
|
|
||||||
} = null,
|
|
||||||
role_arn: []const u8,
|
|
||||||
principal_arn: []const u8,
|
|
||||||
saml_assertion: []const u8,
|
|
||||||
duration_seconds: ?i64 = null,
|
|
||||||
policy: ?[]const u8 = null,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
credentials: struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
secret_access_key: []const u8,
|
|
||||||
session_token: []const u8,
|
|
||||||
expiration: i64,
|
|
||||||
},
|
|
||||||
packed_policy_size: i64,
|
|
||||||
subject_type: []const u8,
|
|
||||||
name_qualifier: []const u8,
|
|
||||||
source_identity: []const u8,
|
|
||||||
assumed_role_user: struct {
|
|
||||||
assumed_role_id: []const u8,
|
|
||||||
arn: []const u8,
|
|
||||||
},
|
|
||||||
issuer: []const u8,
|
|
||||||
audience: []const u8,
|
|
||||||
subject: []const u8,
|
|
||||||
},
|
|
||||||
ServiceError: type = error{
|
|
||||||
ExpiredToken,
|
|
||||||
IDPRejectedClaim,
|
|
||||||
InvalidIdentityToken,
|
|
||||||
MalformedPolicyDocument,
|
|
||||||
PackedPolicyTooLarge,
|
|
||||||
RegionDisabled,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
assume_role_with_web_identity: struct {
|
|
||||||
action_name: []const u8 = "AssumeRoleWithWebIdentity",
|
|
||||||
Request: type = struct {
|
|
||||||
role_session_name: []const u8,
|
|
||||||
duration_seconds: ?i64 = null,
|
|
||||||
policy_arns: ?[]struct {
|
|
||||||
arn: ?[]const u8 = null,
|
|
||||||
} = null,
|
|
||||||
role_arn: []const u8,
|
|
||||||
provider_id: ?[]const u8 = null,
|
|
||||||
web_identity_token: []const u8,
|
|
||||||
policy: ?[]const u8 = null,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
subject_from_web_identity_token: []const u8,
|
|
||||||
credentials: struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
secret_access_key: []const u8,
|
|
||||||
session_token: []const u8,
|
|
||||||
expiration: i64,
|
|
||||||
},
|
|
||||||
provider: []const u8,
|
|
||||||
packed_policy_size: i64,
|
|
||||||
source_identity: []const u8,
|
|
||||||
assumed_role_user: struct {
|
|
||||||
assumed_role_id: []const u8,
|
|
||||||
arn: []const u8,
|
|
||||||
},
|
|
||||||
audience: []const u8,
|
|
||||||
},
|
|
||||||
ServiceError: type = error{
|
|
||||||
ExpiredToken,
|
|
||||||
IDPCommunicationError,
|
|
||||||
IDPRejectedClaim,
|
|
||||||
InvalidIdentityToken,
|
|
||||||
MalformedPolicyDocument,
|
|
||||||
PackedPolicyTooLarge,
|
|
||||||
RegionDisabled,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
decode_authorization_message: struct {
|
|
||||||
action_name: []const u8 = "DecodeAuthorizationMessage",
|
|
||||||
Request: type = struct {
|
|
||||||
encoded_message: []const u8,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
decoded_message: []const u8,
|
|
||||||
},
|
|
||||||
ServiceError: type = error{InvalidAuthorizationMessage},
|
|
||||||
} = .{},
|
|
||||||
get_access_key_info: struct {
|
|
||||||
action_name: []const u8 = "GetAccessKeyInfo",
|
|
||||||
Request: type = struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
account: []const u8,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
get_caller_identity: struct {
|
|
||||||
action_name: []const u8 = "GetCallerIdentity",
|
|
||||||
Request: type = struct {
|
|
||||||
pub fn metaInfo(self: @This()) struct { service: @TypeOf(sts), action: @TypeOf(sts.get_caller_identity) } {
|
|
||||||
return .{ .service = sts, .action = sts.get_caller_identity };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
user_id: []const u8,
|
|
||||||
arn: []const u8,
|
|
||||||
account: []const u8,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
get_federation_token: struct {
|
|
||||||
action_name: []const u8 = "GetFederationToken",
|
|
||||||
Request: type = struct {
|
|
||||||
policy_arns: ?[]struct {
|
|
||||||
arn: ?[]const u8 = null,
|
|
||||||
} = null,
|
|
||||||
name: []const u8,
|
|
||||||
tags: ?[]struct {
|
|
||||||
value: []const u8,
|
|
||||||
key: []const u8,
|
|
||||||
} = null,
|
|
||||||
duration_seconds: ?i64 = null,
|
|
||||||
policy: ?[]const u8 = null,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
credentials: struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
secret_access_key: []const u8,
|
|
||||||
session_token: []const u8,
|
|
||||||
expiration: i64,
|
|
||||||
},
|
|
||||||
federated_user: struct {
|
|
||||||
arn: []const u8,
|
|
||||||
federated_user_id: []const u8,
|
|
||||||
},
|
|
||||||
packed_policy_size: i64,
|
|
||||||
},
|
|
||||||
ServiceError: type = error{
|
|
||||||
MalformedPolicyDocument,
|
|
||||||
PackedPolicyTooLarge,
|
|
||||||
RegionDisabled,
|
|
||||||
},
|
|
||||||
} = .{},
|
|
||||||
get_session_token: struct {
|
|
||||||
action_name: []const u8 = "GetSessionToken",
|
|
||||||
Request: type = struct {
|
|
||||||
duration_seconds: ?i64 = null,
|
|
||||||
serial_number: ?[]const u8 = null,
|
|
||||||
token_code: ?[]const u8 = null,
|
|
||||||
},
|
|
||||||
Response: type = struct {
|
|
||||||
credentials: struct {
|
|
||||||
access_key_id: []const u8,
|
|
||||||
secret_access_key: []const u8,
|
|
||||||
session_token: []const u8,
|
|
||||||
expiration: i64,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ServiceError: type = error{RegionDisabled},
|
|
||||||
} = .{},
|
|
||||||
} = .{}; // end of service: sts
|
|
|
@ -1,17 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn build(b: *std.build.Builder) void {
|
|
||||||
// Standard release options allow the person running `zig build` to select
|
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
|
||||||
const mode = b.standardReleaseOptions();
|
|
||||||
|
|
||||||
const lib = b.addStaticLibrary("smithy", "src/smithy.zig");
|
|
||||||
lib.setBuildMode(mode);
|
|
||||||
lib.install();
|
|
||||||
|
|
||||||
var main_tests = b.addTest("src/smithy.zig");
|
|
||||||
main_tests.setBuildMode(mode);
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
|
||||||
test_step.dependOn(&main_tests.step);
|
|
||||||
}
|
|
|
@ -45,6 +45,7 @@ pub const Aws = struct {
|
||||||
const meta_info = request.metaInfo();
|
const meta_info = request.metaInfo();
|
||||||
const service = meta_info.service;
|
const service = meta_info.service;
|
||||||
const action = meta_info.action;
|
const action = meta_info.action;
|
||||||
|
const R = Response(request);
|
||||||
|
|
||||||
log.debug("call: prefix {s}, sigv4 {s}, version {s}, action {s}", .{
|
log.debug("call: prefix {s}, sigv4 {s}, version {s}, action {s}", .{
|
||||||
service.endpoint_prefix,
|
service.endpoint_prefix,
|
||||||
|
|
|
@ -103,7 +103,7 @@ const EndPoint = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fn cInit(_: *std.mem.Allocator) void {
|
fn cInit(allocator: *std.mem.Allocator) void {
|
||||||
// TODO: what happens if we actually get an allocator?
|
// TODO: what happens if we actually get an allocator?
|
||||||
httplog.debug("auth init", .{});
|
httplog.debug("auth init", .{});
|
||||||
c_allocator = c.aws_default_allocator();
|
c_allocator = c.aws_default_allocator();
|
||||||
|
@ -121,7 +121,7 @@ fn cInit(_: *std.mem.Allocator) void {
|
||||||
// .level = .AWS_LL_INFO,
|
// .level = .AWS_LL_INFO,
|
||||||
// .level = .AWS_LL_DEBUG,
|
// .level = .AWS_LL_DEBUG,
|
||||||
// .level = .AWS_LL_TRACE,
|
// .level = .AWS_LL_TRACE,
|
||||||
.level = 1, //.AWS_LL_FATAL, // https://github.com/awslabs/aws-c-common/blob/057746b2e094f4b7a31743d8ba5a9fd0155f69f3/include/aws/common/logging.h#L33
|
.level = .AWS_LL_FATAL,
|
||||||
.file = c.get_std_err(),
|
.file = c.get_std_err(),
|
||||||
.filename = null,
|
.filename = null,
|
||||||
};
|
};
|
||||||
|
@ -143,7 +143,7 @@ fn cDeinit() void { // probably the wrong name
|
||||||
c.aws_tls_ctx_release(ctx);
|
c.aws_tls_ctx_release(ctx);
|
||||||
httplog.debug("tls_ctx deinit end", .{});
|
httplog.debug("tls_ctx deinit end", .{});
|
||||||
}
|
}
|
||||||
if (tls_ctx_options != null) {
|
if (tls_ctx_options) |opts| {
|
||||||
// See:
|
// See:
|
||||||
// https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/source/tls_channel_handler.c#L25
|
// https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/source/tls_channel_handler.c#L25
|
||||||
//
|
//
|
||||||
|
@ -311,13 +311,10 @@ pub const AwsHttp = struct {
|
||||||
// tls_connection_options = try self.setupTls(host);
|
// tls_connection_options = try self.setupTls(host);
|
||||||
if (tls_ctx_options == null) {
|
if (tls_ctx_options == null) {
|
||||||
httplog.debug("Setting up tls options", .{});
|
httplog.debug("Setting up tls options", .{});
|
||||||
// Language change - translate_c no longer translates c enums
|
|
||||||
// to zig enums as there were too many edge cases:
|
|
||||||
// https://github.com/ziglang/zig/issues/2115#issuecomment-827968279
|
|
||||||
var opts: c.aws_tls_ctx_options = .{
|
var opts: c.aws_tls_ctx_options = .{
|
||||||
.allocator = c_allocator,
|
.allocator = c_allocator,
|
||||||
.minimum_tls_version = 128, // @intToEnum(c.aws_tls_versions, c.AWS_IO_TLS_VER_SYS_DEFAULTS), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/tls_channel_handler.h#L21
|
.minimum_tls_version = @intToEnum(c.aws_tls_versions, c.AWS_IO_TLS_VER_SYS_DEFAULTS),
|
||||||
.cipher_pref = 0, // @intToEnum(c.aws_tls_cipher_pref, c.AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/tls_channel_handler.h#L25
|
.cipher_pref = @intToEnum(c.aws_tls_cipher_pref, c.AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT),
|
||||||
.ca_file = c.aws_byte_buf_from_c_str(""),
|
.ca_file = c.aws_byte_buf_from_c_str(""),
|
||||||
.ca_path = c.aws_string_new_from_c_str(c_allocator, ""),
|
.ca_path = c.aws_string_new_from_c_str(c_allocator, ""),
|
||||||
.alpn_list = null,
|
.alpn_list = null,
|
||||||
|
@ -364,8 +361,8 @@ pub const AwsHttp = struct {
|
||||||
}
|
}
|
||||||
if (signing_options) |opts| try self.signRequest(http_request.?, opts);
|
if (signing_options) |opts| try self.signRequest(http_request.?, opts);
|
||||||
const socket_options = c.aws_socket_options{
|
const socket_options = c.aws_socket_options{
|
||||||
.type = 0, // @intToEnum(c.aws_socket_type, c.AWS_SOCKET_STREAM), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/socket.h#L24
|
.type = @intToEnum(c.aws_socket_type, c.AWS_SOCKET_STREAM),
|
||||||
.domain = 0, // @intToEnum(c.aws_socket_domain, c.AWS_SOCKET_IPV4), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/socket.h#L12
|
.domain = @intToEnum(c.aws_socket_domain, c.AWS_SOCKET_IPV4),
|
||||||
.connect_timeout_ms = 3000, // TODO: change hardcoded 3s value
|
.connect_timeout_ms = 3000, // TODO: change hardcoded 3s value
|
||||||
.keep_alive_timeout_sec = 0,
|
.keep_alive_timeout_sec = 0,
|
||||||
.keepalive = false,
|
.keepalive = false,
|
||||||
|
@ -475,13 +472,13 @@ pub const AwsHttp = struct {
|
||||||
|
|
||||||
// TODO: Re-encapsulate or delete this function. It is not currently
|
// TODO: Re-encapsulate or delete this function. It is not currently
|
||||||
// used and will not be touched by the compiler
|
// used and will not be touched by the compiler
|
||||||
fn setupTls(_: Self, host: []const u8) !*c.aws_tls_connection_options {
|
fn setupTls(self: Self, host: []const u8) !*c.aws_tls_connection_options {
|
||||||
if (tls_ctx_options == null) {
|
if (tls_ctx_options == null) {
|
||||||
httplog.debug("Setting up tls options", .{});
|
httplog.debug("Setting up tls options", .{});
|
||||||
var opts: c.aws_tls_ctx_options = .{
|
var opts: c.aws_tls_ctx_options = .{
|
||||||
.allocator = c_allocator,
|
.allocator = c_allocator,
|
||||||
.minimum_tls_version = 128, // @intToEnum(c.aws_tls_versions, c.AWS_IO_TLS_VER_SYS_DEFAULTS), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/tls_channel_handler.h#L21
|
.minimum_tls_version = @intToEnum(c.aws_tls_versions, c.AWS_IO_TLS_VER_SYS_DEFAULTS),
|
||||||
.cipher_pref = 0, // @intToEnum(c.aws_tls_cipher_pref, c.AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT), // https://github.com/awslabs/aws-c-io/blob/6c7bae503961545c5e99c6c836c4b37749cfc4ad/include/aws/io/tls_channel_handler.h#L25
|
.cipher_pref = @intToEnum(c.aws_tls_cipher_pref, c.AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT),
|
||||||
.ca_file = c.aws_byte_buf_from_c_str(""),
|
.ca_file = c.aws_byte_buf_from_c_str(""),
|
||||||
.ca_path = c.aws_string_new_from_c_str(c_allocator, ""),
|
.ca_path = c.aws_string_new_from_c_str(c_allocator, ""),
|
||||||
.alpn_list = null,
|
.alpn_list = null,
|
||||||
|
@ -556,9 +553,9 @@ pub const AwsHttp = struct {
|
||||||
const signing_service = try std.fmt.allocPrintZ(self.allocator, "{s}", .{options.service});
|
const signing_service = try std.fmt.allocPrintZ(self.allocator, "{s}", .{options.service});
|
||||||
defer self.allocator.free(signing_service);
|
defer self.allocator.free(signing_service);
|
||||||
const temp_signing_config = c.bitfield_workaround_aws_signing_config_aws{
|
const temp_signing_config = c.bitfield_workaround_aws_signing_config_aws{
|
||||||
.algorithm = 0, // .AWS_SIGNING_ALGORITHM_V4, // https://github.com/awslabs/aws-c-auth/blob/ace1311f8ef6ea890b26dd376031bed2721648eb/include/aws/auth/signing_config.h#L38
|
.algorithm = .AWS_SIGNING_ALGORITHM_V4,
|
||||||
.config_type = 1, // .AWS_SIGNING_CONFIG_AWS, // https://github.com/awslabs/aws-c-auth/blob/ace1311f8ef6ea890b26dd376031bed2721648eb/include/aws/auth/signing_config.h#L24
|
.config_type = .AWS_SIGNING_CONFIG_AWS,
|
||||||
.signature_type = 0, // .AWS_ST_HTTP_REQUEST_HEADERS, // https://github.com/awslabs/aws-c-auth/blob/ace1311f8ef6ea890b26dd376031bed2721648eb/include/aws/auth/signing_config.h#L49
|
.signature_type = .AWS_ST_HTTP_REQUEST_HEADERS,
|
||||||
.region = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, signing_region)),
|
.region = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, signing_region)),
|
||||||
.service = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, signing_service)),
|
.service = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, signing_service)),
|
||||||
.should_sign_header = null,
|
.should_sign_header = null,
|
||||||
|
@ -569,7 +566,7 @@ pub const AwsHttp = struct {
|
||||||
.omit_session_token = 1,
|
.omit_session_token = 1,
|
||||||
},
|
},
|
||||||
.signed_body_value = c.aws_byte_cursor_from_c_str(""),
|
.signed_body_value = c.aws_byte_cursor_from_c_str(""),
|
||||||
.signed_body_header = 1, // .AWS_SBHT_X_AMZ_CONTENT_SHA256, //or 0 = AWS_SBHT_NONE // https://github.com/awslabs/aws-c-auth/blob/ace1311f8ef6ea890b26dd376031bed2721648eb/include/aws/auth/signing_config.h#L131
|
.signed_body_header = .AWS_SBHT_X_AMZ_CONTENT_SHA256, //or AWS_SBHT_NONE
|
||||||
.credentials = creds,
|
.credentials = creds,
|
||||||
.credentials_provider = self.credentialsProvider,
|
.credentials_provider = self.credentialsProvider,
|
||||||
.expiration_in_seconds = 0,
|
.expiration_in_seconds = 0,
|
||||||
|
@ -604,7 +601,7 @@ pub const AwsHttp = struct {
|
||||||
async_result.count += 1;
|
async_result.count += 1;
|
||||||
async_result.result.error_code = error_code;
|
async_result.result.error_code = error_code;
|
||||||
|
|
||||||
if (result != null) {
|
if (result) |res| {
|
||||||
if (c.aws_apply_signing_result_to_http_request(http_request, c_allocator, result) != c.AWS_OP_SUCCESS) {
|
if (c.aws_apply_signing_result_to_http_request(http_request, c_allocator, result) != c.AWS_OP_SUCCESS) {
|
||||||
httplog.alert("Could not apply signing request to http request: {s}", .{c.aws_error_debug_str(c.aws_last_error())});
|
httplog.alert("Could not apply signing request to http request: {s}", .{c.aws_error_debug_str(c.aws_last_error())});
|
||||||
}
|
}
|
||||||
|
@ -619,7 +616,7 @@ pub const AwsHttp = struct {
|
||||||
const accept_header = c.aws_http_header{
|
const accept_header = c.aws_http_header{
|
||||||
.name = c.aws_byte_cursor_from_c_str("Accept"),
|
.name = c.aws_byte_cursor_from_c_str("Accept"),
|
||||||
.value = c.aws_byte_cursor_from_c_str("application/json"),
|
.value = c.aws_byte_cursor_from_c_str("application/json"),
|
||||||
.compression = 0, // .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE, // https://github.com/awslabs/aws-c-http/blob/ec42882310900f2b414b279fc24636ba4653f285/include/aws/http/request_response.h#L37
|
.compression = .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
||||||
};
|
};
|
||||||
if (c.aws_http_message_add_header(request, accept_header) != c.AWS_OP_SUCCESS)
|
if (c.aws_http_message_add_header(request, accept_header) != c.AWS_OP_SUCCESS)
|
||||||
return AwsError.AddHeaderError;
|
return AwsError.AddHeaderError;
|
||||||
|
@ -627,7 +624,7 @@ pub const AwsHttp = struct {
|
||||||
const host_header = c.aws_http_header{
|
const host_header = c.aws_http_header{
|
||||||
.name = c.aws_byte_cursor_from_c_str("Host"),
|
.name = c.aws_byte_cursor_from_c_str("Host"),
|
||||||
.value = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, host)),
|
.value = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, host)),
|
||||||
.compression = 0, // .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
.compression = .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
||||||
};
|
};
|
||||||
if (c.aws_http_message_add_header(request, host_header) != c.AWS_OP_SUCCESS)
|
if (c.aws_http_message_add_header(request, host_header) != c.AWS_OP_SUCCESS)
|
||||||
return AwsError.AddHeaderError;
|
return AwsError.AddHeaderError;
|
||||||
|
@ -635,7 +632,7 @@ pub const AwsHttp = struct {
|
||||||
const user_agent_header = c.aws_http_header{
|
const user_agent_header = c.aws_http_header{
|
||||||
.name = c.aws_byte_cursor_from_c_str("User-Agent"),
|
.name = c.aws_byte_cursor_from_c_str("User-Agent"),
|
||||||
.value = c.aws_byte_cursor_from_c_str("zig-aws 1.0, Powered by the AWS Common Runtime."),
|
.value = c.aws_byte_cursor_from_c_str("zig-aws 1.0, Powered by the AWS Common Runtime."),
|
||||||
.compression = 0, // .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
.compression = .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
||||||
};
|
};
|
||||||
if (c.aws_http_message_add_header(request, user_agent_header) != c.AWS_OP_SUCCESS)
|
if (c.aws_http_message_add_header(request, user_agent_header) != c.AWS_OP_SUCCESS)
|
||||||
return AwsError.AddHeaderError;
|
return AwsError.AddHeaderError;
|
||||||
|
@ -657,7 +654,7 @@ pub const AwsHttp = struct {
|
||||||
const content_type_header = c.aws_http_header{
|
const content_type_header = c.aws_http_header{
|
||||||
.name = c.aws_byte_cursor_from_c_str("Content-Type"),
|
.name = c.aws_byte_cursor_from_c_str("Content-Type"),
|
||||||
.value = c.aws_byte_cursor_from_c_str("application/x-www-form-urlencoded"),
|
.value = c.aws_byte_cursor_from_c_str("application/x-www-form-urlencoded"),
|
||||||
.compression = 0, // .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
.compression = .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
||||||
};
|
};
|
||||||
if (c.aws_http_message_add_header(request, content_type_header) != c.AWS_OP_SUCCESS)
|
if (c.aws_http_message_add_header(request, content_type_header) != c.AWS_OP_SUCCESS)
|
||||||
return AwsError.AddHeaderError;
|
return AwsError.AddHeaderError;
|
||||||
|
@ -669,7 +666,7 @@ pub const AwsHttp = struct {
|
||||||
const content_length_header = c.aws_http_header{
|
const content_length_header = c.aws_http_header{
|
||||||
.name = c.aws_byte_cursor_from_c_str("Content-Length"),
|
.name = c.aws_byte_cursor_from_c_str("Content-Length"),
|
||||||
.value = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, len)),
|
.value = c.aws_byte_cursor_from_c_str(@ptrCast([*c]const u8, len)),
|
||||||
.compression = 0, // .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
.compression = .AWS_HTTP_HEADER_COMPRESSION_USE_CACHE,
|
||||||
};
|
};
|
||||||
if (c.aws_http_message_add_header(request, content_length_header) != c.AWS_OP_SUCCESS)
|
if (c.aws_http_message_add_header(request, content_length_header) != c.AWS_OP_SUCCESS)
|
||||||
return AwsError.AddHeaderError;
|
return AwsError.AddHeaderError;
|
||||||
|
@ -688,13 +685,12 @@ pub const AwsHttp = struct {
|
||||||
httplog.debug("connection setup callback end", .{});
|
httplog.debug("connection setup callback end", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connectionShutdownCallback(connection: ?*c.aws_http_connection, error_code: c_int, _: ?*c_void) callconv(.C) void {
|
fn connectionShutdownCallback(connection: ?*c.aws_http_connection, error_code: c_int, user_data: ?*c_void) callconv(.C) void {
|
||||||
// ^^ error_code ^^ user_data
|
httplog.debug("connection shutdown callback start", .{});
|
||||||
httplog.debug("connection shutdown callback start ({*}). error_code: {d}", .{ connection, error_code });
|
|
||||||
httplog.debug("connection shutdown callback end", .{});
|
httplog.debug("connection shutdown callback end", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn incomingHeadersCallback(stream: ?*c.aws_http_stream, _: c.aws_http_header_block, headers: [*c]const c.aws_http_header, num_headers: usize, user_data: ?*c_void) callconv(.C) c_int {
|
fn incomingHeadersCallback(stream: ?*c.aws_http_stream, header_block: c.aws_http_header_block, headers: [*c]const c.aws_http_header, num_headers: usize, user_data: ?*c_void) callconv(.C) c_int {
|
||||||
var context = userDataTo(RequestContext, user_data);
|
var context = userDataTo(RequestContext, user_data);
|
||||||
|
|
||||||
if (context.response_code == null) {
|
if (context.response_code == null) {
|
||||||
|
@ -716,7 +712,7 @@ pub const AwsHttp = struct {
|
||||||
}
|
}
|
||||||
return c.AWS_OP_SUCCESS;
|
return c.AWS_OP_SUCCESS;
|
||||||
}
|
}
|
||||||
fn incomingBodyCallback(_: ?*c.aws_http_stream, data: [*c]const c.aws_byte_cursor, user_data: ?*c_void) callconv(.C) c_int {
|
fn incomingBodyCallback(stream: ?*c.aws_http_stream, data: [*c]const c.aws_byte_cursor, user_data: ?*c_void) callconv(.C) c_int {
|
||||||
var context = userDataTo(RequestContext, user_data);
|
var context = userDataTo(RequestContext, user_data);
|
||||||
|
|
||||||
httplog.debug("inbound body, len {d}", .{data.*.len});
|
httplog.debug("inbound body, len {d}", .{data.*.len});
|
||||||
|
@ -727,8 +723,7 @@ pub const AwsHttp = struct {
|
||||||
httplog.alert("could not append to body!", .{});
|
httplog.alert("could not append to body!", .{});
|
||||||
return c.AWS_OP_SUCCESS;
|
return c.AWS_OP_SUCCESS;
|
||||||
}
|
}
|
||||||
fn requestCompleteCallback(stream: ?*c.aws_http_stream, _: c_int, user_data: ?*c_void) callconv(.C) void {
|
fn requestCompleteCallback(stream: ?*c.aws_http_stream, error_code: c_int, user_data: ?*c_void) callconv(.C) void {
|
||||||
// ^^ error_code
|
|
||||||
var context = userDataTo(RequestContext, user_data);
|
var context = userDataTo(RequestContext, user_data);
|
||||||
context.request_complete.store(true, .SeqCst);
|
context.request_complete.store(true, .SeqCst);
|
||||||
c.aws_http_stream_release(stream);
|
c.aws_http_stream_release(stream);
|
||||||
|
@ -740,9 +735,8 @@ pub const AwsHttp = struct {
|
||||||
var callback_results = AsyncResult(AwsAsyncCallbackResult(c.aws_credentials)){ .result = &credential_result };
|
var callback_results = AsyncResult(AwsAsyncCallbackResult(c.aws_credentials)){ .result = &credential_result };
|
||||||
|
|
||||||
const callback = awsAsyncCallbackResult(c.aws_credentials, "got credentials", assignCredentialsOnCallback);
|
const callback = awsAsyncCallbackResult(c.aws_credentials, "got credentials", assignCredentialsOnCallback);
|
||||||
// const get_async_result =
|
const get_async_result =
|
||||||
_ = c.aws_credentials_provider_get_credentials(self.credentialsProvider, callback, &callback_results);
|
c.aws_credentials_provider_get_credentials(self.credentialsProvider, callback, &callback_results);
|
||||||
// TODO: do we care about the return value from get_creds?
|
|
||||||
|
|
||||||
waitOnCallback(c.aws_credentials, &callback_results);
|
waitOnCallback(c.aws_credentials, &callback_results);
|
||||||
if (credential_result.error_code != c.AWS_ERROR_SUCCESS) {
|
if (credential_result.error_code != c.AWS_ERROR_SUCCESS) {
|
||||||
|
|
28
src/codegen/build.zig
Normal file
28
src/codegen/build.zig
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(b: *std.build.Builder) void {
|
||||||
|
// Standard target options allows the person running `zig build` to choose
|
||||||
|
// what target to build for. Here we do not override the defaults, which
|
||||||
|
// means any target is allowed, and the default is native. Other options
|
||||||
|
// for restricting supported target set are available.
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
|
||||||
|
// Standard release options allow the person running `zig build` to select
|
||||||
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
|
const mode = b.standardReleaseOptions();
|
||||||
|
|
||||||
|
const exe = b.addExecutable("codegen", "src/main.zig");
|
||||||
|
exe.setTarget(target);
|
||||||
|
exe.setBuildMode(mode);
|
||||||
|
exe.override_dest_dir = .{ .Custom = ".." };
|
||||||
|
exe.install();
|
||||||
|
|
||||||
|
const run_cmd = exe.run();
|
||||||
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
if (b.args) |args| {
|
||||||
|
run_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const run_step = b.step("run", "Run the app");
|
||||||
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user