model

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CertificateStateActive  CertificateState = "ACTIVE"
	CertificateStateExpired CertificateState = "EXPIRED"

	CertificateSubjectKey string = "certificateSubject"
)
View Source
const (
	MaxIAMIdentifierLength = 128
	MaxNameLength          = 64

	// ValidTextPattern is a pattern matching
	// alphanumeric, "_" and "-"
	ValidTextPattern = `^[a-zA-Z0-9 _-]+$`
)
View Source
const (
	WorkflowStateInitial          WorkflowState = "INITIAL"
	WorkflowStateRevoked          WorkflowState = "REVOKED"
	WorkflowStateRejected         WorkflowState = "REJECTED"
	WorkflowStateExpired          WorkflowState = "EXPIRED"
	WorkflowStateWaitApproval     WorkflowState = "WAIT_APPROVAL"
	WorkflowStateWaitConfirmation WorkflowState = "WAIT_CONFIRMATION"
	WorkflowStateExecuting        WorkflowState = "EXECUTING"
	WorkflowStateSuccessful       WorkflowState = "SUCCESSFUL"
	WorkflowStateFailed           WorkflowState = "FAILED"

	WorkflowArtifactTypeKey              WorkflowArtifactType = "KEY"
	WorkflowArtifactTypeKeyConfiguration WorkflowArtifactType = "KEY_CONFIGURATION"
	WorkflowArtifactTypeSystem           WorkflowArtifactType = "SYSTEM"

	WorkflowActionTypeUpdateState   WorkflowActionType = "UPDATE_STATE"
	WorkflowActionTypeUpdatePrimary WorkflowActionType = "UPDATE_PRIMARY"
	WorkflowActionTypeLink          WorkflowActionType = "LINK"
	WorkflowActionTypeUnlink        WorkflowActionType = "UNLINK"
	WorkflowActionTypeSwitch        WorkflowActionType = "SWITCH"
	WorkflowActionTypeDelete        WorkflowActionType = "DELETE"

	WorkflowParametersResourceTypeKey              WorkflowParametersResourceType = "KEY"
	WorkflowParametersResourceTypeKeyConfiguration WorkflowParametersResourceType = "KEY_CONFIGURATION"
)
View Source
const ResourceID = "resource_id"
View Source
const VirtualSystemGroup = "root"
View Source
const WorkflowID = "workflow_id"

Variables

View Source
var (
	ErrMissingTag       = errors.New("exported struct field missing flatten tag")
	ErrUnsupportedField = errors.New("field type slice/array is not supported")
	ErrUnflattenDecoder = errors.New("failed to create unflatten decoder")
	ErrDecodeFlatten    = errors.New("failed to decode flatten")
)

ErrMissingTag is returned when an exported struct field has no `flatten` tag.

View Source
var (
	ErrInvalidIAMIdentifier = fmt.Errorf("%w: invalid group IAMIdentifier", ErrValidation)
	ErrInvalidName          = fmt.Errorf("%w: invalid group name", ErrValidation)
)
View Source
var (
	ErrInvalidWorkflowState                  = fmt.Errorf("%w: invalid workflow state", ErrValidation)
	ErrInvalidWorkflowArtifactType           = fmt.Errorf("%w: invalid workflow artifact type", ErrValidation)
	ErrInvalidWorkflowActionType             = fmt.Errorf("%w: invalid workflow action type", ErrValidation)
	ErrInvalidWorkflowParametersResourceType = fmt.Errorf("%w: invalid workflow parameters resource type", ErrValidation)
)
View Source
var ErrInvalidCertificatePurpose = fmt.Errorf("%w: invalid certificate purpose", ErrValidation)
View Source
var ErrInvalidCertificateState = fmt.Errorf("%w: invalid certificate state", ErrValidation)
View Source
var ErrInvalidSystemType = fmt.Errorf("%w: invalid system type", ErrValidation)
View Source
var (
	ErrInvalidTenantRole = fmt.Errorf("%w: tenant role is not valid", ErrValidation)
)
View Source
var (
	ErrInvalidTenantStatus = fmt.Errorf("%w: tenant status is not valid", ErrValidation)
)
View Source
var ErrValidation = errors.New("validation failed")

ErrValidation is the shared parent of all model-level validation errors. Every "invalid X" validation sentinel in this package wraps it, so callers can classify any validation failure with errors.Is(err, ErrValidation) without enumerating each specific error. Such failures are permanent: the input will never become valid on retry.

SingletonCertificatePurposes defines the certificate purposes for which only one active certificate can exist at a time.

Functions

func Flatten added in v0.12.2

func Flatten[T Flattenable](item T) (map[string]any, error)

Flatten takes an item and returns all of its fields as a map[string]any It puts all first level items under <root>/<field> Root is set on the Flatabble interface implementation and field from the flatten tag on the struct fields All the fields and nested fields must contain a flatten tag, otherwise this method will throw an error This method does also not support slices, throwing UnsupportedField

Only fields that are exported and do not have tag set as "-" are flatten

func LogInjectGroups

func LogInjectGroups(ctx context.Context, groups []*Group) context.Context

func LogInjectKey

func LogInjectKey(ctx context.Context, key *Key) context.Context

func LogInjectSystem

func LogInjectSystem(ctx context.Context, sys *System) context.Context

func LogInjectTenant

func LogInjectTenant(ctx context.Context, tenant *Tenant) context.Context

func NewIAMIdentifier

func NewIAMIdentifier(name string, tenantID string) string

func Unflatten added in v0.12.2

func Unflatten[T Flattenable](flatValues map[string]any) (T, error)

Unflatten takes a map[string]any, containing each flattenKey <root>/<field>... and transforms it into T. The flattenKeys must map exactly into the struct that it's trying to be built. So this should only be used for structures that were flattened using the Flatten() method.

func ValidateAll

func ValidateAll(v ...Validator) error

ValidateAll goes through the given validators and calls their Validate method. It stops and returns at the first error encountered, if any. If all validate successfully, it returns nil.

func WithLogInjectGroups added in v0.4.0

func WithLogInjectGroups(groups []*Group) cmkcontext.Opt

func WithLogInjectKey added in v0.4.0

func WithLogInjectKey(key *Key) cmkcontext.Opt

func WithLogInjectSystem added in v0.4.0

func WithLogInjectSystem(sys *System) cmkcontext.Opt

func WithLogInjectTenant added in v0.4.0

func WithLogInjectTenant(tenant *Tenant) cmkcontext.Opt

Types

type AssigneeRole added in v0.10.0

type AssigneeRole string
const (
	AssigneeRoleApprover  AssigneeRole = "APPROVER"
	AssigneeRoleInitiator AssigneeRole = "INITIATOR"
)

type AutoTimeModel

type AutoTimeModel struct {
	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time `gorm:"not null"`
}

func (*AutoTimeModel) BeforeCreate

func (b *AutoTimeModel) BeforeCreate(_ *gorm.DB) error

BeforeCreate ensures timestamps are set before creating a record

func (*AutoTimeModel) BeforeUpdate

func (b *AutoTimeModel) BeforeUpdate(_ *gorm.DB) error

BeforeUpdate ensures UpdatedAt is set before updating a record

type BaseLabel

type BaseLabel struct {
	ID         uuid.UUID `gorm:"type:uuid;primaryKey"`
	Key        string    `gorm:"type:varchar(255);not null"`
	Value      string    `gorm:"type:varchar(255)"`
	ResourceID uuid.UUID `gorm:"type:uuid;not null"`
}

type Certificate

type Certificate struct {
	ID             uuid.UUID          `gorm:"type:uuid;primaryKey"`
	Fingerprint    string             `gorm:"type:text;not null"`
	CommonName     string             `gorm:"type:varchar(64);not null"`
	State          CertificateState   `gorm:"type:varchar(255)"`
	Purpose        CertificatePurpose `gorm:"type:varchar(255)"`
	CreationDate   time.Time          `gorm:"not null"`
	ExpirationDate time.Time          `gorm:"not null"`
	CertPEM        string             `gorm:"type:text"` // Base64 encoded PEM certificate
	PrivateKeyPEM  string             `gorm:"type:text"` // Base64 encoded PEM private key
	AutoRotate     bool               `gorm:"not null;default:true"`
	SupersedesID   *uuid.UUID         `gorm:"foreignKey:CertificateID"`
}

func (Certificate) CheckAuthz added in v0.5.0

func (m Certificate) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Certificate) IsSharedModel

func (Certificate) IsSharedModel() bool

func (Certificate) TableName

func (m Certificate) TableName() string

TableName returns the table name for Certificate

func (Certificate) TableResourceType added in v0.5.0

func (Certificate) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type CertificatePurpose

type CertificatePurpose string
const (
	CertificatePurposeGeneric        CertificatePurpose = "GENERIC"
	CertificatePurposeHYOKManagement CertificatePurpose = "TENANT_DEFAULT"
	CertificatePurposeRoleManagement CertificatePurpose = "ROLE_MANAGEMENT"
	CertificatePurposeKeyManagement  CertificatePurpose = "KEY_MANAGEMENT"
	CertificatePurposeCrypto         CertificatePurpose = "CRYPTO"
)

- Generic purpose is used as a fallback default purpose when no specific purpose is provided. - HYOKManagement purpose is used for managing tenant default HYOK certificates. The name is kept for backward compatibility. - RoleManagement purpose is used for managing other keystore roles. - KeyManagement purpose is used for managing BYOK/Managed key lifecycle. - Crypto purpose is used only for displaying purposes, not for creation.

func (*CertificatePurpose) Scan added in v0.10.0

func (p *CertificatePurpose) Scan(src any) error

func (CertificatePurpose) Valid added in v0.10.0

func (p CertificatePurpose) Valid() bool

func (CertificatePurpose) Value added in v0.10.0

func (p CertificatePurpose) Value() (driver.Value, error)

type CertificateState

type CertificateState string

func (*CertificateState) Scan added in v0.10.0

func (s *CertificateState) Scan(src any) error

func (CertificateState) Valid added in v0.10.0

func (s CertificateState) Valid() bool

func (CertificateState) Value added in v0.10.0

func (s CertificateState) Value() (driver.Value, error)

type CertificateSubject added in v0.9.0

type CertificateSubject struct {
	Locality           []string `yaml:"locality"`
	OrganizationalUnit []string `yaml:"organizationUnit"` //nolint:tagliatelle
	Organization       []string `yaml:"organization"`
	Country            []string `yaml:"country"`
	CommonName         string
}

CertificateSubject holds the subject fields of a client certificate.

func ToCertificateSubjectFromPKIX added in v0.9.0

func ToCertificateSubjectFromPKIX(subject pkix.Name) CertificateSubject

func (CertificateSubject) String added in v0.9.0

func (subject CertificateSubject) String() string

type ClientCertificate added in v0.9.0

type ClientCertificate struct {
	Name    string             `yaml:"name"`
	RootCA  string             `yaml:"rootCA"` //nolint:tagliatelle
	Subject CertificateSubject `yaml:"subject"`
}

ClientCertificate represents a client certificate used for HYOK key management.

func NewClientCertificate added in v0.9.0

func NewClientCertificate(value config.CryptoCert, tenant string) ClientCertificate

type ClientCertificates added in v0.9.0

type ClientCertificates map[CertificatePurpose][]*ClientCertificate

type ConfigType added in v0.12.2

type ConfigType string
const (
	TenantConfigTypeWorkflow        ConfigType = "workflow"
	TenantConfigTypeDefaultKeystore ConfigType = "default_keystore"
	TenantConfigTypeLimits          ConfigType = "limits"
	TenantConfigTypeSystemGrouping  ConfigType = "system_grouping"
)

type CryptoConfig added in v0.9.0

type CryptoConfig struct {
	Subject    string             `yaml:"subject" json:"subject" flatten:"subject"`
	AccessData KeystoreAccessData `yaml:"accessData" json:"accessData" flatten:"access_data"`
}

type Event

type Event struct {
	AutoTimeModel

	Identifier string            `gorm:"type:varchar(255);primaryKey"`
	Type       string            `gorm:"type:varchar(255);not null"`
	Data       json.RawMessage   `gorm:"type:jsonb;not null"`
	Status     orbital.JobStatus `gorm:"type:varchar(255);not null"`

	// Stores error content for failed events
	// It's split from orbital error_message by ERROR_CODE:ErrorMessage
	ErrorCode    string `gorm:"type:varchar(255)"`
	ErrorMessage string `gorm:"type:text"`

	// PreviousItemStatus represents the state an item was before the event was sent
	// This is used for cancel actions to recover an item to it's previous state
	PreviousItemStatus string `gorm:"type:varchar(255)"`
}

Event is a model that holds the result of the latest sent events that terminated unsuccessfully

func (Event) CheckAuthz added in v0.5.0

func (m Event) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Event) IsSharedModel

func (Event) IsSharedModel() bool

func (Event) TableName

func (m Event) TableName() string

TableName returns the table name for Key

func (Event) TableResourceType added in v0.5.0

func (m Event) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type Flattenable added in v0.12.2

type Flattenable interface {
	FlattenKeyRoot() string
}

type Group

type Group struct {
	ID            uuid.UUID              `gorm:"type:uuid;primaryKey"`
	Name          string                 `gorm:"type:varchar(64);not null;unique"`
	Description   string                 `gorm:"type:text"`
	Role          constants.BusinessRole `gorm:"type:varchar(255);not null"`
	IAMIdentifier string                 `gorm:"type:varchar(128);not null;unique"`
}

func (*Group) BeforeSave

func (m *Group) BeforeSave(_ *gorm.DB) error

BeforeSave is ran before any creating/updating the group but before finishing the transaction If this step fails the transaction should be aborted

func (Group) CheckAuthz added in v0.5.0

func (m Group) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Group) IsSharedModel

func (Group) IsSharedModel() bool

func (Group) TableName

func (m Group) TableName() string

TableName returns the table name for Key

func (Group) TableResourceType added in v0.5.0

func (m Group) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type ImportParams

type ImportParams struct {
	AutoTimeModel

	KeyID              uuid.UUID                            `gorm:"type:uuid;primaryKey"`
	WrappingAlg        cmkapi.WrappingAlgorithmName         `gorm:"type:varchar(50);not null"`
	HashFunction       cmkapi.WrappingAlgorithmHashFunction `gorm:"type:varchar(50);not null"`
	PublicKeyPEM       string                               `gorm:"type:text;not null"`
	Expires            *time.Time
	ProviderParameters json.RawMessage `gorm:"type:jsonb"`
}

ImportParams represents the parameters for a Bring Your Own Key (BYOK) configuration.

func (ImportParams) CheckAuthz added in v0.5.0

func (m ImportParams) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (ImportParams) IsExpired

func (b ImportParams) IsExpired() bool

IsExpired checks if the ImportParams has expired based on the Expires field.

func (ImportParams) IsSharedModel

func (ImportParams) IsSharedModel() bool

func (ImportParams) TableName

func (m ImportParams) TableName() string

TableName returns the table name for ImportParams

func (ImportParams) TableResourceType added in v0.5.0

func (m ImportParams) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type JoinSystemAndProperties added in v0.11.0

type JoinSystemAndProperties struct {
	System

	KeyConfigurationName       *string `gorm:"column:key_configuration_name"`
	TargetKeyConfigurationName *string `gorm:"column:target_key_configuration_name"`
	ErrorCode                  string  `gorm:"column:error_code"`
	ErrorMessage               string  `gorm:"column:error_message"`

	Key   string `gorm:"type:varchar(255);primaryKey"`
	Value string `gorm:"type:varchar(255)"`
}

type JoinSystemGroupsAndSystem added in v0.11.0

type JoinSystemGroupsAndSystem struct {
	JoinSystemAndProperties

	SystemGroup SystemGroup `gorm:"embedded;embeddedPrefix:group_"`
}

func (JoinSystemGroupsAndSystem) CheckAuthz added in v0.11.0

func (JoinSystemGroupsAndSystem) IsSharedModel added in v0.11.0

func (m JoinSystemGroupsAndSystem) IsSharedModel() bool

func (JoinSystemGroupsAndSystem) TableName added in v0.11.0

func (m JoinSystemGroupsAndSystem) TableName() string

func (JoinSystemGroupsAndSystem) TableResourceType added in v0.11.0

func (m JoinSystemGroupsAndSystem) TableResourceType() authz.RepoResourceType

type Key

type Key struct {
	AutoTimeModel

	ID                   uuid.UUID           `gorm:"type:uuid;primaryKey"`
	KeyConfigurationID   uuid.UUID           `gorm:"type:uuid;not null;uniqueindex:keyname,priority:1"`
	Name                 string              `gorm:"type:varchar(255);not null;uniqueindex:keyname,priority:2"`
	KeyType              cmkapi.KeyType      `gorm:"type:varchar(50);not null"`
	Description          string              `gorm:"type:text"`
	Algorithm            cmkapi.KeyAlgorithm `gorm:"type:varchar(50);not null"`
	Provider             string              `gorm:"type:varchar(50);not null"`
	Region               string              `gorm:"type:varchar(50);not null"`
	State                cmkapi.KeyState     `gorm:"type:varchar(50);not null;default:'ENABLED'"`
	KeyVersions          []KeyVersion        `gorm:"foreignKey:KeyID"`
	ImportParams         *ImportParams       `gorm:"foreignKey:KeyID;references:ID;constraint:OnDelete:CASCADE"`
	NativeID             *string             `gorm:"type:varchar(255)"`
	KeyLabels            []KeyLabel          `gorm:"foreignKey:ResourceID"`
	LastUsed             *time.Time
	ManagementAccessData json.RawMessage `gorm:"type:jsonb"`
	CryptoAccessData     json.RawMessage `gorm:"type:jsonb"`
	UnderWorkflow        bool            `gorm:"type:bool"`
	ErrorDetail          json.RawMessage `gorm:"type:jsonb"`

	IsPrimary       bool            `gorm:"-:all"` // Loaded on the managear/get methods
	EditableRegions map[string]bool `gorm:"-:all"`
}

func (*Key) AfterFind added in v0.3.0

func (m *Key) AfterFind(tx *gorm.DB) error

func (Key) CheckAuthz added in v0.5.0

func (m Key) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (*Key) GetCryptoAccessData

func (m *Key) GetCryptoAccessData() KeyAccessData

func (*Key) GetManagementAccessData

func (m *Key) GetManagementAccessData() (cmkapi.KeyAccessDetailsRegion, error)

func (Key) IsSharedModel

func (Key) IsSharedModel() bool

func (Key) TableName

func (m Key) TableName() string

TableName returns the table name for Key

func (Key) TableResourceType added in v0.5.0

func (m Key) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type KeyAccessData

type KeyAccessData map[string]cmkapi.KeyAccessDetailsRegion // Map of regions and their properties

type KeyConfiguration

type KeyConfiguration struct {
	AutoTimeModel

	ID           uuid.UUID  `gorm:"type:uuid;primaryKey"`
	Name         string     `gorm:"type:varchar(255);not null;unique"`
	Description  string     `gorm:"type:text"`
	AdminGroupID uuid.UUID  `gorm:"type:uuid;not null"`
	AdminGroup   Group      `gorm:"foreignKey:AdminGroupID"`
	CreatorID    string     `gorm:"type:varchar(255);not null"`
	PrimaryKeyID *uuid.UUID `gorm:"type:uuid"`
	TotalKeys    int        `gorm:"->;-:migration"`
	TotalSystems int        `gorm:"->;-:migration"`
	// contains filtered or unexported fields
}

KeyConfiguration represents a key configuration in the database.

func (KeyConfiguration) CheckAuthz added in v0.5.0

func (m KeyConfiguration) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (*KeyConfiguration) GetCreatorName added in v0.9.0

func (kc *KeyConfiguration) GetCreatorName(
	ctx context.Context,
	identityManager identitymanagement.IdentityManagement,
) (string, error)

func (KeyConfiguration) IsSharedModel

func (KeyConfiguration) IsSharedModel() bool

func (*KeyConfiguration) SetID

func (kc *KeyConfiguration) SetID(id uuid.UUID)

func (KeyConfiguration) TableName

func (m KeyConfiguration) TableName() string

TableName returns the table name for KeyConfiguration

func (KeyConfiguration) TableResourceType added in v0.5.0

func (m KeyConfiguration) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type KeyLabel

type KeyLabel struct {
	BaseLabel
	AutoTimeModel

	CryptoKey Key `gorm:"foreignKey:ResourceID"`
}

func (KeyLabel) CheckAuthz added in v0.5.0

func (m KeyLabel) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (KeyLabel) IsSharedModel

func (KeyLabel) IsSharedModel() bool

func (KeyLabel) TableName

func (m KeyLabel) TableName() string

func (KeyLabel) TableResourceType added in v0.5.0

func (m KeyLabel) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type KeyVersion

type KeyVersion struct {
	AutoTimeModel

	ID        uuid.UUID `gorm:"type:uuid;primaryKey"`
	NativeID  string    `gorm:"type:varchar(255);not null"`
	KeyID     uuid.UUID `gorm:"type:uuid;not null;index"`
	RotatedAt time.Time `gorm:"type:timestamptz;not null"` // Rotation timestamp (latest = current version)
	Status    string    `gorm:"type:varchar(50);not null;default:'UNKNOWN'"`
}

KeyVersion represents a version of a key in the database.

func (KeyVersion) CheckAuthz added in v0.5.0

func (m KeyVersion) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (KeyVersion) IsSharedModel

func (KeyVersion) IsSharedModel() bool

func (KeyVersion) TableName

func (m KeyVersion) TableName() string

TableName returns the table name for KeyVersion

func (KeyVersion) TableResourceType added in v0.5.0

func (m KeyVersion) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type Keystore

type Keystore struct {
	AutoTimeModel

	ID       uuid.UUID       `gorm:"type:uuid;primaryKey"`
	Provider string          `gorm:"type:varchar(50);not null"`
	Config   json.RawMessage `gorm:"type:jsonb;not null;unique"`
}

Keystore is an internal entity of pool item that should be persisted.

func (Keystore) CheckAuthz added in v0.5.0

func (m Keystore) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Keystore) IsSharedModel

func (Keystore) IsSharedModel() bool

func (Keystore) TableName

func (m Keystore) TableName() string

func (Keystore) TableResourceType added in v0.5.0

func (m Keystore) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type KeystoreAccessData

type KeystoreAccessData map[string]any

type KeystoreConfig

type KeystoreConfig struct {
	RoleManagementConfig ManagementConfig         `yaml:"roleManagementConfig" json:"roleManagementConfig" flatten:"role_mgmt"`
	KeyManagementConfig  ManagementConfig         `yaml:"keyManagementConfig" json:"keyManagementConfig" flatten:"key_mgmt"`
	CryptoAccessData     map[string]CryptoConfig  `yaml:"cryptoAccessData" json:"cryptoAccessData" flatten:"crypto"`
	SupportedRegions     map[string]config.Region `yaml:"supportedRegions" json:"supportedRegions" flatten:"supported_region"`
}

func (KeystoreConfig) FlattenKeyRoot added in v0.12.2

func (c KeystoreConfig) FlattenKeyRoot() string

func (KeystoreConfig) Type added in v0.12.2

func (c KeystoreConfig) Type() ConfigType

type ManagementConfig added in v0.9.0

type ManagementConfig struct {
	LocalityID string             `yaml:"localityId" json:"localityId" flatten:"locality_id"`
	CommonName string             `yaml:"commonName" json:"commonName" flatten:"common_name"`
	AccessData KeystoreAccessData `yaml:"accessData" json:"accessData" flatten:"access_data"`
}

type RequestCertArgs

type RequestCertArgs struct {
	CertPurpose CertificatePurpose
	Supersedes  *uuid.UUID
	CommonName  string
	Locality    []string
}

type System

type System struct {
	ID uuid.UUID `gorm:"type:uuid;primaryKey"`

	Identifier string `gorm:"type:varchar(255);not null;uniqueindex:region_sys,priority:2"`

	Region                     string            `gorm:"type:varchar(50);not null;uniqueindex:region_sys,priority:1"`
	Type                       SystemType        `gorm:"type:varchar(50);not null"`
	KeyConfigurationID         *uuid.UUID        `gorm:"type:uuid"`
	TargetKeyConfigurationID   *uuid.UUID        `gorm:"type:uuid"`
	KeyConfigurationName       *string           `gorm:"-"`
	TargetKeyConfigurationName *string           `gorm:"-"`
	Properties                 map[string]string `gorm:"-:all"`
	SystemGroupID              *uuid.UUID        `gorm:"type:uuid"`

	// Status can be 'CONNECTED', 'DISCONNECTED', 'FAILED', or 'PROCESSING'
	Status        cmkapi.SystemStatus `gorm:"type:varchar(50);default:'DISCONNECTED'"`
	UnderWorkflow bool                `gorm:"type:bool"`

	// Only set for failed systems by the event table
	ErrorCode    string `gorm:"-"`
	ErrorMessage string `gorm:"-"`
}

func (*System) AfterSave

func (m *System) AfterSave(tx *gorm.DB) error

AfterSave is ran before any creating/updating the system but before finishing the transaction If this step fails the transaction should be aborted

func (*System) BeforeDelete

func (m *System) BeforeDelete(tx *gorm.DB) error

BeforeDelete is ran before deleting the system but before finishing the transaction If this step fails the transaction should be aborted

func (System) CheckAuthz added in v0.5.0

func (m System) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (System) IsSharedModel

func (System) IsSharedModel() bool

func (System) TableName

func (m System) TableName() string

TableName returns the table name for System

func (System) TableResourceType added in v0.5.0

func (m System) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

func (*System) UpdateSystemProperties

func (m *System) UpdateSystemProperties(
	ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	props map[string]string,
	cfg *config.System,
) (bool, error)

UpdateSystemProperties if they are set and returns a bool if any field was updated

type SystemGroup added in v0.11.0

type SystemGroup struct {
	ID              uuid.UUID `gorm:"type:uuid;primaryKey"`
	Name            string    `gorm:"type:varchar(255);not null;unique"`
	Description     string    `gorm:"type:varchar(255)"`
	SuppressWarning bool      `gorm:"type:bool"`

	Systems      []*System `gorm:"-"`
	WarnCoverage bool      `gorm:"-"`
}

func (SystemGroup) CheckAuthz added in v0.11.0

func (m SystemGroup) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (SystemGroup) IsSharedModel added in v0.11.0

func (m SystemGroup) IsSharedModel() bool

func (SystemGroup) TableName added in v0.11.0

func (m SystemGroup) TableName() string

func (SystemGroup) TableResourceType added in v0.11.0

func (m SystemGroup) TableResourceType() authz.RepoResourceType

type SystemGroupConfig added in v0.12.2

type SystemGroupConfig struct {
	Enabled      bool `flatten:"enabled"`
	WarnCoverage bool `flatten:"warn_coverage"`
}

func (SystemGroupConfig) FlattenKeyRoot added in v0.12.2

func (c SystemGroupConfig) FlattenKeyRoot() string

func (SystemGroupConfig) Type added in v0.12.2

func (c SystemGroupConfig) Type() ConfigType

type SystemGroupCoverage added in v0.11.0

type SystemGroupCoverage struct {
	SystemGroupID *uuid.UUID `gorm:"column:system_group_id"`
	WarnCoverage  bool       `gorm:"column:warn_coverage"`
}

func (SystemGroupCoverage) CheckAuthz added in v0.11.0

func (SystemGroupCoverage) IsSharedModel added in v0.11.0

func (SystemGroupCoverage) IsSharedModel() bool

func (SystemGroupCoverage) TableName added in v0.11.0

func (m SystemGroupCoverage) TableName() string

func (SystemGroupCoverage) TableResourceType added in v0.11.0

func (SystemGroupCoverage) TableResourceType() authz.RepoResourceType

type SystemProperty

type SystemProperty struct {
	ID    uuid.UUID `gorm:"type:uuid;primaryKey"`
	Key   string    `gorm:"type:varchar(255);primaryKey"`
	Value string    `gorm:"type:varchar(255)"`
}

func (SystemProperty) CheckAuthz added in v0.5.0

func (m SystemProperty) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (SystemProperty) IsSharedModel

func (SystemProperty) IsSharedModel() bool

func (SystemProperty) TableName

func (m SystemProperty) TableName() string

func (SystemProperty) TableResourceType added in v0.5.0

func (m SystemProperty) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type SystemType added in v0.10.0

type SystemType string

SystemType identifies the kind of registered system.

const (
	SystemTypeSYSTEM     SystemType = "SYSTEM"
	SystemTypeSUBACCOUNT SystemType = "SUBACCOUNT"
)

func (*SystemType) Scan added in v0.10.0

func (t *SystemType) Scan(src any) error

func (SystemType) Valid added in v0.10.0

func (t SystemType) Valid() bool

func (SystemType) Value added in v0.10.0

func (t SystemType) Value() (driver.Value, error)

type Tag

type Tag struct {
	ID     uuid.UUID       `gorm:"type:uuid;primaryKey"` // ID of the Item
	Values json.RawMessage `gorm:"type:jsonb"`
}

func (Tag) CheckAuthz added in v0.5.0

func (m Tag) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Tag) IsSharedModel

func (Tag) IsSharedModel() bool

func (Tag) TableName

func (m Tag) TableName() string

func (Tag) TableResourceType added in v0.5.0

func (m Tag) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type Tenant

type Tenant struct {
	multitenancy.TenantModel

	ID        string       `gorm:"type:varchar(255);not null;unique"`
	Name      string       `gorm:"type:varchar(255)"`
	Status    TenantStatus `gorm:"type:varchar(50);not null"`
	OwnerType string       `gorm:"type:varchar(50);not null;default:''"`
	OwnerID   string       `gorm:"type:varchar(255);not null;default:''"`
	IssuerURL string       `gorm:"type:varchar(255);not null;default:''"`
	Role      TenantRole   `gorm:"type:varchar(50);not null;default:''"`
}

func (Tenant) CheckAuthz added in v0.5.0

func (m Tenant) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Tenant) IsSharedModel

func (m Tenant) IsSharedModel() bool

func (Tenant) TableName

func (m Tenant) TableName() string

func (Tenant) TableResourceType added in v0.5.0

func (m Tenant) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

func (Tenant) Validate

func (m Tenant) Validate() error

Validate validates given tenant data.

type TenantConfig

type TenantConfig struct {
	Key   string     `gorm:"type:varchar(255);primaryKey"`
	Value string     `gorm:"type:text;not null"`
	Type  ConfigType `gorm:"type:varchar(255);primaryKey;default:''"`
}

TenantConfig represents a flat config row in the database. Key + Type form the composite primary key (Type groups related entries, e.g. "workflow").

func (TenantConfig) CheckAuthz added in v0.5.0

func (m TenantConfig) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (TenantConfig) IsSharedModel

func (TenantConfig) IsSharedModel() bool

func (TenantConfig) TableName

func (m TenantConfig) TableName() string

TableName returns the table name for Key

func (TenantConfig) TableResourceType added in v0.5.0

func (m TenantConfig) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type TenantConfiguration added in v0.12.2

type TenantConfiguration interface {
	Flattenable
	Type() ConfigType
}

type TenantLimits added in v0.12.2

type TenantLimits struct {
	Systems    *int `flatten:"system"`
	Keys       *int `flatten:"keys"`
	KeyConfigs *int `flatten:"key_configs"`
}

func (TenantLimits) FlattenKeyRoot added in v0.12.2

func (c TenantLimits) FlattenKeyRoot() string

func (TenantLimits) Type added in v0.12.2

func (c TenantLimits) Type() ConfigType

type TenantRole

type TenantRole string

TenantRole represents the role of the tenant.

func (TenantRole) Validate

func (s TenantRole) Validate() error

Validate validates the given role of the tenant. Returns an error if the status is invalid.

type TenantStatus

type TenantStatus string

TenantStatus represents the status of the tenant.

func (TenantStatus) Validate

func (s TenantStatus) Validate() error

Validate validates the given status of the tenant. Returns an error if the status is invalid.

type Validator

type Validator interface {
	Validate() error
}

Validator defines the methods for validation.

type Workflow

type Workflow struct {
	AutoTimeModel

	ID          uuid.UUID     `gorm:"type:uuid;primaryKey"`
	State       WorkflowState `gorm:"type:varchar(50);not null"`
	InitiatorID string        `gorm:"type:varchar(255);not null"`

	Tasks            []WorkflowTask       `gorm:"foreignKey:WorkflowID"`
	ApproverGroupIDs json.RawMessage      `gorm:"type:jsonb"`
	ArtifactType     WorkflowArtifactType `gorm:"type:varchar(50);not null"`
	ArtifactID       uuid.UUID            `gorm:"type:uuid;not null"`
	// ArtifactName is currently a snapshot at time of creation
	ArtifactName           *string                         `gorm:"type:varchar(255)"`
	ActionType             WorkflowActionType              `gorm:"type:varchar(50);not null"`
	Parameters             string                          `gorm:"type:text"`
	ParametersResourceName *string                         `gorm:"type:varchar(255)"`
	ParametersResourceType *WorkflowParametersResourceType `gorm:"type:varchar(50)"`
	FailureReason          string                          `gorm:"type:text"`
	ExpiryDate             *time.Time
	MinimumApprovalCount   int `gorm:"type:integer;default:2"` // Snapshot of minimum approvals at creation time
	// contains filtered or unexported fields
}

Workflow is an action on a data model (artifact) and can be read as <Artifact><ActionType> Artifact type is the type of item, identified by ArtifactID and ActionType the executed action Parameters will have different values depending on the ActionType. Check API Yaml for possible Parameters

e.g. of a workflow System Link

func (Workflow) BeforeDelete

func (m Workflow) BeforeDelete(tx *gorm.DB) error

func (*Workflow) BeforeSave

func (m *Workflow) BeforeSave(tx *gorm.DB) error

func (Workflow) CheckAuthz added in v0.5.0

func (m Workflow) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (Workflow) Description

Description generates a human-readable description of the workflow based on its action type

func (Workflow) GetArtifactName

func (m Workflow) GetArtifactName() string

GetArtifactName returns the artifact name or a default value if nil

func (*Workflow) GetInitiatorName added in v0.9.0

func (w *Workflow) GetInitiatorName(
	ctx context.Context,
	identityManager identitymanagement.IdentityManagement,
) (string, error)

func (Workflow) IsSharedModel

func (Workflow) IsSharedModel() bool

func (Workflow) TableName

func (m Workflow) TableName() string

func (Workflow) TableResourceType added in v0.5.0

func (m Workflow) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type WorkflowActionType added in v0.9.0

type WorkflowActionType string

func (WorkflowActionType) DisplayName added in v0.12.2

func (t WorkflowActionType) DisplayName() string

func (*WorkflowActionType) Scan added in v0.9.0

func (t *WorkflowActionType) Scan(src any) error

func (WorkflowActionType) String added in v0.9.0

func (t WorkflowActionType) String() string

func (WorkflowActionType) Valid added in v0.9.0

func (t WorkflowActionType) Valid() bool

func (WorkflowActionType) Value added in v0.9.0

func (t WorkflowActionType) Value() (driver.Value, error)

type WorkflowApprover

type WorkflowApprover = WorkflowTask

WorkflowApprover is a deprecated alias; use WorkflowTask.

type WorkflowApproverGroup added in v0.9.0

type WorkflowApproverGroup struct {
	ID         uuid.UUID `gorm:"type:uuid;primaryKey"`
	WorkflowID uuid.UUID `gorm:"type:uuid;not null"`
	GroupID    uuid.UUID `gorm:"type:uuid;not null"`
}

WorkflowApproverGroup represents the many-to-many relationship between workflows and approver groups

func (WorkflowApproverGroup) CheckAuthz added in v0.9.0

func (WorkflowApproverGroup) IsSharedModel added in v0.9.0

func (w WorkflowApproverGroup) IsSharedModel() bool

func (WorkflowApproverGroup) TableName added in v0.9.0

func (w WorkflowApproverGroup) TableName() string

func (WorkflowApproverGroup) TableResourceType added in v0.9.0

func (w WorkflowApproverGroup) TableResourceType() authz.RepoResourceType

type WorkflowArtifactType added in v0.9.0

type WorkflowArtifactType string

func (WorkflowArtifactType) DisplayName added in v0.12.2

func (t WorkflowArtifactType) DisplayName() string

func (*WorkflowArtifactType) Scan added in v0.9.0

func (t *WorkflowArtifactType) Scan(src any) error

func (WorkflowArtifactType) String added in v0.9.0

func (t WorkflowArtifactType) String() string

func (WorkflowArtifactType) Valid added in v0.9.0

func (t WorkflowArtifactType) Valid() bool

func (WorkflowArtifactType) Value added in v0.9.0

func (t WorkflowArtifactType) Value() (driver.Value, error)

type WorkflowConfig

type WorkflowConfig struct {
	Enabled                       bool `flatten:"enabled"`
	RequiredApprovals             int  `flatten:"required_approvals"`
	MinAllowedApprovals           int  `flatten:"min_allowed_approvals"`
	MaxAllowedApprovals           int  `flatten:"max_allowed_approvals"`
	RetentionPeriodDays           int  `flatten:"retention_period_days"`
	MinAllowedRetentionPeriodDays int  `flatten:"min_allowed_retention_period_days"`
	MaxAllowedRetentionPeriodDays int  `flatten:"max_allowed_retention_period_days"`
	ExpiryPeriodDays              int  `flatten:"expiry_period_days"`
	MaxAllowedExpiryPeriodDays    int  `flatten:"max_allowed_expiry_period_days"`
}

func (WorkflowConfig) FlattenKeyRoot added in v0.12.2

func (c WorkflowConfig) FlattenKeyRoot() string

func (WorkflowConfig) Type added in v0.12.2

func (c WorkflowConfig) Type() ConfigType

type WorkflowParametersResourceType added in v0.10.0

type WorkflowParametersResourceType string

func (*WorkflowParametersResourceType) Scan added in v0.10.0

func (WorkflowParametersResourceType) String added in v0.10.0

func (WorkflowParametersResourceType) Valid added in v0.10.0

func (WorkflowParametersResourceType) Value added in v0.10.0

type WorkflowState added in v0.9.0

type WorkflowState string

func (*WorkflowState) Scan added in v0.9.0

func (s *WorkflowState) Scan(src any) error

func (WorkflowState) String added in v0.9.0

func (s WorkflowState) String() string

func (WorkflowState) Valid added in v0.9.0

func (s WorkflowState) Valid() bool

func (WorkflowState) Value added in v0.9.0

func (s WorkflowState) Value() (driver.Value, error)

type WorkflowTask added in v0.10.0

type WorkflowTask struct {
	ID         uuid.UUID `gorm:"type:uuid;primaryKey"`
	WorkflowID uuid.UUID `gorm:"type:uuid;not null"`
	UserID     string    `gorm:"type:varchar(255);not null"`

	AssigneeRole AssigneeRole `gorm:"type:varchar(50);not null;default:'APPROVER'"`
	CreatedAt    time.Time    `gorm:"not null"`
	CompletedAt  *time.Time

	Workflow Workflow     `gorm:"foreignKey:WorkflowID"`
	Approved sql.NullBool `gorm:"default:null"`
	// contains filtered or unexported fields
}

func (WorkflowTask) CheckAuthz added in v0.10.0

func (m WorkflowTask) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (*WorkflowTask) GetUserName added in v0.10.0

func (m *WorkflowTask) GetUserName(
	ctx context.Context,
	identityManager identitymanagement.IdentityManagement,
) (string, error)

func (WorkflowTask) IsSharedModel added in v0.10.0

func (WorkflowTask) IsSharedModel() bool

func (WorkflowTask) TableName added in v0.10.0

func (m WorkflowTask) TableName() string

func (WorkflowTask) TableResourceType added in v0.10.0

func (m WorkflowTask) TableResourceType() authz.RepoResourceType

TableResourceType return the authz resource type

type WorkflowTaskView added in v0.10.0

type WorkflowTaskView struct {
	ID            uuid.UUID `gorm:"type:uuid;primaryKey"`
	WorkflowID    uuid.UUID `gorm:"type:uuid"`
	UserID        string    `gorm:"type:varchar(255)"`
	Approved      sql.NullBool
	AssigneeRole  AssigneeRole `gorm:"type:varchar(50)"`
	CreatedAt     time.Time
	CompletedAt   *time.Time
	WorkflowState WorkflowState        `gorm:"type:varchar(50)"`
	ArtifactType  WorkflowArtifactType `gorm:"type:varchar(50)"`
	ArtifactID    uuid.UUID            `gorm:"type:uuid"`
	ArtifactName  *string              `gorm:"type:varchar(255)"`
	ActionType    WorkflowActionType   `gorm:"type:varchar(50)"`
	InitiatorID   string               `gorm:"type:varchar(255)"`
	ExpiryDate    *time.Time
}

WorkflowTaskView is a read-only GORM model backed by the workflow_task_view DB view.

func (WorkflowTaskView) CheckAuthz added in v0.10.0

func (m WorkflowTaskView) CheckAuthz(ctx context.Context,
	authzHandler *authz.Handler[authz.RepoResourceType, authz.RepoAction],
	action authz.RepoAction,
) (bool, error)

func (WorkflowTaskView) IsSharedModel added in v0.10.0

func (WorkflowTaskView) IsSharedModel() bool

func (WorkflowTaskView) TableName added in v0.10.0

func (WorkflowTaskView) TableName() string

Jump to

Keyboard shortcuts

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