get account id printing with leading zeros

This commit is contained in:
Emil Lerch 2024-03-04 13:35:57 -08:00
parent 4f0c608392
commit ff81524caa
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
3 changed files with 5 additions and 5 deletions

View File

@ -215,7 +215,7 @@ fn generateCredentials(s: *std.build.Step, prog_node: *std.Progress.Node) error{
// },
// ) catch return error.MakeFailed;
stdout.print(
"# access_key: ELAK{s}, secret_key: {s}, account_number: {d}, db_encryption_key: {s}",
"# access_key: ELAK{s}, secret_key: {s}, account_number: {d:0>12}, db_encryption_key: {s}",
.{
access_key_suffix_encoded,
encoded_secret,
@ -224,7 +224,7 @@ fn generateCredentials(s: *std.build.Step, prog_node: *std.Progress.Node) error{
},
) catch return error.MakeFailed;
stdout.print(
"\n#\n# You can copy/paste the following line into access_keys.csv:\nELAK{s},{s},{d},{s}\n",
"\n#\n# You can copy/paste the following line into access_keys.csv:\nELAK{s},{s},{d:0>12},{s}\n",
.{
access_key_suffix_encoded,
encoded_secret,

View File

@ -38,7 +38,7 @@ pub fn accountForId(allocator: std.mem.Allocator, account_id: u40) !Self {
}
// TODO: Check STS
log.err("Got account id '{d}', but could not find this ('1234' is test account). STS GetAccessKeyInfo not implemented", .{account_id});
log.err("Got account id '{d:0>12}', but could not find this ('1234' is test account). STS GetAccessKeyInfo not implemented", .{account_id});
return error.NotImplemented;
}
@ -66,7 +66,7 @@ pub fn dbForAccount(allocator: std.mem.Allocator, account_id: u40) !*sqlite.Db {
// TODO: Need to move this function somewhere central
// TODO: Need configuration for what directory to use
// TODO: Should this be a pool, and if so, how would we know when to close?
const file_without_path = try std.fmt.allocPrint(allocator, "ddb-{d}.sqlite3", .{account_id});
const file_without_path = try std.fmt.allocPrint(allocator, "ddb-{d:0>12}.sqlite3", .{account_id});
defer allocator.free(file_without_path);
const db_file_name = try std.fs.path.joinZ(allocator, &[_][]const u8{ data_dir, file_without_path });
defer allocator.free(db_file_name);

View File

@ -144,7 +144,7 @@ pub fn handler(request: *AuthenticatedRequest, writer: anytype) ![]const u8 {
var al = std.ArrayList(u8).init(allocator);
var response_writer = al.writer();
try response_writer.print("table created for account {d}\n", .{account_id});
try response_writer.print("table created for account {d:0>12}\n", .{account_id});
return al.toOwnedSlice();
}