doppler

package module
v0.0.0-...-28863ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 18 Imported by: 0

README

Doppler-Go

Go SDK client for doppler.com API.

Installation

  go get -u github.com/dilutedev/doppler

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

DOPPLER_KEY

Read more about keys here

Documentation

API Documentation

Features

  • Auth
  • Workplace
  • Workplace Roles
  • Activity logs
  • Projects
  • Project Roles
  • Project Members
  • Environments
  • Configs
  • Config logs
  • Trusted IPs
  • Secrets
  • Integrations
  • Secrets Sync
  • Dynamic Secrets
  • Service Tokens
  • Invites
  • Groups
  • Service Accounts
  • Audit
  • Share

Usage/Examples

package main

import (
    "github.com/dilutedev/doppler"
    _ "github.com/joho/godotenv/autoload"
)

func main(){
    dp, err := doppler.NewFromEnv()
    if err != nil {
        panic(err)
    }

    projects, err := dp.ListProjects(1, nil)
    if err != nil {
        panic(err)
    }

    log.Println(projects)
}

Authors

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("received invalid token")
)
View Source
var (
	TokenFormats = map[string]*regexp.Regexp{
		"service":        regexp.MustCompile(`dp\.st\.(?:[a-z0-9\-_]{2,35}\.)?[a-zA-Z0-9]{40,44}`),
		"cli":            regexp.MustCompile(`dp\.ct\.[a-zA-Z0-9]{40,44}`),
		"personal":       regexp.MustCompile(`dp\.pt\.[a-zA-Z0-9]{40,44}`),
		"service_access": regexp.MustCompile(`dp\.sa\.[a-zA-Z0-9]{40,44}`),
		"scim":           regexp.MustCompile(`dp\.scim\.[a-zA-Z0-9]{40,44}`),
		"audit":          regexp.MustCompile(`dp\.audit\.[a-zA-Z0-9]{40,44}`),
	}
)

Functions

func EncryptSecret

func EncryptSecret(secret string) (map[string]interface{}, error)

Go implementation of the Encryption Example here: https://docs.doppler.com/reference/share-secret-encrypted

func New

func New(key string) (*doppler, error)

create new doppler config

func NewFromEnv

func NewFromEnv() (*doppler, error)

Types

type ActivityLog

type ActivityLog struct {
	Log     Log  `json:"log"`
	Success bool `json:"success"`
}

type ActivityLogs

type ActivityLogs struct {
	Page    int   `json:"page"`
	Logs    []Log `json:"logs"`
	Success bool  `json:"success"`
}

type AddProjectMemberParam

type AddProjectMemberParam struct {
	Type         string   `json:"type"`
	Slug         string   `json:"slug"`
	Role         string   `json:"role"`
	Environments []string `json:"environments"`
}

type Config

type Config struct {
	Name           string `json:"name"`             // Name of the config.
	Project        string `json:"project"`          // Identifier of the project that the config belongs to.
	Environment    string `json:"environment"`      // Identifier of the environment that the config belongs to.
	CreatedAt      string `json:"created_at"`       // Date and time of the object's creation.
	InitialFetchAt string `json:"initial_fetch_at"` // Date and time of the first secrets fetch.
	LastFetchAt    string `json:"last_fetch_at"`    // Date and time of the last secrets fetch.
	Root           bool   `json:"root"`             // Whether the config is the root of the environment.
	Locked         bool   `json:"locked"`           // Whether the config can be renamed and/or deleted.
	Slug           string `json:"slug"`
}

type ConfigLog

type ConfigLog struct {
	ID          string          `json:"id"`   // Unique identifier for the object
	Text        string          `json:"text"` // Text describing the event
	HTML        string          `json:"html"` // HTML describing the event
	Diff        []ConfigLogDiff `json:"diff,omitempty"`
	Rollback    bool            `json:"rollback"` // Is this config log a rollback of a previous log
	User        User            `json:"user"`
	Project     string          `json:"project"`     // Unique identifier for the object
	Environment string          `json:"environment"` // Unique identifier for the enironment object
	Config      string          `json:"config"`      // The config's name
	CreatedAt   string          `json:"created_at"`  // Date and time of the object's creation
}

type ConfigLogDiff

type ConfigLogDiff struct {
	Name    string `json:"name"`
	Added   string `json:"added"`
	Removed string `json:"removed"`
}

type ConfigLogs

type ConfigLogs struct {
	Logs    []ConfigLog `json:"logs"`
	Page    int         `json:"page"`
	Success bool        `json:"success"`
}

type Configs

type Configs struct {
	Configs []Config `json:"configs"`
	Page    int      `json:"page"`
	Success bool     `json:"success"`
}

type CreateConfigParams

type CreateConfigParams struct {
	Project     string `json:"project"`     // Unique identifier for the project object
	Environment string `json:"environment"` // Identifier for the environment object
	Name        string `json:"name"`        // Name of the new branch config
}

type CreateProjectParams

type CreateProjectParams struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type CreateRoleParams

type CreateRoleParams struct {
	Name        string   `json:"name,omitempty"`
	Permissions []string `json:"permissions,omitempty"`
}

type CreateTokenParams

type CreateTokenParams struct {
	Project  string `json:"project,omitempty"`   // Unique identifier for the project object.
	Config   string `json:"config,omitempty"`    // Name of the config object.
	Name     string `json:"name,omitempty"`      // Name of the service token.
	ExpireAt string `json:"expire_at,omitempty"` // Unix timestamp of when token should expire.
	Access   string `json:"access,omitempty"`    // Token's capabilities. "read/write" or "read". Default: read
}

type DefaultProjectRole

type DefaultProjectRole struct {
	Identifier string `json:"identifier,omitempty"`
}

type DeletConfigParams

type DeletConfigParams struct {
	Project string `json:"project"` // Unique identifier for the project (project name)
	Config  string `json:"config"`  // Name of the config object
}

type DeleteTokenParams

type DeleteTokenParams struct {
	Project string `json:"project,omitempty"` // Unique identifier for the project object.
	Config  string `json:"config,omitempty"`  // Name of the config object.
	Slug    string `json:"slug,omitempty"`    // The slug of the service token.
}

type Diff

type Diff struct {
	Name    *string  `json:"name"`
	Added   []string `json:"added"`
	Removed []string `json:"removed"`
	Updated []string `json:"updated"`
}

type DopplerError

type DopplerError struct {
	Status   int      `json:"status"`
	Messages []string `json:"message"`
}

func (*DopplerError) Error

func (err *DopplerError) Error() string

type DownloadSecretParams

type DownloadSecretParams struct {
	Project               string
	Config                string
	Format                string // Acceptable values: json, env, yaml, docker, env-no-quotes, dotnet-json. defaults json
	NameTransformer       string // Acceptable values: camel, upper-camel, lower-snake, tf-var, dotnet, dotnet-env, lower-kebab. defaults to upper snake case
	IncludeDynamicSecrets bool
	DynamicSecretsTTLSec  int
}

type EncryptedSecretArgs

type EncryptedSecretArgs struct {
	Secret      string `json:"secret"`
	ExpireViews int32  `json:"expire_views"`
	ExpireDays  int32  `json:"expire_days"`
}

type Environment

type Environment struct {
	ID             string `json:"id"`               // An identifier for the object
	Name           string `json:"name"`             // Name of the environment
	Project        string `json:"project"`          // Identifier of the project the environment belongs to
	CreatedAt      string `json:"created_at"`       // Date and time of the object's creation
	InitialFetchAt string `json:"initial_fetch_at"` // Date and time of the first secrets fetch from a config in the environment
}

type EnvironmentBodyParams

type EnvironmentBodyParams struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type Environments

type Environments struct {
	Environments []Environment `json:"environments"`
	Page         int           `json:"page"`
	Success      bool          `json:"success"`
}

type FailedRequest

type FailedRequest struct {
	Messages []string `json:"messages"`
	Success  bool     `json:"success"`
}

failed response

type Group

type Group struct {
	Name               string             `json:"name,omitempty"`
	Slug               string             `json:"slug,omitempty"`
	CreatedAt          string             `json:"created_at,omitempty"`
	DefaultProjectRole DefaultProjectRole `json:"default_project_role,omitempty"`
}

type GroupBodyParams

type GroupBodyParams struct {
	Name               string `json:"name,omitempty"`
	DefaultProjectRole string `json:"default_project_role,omitempty"` // Identifier of the project role
}

type GroupData

type GroupData struct {
	Group    Group     `json:"group,omitempty"`
	Projects []Project `json:"projects,omitempty"`
	Members  []Member  `json:"members,omitempty"`
}

type Groups

type Groups struct {
	Groups  []Group `json:"groups,omitempty"`
	Success bool    `json:"success,omitempty"`
}

type IConfig

type IConfig struct {
	Config  Config `json:"config"`
	Success bool   `json:"success"`
}

type IConfigLog

type IConfigLog struct {
	Log     ConfigLog `json:"log"`
	Success bool      `json:"success"`
}

type IEnvironment

type IEnvironment struct {
	Environment Environment `json:"environment"`
	Success     bool        `json:"success,omitempty"`
}

type IP

type IP struct {
	IP string `json:"ip"`
}

type IProject

type IProject struct {
	Project Project `json:"project"`
	Success bool    `json:"success"`
}

type IPs

type IPs struct {
	IPs     []string `json:"ips"`
	Success bool     `json:"success"`
}

type Integration

type Integration struct {
	Slug    string `json:"slug,omitempty"`
	Name    string `json:"name,omitempty"`
	Type    string `json:"type,omitempty"`
	Kind    string `json:"kind,omitempty"`
	Enabled bool   `json:"enabled,omitempty"`
}

type IntegrationData

type IntegrationData struct {
	Integration Integration `json:"integration,omitempty"`
	Success     bool        `json:"success,omitempty"`
}

type Integrations

type Integrations struct {
	Integrations []Integration `json:"integrations,omitempty"`
	Success      bool          `json:"success,omitempty"`
}

type Invite

type Invite struct {
	Slug          string        `json:"slug"`
	Email         string        `json:"email"`
	CreatedAt     string        `json:"created_at"`
	WorkplaceRole WorkplaceRole `json:"workplace_role"`
}

type Invites

type Invites struct {
	Invites []Invite `json:"invites"`
	Success bool     `json:"success"`
}

type IssueLeaseArgs

type IssueLeaseArgs struct {
	Project       string `json:"project"`
	Config        string `json:"config"`
	DynamicSecret string `json:"dynamic_secret"`
	TtlSec        int32  `json:"ttl_sec"`
}

type ListSecretNamesParams

type ListSecretNamesParams struct {
	Project               string // Unique identifier for the project object.
	Config                string // Name of the config object.
	IncludeDynamicSecrets bool   // Whether or not to issue leases and include dynamic secret values for the config
	IncludeManagedSecrets bool   // Whether to include Doppler's auto-generated (managed) secrets. defaults to false
}

type ListSecretsParams

type ListSecretsParams struct {
	Project               string // Unique identifier for the project object.
	Config                string // Name of the config object.
	IncludeDynamicSecrets bool   // Whether or not to issue leases and include dynamic secret values for the config
	DynamicSecretsTTLSec  int    // The number of seconds until dynamic leases expire. Must be used with IncludeDynamicSecrets. Defaults to 1800 (30 minutes).
	Secrets               string // A comma-separated list of secrets to include in the response, may only contain uppercase letters, numbers, and underscores.
	IncludeManagedSecrets bool   // Whether to include Doppler's auto-generated (managed) secrets. defaults to false
}

type Log

type Log struct {
	ID                 string  `json:"id"`                  // Unique identifier for the object.
	Text               string  `json:"text"`                // Text describing the event.
	HTML               string  `json:"html"`                // HTML describing the event.
	CreatedAt          string  `json:"created_at"`          // Date and time of the object's creation.
	EnclaveConfig      *string `json:"enclave_config"`      // The config's name.
	EnclaveEnvironment *string `json:"enclave_environment"` // Unique identifier for the environment object.
	EnclaveProject     *string `json:"enclave_project"`     // Unique identifier for the project object.
	User               User    `json:"user"`
	Diff               *Diff   `json:"diff"`
}

type Member

type Member struct {
	Type                  string      `json:"type"`
	Slug                  string      `json:"slug"`
	Role                  Role        `json:"role"`
	AccessAllEnvironments bool        `json:"access_all_environments"`
	Environments          interface{} `json:"environments"`
}

type MemberBodyParams

type MemberBodyParams struct {
	Type string `json:"type,omitempty"`
	Slug string `json:"slug,omitempty"` // The member's slug
}

type MemberType

type MemberType int
const (
	MemberWorkplaceUser MemberType = iota
	MemberGroup
	MemberInvite
	MemberServiceAccount
)

func (MemberType) String

func (m MemberType) String() string

type ModifyConfigParams

type ModifyConfigParams struct {
	Project string `json:"project"` // Unique identifier for the project (project name)
	Config  string `json:"config"`  // Name of the config object
	Name    string `json:"name"`    // The new name of config
}

ModifyConfigParams is used for update and clone params

type NoteResponse

type NoteResponse struct {
	Secret string `json:"secret"`
	Note   string `json:"note"`
}

type PlainTextArgs

type PlainTextArgs struct {
	Secret      string `json:"secret"`
	ExpireViews int32  `json:"expire_views"`
	ExpireDays  int32  `json:"expire_days"`
}

type PlainTextResp

type PlainTextResp struct {
	Url              string `json:"url"`
	AuthenticatedUrl string `json:"authenticated_url"`
	Password         string `json:"password"`
	Success          bool   `json:"success"`
}

type Project

type Project struct {
	ID          string      `json:"id"`
	Slug        string      `json:"slug"`
	Name        string      `json:"name"`
	Description interface{} `json:"description"`
	CreatedAt   string      `json:"created_at"`
}

type ProjectMemberResp

type ProjectMemberResp struct {
	Member  Member `json:"member"`
	Success bool   `json:"success"`
}

type ProjectMembersResp

type ProjectMembersResp struct {
	Members []Member `json:"members"`
	Success bool     `json:"success"`
}

type ProjectPermissions

type ProjectPermissions struct {
	Permissions []string `json:"permissions,omitempty"`
	Success     bool     `json:"success,omitempty"`
}

type ProjectRole

type ProjectRole struct {
	Name         string   `json:"name,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
	Identifier   string   `json:"identifier,omitempty"`
	CreatedAt    string   `json:"created_at,omitempty"`
	IsCustomRole bool     `json:"is_custom_role,omitempty"`
}

type ProjectRoles

type ProjectRoles struct {
	ProjectRoles []ProjectRole `json:"roles,omitempty"`
	Success      bool          `json:"success,omitempty"`
}

type Projects

type Projects struct {
	Projects []Project `json:"projects"`
	Page     int       `json:"page"`
	Success  bool      `json:"success"`
}

type RetrieveProjectResponse

type RetrieveProjectResponse struct {
	Role    ProjectRole `json:"role"`
	Success bool        `json:"success"`
}

type RetrieveWorkplaceResponse

type RetrieveWorkplaceResponse struct {
	Role    ProjectRole `json:"role"`
	Success bool        `json:"success"`
}

type RevokeLeaseArgs

type RevokeLeaseArgs struct {
	Project       string `json:"project"`
	Config        string `json:"config"`
	DynamicSecret string `json:"dynamic_secret"`
	Slug          string `json:"slug"`
}

type RevokeLeaseData

type RevokeLeaseData struct {
	Success bool `json:"success"`
}

type RevokeTokenParam

type RevokeTokenParam struct {
	Token string `json:"token,omitempty"`
}

type Role

type Role struct {
	Identifier string `json:"identifier"`
}

type RollbackConfigLogParams

type RollbackConfigLogParams struct {
	Project string `json:"project"` // Unique identifier for the project (project name)
	Config  string `json:"config"`  // Name of the config object
	Log     string `json:"log"`     // Unique identifier for the log object
}

type Secret

type Secret struct {
	Name    string      `json:"name"`
	Value   SecretValue `json:"value"`
	Success bool        `json:"success"`
}

type SecretNames

type SecretNames struct {
	Names   []string `json:"names"`
	Success bool     `json:"success"`
}

type SecretValue

type SecretValue struct {
	Raw                string `json:"raw"`
	Computed           string `json:"computed"`
	Note               string `json:"note"`
	RawVisibility      string `json:"rawVisibility,omitempty"`
	ComputedVisibility string `json:"computedVisibility,omitempty"`
}

type Secrets

type Secrets struct {
	Secrets map[string]Secret `json:"secrets"`
	Success bool              `json:"success"`
}

type ServiceAccount

type ServiceAccount struct {
	Name          string        `json:"name,omitempty"`
	Slug          string        `json:"slug,omitempty"`
	CreatedAt     string        `json:"created_at,omitempty"`
	WorkplaceRole WorkplaceRole `json:"workplace_role,omitempty"`
}

type ServiceAccountBodyParams

type ServiceAccountBodyParams struct {
	Name          string              `json:"name,omitempty"`
	WorkplaceRole WorkplaceRoleObject `json:"workplace_role,omitempty"` // You may provide an identifier OR permissions, but not both
}

type ServiceAccountModel

type ServiceAccountModel struct {
	ServiceAccount ServiceAccount `json:"service_account,omitempty"`
	Success        bool           `json:"success,omitempty"`
}

type ServiceAccounts

type ServiceAccounts struct {
	ServiceAccounts []ServiceAccount `json:"service_accounts,omitempty"`
	Success         bool             `json:"success,omitempty"`
}

type ServiceToken

type ServiceToken struct {
	Name         string `json:"name,omitempty"`
	Slug         string `json:"slug,omitempty"`
	Access       string `json:"access,omitempty"`
	CreatedAt    string `json:"created_at,omitempty"`
	Key          string `json:"key,omitempty"`
	Project      string `json:"project,omitempty"`
	Environment  string `json:"environment,omitempty"`
	Config       string `json:"config,omitempty"`
	ExpiresAt    string `json:"expires_at,omitempty"`
	LastSeenAt   string `json:"last_seen_at,omitempty"`
	TokenPreview string `json:"token_preview,omitempty"`
}

type ServiceTokenModel

type ServiceTokenModel struct {
	Token   ServiceToken `json:"token,omitempty"`
	Success bool         `json:"success,omitempty"`
}

type ServiceTokens

type ServiceTokens struct {
	Tokens  []ServiceToken `json:"tokens,omitempty"`
	Success bool           `json:"success,omitempty"`
}

type SetNoteParams

type SetNoteParams struct {
	Project string `json:"project"` // Unique identifier for the project object(project name)
	Config  string `json:"config"`  // Name of the config object
	Secret  string `json:"secret"`
	Note    string `json:"note"`
}

type Success

type Success struct {
	Success bool `json:"success"`
}

type Sync

type Sync struct {
	Slug         string `json:"slug,omitempty"`
	Integration  string `json:"integration,omitempty"`
	Project      string `json:"project,omitempty"`
	Config       string `json:"config,omitempty"`
	Enabled      bool   `json:"enabled,omitempty"`
	LastSyncedAt string `json:"last_synced_at,omitempty"`
}

type SyncBodyParams

type SyncBodyParams struct {
	Integration  string // The integration slug which the sync will use
	ImportOption string // prefer_doppler or prefer_integration, defaults to none
}

type SyncData

type SyncData struct {
	Sync    Sync `json:"sync,omitempty"`
	Success bool `json:"success,omitempty"`
}

type SyncQueryParams

type SyncQueryParams struct {
	Project          string // The project slug
	Config           string // The config slug
	Sync             string // The sync slug: use with RetrieveSync and DeleteSync
	DeleteFromTarget bool   // use with DeleteSync function only
}

type UpdateIntegrationParams

type UpdateIntegrationParams struct {
	Name        string `json:"name,omitempty"`        // The new name of the integration
	Data        string `json:"data,omitempty"`        // The new authentication data for the integration
	Integration string `json:"integration,omitempty"` // The slug of the integration to update
}

type UpdateProjectMemberParams

type UpdateProjectMemberParams struct {
	Role         string   `json:"role"`
	Environments []string `json:"environments"`
}

type UpdateProjectParams

type UpdateProjectParams struct {
	ProjectID   string `json:"project"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

type UpdateSecretParams

type UpdateSecretParams struct {
	Project string            `json:"project"`
	Config  string            `json:"config"`
	Secrets map[string]string `json:"secrets"` // map of secret to new value
}

type User

type User struct {
	Email           string `json:"email"`
	Name            string `json:"name"`
	Username        string `json:"username"`
	ProfileImageURL string `json:"profile_image_url"`
}

type WUser

type WUser struct {
	Email                string `json:"email"`
	Name                 string `json:"name"`
	Username             string `json:"username"`
	ProfileImageURL      string `json:"profile_image_url"`
	MfaEnabled           bool   `json:"mfa_enabled"`
	ThirdpartySsoEnabled bool   `json:"thirdparty_sso_enabled"`
	SamlSsoEnabled       bool   `json:"saml_sso_enabled"`
}

type Workplace

type Workplace struct {
	Workplace WorkplaceClass `json:"workplace"`
	Success   bool           `json:"success"`
}

type WorkplaceClass

type WorkplaceClass struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	BillingEmail string `json:"billing_email"`
}

type WorkplaceParams

type WorkplaceParams struct {
	Name         string `json:"name,omitempty"`
	BillingEmail string `json:"billing_email,omitempty"`
}

type WorkplacePermissions

type WorkplacePermissions struct {
	Permissions []string `json:"permissions,omitempty"`
	Success     bool     `json:"success,omitempty"`
}

type WorkplaceRole

type WorkplaceRole struct {
	Name         string   `json:"name,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
	Identifier   string   `json:"identifier,omitempty"`
	CreatedAt    string   `json:"created_at,omitempty"`
	IsCustomRole bool     `json:"is_custom_role,omitempty"`
	IsInlineRole bool     `json:"is_inline_role,omitempty"`
}

type WorkplaceRoleObject

type WorkplaceRoleObject struct {
	Identifier  string   `json:"identifier,omitempty"`  // Identifier of an existing workplace role
	Permissions []string `json:"permissions,omitempty"` // Workplace permissions to grant
}

type WorkplaceRoles

type WorkplaceRoles struct {
	WorkplaceRoles []WorkplaceRole `json:"roles,omitempty"`
	Success        bool            `json:"success,omitempty"`
}

type WorkplaceUser

type WorkplaceUser struct {
	ID        string `json:"id"`
	Access    string `json:"access"`
	CreatedAt string `json:"created_at"`
	User      WUser  `json:"user"`
}

type WorkplaceUserResp

type WorkplaceUserResp struct {
	WorkplaceUser WorkplaceUser `json:"workplace_user"`
	Success       bool          `json:"success"`
}

type WorkplaceUsers

type WorkplaceUsers struct {
	WorkplaceUsers []WorkplaceUser `json:"workplace_users"`
	Page           int64           `json:"page"`
	Success        bool            `json:"success"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL