CoveClient

live · 1.0.0Go library

One consistent way for my Go projects to communicate with Cove.

What it is

CoveClient is a Go library for communicating with Cove, my self-hosted secrets manager.

It gives my other projects a consistent way to retrieve and manage secrets without having to implement the same API communication themselves.

Why I made it

There are two reasons I built CoveClient.

First, I don’t like rewriting code I’ve already written. It’s boring, cumbersome, and usually a waste of time.

But the more important reason came from working on Lys.

After building and rebuilding parts of Lys, I started realizing how much easier my life would be if I had clearly defined ways for different parts of my projects to communicate.

When everything has its own way of doing things, making changes or adding features can turn into a headache pretty quickly.

I wanted to get better about defining those boundaries from the start.

CoveClient was an opportunity to do that. Instead of letting every project interact with Cove however it wanted, I could provide a package with predefined methods, inputs, outputs, and errors.

That way, I only have to solve the problem once, and every project using it follows the same approach.

How it works

CoveClient wraps Cove’s API in a collection of Go methods.

Instead of writing HTTP requests, handling responses, and figuring out errors every time a project needs to interact with Cove, I can call the methods provided by the library.

It handles things like authentication, retrieving or updating secrets, checking whether Cove is available, and reporting errors in a consistent format.

The methods also define what information they accept and return, giving projects a predictable interface to work with.

It makes the code easier to reuse, but more importantly, it keeps the communication between Cove and the applications using it consistent.

Where it’s at

CoveClient is functional and used by my infrastructure.

It’s a relatively small library, and that’s intentional. I want it to handle communication with Cove without growing into something unnecessarily complicated.

I’ll continue maintaining it alongside Cove as the API and my projects evolve.

Changelog

1.0.0latest6 new · 7 changes

changed

  • Requests time out after 15 seconds (WithTimeout to change it) instead of waiting forever.
  • The client uses its own http.Client: settings made on http.DefaultClient no longer apply (use WithHTTPClient). Redirects aren’t followed.
  • Error text keeps Unexpected Status N and adds Cove’s explanation after it: ... Unexpected Status 404: not_found: secret not found.
  • Keys are checked before anything is sent; ?, # or ../ in a key can no longer reach a different URL.
  • Bootstrap() and the SecretValue type. Use LoadOrBootstrap(path), which also saves the token and sets it on the client.
  • The platform name: New(baseURL, token) replaces New(baseURL, clientSecret, platformName), and Client.Platform is gone. Cove 1.0 records a request under its token’s name, so X-Cove-Source is no longer sent.
  • Client.ClientSecret is now Client.Token.

added

  • APIError and sentinel errors for errors.Is: ErrNotFound, ErrUnauthorized, ErrForbidden, ErrAlreadyExists, ErrInvalidKey, ErrBootstrapClosed.
  • ...Context versions of every method.
  • GetSecrets(keys...): several secrets in one request (Cove’s POST /v0/batch), naming every missing key.
  • LoadOrBootstrap(path): onboarding in one call (reads a saved token, or fetches and saves it safely).
  • WaitForReady(ctx): waits until Cove and its database are up.
  • ValidateKey, WithTimeout, WithHTTPClient, doc comments, examples, and CI on Go 1.21 and the latest Go.

all releases on GitHub

More to look at

all projects
  • Lighthouse

    live · 1.6.1internal

    I push code to GitHub, and my server takes it from there.

  • Cove

    live · 1.0.4internal

    My own little vault for the passwords, keys, and secrets my projects need.

  • Blackbox

    live · 0.0.2internal

    One place to find out what my server's containers have been saying.