mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 05:56:38 +08:00
73d8173018
Result: {"status":"keep","total_issues":9,"golint_canonicalheader":0,"golint_errname":0,"golint_errorlint":1,"golint_forcetypeassert":0,"golint_gosec":0,"golint_intrange":0,"golint_modernize":3,"golint_nilnil":3,"golint_perfsprint":0,"golint_prealloc":0,"golint_recvcheck":1,"golint_usestdlibvars":0,"golint_wastedassign":0,"golint_total":8,"eslint_problems":1,"eslint_errors":0,"eslint_warnings":1,"tsc_errors":0,"measure_s":45}
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// ConfigVersionSummary is the list view for config versions.
|
|
type ConfigVersionSummary struct {
|
|
ID string `json:"id" gorm:"-"`
|
|
Version string `json:"version" gorm:"primaryKey;column:version"`
|
|
Checksum string `json:"checksum"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedBy string `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// AfterFind hook for ConfigVersionSummary.
|
|
func (cvs *ConfigVersionSummary) AfterFind(_ *gorm.DB) (err error) {
|
|
cvs.ID = cvs.Version
|
|
return
|
|
}
|
|
|
|
// ConfigVersion stores a published OpenResty configuration snapshot.
|
|
type ConfigVersion struct {
|
|
ID string `json:"id" gorm:"-"`
|
|
Version string `json:"version" gorm:"primaryKey;size:32;not null"`
|
|
SnapshotJSON string `json:"snapshot_json" gorm:"type:text;not null"`
|
|
MainConfig string `json:"main_config" gorm:"type:text;not null;default:''"`
|
|
RenderedConfig string `json:"rendered_config" gorm:"type:text;not null"`
|
|
SupportFilesJSON string `json:"support_files_json" gorm:"type:text;not null;default:'[]'"`
|
|
Checksum string `json:"checksum" gorm:"size:64;not null"`
|
|
IsActive bool `json:"is_active" gorm:"not null;default:false;index"`
|
|
CreatedBy string `json:"created_by" gorm:"size:64;not null"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
|
}
|
|
|
|
// AfterFind hook for ConfigVersion.
|
|
func (cv *ConfigVersion) AfterFind(_ *gorm.DB) (err error) {
|
|
cv.ID = cv.Version
|
|
return
|
|
}
|
|
|
|
// AfterCreate hook for ConfigVersion.
|
|
func (cv *ConfigVersion) AfterCreate(_ *gorm.DB) (err error) {
|
|
cv.ID = cv.Version
|
|
return
|
|
}
|
|
|
|
// TableName returns the GORM table name.
|
|
func (*ConfigVersion) TableName() string {
|
|
return "of_config_versions"
|
|
}
|