From 4cd240c061c2bbb6df7c28276874ec8513a85e15 Mon Sep 17 00:00:00 2001 From: Bruno Calza Date: Tue, 26 Mar 2024 17:56:04 -0300 Subject: [PATCH] checks if vault already exists Signed-off-by: Bruno Calza --- pkg/vaultsprovider/provider.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/vaultsprovider/provider.go b/pkg/vaultsprovider/provider.go index 8c13751..ace66dd 100644 --- a/pkg/vaultsprovider/provider.go +++ b/pkg/vaultsprovider/provider.go @@ -56,11 +56,15 @@ func (bp *VaultsProvider) CreateVault(ctx context.Context, params app.CreateVaul _ = resp.Body.Close() }() - if resp.StatusCode != http.StatusCreated { - return errors.New("account was not created") + if resp.StatusCode == http.StatusCreated { + return nil } - return nil + if resp.StatusCode == http.StatusConflict { + return errors.New("vault already exists") + } + + return errors.New("failed to create vault") } // ListVaults lists all vaults from a given account.