// Package slapshotapi provides utilities for interacting with the slapshot public API package slapshotapi import ( "git.haelnorr.com/h/golib/env" "github.com/pkg/errors" ) type Config struct { Environment string // ENV SLAPSHOT_ENVIRONMENT: API environment to connect to (default: staging) Key string // ENV SLAPSHOT_API_KEY: API Key for authorisation with the API (required) } func ConfigFromEnv() (any, error) { cfg := &Config{ Environment: env.String("SLAPSHOT_ENVIRONMENT", "staging"), Key: env.String("SLAPSHOT_API_KEY", ""), } if cfg.Key == "" { return nil, errors.New("Envar not set: SLAPSHOT_API_KEY") } return cfg, nil }