diff --git a/.mise.toml b/.mise.toml index 5ef8ebd..2405a24 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,5 +1,5 @@ [tools] -pre-commit = "4.2.0" zig = "0.15.2" zls = "0.15.1" "ubi:DonIsaac/zlint" = "0.7.6" +prek = "0.3.1" diff --git a/tools/build/build.zig.zon b/tools/build/build.zig.zon index 20764b9..f1f10d4 100644 --- a/tools/build/build.zig.zon +++ b/tools/build/build.zig.zon @@ -4,8 +4,8 @@ .fingerprint = 0x6e61de08e7e51114, .dependencies = .{ .aws = .{ - .url = "git+https://git.lerch.org/lobo/aws-sdk-for-zig#c1df6ef3a6f4eb4eb75608c3cc6488cffc300793", - .hash = "aws-0.0.1-SbsFcC47CgCWY3bwHxku5J4BAohk-6UJZEUX1B0azJ_D", + .url = "git+https://git.lerch.org/lobo/aws-sdk-for-zig#5c7aed071f6251d53a1627080a21d604ff58f0a5", + .hash = "aws-0.0.1-SbsFcFE7CgDBilPa15i4gIB6Qr5ozBz328O63abDQDDk", }, }, .paths = .{ diff --git a/tools/build/src/deploy.zig b/tools/build/src/deploy.zig index 7bbd8d1..86f17a4 100644 --- a/tools/build/src/deploy.zig +++ b/tools/build/src/deploy.zig @@ -278,7 +278,7 @@ fn deployFunction(deploy_opts: DeployOptions, options: RunOptions) !void { std.log.info("Attempting to create function: {s}", .{deploy_opts.function_name}); var create_diagnostics = aws.Diagnostics{ - .http_code = undefined, + .response_status = undefined, .response_body = undefined, .allocator = options.allocator, }; @@ -302,10 +302,9 @@ fn deployFunction(deploy_opts: DeployOptions, options: RunOptions) !void { .environment = if (env_variables) |vars| .{ .variables = vars } else null, }, create_options) catch |err| { defer create_diagnostics.deinit(); - std.log.info("CreateFunction returned: error={}, HTTP code={}", .{ err, create_diagnostics.http_code }); // Function already exists (409 Conflict) - update it instead - if (create_diagnostics.http_code == 409) { + if (create_diagnostics.response_status == .conflict) { std.log.info("Function already exists, updating: {s}", .{deploy_opts.function_name}); const update_result = try aws.Request(services.lambda.update_function_code).call(.{ @@ -342,8 +341,10 @@ fn deployFunction(deploy_opts: DeployOptions, options: RunOptions) !void { return; } - - std.log.err("Lambda CreateFunction failed: {} (HTTP {})", .{ err, create_diagnostics.http_code }); + std.log.err( + "Lambda CreateFunction failed: {} (HTTP Response code {})", + .{ err, create_diagnostics.response_status }, + ); return error.LambdaCreateFunctionFailed; }; defer create_result.deinit(); @@ -483,7 +484,7 @@ fn addPermission( std.log.info("Adding invoke permission for principal: {s}", .{principal}); var diagnostics = aws.Diagnostics{ - .http_code = undefined, + .response_status = undefined, .response_body = undefined, .allocator = options.allocator, }; @@ -500,14 +501,17 @@ fn addPermission( defer diagnostics.deinit(); // 409 Conflict means permission already exists - that's fine - if (diagnostics.http_code == 409) { + if (diagnostics.response_status == .conflict) { std.log.info("Permission already exists for: {s}", .{principal}); try options.stdout.print("Permission already exists for: {s}\n", .{principal}); try options.stdout.flush(); return; } - std.log.err("AddPermission failed: {} (HTTP {})", .{ err, diagnostics.http_code }); + std.log.err( + "AddPermission failed: {} (HTTP Response code {})", + .{ err, diagnostics.response_status }, + ); return error.AddPermissionFailed; }; defer result.deinit(); diff --git a/tools/build/src/iam.zig b/tools/build/src/iam.zig index b9724a3..8fa5848 100644 --- a/tools/build/src/iam.zig +++ b/tools/build/src/iam.zig @@ -61,7 +61,7 @@ pub fn getOrCreateRole(role_name: []const u8, options: RunOptions) ![]const u8 { const services = aws.Services(.{.iam}){}; var diagnostics = aws.Diagnostics{ - .http_code = undefined, + .response_status = undefined, .response_body = undefined, .allocator = options.allocator, }; @@ -74,11 +74,14 @@ pub fn getOrCreateRole(role_name: []const u8, options: RunOptions) ![]const u8 { .role_name = role_name, }, aws_options) catch |err| { defer diagnostics.deinit(); - if (diagnostics.http_code == 404) { + if (diagnostics.response_status == .not_found) { // Role doesn't exist, create it return try createRole(role_name, options); } - std.log.err("IAM GetRole failed: {} (HTTP {})", .{ err, diagnostics.http_code }); + std.log.err( + "IAM GetRole failed: {} (HTTP Response code {})", + .{ err, diagnostics.response_status }, + ); return error.IamGetRoleFailed; }; defer get_result.deinit();