chore: Update sqlc to v1.16.0 (#5788)

* chore: Update sqlc to v1.16.0

* chore: Fix cases where types became Null-types

* chore: Set parameter_schemas default_destination_scheme and default_source_scheme to NOT NULL

* chore: Add enum validation to database fake

* chore: Fix all tests that skipping enum values

* fix: Use correct err in providionerdserver audit log failure log
This commit is contained in:
Mathias Fredriksson
2023-01-23 13:14:47 +02:00
committed by GitHub
parent f67acac2b7
commit 8afdf24d10
29 changed files with 1525 additions and 216 deletions

View File

@ -1,11 +1,12 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.13.0
// sqlc v1.16.0
package database
import (
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
"time"
@ -35,6 +36,45 @@ func (e *APIKeyScope) Scan(src interface{}) error {
return nil
}
type NullAPIKeyScope struct {
APIKeyScope APIKeyScope
Valid bool // Valid is true if APIKeyScope is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAPIKeyScope) Scan(value interface{}) error {
if value == nil {
ns.APIKeyScope, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.APIKeyScope.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAPIKeyScope) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.APIKeyScope, nil
}
func (e APIKeyScope) Valid() bool {
switch e {
case APIKeyScopeAll,
APIKeyScopeApplicationConnect:
return true
}
return false
}
func AllAPIKeyScopeValues() []APIKeyScope {
return []APIKeyScope{
APIKeyScopeAll,
APIKeyScopeApplicationConnect,
}
}
type AppSharingLevel string
const (
@ -55,6 +95,47 @@ func (e *AppSharingLevel) Scan(src interface{}) error {
return nil
}
type NullAppSharingLevel struct {
AppSharingLevel AppSharingLevel
Valid bool // Valid is true if AppSharingLevel is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAppSharingLevel) Scan(value interface{}) error {
if value == nil {
ns.AppSharingLevel, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AppSharingLevel.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAppSharingLevel) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.AppSharingLevel, nil
}
func (e AppSharingLevel) Valid() bool {
switch e {
case AppSharingLevelOwner,
AppSharingLevelAuthenticated,
AppSharingLevelPublic:
return true
}
return false
}
func AllAppSharingLevelValues() []AppSharingLevel {
return []AppSharingLevel{
AppSharingLevelOwner,
AppSharingLevelAuthenticated,
AppSharingLevelPublic,
}
}
type AuditAction string
const (
@ -77,6 +158,51 @@ func (e *AuditAction) Scan(src interface{}) error {
return nil
}
type NullAuditAction struct {
AuditAction AuditAction
Valid bool // Valid is true if AuditAction is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAuditAction) Scan(value interface{}) error {
if value == nil {
ns.AuditAction, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AuditAction.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAuditAction) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.AuditAction, nil
}
func (e AuditAction) Valid() bool {
switch e {
case AuditActionCreate,
AuditActionWrite,
AuditActionDelete,
AuditActionStart,
AuditActionStop:
return true
}
return false
}
func AllAuditActionValues() []AuditAction {
return []AuditAction{
AuditActionCreate,
AuditActionWrite,
AuditActionDelete,
AuditActionStart,
AuditActionStop,
}
}
type BuildReason string
const (
@ -97,6 +223,47 @@ func (e *BuildReason) Scan(src interface{}) error {
return nil
}
type NullBuildReason struct {
BuildReason BuildReason
Valid bool // Valid is true if BuildReason is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullBuildReason) Scan(value interface{}) error {
if value == nil {
ns.BuildReason, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.BuildReason.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullBuildReason) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.BuildReason, nil
}
func (e BuildReason) Valid() bool {
switch e {
case BuildReasonInitiator,
BuildReasonAutostart,
BuildReasonAutostop:
return true
}
return false
}
func AllBuildReasonValues() []BuildReason {
return []BuildReason{
BuildReasonInitiator,
BuildReasonAutostart,
BuildReasonAutostop,
}
}
type LogLevel string
const (
@ -119,6 +286,51 @@ func (e *LogLevel) Scan(src interface{}) error {
return nil
}
type NullLogLevel struct {
LogLevel LogLevel
Valid bool // Valid is true if LogLevel is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullLogLevel) Scan(value interface{}) error {
if value == nil {
ns.LogLevel, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.LogLevel.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullLogLevel) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.LogLevel, nil
}
func (e LogLevel) Valid() bool {
switch e {
case LogLevelTrace,
LogLevelDebug,
LogLevelInfo,
LogLevelWarn,
LogLevelError:
return true
}
return false
}
func AllLogLevelValues() []LogLevel {
return []LogLevel{
LogLevelTrace,
LogLevelDebug,
LogLevelInfo,
LogLevelWarn,
LogLevelError,
}
}
type LogSource string
const (
@ -138,6 +350,45 @@ func (e *LogSource) Scan(src interface{}) error {
return nil
}
type NullLogSource struct {
LogSource LogSource
Valid bool // Valid is true if LogSource is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullLogSource) Scan(value interface{}) error {
if value == nil {
ns.LogSource, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.LogSource.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullLogSource) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.LogSource, nil
}
func (e LogSource) Valid() bool {
switch e {
case LogSourceProvisionerDaemon,
LogSourceProvisioner:
return true
}
return false
}
func AllLogSourceValues() []LogSource {
return []LogSource{
LogSourceProvisionerDaemon,
LogSourceProvisioner,
}
}
type LoginType string
const (
@ -159,6 +410,49 @@ func (e *LoginType) Scan(src interface{}) error {
return nil
}
type NullLoginType struct {
LoginType LoginType
Valid bool // Valid is true if LoginType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullLoginType) Scan(value interface{}) error {
if value == nil {
ns.LoginType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.LoginType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullLoginType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.LoginType, nil
}
func (e LoginType) Valid() bool {
switch e {
case LoginTypePassword,
LoginTypeGithub,
LoginTypeOIDC,
LoginTypeToken:
return true
}
return false
}
func AllLoginTypeValues() []LoginType {
return []LoginType{
LoginTypePassword,
LoginTypeGithub,
LoginTypeOIDC,
LoginTypeToken,
}
}
type ParameterDestinationScheme string
const (
@ -179,6 +473,47 @@ func (e *ParameterDestinationScheme) Scan(src interface{}) error {
return nil
}
type NullParameterDestinationScheme struct {
ParameterDestinationScheme ParameterDestinationScheme
Valid bool // Valid is true if ParameterDestinationScheme is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullParameterDestinationScheme) Scan(value interface{}) error {
if value == nil {
ns.ParameterDestinationScheme, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ParameterDestinationScheme.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullParameterDestinationScheme) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ParameterDestinationScheme, nil
}
func (e ParameterDestinationScheme) Valid() bool {
switch e {
case ParameterDestinationSchemeNone,
ParameterDestinationSchemeEnvironmentVariable,
ParameterDestinationSchemeProvisionerVariable:
return true
}
return false
}
func AllParameterDestinationSchemeValues() []ParameterDestinationScheme {
return []ParameterDestinationScheme{
ParameterDestinationSchemeNone,
ParameterDestinationSchemeEnvironmentVariable,
ParameterDestinationSchemeProvisionerVariable,
}
}
type ParameterScope string
const (
@ -199,6 +534,47 @@ func (e *ParameterScope) Scan(src interface{}) error {
return nil
}
type NullParameterScope struct {
ParameterScope ParameterScope
Valid bool // Valid is true if ParameterScope is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullParameterScope) Scan(value interface{}) error {
if value == nil {
ns.ParameterScope, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ParameterScope.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullParameterScope) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ParameterScope, nil
}
func (e ParameterScope) Valid() bool {
switch e {
case ParameterScopeTemplate,
ParameterScopeImportJob,
ParameterScopeWorkspace:
return true
}
return false
}
func AllParameterScopeValues() []ParameterScope {
return []ParameterScope{
ParameterScopeTemplate,
ParameterScopeImportJob,
ParameterScopeWorkspace,
}
}
type ParameterSourceScheme string
const (
@ -218,6 +594,45 @@ func (e *ParameterSourceScheme) Scan(src interface{}) error {
return nil
}
type NullParameterSourceScheme struct {
ParameterSourceScheme ParameterSourceScheme
Valid bool // Valid is true if ParameterSourceScheme is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullParameterSourceScheme) Scan(value interface{}) error {
if value == nil {
ns.ParameterSourceScheme, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ParameterSourceScheme.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullParameterSourceScheme) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ParameterSourceScheme, nil
}
func (e ParameterSourceScheme) Valid() bool {
switch e {
case ParameterSourceSchemeNone,
ParameterSourceSchemeData:
return true
}
return false
}
func AllParameterSourceSchemeValues() []ParameterSourceScheme {
return []ParameterSourceScheme{
ParameterSourceSchemeNone,
ParameterSourceSchemeData,
}
}
type ParameterTypeSystem string
const (
@ -237,6 +652,45 @@ func (e *ParameterTypeSystem) Scan(src interface{}) error {
return nil
}
type NullParameterTypeSystem struct {
ParameterTypeSystem ParameterTypeSystem
Valid bool // Valid is true if ParameterTypeSystem is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullParameterTypeSystem) Scan(value interface{}) error {
if value == nil {
ns.ParameterTypeSystem, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ParameterTypeSystem.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullParameterTypeSystem) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ParameterTypeSystem, nil
}
func (e ParameterTypeSystem) Valid() bool {
switch e {
case ParameterTypeSystemNone,
ParameterTypeSystemHCL:
return true
}
return false
}
func AllParameterTypeSystemValues() []ParameterTypeSystem {
return []ParameterTypeSystem{
ParameterTypeSystemNone,
ParameterTypeSystemHCL,
}
}
type ProvisionerJobType string
const (
@ -257,6 +711,47 @@ func (e *ProvisionerJobType) Scan(src interface{}) error {
return nil
}
type NullProvisionerJobType struct {
ProvisionerJobType ProvisionerJobType
Valid bool // Valid is true if ProvisionerJobType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullProvisionerJobType) Scan(value interface{}) error {
if value == nil {
ns.ProvisionerJobType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ProvisionerJobType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullProvisionerJobType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ProvisionerJobType, nil
}
func (e ProvisionerJobType) Valid() bool {
switch e {
case ProvisionerJobTypeTemplateVersionImport,
ProvisionerJobTypeWorkspaceBuild,
ProvisionerJobTypeTemplateVersionDryRun:
return true
}
return false
}
func AllProvisionerJobTypeValues() []ProvisionerJobType {
return []ProvisionerJobType{
ProvisionerJobTypeTemplateVersionImport,
ProvisionerJobTypeWorkspaceBuild,
ProvisionerJobTypeTemplateVersionDryRun,
}
}
type ProvisionerStorageMethod string
const (
@ -275,6 +770,43 @@ func (e *ProvisionerStorageMethod) Scan(src interface{}) error {
return nil
}
type NullProvisionerStorageMethod struct {
ProvisionerStorageMethod ProvisionerStorageMethod
Valid bool // Valid is true if ProvisionerStorageMethod is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullProvisionerStorageMethod) Scan(value interface{}) error {
if value == nil {
ns.ProvisionerStorageMethod, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ProvisionerStorageMethod.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullProvisionerStorageMethod) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ProvisionerStorageMethod, nil
}
func (e ProvisionerStorageMethod) Valid() bool {
switch e {
case ProvisionerStorageMethodFile:
return true
}
return false
}
func AllProvisionerStorageMethodValues() []ProvisionerStorageMethod {
return []ProvisionerStorageMethod{
ProvisionerStorageMethodFile,
}
}
type ProvisionerType string
const (
@ -294,6 +826,45 @@ func (e *ProvisionerType) Scan(src interface{}) error {
return nil
}
type NullProvisionerType struct {
ProvisionerType ProvisionerType
Valid bool // Valid is true if ProvisionerType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullProvisionerType) Scan(value interface{}) error {
if value == nil {
ns.ProvisionerType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ProvisionerType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullProvisionerType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ProvisionerType, nil
}
func (e ProvisionerType) Valid() bool {
switch e {
case ProvisionerTypeEcho,
ProvisionerTypeTerraform:
return true
}
return false
}
func AllProvisionerTypeValues() []ProvisionerType {
return []ProvisionerType{
ProvisionerTypeEcho,
ProvisionerTypeTerraform,
}
}
type ResourceType string
const (
@ -320,6 +891,59 @@ func (e *ResourceType) Scan(src interface{}) error {
return nil
}
type NullResourceType struct {
ResourceType ResourceType
Valid bool // Valid is true if ResourceType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullResourceType) Scan(value interface{}) error {
if value == nil {
ns.ResourceType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ResourceType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullResourceType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.ResourceType, nil
}
func (e ResourceType) Valid() bool {
switch e {
case ResourceTypeOrganization,
ResourceTypeTemplate,
ResourceTypeTemplateVersion,
ResourceTypeUser,
ResourceTypeWorkspace,
ResourceTypeGitSshKey,
ResourceTypeApiKey,
ResourceTypeGroup,
ResourceTypeWorkspaceBuild:
return true
}
return false
}
func AllResourceTypeValues() []ResourceType {
return []ResourceType{
ResourceTypeOrganization,
ResourceTypeTemplate,
ResourceTypeTemplateVersion,
ResourceTypeUser,
ResourceTypeWorkspace,
ResourceTypeGitSshKey,
ResourceTypeApiKey,
ResourceTypeGroup,
ResourceTypeWorkspaceBuild,
}
}
type UserStatus string
const (
@ -339,6 +963,45 @@ func (e *UserStatus) Scan(src interface{}) error {
return nil
}
type NullUserStatus struct {
UserStatus UserStatus
Valid bool // Valid is true if UserStatus is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullUserStatus) Scan(value interface{}) error {
if value == nil {
ns.UserStatus, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.UserStatus.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullUserStatus) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.UserStatus, nil
}
func (e UserStatus) Valid() bool {
switch e {
case UserStatusActive,
UserStatusSuspended:
return true
}
return false
}
func AllUserStatusValues() []UserStatus {
return []UserStatus{
UserStatusActive,
UserStatusSuspended,
}
}
type WorkspaceAppHealth string
const (
@ -360,6 +1023,49 @@ func (e *WorkspaceAppHealth) Scan(src interface{}) error {
return nil
}
type NullWorkspaceAppHealth struct {
WorkspaceAppHealth WorkspaceAppHealth
Valid bool // Valid is true if WorkspaceAppHealth is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullWorkspaceAppHealth) Scan(value interface{}) error {
if value == nil {
ns.WorkspaceAppHealth, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.WorkspaceAppHealth.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullWorkspaceAppHealth) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.WorkspaceAppHealth, nil
}
func (e WorkspaceAppHealth) Valid() bool {
switch e {
case WorkspaceAppHealthDisabled,
WorkspaceAppHealthInitializing,
WorkspaceAppHealthHealthy,
WorkspaceAppHealthUnhealthy:
return true
}
return false
}
func AllWorkspaceAppHealthValues() []WorkspaceAppHealth {
return []WorkspaceAppHealth{
WorkspaceAppHealthDisabled,
WorkspaceAppHealthInitializing,
WorkspaceAppHealthHealthy,
WorkspaceAppHealthUnhealthy,
}
}
type WorkspaceTransition string
const (
@ -380,6 +1086,47 @@ func (e *WorkspaceTransition) Scan(src interface{}) error {
return nil
}
type NullWorkspaceTransition struct {
WorkspaceTransition WorkspaceTransition
Valid bool // Valid is true if WorkspaceTransition is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullWorkspaceTransition) Scan(value interface{}) error {
if value == nil {
ns.WorkspaceTransition, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.WorkspaceTransition.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullWorkspaceTransition) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return ns.WorkspaceTransition, nil
}
func (e WorkspaceTransition) Valid() bool {
switch e {
case WorkspaceTransitionStart,
WorkspaceTransitionStop,
WorkspaceTransitionDelete:
return true
}
return false
}
func AllWorkspaceTransitionValues() []WorkspaceTransition {
return []WorkspaceTransition{
WorkspaceTransitionStart,
WorkspaceTransitionStop,
WorkspaceTransitionDelete,
}
}
type APIKey struct {
ID string `db:"id" json:"id"`
// hashed_secret contains a SHA256 hash of the key secret. This is considered a secret and MUST NOT be returned from the API as it is used for API key encryption in app proxying code.