pgxtenants

package
v0.0.0-test-multiarch Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTenantZones

func AddTenantZones(ctx context.Context, tx pgx.Tx, tenantID string, zones []string) error

AddTenantZones will store an association between the given tenant and a set of zones. Will fail if the tenant doesn't exist.

func CreateTenant

func CreateTenant(ctx context.Context, tx pgx.Tx, title string) (*gen.Tenant, error)

CreateTenant registers a new tenant in the database. The tenant has an autogenerated ID. The new tenant has no zones assigned.

func CreateTenantSecret

func CreateTenantSecret(ctx context.Context, tx pgx.Tx, secret *gen.Secret) (*gen.Secret, error)

CreateTenantSecret adds a tenant secret to the database. Only the fields TenantID, Name, SecretHash and Expires will be used from secret. Returns the newly created tenant secret row.

func DeleteTenant

func DeleteTenant(ctx context.Context, tx pgx.Tx, id string) error

func DeleteTenantSecret

func DeleteTenantSecret(ctx context.Context, tx pgx.Tx, secretID string) error

func GetTenant

func GetTenant(ctx context.Context, tx pgx.Tx, id string) (*gen.Tenant, error)

func GetTenantSecret

func GetTenantSecret(ctx context.Context, tx pgx.Tx, id string) (*gen.Secret, error)

GetTenantSecret returns a gen.Secret by secret id.

func ListTenantSecrets

func ListTenantSecrets(ctx context.Context, tx pgx.Tx, tenantID string) ([]*gen.Secret, error)

ListTenantSecrets returns all tenant secrets stored in the database. If tenantID is non-empty, then only secrets associated with that tenant will be returned. If tenantID is empty then secrets from all tenants are returned.

func ListTenants

func ListTenants(ctx context.Context, tx pgx.Tx) ([]*gen.Tenant, error)

func RemoveTenantZones

func RemoveTenantZones(ctx context.Context, tx pgx.Tx, tenantID string, zones []string) error

func ReplaceTenantZones

func ReplaceTenantZones(ctx context.Context, tx pgx.Tx, tenantID string, zones []string) error

func SetupDB

func SetupDB(ctx context.Context, pool *pgxpool.Pool) error

func UpdateTenantTitle

func UpdateTenantTitle(ctx context.Context, tx pgx.Tx, id string, title string) error

Types

type Option

type Option func(server *Server)

func WithLogger

func WithLogger(logger *zap.Logger) Option

type Server

type Server struct {
	gen.UnimplementedTenantApiServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, connStr string) (*Server, error)

func NewServerFromPool

func NewServerFromPool(ctx context.Context, pool *pgxpool.Pool, opts ...Option) (*Server, error)

func (*Server) AddTenantZones

func (s *Server) AddTenantZones(ctx context.Context, request *gen.AddTenantZonesRequest) (*gen.Tenant, error)

func (*Server) CreateSecret

func (s *Server) CreateSecret(ctx context.Context, request *gen.CreateSecretRequest) (*gen.Secret, error)

func (*Server) CreateTenant

func (s *Server) CreateTenant(ctx context.Context, request *gen.CreateTenantRequest) (*gen.Tenant, error)

func (*Server) DeleteSecret

func (s *Server) DeleteSecret(ctx context.Context, request *gen.DeleteSecretRequest) (*gen.DeleteSecretResponse, error)

func (*Server) DeleteTenant

func (s *Server) DeleteTenant(ctx context.Context, request *gen.DeleteTenantRequest) (*gen.DeleteTenantResponse, error)

func (*Server) GetSecret

func (s *Server) GetSecret(ctx context.Context, request *gen.GetSecretRequest) (*gen.Secret, error)

func (*Server) GetTenant

func (s *Server) GetTenant(ctx context.Context, request *gen.GetTenantRequest) (*gen.Tenant, error)

func (*Server) ListSecrets

func (s *Server) ListSecrets(ctx context.Context, request *gen.ListSecretsRequest) (*gen.ListSecretsResponse, error)

func (*Server) ListTenants

func (s *Server) ListTenants(ctx context.Context, request *gen.ListTenantsRequest) (*gen.ListTenantsResponse, error)

func (*Server) PullSecret

func (s *Server) PullSecret(request *gen.PullSecretRequest, server gen.TenantApi_PullSecretServer) error

func (*Server) PullSecrets

func (s *Server) PullSecrets(request *gen.PullSecretsRequest, server gen.TenantApi_PullSecretsServer) error

func (*Server) PullTenant

func (s *Server) PullTenant(request *gen.PullTenantRequest, server gen.TenantApi_PullTenantServer) error

func (*Server) PullTenants

func (s *Server) PullTenants(request *gen.PullTenantsRequest, server gen.TenantApi_PullTenantsServer) error

func (*Server) RegenerateSecret

func (s *Server) RegenerateSecret(ctx context.Context, request *gen.RegenerateSecretRequest) (*gen.Secret, error)

func (*Server) RemoveTenantZones

func (s *Server) RemoveTenantZones(ctx context.Context, request *gen.RemoveTenantZonesRequest) (*gen.Tenant, error)

func (*Server) UpdateSecret

func (s *Server) UpdateSecret(ctx context.Context, request *gen.UpdateSecretRequest) (*gen.Secret, error)

func (*Server) UpdateTenant

func (s *Server) UpdateTenant(ctx context.Context, request *gen.UpdateTenantRequest) (*gen.Tenant, error)

func (*Server) VerifySecret

func (s *Server) VerifySecret(ctx context.Context, request *gen.VerifySecretRequest) (*gen.Secret, error)

Jump to

Keyboard shortcuts

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