common

package
v0.0.0-...-0176d58 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: BSD-3-Clause Imports: 47 Imported by: 0

README

Common

The common package contains functions and structs that are used by multiple services

Documentation

Overview

Package common provides functions and structs used by multiple Nafigos services for interacting with Kubernetes clusters, NATS queues, and other services

Index

Constants

This section is empty.

Variables

View Source
var MonitoringSubject = "Phylax.CreateSubscriber"

MonitoringSubject is the subject phylax monitors for creating subscribers

Functions

func CreateCloudEvent

func CreateCloudEvent(request []byte, eventType string, source string, id string) ([]byte, error)

CreateCloudEvent takes a JSON byte slice and uses it as the data for a new CloudEvent object Marshaled as a JSON byte slice

func CreateResourceName

func CreateResourceName(username, name, id string) string

CreateResourceName is used to create a K8s resource name that is both unique and informative to users:

<username:limit to 8>-<name:limit to 32 chars>-<xid>

func FixName

func FixName(name string) string

FixName will make a string K8s-valid by making it lowercase and hyphenated

func GetDNS1123Name

func GetDNS1123Name(name string) (dns1123Name string, err error)

GetDNS1123Name accepts a string a returns a version of that string that is compatible with DNS 1123. It replaces all underscores with hyphens to preserve readability and then strips anything that does not conform to then regex for the standard.

func GetNATSInfo

func GetNATSInfo(defaultClusterID string, defaultClientID string, defaultConnAddress string) map[string]string

GetNATSInfo returns a map containing necessary NATS connection variables. It is used to get this information from environment variables or use the defaults

func GetRequestFromCloudEvent

func GetRequestFromCloudEvent(msg []byte) (dataBytes []byte, err error)

GetRequestFromCloudEvent will unmarshal a CloudEvent object and unmarshal the data field into JSON bytes

func PublishRequest

func PublishRequest(request Request, subject string, source string, connAddress string) (result []byte, err error)

PublishRequest can be used to create a CloudEvent and publish it on NATS. It expects a reply

func RegisterMonitoring

func RegisterMonitoring(subject string, natsInfo map[string]string)

RegisterMonitoring is used to monitor a separate streaming channel

func StanQueueSubscriber

func StanQueueSubscriber(subject string, queue string, cb stan.MsgHandler, natsInfo map[string]string, wg *sync.WaitGroup)

StanQueueSubscriber creates a NATS Streaming Subscriber that will listen on a subject as a queue subscriber and perform asynchronous actions. The cb parameter can by any function which conforms to the stan.MsgHandler type (i.e. accepts *stan.Msg as a parameter). For information on queue subscribers, see https://docs.nats.io/developing-with-nats-streaming/queues

func StanSubscriber

func StanSubscriber(subject string, cb stan.MsgHandler, natsInfo map[string]string, wg *sync.WaitGroup)

StanSubscriber creates a NATS Streaming Subscriber that will listen on a subject and perform asynchronous actions. The cb parameter can by any function which conforms to the stan.MsgHandler type (i.e. accepts *stan.Msg as a parameter)

func StreamingPublish

func StreamingPublish(request []byte, natsInfo map[string]string, subject string, source string) error

StreamingPublish can be used to create a CloudEvent and publish it on NATS Streaming

func StreamingQueueSubscriber

func StreamingQueueSubscriber(subject string, queue string, action func([]byte, map[string]string), natsInfo map[string]string, wg *sync.WaitGroup)

StreamingQueueSubscriber creates a NATS Streaming Queue Subscriber that will listen on a subject and perform asynchronous actions. The action function should accept a []byte that represents JSON data, and a map[string]string, which represents NATS connection info.

func StreamingSubscriber

func StreamingSubscriber(subject string, action func([]byte, map[string]string), natsInfo map[string]string, wg *sync.WaitGroup)

StreamingSubscriber creates a NATS Streaming Subscriber that will listen on a subject and perform asynchronous actions. The action function should accept a []byte that represents JSON data, and a map[string]string, which represents NATS connection info.

func StreamingTestSubscriber

func StreamingTestSubscriber(subject string, queue string, action func([]byte, map[string]string), natsInfo map[string]string, wg *sync.WaitGroup)

StreamingTestSubscriber is the same as StreamingSubscriber but will exit after receiving and processing one request

func SynchronousSubscriber

func SynchronousSubscriber(subject string, queue string, action func([]byte, *nats.Msg, map[string]string), natsInfo map[string]string, wg *sync.WaitGroup)

SynchronousSubscriber is used to synchronously respond to requests

func SynchronousTestSubscriber

func SynchronousTestSubscriber(subject string, queue string, action func([]byte, *nats.Msg, map[string]string), natsInfo map[string]string, wg *sync.WaitGroup)

SynchronousTestSubscriber is the same as SynchronousSubscriber but will exit after receiving and processing one request

Types

type BasicRequest

type BasicRequest struct {
	User             User   `json:"user,omitempty"`
	ClusterID        string `json:"cluster_id,omitempty"`
	RegistrySecretID string `json:"registry_secret_id,omitempty"`
	GitSecretID      string `json:"git_secret_id,omitempty"`
	WorkflowID       string `json:"workflow_id,omitempty"`
	BuildID          string `json:"build_id,omitempty"`
	RunID            string `json:"run_id,omitempty"`

	Error Error `json:"error,omitempty"`
}

BasicRequest is the simplest implementation of the Request interface and is intended to be included as an embedded/anonymous struct in extending types

func (*BasicRequest) GetBuildID

func (r *BasicRequest) GetBuildID() string

GetBuildID ...

func (*BasicRequest) GetClusterID

func (r *BasicRequest) GetClusterID() string

GetClusterID ...

func (*BasicRequest) GetError

func (r *BasicRequest) GetError() Error

GetError ...

func (*BasicRequest) GetGitSecretID

func (r *BasicRequest) GetGitSecretID() string

GetGitSecretID ...

func (*BasicRequest) GetRedacted

func (r *BasicRequest) GetRedacted() BasicRequest

GetRedacted will return a new BasicRequest with the confidential fields removed from the User's Secrets and Clusters

func (*BasicRequest) GetRegistrySecretID

func (r *BasicRequest) GetRegistrySecretID() string

GetRegistrySecretID ...

func (*BasicRequest) GetRunID

func (r *BasicRequest) GetRunID() string

GetRunID ...

func (*BasicRequest) GetUser

func (r *BasicRequest) GetUser() User

GetUser ...

func (*BasicRequest) GetWorkflowID

func (r *BasicRequest) GetWorkflowID() string

GetWorkflowID ...

func (*BasicRequest) SetBuildID

func (r *BasicRequest) SetBuildID(value string)

SetBuildID ...

func (*BasicRequest) SetClusterID

func (r *BasicRequest) SetClusterID(value string)

SetClusterID ...

func (*BasicRequest) SetGitSecretID

func (r *BasicRequest) SetGitSecretID(value string)

SetGitSecretID ...

func (*BasicRequest) SetRegistrySecretID

func (r *BasicRequest) SetRegistrySecretID(value string)

SetRegistrySecretID ...

func (*BasicRequest) SetRunID

func (r *BasicRequest) SetRunID(value string)

SetRunID ...

func (*BasicRequest) SetUser

func (r *BasicRequest) SetUser(value User)

SetUser ...

func (*BasicRequest) SetWorkflowID

func (r *BasicRequest) SetWorkflowID(value string)

SetWorkflowID ...

type BuildStatus

type BuildStatus struct {
	Complete bool   `json:"complete"`
	Success  bool   `json:"success"`
	Info     string `json:"info"`
}

BuildStatus is used to get information about a Build. Info will be a container's output log

type BuildStep

type BuildStep struct {
	Image      string        `bson:"image" json:"image,omitempty" yaml:"image,omitempty"`
	Dockerfile string        `bson:"dockerfile" json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
	Args       []core.EnvVar `bson:"args" json:"args,omitempty" yaml:"args,omitempty"`
}

BuildStep ...

type CRUD

type CRUD interface {
	GetMock() *mock.Mock
	Create(string, NafigosBase) error
	Read(string, string) ([]byte, error)
	Update(string, NafigosBase) error
	Replace(string, NafigosBase) error
	Delete(string, string) error
	ReadFor(string, string, string) ([]map[string]interface{}, error)
	ReadForUser(string, string) ([]map[string]interface{}, error)
}

CRUD is an interface that allows for mocking of the MongoDB

type Cluster

type Cluster struct {
	ID               string `json:"id,omitempty"`
	Name             string `json:"name,omitempty"`
	DefaultNamespace string `json:"default_namespace,omitempty"`
	Config           string `json:"config,omitempty"`
	Host             string `json:"host,omitempty"`
	Slug             string `json:"slug,omitempty"`
	Admin            bool   `json:"admin,omitempty"`
}

Cluster ...

func (*Cluster) GetRedacted

func (c *Cluster) GetRedacted() Cluster

GetRedacted will return a new Cluster with the Value set to "REDACTED"

type DatabaseAdapter

type DatabaseAdapter struct {
	*mongo.Database
}

DatabaseAdapter implements the CRUD interface to allow for mocking

func GetMongoDBAdapter

func GetMongoDBAdapter(name, address string) (adapter DatabaseAdapter, err error)

GetMongoDBAdapter returns a new connection to MongoDB and wraps it in a CRUD interface

func (DatabaseAdapter) Create

func (d DatabaseAdapter) Create(collectionName string, document NafigosBase) (err error)

Create will insert into the database

func (DatabaseAdapter) Delete

func (d DatabaseAdapter) Delete(collectionName, id string) (err error)

Delete will delete from the database

func (DatabaseAdapter) GetMock

func (d DatabaseAdapter) GetMock() (m *mock.Mock)

GetMock ...

func (DatabaseAdapter) Read

func (d DatabaseAdapter) Read(collectionName string, id string) (data []byte, err error)

Read will read from the database

func (DatabaseAdapter) ReadFor

func (d DatabaseAdapter) ReadFor(collectionName, key, value string) (results []map[string]interface{}, err error)

ReadFor will return all objects with a key

func (DatabaseAdapter) ReadForUser

func (d DatabaseAdapter) ReadForUser(collectionName, owner string) (results []map[string]interface{}, err error)

ReadForUser will return all objects owned by a user

func (DatabaseAdapter) Replace

func (d DatabaseAdapter) Replace(collectionName string, document NafigosBase) (err error)

Replace will save/replace an existing object in the database

func (DatabaseAdapter) Update

func (d DatabaseAdapter) Update(collectionName string, document NafigosBase) (err error)

Update wil update/edit in the database

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Code    int    `json:"code,omitempty"`
}

Error is used for responding to synchronous requests with an error that is JSON friendly

type K8sClientsets

type K8sClientsets struct {
	// contains filtered or unexported fields
}

K8sClientsets contains all the necessary clientsets for creating resources in K8s

func NewServiceClusterK8sClientsets

func NewServiceClusterK8sClientsets() (*K8sClientsets, error)

NewServiceClusterK8sClientsets creates clientsets necessary for creating Kubernetes objects on the cluster this program is currently running on

func NewTestK8sClientsets

func NewTestK8sClientsets() (*K8sClientsets, error)

NewTestK8sClientsets is used to create mock clientsets for testing

func NewUserClusterK8sClientsets

func NewUserClusterK8sClientsets(configString string) (*K8sClientsets, error)

NewUserClusterK8sClientsets creates clientsets necessary for creating Kubernetes objects on a user's cluster using the provided config

func (*K8sClientsets) ApproveCertificateSigningRequest

func (o *K8sClientsets) ApproveCertificateSigningRequest(approval *certificates.CertificateSigningRequest) (*certificates.CertificateSigningRequest, error)

ApproveCertificateSigningRequest ...

func (*K8sClientsets) CanI

func (o *K8sClientsets) CanI(verb, resource string) (bool, error)

CanI checks if an verb can be performed on a resource

func (*K8sClientsets) CreateArgoWorkflow

func (o *K8sClientsets) CreateArgoWorkflow(workflow *argotypes.Workflow, namespace string) (*argotypes.Workflow, error)

CreateArgoWorkflow ...

func (*K8sClientsets) CreateAuthorizationPolicy

func (o *K8sClientsets) CreateAuthorizationPolicy(policy *istiosec.AuthorizationPolicy, namespace string) (*istiosec.AuthorizationPolicy, error)

CreateAuthorizationPolicy ...

func (*K8sClientsets) CreateCertificateSigningRequest

CreateCertificateSigningRequest ...

func (*K8sClientsets) CreateClusterRole

func (o *K8sClientsets) CreateClusterRole(cr *rbac.ClusterRole) (*rbac.ClusterRole, error)

CreateClusterRole ...

func (*K8sClientsets) CreateDeployment

func (o *K8sClientsets) CreateDeployment(deployment *appsv1.Deployment, namespace string) (*appsv1.Deployment, error)

CreateDeployment ...

func (*K8sClientsets) CreateDestinationRule

func (o *K8sClientsets) CreateDestinationRule(dr *istio.DestinationRule, namespace string) (*istio.DestinationRule, error)

CreateDestinationRule ...

func (*K8sClientsets) CreateFunction

func (o *K8sClientsets) CreateFunction(fn *openfaas.Function, namespace string) (*openfaas.Function, error)

CreateFunction ...

func (*K8sClientsets) CreateGateway

func (o *K8sClientsets) CreateGateway(gateway *istio.Gateway, namespace string) (*istio.Gateway, error)

CreateGateway ...

func (*K8sClientsets) CreateInformer

func (o *K8sClientsets) CreateInformer(namespace string, handlers cache.ResourceEventHandlerFuncs) cache.SharedIndexInformer

CreateInformer creates a SharedIndexInformer on the specified namespace and with the attached handlers.

func (*K8sClientsets) CreateJob

func (o *K8sClientsets) CreateJob(job *batch.Job, namespace string) (*batch.Job, error)

CreateJob ...

func (*K8sClientsets) CreateNamespace

func (o *K8sClientsets) CreateNamespace(ns *v1.Namespace) (*v1.Namespace, error)

CreateNamespace ...

func (*K8sClientsets) CreatePods

func (o *K8sClientsets) CreatePods(pod *v1.Pod, namespace string) (*v1.Pod, error)

CreatePods ...

func (*K8sClientsets) CreateRequestAuthentication

func (o *K8sClientsets) CreateRequestAuthentication(requestAuthentication *istiosec.RequestAuthentication, namespace string) (*istiosec.RequestAuthentication, error)

CreateRequestAuthentication ...

func (*K8sClientsets) CreateRole

func (o *K8sClientsets) CreateRole(role *rbac.Role, namespace string) (*rbac.Role, error)

CreateRole ...

func (*K8sClientsets) CreateRoleBinding

func (o *K8sClientsets) CreateRoleBinding(rolebinding *rbac.RoleBinding, namespace string) (*rbac.RoleBinding, error)

CreateRoleBinding ...

func (*K8sClientsets) CreateScaledObject

func (o *K8sClientsets) CreateScaledObject(scaledObject *unstructured.Unstructured, namespace string) (*unstructured.Unstructured, error)

CreateScaledObject ...

func (*K8sClientsets) CreateSecret

func (o *K8sClientsets) CreateSecret(secret *v1.Secret, namespace string) (*v1.Secret, error)

CreateSecret ...

func (*K8sClientsets) CreateService

func (o *K8sClientsets) CreateService(service *v1.Service, namespace string) (*v1.Service, error)

CreateService ...

func (*K8sClientsets) CreateServiceEntry

func (o *K8sClientsets) CreateServiceEntry(se *istio.ServiceEntry, namespace string) (*istio.ServiceEntry, error)

CreateServiceEntry ...

func (*K8sClientsets) CreateVirtualService

func (o *K8sClientsets) CreateVirtualService(vs *istio.VirtualService, namespace string) (*istio.VirtualService, error)

CreateVirtualService ...

func (*K8sClientsets) DeleteArgoWorkflow

func (o *K8sClientsets) DeleteArgoWorkflow(name, namespace string) error

DeleteArgoWorkflow ...

func (*K8sClientsets) DeleteAuthorizationPolicy

func (o *K8sClientsets) DeleteAuthorizationPolicy(name, namespace string) error

DeleteAuthorizationPolicy ...

func (*K8sClientsets) DeleteCertificateSigningRequest

func (o *K8sClientsets) DeleteCertificateSigningRequest(name string) error

DeleteCertificateSigningRequest ...

func (*K8sClientsets) DeleteDeployment

func (o *K8sClientsets) DeleteDeployment(name, namespace string) error

DeleteDeployment ...

func (*K8sClientsets) DeleteDestinationRule

func (o *K8sClientsets) DeleteDestinationRule(name, namespace string) error

DeleteDestinationRule ...

func (*K8sClientsets) DeleteFunction

func (o *K8sClientsets) DeleteFunction(name, namespace string) error

DeleteFunction ...

func (*K8sClientsets) DeleteGateway

func (o *K8sClientsets) DeleteGateway(name, namespace string) error

DeleteGateway ...

func (*K8sClientsets) DeleteJob

func (o *K8sClientsets) DeleteJob(name, namespace string) error

DeleteJob ...

func (*K8sClientsets) DeletePods

func (o *K8sClientsets) DeletePods(name, namespace string) error

DeletePods ...

func (*K8sClientsets) DeleteRequestAuthentication

func (o *K8sClientsets) DeleteRequestAuthentication(name, namespace string) error

DeleteRequestAuthentication ...

func (*K8sClientsets) DeleteScaledObject

func (o *K8sClientsets) DeleteScaledObject(name, namespace string) error

DeleteScaledObject ...

func (*K8sClientsets) DeleteSecret

func (o *K8sClientsets) DeleteSecret(name, namespace string) error

DeleteSecret ...

func (*K8sClientsets) DeleteService

func (o *K8sClientsets) DeleteService(name, namespace string) error

DeleteService ...

func (*K8sClientsets) DeleteServiceEntry

func (o *K8sClientsets) DeleteServiceEntry(name, namespace string) error

DeleteServiceEntry ...

func (*K8sClientsets) DeleteVirtualService

func (o *K8sClientsets) DeleteVirtualService(name, namespace string) error

DeleteVirtualService ...

func (*K8sClientsets) GetArgoWorkflow

func (o *K8sClientsets) GetArgoWorkflow(name, namespace string) (*argotypes.Workflow, error)

GetArgoWorkflow ...

func (*K8sClientsets) GetCertificateSigningRequest

func (o *K8sClientsets) GetCertificateSigningRequest(name string) (*certificates.CertificateSigningRequest, error)

GetCertificateSigningRequest ...

func (*K8sClientsets) GetDeployment

func (o *K8sClientsets) GetDeployment(name, namespace string) (*appsv1.Deployment, error)

GetDeployment ...

func (*K8sClientsets) GetJob

func (o *K8sClientsets) GetJob(name, namespace string) (*batch.Job, error)

GetJob ...

func (*K8sClientsets) GetLogs

func (o *K8sClientsets) GetLogs(name, namespace string) ([]byte, error)

GetLogs ...

func (*K8sClientsets) GetPods

func (o *K8sClientsets) GetPods(name, namespace string) (*v1.Pod, error)

GetPods ...

func (*K8sClientsets) GetService

func (o *K8sClientsets) GetService(name, namespace string) (*v1.Service, error)

GetService ...

func (*K8sClientsets) ListArgoWorkflows

func (o *K8sClientsets) ListArgoWorkflows(options metav1.ListOptions, namespace string) (*argotypes.WorkflowList, error)

ListArgoWorkflows ...

func (*K8sClientsets) ListDeployments

func (o *K8sClientsets) ListDeployments(options metav1.ListOptions, namespace string) (*appsv1.DeploymentList, error)

ListDeployments ...

func (*K8sClientsets) ListJobs

func (o *K8sClientsets) ListJobs(options metav1.ListOptions, namespace string) (*batch.JobList, error)

ListJobs ...

func (*K8sClientsets) ListPods

func (o *K8sClientsets) ListPods(options metav1.ListOptions, namespace string) (*v1.PodList, error)

ListPods ...

func (*K8sClientsets) ScaleDeployment

func (o *K8sClientsets) ScaleDeployment(name, namespace string, replicas int32) error

ScaleDeployment ...

func (*K8sClientsets) UpdateArgoWorkflow

func (o *K8sClientsets) UpdateArgoWorkflow(workflow *argotypes.Workflow, namespace string) (*argotypes.Workflow, error)

UpdateArgoWorkflow ...

func (*K8sClientsets) UpdateDeployment

func (o *K8sClientsets) UpdateDeployment(deployment *appsv1.Deployment, namespace string) (*appsv1.Deployment, error)

UpdateDeployment ...

func (*K8sClientsets) UpdateDestinationRule

func (o *K8sClientsets) UpdateDestinationRule(dr *istio.DestinationRule, namespace string) (*istio.DestinationRule, error)

UpdateDestinationRule ...

func (*K8sClientsets) UpdateGateway

func (o *K8sClientsets) UpdateGateway(gateway *istio.Gateway, namespace string) (*istio.Gateway, error)

UpdateGateway ...

func (*K8sClientsets) UpdateJob

func (o *K8sClientsets) UpdateJob(job *batch.Job, namespace string) (*batch.Job, error)

UpdateJob ...

func (*K8sClientsets) UpdateScaledObject

func (o *K8sClientsets) UpdateScaledObject(scaledObject *unstructured.Unstructured, namespace string) (*unstructured.Unstructured, error)

UpdateScaledObject ...

func (*K8sClientsets) UpdateSecret

func (o *K8sClientsets) UpdateSecret(secret *v1.Secret, namespace string) (*v1.Secret, error)

UpdateSecret ...

func (*K8sClientsets) UpdateService

func (o *K8sClientsets) UpdateService(service *v1.Service, namespace string) (*v1.Service, error)

UpdateService ...

func (*K8sClientsets) UpdateServiceEntry

func (o *K8sClientsets) UpdateServiceEntry(se *istio.ServiceEntry, namespace string) (*istio.ServiceEntry, error)

UpdateServiceEntry ...

func (*K8sClientsets) UpdateVirtualService

func (o *K8sClientsets) UpdateVirtualService(vs *istio.VirtualService, namespace string) (*istio.VirtualService, error)

UpdateVirtualService ...

type MockedAdapter

type MockedAdapter struct {
	Mock *mock.Mock
}

MockedAdapter for testing

func (MockedAdapter) Create

func (d MockedAdapter) Create(collectionName string, document NafigosBase) error

Create ...

func (MockedAdapter) Delete

func (d MockedAdapter) Delete(collectionName, id string) error

Delete ...

func (MockedAdapter) GetMock

func (d MockedAdapter) GetMock() *mock.Mock

GetMock ...

func (MockedAdapter) Read

func (d MockedAdapter) Read(collectionName, id string) ([]byte, error)

Read ...

func (MockedAdapter) ReadFor

func (d MockedAdapter) ReadFor(collectionName, key, value string) ([]map[string]interface{}, error)

ReadFor ...

func (MockedAdapter) ReadForUser

func (d MockedAdapter) ReadForUser(collectionName, owner string) ([]map[string]interface{}, error)

ReadForUser ...

func (MockedAdapter) Replace

func (d MockedAdapter) Replace(collectionName string, document NafigosBase) error

Replace ...

func (MockedAdapter) Update

func (d MockedAdapter) Update(collectionName string, document NafigosBase) error

Update ...

type NafigosBase

type NafigosBase interface {
	GetID() string
	GetCollection() string
	GetOwner() string
}

NafigosBase is a base interface type for Nafigos entities that need to be stored

type Repository

type Repository struct {
	RawURL string `bson:"rawurl" json:"rawurl,omitempty"`
	URL    string `bson:"url" json:"url,omitempty"`
	Branch string `bson:"branch" json:"branch,omitempty"`
}

Repository contains basic information required to interact with git The URL is the RawURL without the leading `https://` in order to use as an ID and the RawURL is saved for cloning

type Request

type Request interface {
	GetClusterID() string
	GetRegistrySecretID() string
	GetGitSecretID() string
	GetWorkflowID() string
	GetBuildID() string
	GetRunID() string
	GetUser() User
	GetError() Error

	SetClusterID(value string)
	SetRegistrySecretID(value string)
	SetGitSecretID(value string)
	SetWorkflowID(value string)
	SetBuildID(value string)
	SetRunID(value string)
	SetUser(value User)
}

Request is an interface that allows for reading common HTTP request fields and can be extended by service-specific types for reading additional fields

type Secret

type Secret struct {
	Username string     `json:"username,omitempty"`
	Value    string     `json:"value,omitempty"`
	Type     SecretType `json:"type,omitempty"`
	ID       string     `json:"id,omitempty"`
}

Secret ...

func (*Secret) GetRedacted

func (s *Secret) GetRedacted() Secret

GetRedacted will return a new Secret with the Value set to "REDACTED"

type SecretType

type SecretType string

SecretType associates a type with a Secret

const (
	// GCRSecret is used for Google Container Registry
	GCRSecret SecretType = "gcr"
	// DockerhubSecret is used for Dockerhub
	DockerhubSecret SecretType = "dockerhub"
	// GitSecret is used for Github, GitLab, etc.
	GitSecret SecretType = "git"
)

type User

type User struct {
	Username string             `json:"username,omitempty"`
	Password string             `json:"password,omitempty,omitempty"`
	Secrets  map[string]Secret  `json:"secrets,omitempty"`
	Clusters map[string]Cluster `json:"clusters,omitempty"`
	IsAdmin  bool               `json:"is_admin"`
}

User defines user attributes, primarily Secrets that are written to Vault. Note that the Password field is only used for creating the User

func (*User) GetRedacted

func (u *User) GetRedacted() User

GetRedacted will return a new User with sensitive fields redacted

Jump to

Keyboard shortcuts

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