added slapapi
This commit is contained in:
23
pkg/slapshotapi/config.go
Normal file
23
pkg/slapshotapi/config.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user