db

package
v0.0.6-beta Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ClientID                    uuid.UUID      `json:"client_id"`
	ApiToken                    string         `json:"api_token"`
	ServiceAccount              string         `json:"service_account"`
	Environment                 string         `json:"environment"`
	Team                        string         `json:"team"`
	Email                       string         `json:"email"`
	RegularExpression           sql.NullString `json:"regular_expression"`
	ValidSubjectAlternateName   []string       `json:"valid_subject_alternate_name"`
	ValidCertificateAuthorities []string       `json:"valid_certificate_authorities"`
	ExtendedKey                 string         `json:"extended_key"`
	CertificateValidity         int16          `json:"certificate_validity"`
	SubordinateCa               string         `json:"subordinate_ca"`
	Provisioned                 bool           `json:"provisioned"`
	NodeAttestation             []string       `json:"node_attestation"`
	CreatedAt                   time.Time      `json:"created_at"`
	CreatedBy                   uuid.UUID      `json:"created_by"`
}

type AwsAttestation

type AwsAttestation struct {
	ClientID        uuid.UUID             `json:"client_id"`
	RoleArn         sql.NullString        `json:"role_arn"`
	AssumeRole      sql.NullString        `json:"assume_role"`
	SecurityGroupID []string              `json:"security_group_id"`
	Region          sql.NullString        `json:"region"`
	InstanceID      sql.NullString        `json:"instance_id"`
	ImageID         sql.NullString        `json:"image_id"`
	InstanceTags    pqtype.NullRawMessage `json:"instance_tags"`
}

type Certificate

type Certificate struct {
	SerialNumber            string         `json:"serial_number"`
	Account                 string         `json:"account"`
	Environment             string         `json:"environment"`
	ExtendedKey             string         `json:"extended_key"`
	CommonName              string         `json:"common_name"`
	SubjectAlternativeName  []string       `json:"subject_alternative_name"`
	ExpirationDate          time.Time      `json:"expiration_date"`
	IssuedDate              time.Time      `json:"issued_date"`
	Revoked                 bool           `json:"revoked"`
	RevokedBy               sql.NullString `json:"revoked_by"`
	RevokeDate              sql.NullTime   `json:"revoke_date"`
	CertificateAuthorityArn sql.NullString `json:"certificate_authority_arn"`
}

type CreateProvisionerAccountParams

type CreateProvisionerAccountParams struct {
	ClientID                   uuid.UUID      `json:"client_id"`
	ApiToken                   string         `json:"api_token"`
	ProvisionerAccount         string         `json:"provisioner_account"`
	Environments               []string       `json:"environments"`
	Team                       string         `json:"team"`
	Email                      string         `json:"email"`
	RegularExpression          sql.NullString `json:"regular_expression"`
	NodeAttestation            []string       `json:"node_attestation"`
	ValidSubjectAlternateNames []string       `json:"valid_subject_alternate_names"`
	ExtendedKeys               []string       `json:"extended_keys"`
	MaxCertificateValidity     int16          `json:"max_certificate_validity"`
	CreatedAt                  time.Time      `json:"created_at"`
	CreatedBy                  uuid.UUID      `json:"created_by"`
}

type CreateServiceAccountParams

type CreateServiceAccountParams struct {
	ClientID                    uuid.UUID      `json:"client_id"`
	ApiToken                    string         `json:"api_token"`
	ServiceAccount              string         `json:"service_account"`
	Environment                 string         `json:"environment"`
	Team                        string         `json:"team"`
	Email                       string         `json:"email"`
	RegularExpression           sql.NullString `json:"regular_expression"`
	ValidSubjectAlternateName   []string       `json:"valid_subject_alternate_name"`
	ValidCertificateAuthorities []string       `json:"valid_certificate_authorities"`
	ExtendedKey                 string         `json:"extended_key"`
	CertificateValidity         int16          `json:"certificate_validity"`
	SubordinateCa               string         `json:"subordinate_ca"`
	Provisioned                 bool           `json:"provisioned"`
	NodeAttestation             []string       `json:"node_attestation"`
	CreatedAt                   time.Time      `json:"created_at"`
	CreatedBy                   uuid.UUID      `json:"created_by"`
}

type CreateUserParams

type CreateUserParams struct {
	Uuid             uuid.UUID `json:"uuid"`
	Username         string    `json:"username"`
	HashedCredential string    `json:"hashed_credential"`
	FullName         string    `json:"full_name"`
	Email            string    `json:"email"`
	Permissions      string    `json:"permissions"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DatabaseEndpoints

type DatabaseEndpoints struct {
	Writer Store
	Reader Store
}

type GetServiceAccountByMetadataParams

type GetServiceAccountByMetadataParams struct {
	ServiceAccount string `json:"service_account"`
	Environment    string `json:"environment"`
	ExtendedKey    string `json:"extended_key"`
}

type GetSignedCertificateByMetadataParams

type GetSignedCertificateByMetadataParams struct {
	SerialNumber string `json:"serial_number"`
	Account      string `json:"account"`
	Environment  string `json:"environment"`
	ExtendedKey  string `json:"extended_key"`
}

type ListCertificateSubjectAlternativeNameParams

type ListCertificateSubjectAlternativeNameParams struct {
	CommonName string `json:"common_name"`
	Limit      int32  `json:"limit"`
	Offset     int32  `json:"offset"`
}

type ListCertificatesParams

type ListCertificatesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListProvisionerAccountsParams

type ListProvisionerAccountsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListServiceAccountsParams

type ListServiceAccountsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListValidCertificateAuthorityFromSubordinateCAParams

type ListValidCertificateAuthorityFromSubordinateCAParams struct {
	SubordinateCa string `json:"subordinate_ca"`
	Environment   string `json:"environment"`
}

type LogCertificateParams

type LogCertificateParams struct {
	SerialNumber            string         `json:"serial_number"`
	Account                 string         `json:"account"`
	Environment             string         `json:"environment"`
	ExtendedKey             string         `json:"extended_key"`
	CommonName              string         `json:"common_name"`
	SubjectAlternativeName  []string       `json:"subject_alternative_name"`
	ExpirationDate          time.Time      `json:"expiration_date"`
	IssuedDate              time.Time      `json:"issued_date"`
	CertificateAuthorityArn sql.NullString `json:"certificate_authority_arn"`
}

type Provisioner

type Provisioner struct {
	ClientID                   uuid.UUID      `json:"client_id"`
	ApiToken                   string         `json:"api_token"`
	ProvisionerAccount         string         `json:"provisioner_account"`
	Environments               []string       `json:"environments"`
	Team                       string         `json:"team"`
	Email                      string         `json:"email"`
	RegularExpression          sql.NullString `json:"regular_expression"`
	ValidSubjectAlternateNames []string       `json:"valid_subject_alternate_names"`
	ExtendedKeys               []string       `json:"extended_keys"`
	MaxCertificateValidity     int16          `json:"max_certificate_validity"`
	NodeAttestation            []string       `json:"node_attestation"`
	CreatedAt                  time.Time      `json:"created_at"`
	CreatedBy                  uuid.UUID      `json:"created_by"`
}

type ProvisionerAccountAttestation

type ProvisionerAccountAttestation struct {
	ProvisionerAccount Provisioner    `json:"provisioner_account"`
	AwsIid             AwsAttestation `json:"aws_iid"`
}

type Querier

type Querier interface {
	CreateProvisionerAccount(ctx context.Context, arg CreateProvisionerAccountParams) (*Provisioner, error)
	CreateServiceAccount(ctx context.Context, arg CreateServiceAccountParams) (*Account, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (*User, error)
	DeleteInstanceIdentityDocument(ctx context.Context, clientID uuid.UUID) error
	DeleteProvisionerAccount(ctx context.Context, clientID uuid.UUID) error
	DeleteServiceAccount(ctx context.Context, clientID uuid.UUID) error
	DeleteUser(ctx context.Context, username string) error
	GetCertificate(ctx context.Context, serialNumber string) (*Certificate, error)
	GetInstanceIdentityDocument(ctx context.Context, clientID uuid.UUID) (*AwsAttestation, error)
	GetProvisionerUUID(ctx context.Context, clientID uuid.UUID) (*Provisioner, error)
	GetServiceAccountByMetadata(ctx context.Context, arg GetServiceAccountByMetadataParams) ([]*Account, error)
	GetServiceAccountBySAN(ctx context.Context, dollar_1 []string) ([]*Account, error)
	GetServiceAccounts(ctx context.Context, serviceAccount string) ([]*Account, error)
	GetServiceUUID(ctx context.Context, clientID uuid.UUID) (*Account, error)
	GetSignedCertificateByMetadata(ctx context.Context, arg GetSignedCertificateByMetadataParams) ([]*Certificate, error)
	GetUser(ctx context.Context, username string) (*User, error)
	ListCertificateSubjectAlternativeName(ctx context.Context, arg ListCertificateSubjectAlternativeNameParams) ([]*Certificate, error)
	ListCertificates(ctx context.Context, arg ListCertificatesParams) ([]*Certificate, error)
	ListProvisionerAccounts(ctx context.Context, arg ListProvisionerAccountsParams) ([]*Provisioner, error)
	ListServiceAccounts(ctx context.Context, arg ListServiceAccountsParams) ([]*Account, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]*User, error)
	ListValidCertificateAuthorityFromSubordinateCA(ctx context.Context, arg ListValidCertificateAuthorityFromSubordinateCAParams) ([]interface{}, error)
	LogCertificate(ctx context.Context, arg LogCertificateParams) (*Certificate, error)
	RevokeIssuedCertificateSerialNumber(ctx context.Context, arg RevokeIssuedCertificateSerialNumberParams) error
	StoreInstanceIdentityDocument(ctx context.Context, arg StoreInstanceIdentityDocumentParams) (*AwsAttestation, error)
	UpdateInstanceIdentityNodeAttestor(ctx context.Context, arg UpdateInstanceIdentityNodeAttestorParams) (*Account, error)
	UpdateServiceAccount(ctx context.Context, arg UpdateServiceAccountParams) (*Account, error)
	UpdateUserAuthentication(ctx context.Context, arg UpdateUserAuthenticationParams) (*User, error)
	UpdateUserPermission(ctx context.Context, arg UpdateUserPermissionParams) (*User, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateProvisionerAccount

func (q *Queries) CreateProvisionerAccount(ctx context.Context, arg CreateProvisionerAccountParams) (*Provisioner, error)

func (*Queries) CreateServiceAccount

func (q *Queries) CreateServiceAccount(ctx context.Context, arg CreateServiceAccountParams) (*Account, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (*User, error)

func (*Queries) DeleteInstanceIdentityDocument

func (q *Queries) DeleteInstanceIdentityDocument(ctx context.Context, clientID uuid.UUID) error

func (*Queries) DeleteProvisionerAccount

func (q *Queries) DeleteProvisionerAccount(ctx context.Context, clientID uuid.UUID) error

func (*Queries) DeleteServiceAccount

func (q *Queries) DeleteServiceAccount(ctx context.Context, clientID uuid.UUID) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, username string) error

func (*Queries) GetCertificate

func (q *Queries) GetCertificate(ctx context.Context, serialNumber string) (*Certificate, error)

func (*Queries) GetInstanceIdentityDocument

func (q *Queries) GetInstanceIdentityDocument(ctx context.Context, clientID uuid.UUID) (*AwsAttestation, error)

func (*Queries) GetProvisionerUUID

func (q *Queries) GetProvisionerUUID(ctx context.Context, clientID uuid.UUID) (*Provisioner, error)

func (*Queries) GetServiceAccountByMetadata

func (q *Queries) GetServiceAccountByMetadata(ctx context.Context, arg GetServiceAccountByMetadataParams) ([]*Account, error)

func (*Queries) GetServiceAccountBySAN

func (q *Queries) GetServiceAccountBySAN(ctx context.Context, dollar_1 []string) ([]*Account, error)

func (*Queries) GetServiceAccounts

func (q *Queries) GetServiceAccounts(ctx context.Context, serviceAccount string) ([]*Account, error)

func (*Queries) GetServiceUUID

func (q *Queries) GetServiceUUID(ctx context.Context, clientID uuid.UUID) (*Account, error)

func (*Queries) GetSignedCertificateByMetadata

func (q *Queries) GetSignedCertificateByMetadata(ctx context.Context, arg GetSignedCertificateByMetadataParams) ([]*Certificate, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, username string) (*User, error)

func (*Queries) ListCertificateSubjectAlternativeName

func (q *Queries) ListCertificateSubjectAlternativeName(ctx context.Context, arg ListCertificateSubjectAlternativeNameParams) ([]*Certificate, error)

func (*Queries) ListCertificates

func (q *Queries) ListCertificates(ctx context.Context, arg ListCertificatesParams) ([]*Certificate, error)

func (*Queries) ListProvisionerAccounts

func (q *Queries) ListProvisionerAccounts(ctx context.Context, arg ListProvisionerAccountsParams) ([]*Provisioner, error)

func (*Queries) ListServiceAccounts

func (q *Queries) ListServiceAccounts(ctx context.Context, arg ListServiceAccountsParams) ([]*Account, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]*User, error)

func (*Queries) ListValidCertificateAuthorityFromSubordinateCA

func (q *Queries) ListValidCertificateAuthorityFromSubordinateCA(ctx context.Context, arg ListValidCertificateAuthorityFromSubordinateCAParams) ([]interface{}, error)

func (*Queries) LogCertificate

func (q *Queries) LogCertificate(ctx context.Context, arg LogCertificateParams) (*Certificate, error)

func (*Queries) RevokeIssuedCertificateSerialNumber

func (q *Queries) RevokeIssuedCertificateSerialNumber(ctx context.Context, arg RevokeIssuedCertificateSerialNumberParams) error

func (*Queries) StoreInstanceIdentityDocument

func (q *Queries) StoreInstanceIdentityDocument(ctx context.Context, arg StoreInstanceIdentityDocumentParams) (*AwsAttestation, error)

func (*Queries) UpdateInstanceIdentityNodeAttestor

func (q *Queries) UpdateInstanceIdentityNodeAttestor(ctx context.Context, arg UpdateInstanceIdentityNodeAttestorParams) (*Account, error)

func (*Queries) UpdateServiceAccount

func (q *Queries) UpdateServiceAccount(ctx context.Context, arg UpdateServiceAccountParams) (*Account, error)

func (*Queries) UpdateUserAuthentication

func (q *Queries) UpdateUserAuthentication(ctx context.Context, arg UpdateUserAuthenticationParams) (*User, error)

func (*Queries) UpdateUserPermission

func (q *Queries) UpdateUserPermission(ctx context.Context, arg UpdateUserPermissionParams) (*User, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type RevokeIssuedCertificateSerialNumberParams

type RevokeIssuedCertificateSerialNumberParams struct {
	SerialNumber string         `json:"serial_number"`
	RevokeDate   sql.NullTime   `json:"revoke_date"`
	RevokedBy    sql.NullString `json:"revoked_by"`
}

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

func (*SQLStore) TxCreateServiceAccount

func (store *SQLStore) TxCreateServiceAccount(ctx context.Context, arg CreateServiceAccountParams, iid StoreInstanceIdentityDocumentParams) (*Account, error)

func (*SQLStore) TxDeleteProvisionerAccount

func (store *SQLStore) TxDeleteProvisionerAccount(ctx context.Context, client_id uuid.UUID) error

func (*SQLStore) TxDeleteServiceAccount

func (store *SQLStore) TxDeleteServiceAccount(ctx context.Context, client_id uuid.UUID) error

func (*SQLStore) TxUpdateServiceAccount

func (store *SQLStore) TxUpdateServiceAccount(ctx context.Context, arg Account, attestation types.NodeAttestation) (*Account, error)

type ServiceAccountAttestation

type ServiceAccountAttestation struct {
	ServiceAccount Account        `json:"service_account"`
	AwsIid         AwsAttestation `json:"aws_iid"`
}

type Store

type Store interface {
	Querier
	TxCreateServiceAccount(ctx context.Context, arg CreateServiceAccountParams, iid StoreInstanceIdentityDocumentParams) (*Account, error)
	TxDeleteServiceAccount(ctx context.Context, client_id uuid.UUID) error
	TxUpdateServiceAccount(ctx context.Context, arg Account, attestation types.NodeAttestation) (*Account, error)
	TxCreateProvisionerAccount(ctx context.Context, arg CreateProvisionerAccountParams, iid StoreInstanceIdentityDocumentParams) (*Provisioner, error)
	TxDeleteProvisionerAccount(ctx context.Context, client_id uuid.UUID) error
}

func BuildDatastore

func BuildDatastore(db *sql.DB) Store

func BuildReadDatastore

func BuildReadDatastore(db *sql.DB) Store

type StoreInstanceIdentityDocumentParams

type StoreInstanceIdentityDocumentParams struct {
	ClientID        uuid.UUID             `json:"client_id"`
	RoleArn         sql.NullString        `json:"role_arn"`
	AssumeRole      sql.NullString        `json:"assume_role"`
	SecurityGroupID []string              `json:"security_group_id"`
	Region          sql.NullString        `json:"region"`
	InstanceID      sql.NullString        `json:"instance_id"`
	ImageID         sql.NullString        `json:"image_id"`
	InstanceTags    pqtype.NullRawMessage `json:"instance_tags"`
}

type UpdateInstanceIdentityNodeAttestorParams

type UpdateInstanceIdentityNodeAttestorParams struct {
	ClientID        uuid.UUID `json:"client_id"`
	NodeAttestation []string  `json:"node_attestation"`
}

type UpdateServiceAccountParams

type UpdateServiceAccountParams struct {
	ClientID                    uuid.UUID      `json:"client_id"`
	Environment                 string         `json:"environment"`
	Team                        string         `json:"team"`
	Email                       string         `json:"email"`
	RegularExpression           sql.NullString `json:"regular_expression"`
	ValidSubjectAlternateName   []string       `json:"valid_subject_alternate_name"`
	ValidCertificateAuthorities []string       `json:"valid_certificate_authorities"`
	ExtendedKey                 string         `json:"extended_key"`
	CertificateValidity         int16          `json:"certificate_validity"`
	SubordinateCa               string         `json:"subordinate_ca"`
	NodeAttestation             []string       `json:"node_attestation"`
}

type UpdateUserAuthenticationParams

type UpdateUserAuthenticationParams struct {
	Username         string `json:"username"`
	HashedCredential string `json:"hashed_credential"`
}

type UpdateUserPermissionParams

type UpdateUserPermissionParams struct {
	Username    string `json:"username"`
	Permissions string `json:"permissions"`
}

type User

type User struct {
	Uuid                uuid.UUID `json:"uuid"`
	Username            string    `json:"username"`
	HashedCredential    string    `json:"hashed_credential"`
	FullName            string    `json:"full_name"`
	Email               string    `json:"email"`
	Permissions         string    `json:"permissions"`
	CredentialChangedAt time.Time `json:"credential_changed_at"`
	CreatedAt           time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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