From 82a31bee030e8954fe854e2a3b5269e65ef05d07 Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Mon, 15 Aug 2022 23:14:41 +0800 Subject: [PATCH] implement erase --- cmd/docker-credential-himitsu/erase.ha | 19 +++++++++++++++++++ cmd/docker-credential-himitsu/main.ha | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 cmd/docker-credential-himitsu/erase.ha diff --git a/cmd/docker-credential-himitsu/erase.ha b/cmd/docker-credential-himitsu/erase.ha new file mode 100644 index 0000000..1a9570a --- /dev/null +++ b/cmd/docker-credential-himitsu/erase.ha @@ -0,0 +1,19 @@ +use bufio; +use himitsu::client; +use himitsu::query; +use os; +use strings; + +fn erase() void = { + const hi = client::connect()!; + const url = strings::fromutf8(bufio::scanline(os::stdin)! as []u8); + const query = query::query { + items = [ + query::pair { key = "proto", value = "docker", private = false, optional = false}, + query::pair { key = "host", value = url, private = false, optional = false}, + query::pair { key = "username", value = "", private = false, optional = false}, + query::pair { key = "secret", value = "", private = true, optional = false}, + ], + }; + client::query(hi, client::operation::DEL, &query, 0)!; +}; diff --git a/cmd/docker-credential-himitsu/main.ha b/cmd/docker-credential-himitsu/main.ha index 173642c..cbac3eb 100644 --- a/cmd/docker-credential-himitsu/main.ha +++ b/cmd/docker-credential-himitsu/main.ha @@ -7,6 +7,8 @@ export fn main() void = { store(); case "get" => get(); + case "erase" => + erase(); case "list" => list(); case => -- 2.45.2