common

package
v0.0.0-...-22a6a96 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: BSD-3-Clause Imports: 11 Imported by: 121

Documentation

Overview

Package common will be a deprecated package, referring to old nafigos content

Index

Constants

View Source
const EventTypePrefix = "org.cyverse.events."

EventTypePrefix is the prefix for EventType

View Source
const EventsSubject = "cyverse.events"

EventsSubject is the event channel that all cyverse events are posted

View Source
const NatsQueryOpPrefix = "cyverse."

NatsQueryOpPrefix is the prefix for NatsQueryOp

Variables

This section is empty.

Functions

func CancelWhenSignaled

func CancelWhenSignaled(cancelFunc context.CancelFunc)

CancelWhenSignaled calls the cancel function when receiving SIGINT or SIGTERM.

This is useful for implementing graceful termination in service, create a context for the entire service, and then pass the cancel function to this function. The service will need to stop its different components upon context cancellation.

Types

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 is a seed for cluster resource naming.
	// Use the Slug value for naming if the name is not occupied.
	// Otherwise, use it as a prefix.
	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 EventID

type EventID string

EventID is the unique ID of event

type EventType

type EventType string

EventType is a type to represent event operations

type EventTypeSet

type EventTypeSet = map[EventType]struct{}

EventTypeSet is a set of EventType

func NewEventTypeSet

func NewEventTypeSet(eventTypes ...EventType) EventTypeSet

NewEventTypeSet construct a new EventTypeSet

type HTTPStatus

type HTTPStatus struct {
	Message string `json:"message,omitempty"` // Human-readable text message
	Code    int    `json:"code,omitempty"`    // HTTP status code
}

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

type HTTPUser

type HTTPUser struct {
	Username     string       `json:"username"`
	FirstName    string       `json:"first_name"`
	LastName     string       `json:"last_name"`
	PrimaryEmail string       `json:"primary_email"`
	CreatedAt    string       `json:"created_at"`
	UpdatedAt    string       `json:"updated_at"`
	UpdatedBy    string       `json:"updated_by"`
	IsAdmin      bool         `json:"is_admin"`
	DisabledAt   string       `json:"disabled_at,omitempty"`
	UserSettings UserSettings `json:"settings,omitempty"`
}

HTTPUser contains the json data structure for between the api service and the client

type ID

type ID string

ID for entities, xid with a prefix. <prefix>-<xid>

func NewID

func NewID(prefix string) ID

NewID creates a new ID with a prefix. Prefix must be lowercase letters, No special characters or numbers may be used.

func NewIDFromXID

func NewIDFromXID(prefix string, id xid.ID) ID

NewIDFromXID creates a new ID from a prefix and an existing xid.

func (ID) FullPrefix

func (id ID) FullPrefix() string

FullPrefix returns the entire prefix which is anything before the last hyphen (the hyphen before the xid string).

func (ID) Prefix deprecated

func (id ID) Prefix() string

Prefix is the same as PrimaryType.

Deprecated: Even though this method is called Prefix, it only returns the primary type, not the full prefix. This is meant to maintain the behavior for existing usages of this method. For full prefix (everything before the last hyphen), use FullPrefix() instead.

func (ID) PrimaryType

func (id ID) PrimaryType() string

PrimaryType return the first hyphen separated field in the prefix, or anything before 1st hyphen. Behavior of this method on invalid ID should not be relied on.

func (ID) String

func (id ID) String() string

String ...

func (ID) SubType

func (id ID) SubType() string

SubType return the substring between first hyphen and last hyphen (the hyphen before xid string). Behavior of this method on invalid ID should not be relied on.

func (ID) Validate

func (id ID) Validate() bool

Validate return true if id is validate.

func (ID) XID

func (id ID) XID() (xid.ID, error)

XID convert to XID

func (ID) XIDMustParse

func (id ID) XIDMustParse() xid.ID

XIDMustParse convert to XID, panic if error

type QueryOp

type QueryOp string

QueryOp is a queue for a query operation

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 ServiceRequestResult

type ServiceRequestResult struct {
	Data   interface{} `json:"data"` // return object, can be nil
	Status HTTPStatus  `json:"status,omitempty"`
}

ServiceRequestResult can be used for result of query requests and streaming requests

type TokenID

type TokenID string

TokenID is an id for Cacao Tokens, with format '<prefix>-<SHA3-hash>-<xid>'

func NewTokenID

func NewTokenID(typeString, owner string, createdAt time.Time, tokenXid xid.ID) (id TokenID, hash string, salt string, err error)

NewTokenID creates a new TokenID for the given type, owner, + created time

func (TokenID) Prefix

func (tokenID TokenID) Prefix() string

Prefix returns the token type prefix portion of a TokenID

func (TokenID) String

func (tokenID TokenID) String() string

String returns the string representation of a TokenID

func (TokenID) Validate

func (tokenID TokenID) Validate() bool

Validate returns true if the token is considered valid, false otherwise

func (TokenID) XID

func (tokenID TokenID) XID() xid.ID

XID returns the XID portion of a TokenID

type TokenIDPrefix

type TokenIDPrefix string

TokenIDPrefix is the prefix for different types of tokens

const (
	// PersonalTokenPrefix is the personal token type prefix
	PersonalTokenPrefix TokenIDPrefix = "cptoken"
	// DelegatedTokenPrefix is the delegated token type prefix
	DelegatedTokenPrefix TokenIDPrefix = "cdtoken"
	// InternalTokenPrefix is the internal token type prefix
	InternalTokenPrefix TokenIDPrefix = "citoken"
)

type TransactionID

type TransactionID string

TransactionID is used to track transaction

type User

type User struct {
	Username string             `json:"username,omitempty"`
	Password string             `json:"password,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

type UserSettings

type UserSettings struct {
	Configs   map[string]string   `json:"configs,omitempty"`
	Favorites map[string][]string `json:"favorites,omitempty"`
	Recents   map[string]string   `json:"recents,omitempty"`
}

UserSettings contain the Settings, Favorites, and Recents for a user

Jump to

Keyboard shortcuts

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