Skip to content

Commit

Permalink
ociclient: Add DeleteKey() functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Colp <[email protected]>
  • Loading branch information
pjcolp committed Oct 25, 2024
1 parent 13c9446 commit 93bc23f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ociclient/ociclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"intel/kbs/v1/model"
"regexp"
"time"

"github.com/oracle/oci-go-sdk/v65/common"
"github.com/oracle/oci-go-sdk/v65/secrets"
Expand Down Expand Up @@ -91,6 +92,28 @@ func (oc *ociClient) CreateKey(keyAttributes *model.KeyAttributes) error {
}

func (oc *ociClient) DeleteKey(secretId string) error {
// Create a request and dependent object(s).
req := vault.ScheduleSecretDeletionRequest{
SecretId: common.String(secretId),

ScheduleSecretDeletionDetails: vault.ScheduleSecretDeletionDetails{
TimeOfDeletion: &common.SDKTime{
Time: time.Now().Add(time.Hour * 48),
},
},
}

// Send the request using the vault client.
resp, err := oc.vc.ScheduleSecretDeletion(context.Background(), req)
if err != nil {
return errors.Wrapf(err, "Failed to delete key '%s' from oci server", secretId)
}

// TODO: Check response for error.
fmt.Printf("ociclient/ociclient:DeleteKey(): response:\n%s\n\n", resp)

log.Infof("ociclient/ociclient:DeleteKey() Deleted key '%s' from oci server", secretId)

return nil
}

Expand Down

0 comments on commit 93bc23f

Please sign in to comment.