style(frontend): gofmt the apiserver and xcecli sources
Formatting only (gofmt -w on the 29 non-vendored, non-generated files gofmt -l reported); swag-generated apiserver/docs/docs.go left as is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b57ce6d6a9
commit
3615c7c0fb
29 changed files with 1280 additions and 1285 deletions
|
|
@ -7,46 +7,46 @@ import (
|
|||
|
||||
func TestClusterInfo_NewFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
name string
|
||||
cluster ClusterInfo
|
||||
field string
|
||||
field string
|
||||
want interface{}
|
||||
}{
|
||||
{
|
||||
name: "HeartbeatInterval field exists and serializes",
|
||||
name: "HeartbeatInterval field exists and serializes",
|
||||
cluster: ClusterInfo{ClusterName: "test", HeartbeatInterval: 30},
|
||||
field: "heartbeat_interval",
|
||||
want: float64(30),
|
||||
field: "heartbeat_interval",
|
||||
want: float64(30),
|
||||
},
|
||||
{
|
||||
name: "Vcpus field exists and serializes",
|
||||
name: "Vcpus field exists and serializes",
|
||||
cluster: ClusterInfo{ClusterName: "test", Vcpus: 16},
|
||||
field: "vcpus",
|
||||
want: float64(16),
|
||||
field: "vcpus",
|
||||
want: float64(16),
|
||||
},
|
||||
{
|
||||
name: "InactiveHeartbeatCount field exists and serializes",
|
||||
name: "InactiveHeartbeatCount field exists and serializes",
|
||||
cluster: ClusterInfo{ClusterName: "test", InactiveHeartbeatCount: 3},
|
||||
field: "inactive_heartbeat_count",
|
||||
want: float64(3),
|
||||
field: "inactive_heartbeat_count",
|
||||
want: float64(3),
|
||||
},
|
||||
{
|
||||
name: "HeartbeatInterval zero value serializes as 0 not omitted",
|
||||
name: "HeartbeatInterval zero value serializes as 0 not omitted",
|
||||
cluster: ClusterInfo{ClusterName: "test", HeartbeatInterval: 0, Vcpus: 0, InactiveHeartbeatCount: 0},
|
||||
field: "heartbeat_interval",
|
||||
want: float64(0),
|
||||
field: "heartbeat_interval",
|
||||
want: float64(0),
|
||||
},
|
||||
{
|
||||
name: "Vcpus zero value serializes as 0 not omitted",
|
||||
name: "Vcpus zero value serializes as 0 not omitted",
|
||||
cluster: ClusterInfo{ClusterName: "test", HeartbeatInterval: 0, Vcpus: 0, InactiveHeartbeatCount: 0},
|
||||
field: "vcpus",
|
||||
want: float64(0),
|
||||
field: "vcpus",
|
||||
want: float64(0),
|
||||
},
|
||||
{
|
||||
name: "InactiveHeartbeatCount zero value serializes as 0 not omitted",
|
||||
name: "InactiveHeartbeatCount zero value serializes as 0 not omitted",
|
||||
cluster: ClusterInfo{ClusterName: "test", HeartbeatInterval: 0, Vcpus: 0, InactiveHeartbeatCount: 0},
|
||||
field: "inactive_heartbeat_count",
|
||||
want: float64(0),
|
||||
field: "inactive_heartbeat_count",
|
||||
want: float64(0),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -122,4 +122,4 @@ func mapKeys(m map[string]interface{}) []string {
|
|||
keys = append(keys, k)
|
||||
}
|
||||
return keys
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
package models
|
||||
|
||||
const (
|
||||
CONTROL_JOB = 1
|
||||
CONTROL_HOST = 2
|
||||
CONTROL_QUEUE = 3
|
||||
CONTROL_CLUSTER = 4
|
||||
CONTROL_DEBUG = 5
|
||||
)
|
||||
|
||||
type ActionControl struct {
|
||||
TargetType int `json:"target_type"`
|
||||
ActionType int `json:"action_type"`
|
||||
Content Jsonb `json:"content"`
|
||||
SubmitTime int64 `json:"submit_time"`
|
||||
Submitter string `json:"submitter"`
|
||||
}
|
||||
package models
|
||||
|
||||
const (
|
||||
CONTROL_JOB = 1
|
||||
CONTROL_HOST = 2
|
||||
CONTROL_QUEUE = 3
|
||||
CONTROL_CLUSTER = 4
|
||||
CONTROL_DEBUG = 5
|
||||
)
|
||||
|
||||
type ActionControl struct {
|
||||
TargetType int `json:"target_type"`
|
||||
ActionType int `json:"action_type"`
|
||||
Content Jsonb `json:"content"`
|
||||
SubmitTime int64 `json:"submit_time"`
|
||||
Submitter string `json:"submitter"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ type HostInfo struct {
|
|||
NumSSusp int `json:"num_ssusp"`
|
||||
NumUSusp int `json:"num_ususp"`
|
||||
//NumRsv int `json:"num_rsv"`
|
||||
NumDone int `json:"num_done"`
|
||||
Topology string `json:"topology"` // JSONB
|
||||
SchedStop string `json:"sched_stop"` // JSONB
|
||||
NumDone int `json:"num_done"`
|
||||
Topology string `json:"topology"` // JSONB
|
||||
SchedStop string `json:"sched_stop"` // JSONB
|
||||
ResourceValues []ResourceDistributionInfo `json:"resource_values"` // per-worker resource values
|
||||
//RealLoad string `json:"real_load"` // JSONB
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ func TestHostStateStr(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -591,32 +591,32 @@ type ArrayJobInfo struct {
|
|||
}
|
||||
|
||||
type JobAdditionalFields struct {
|
||||
JobID int64 `json:"job_id"`
|
||||
SubmitUser string `json:"submit_user"`
|
||||
JobStatus int `json:"job_status"`
|
||||
JobID int64 `json:"job_id"`
|
||||
SubmitUser string `json:"submit_user"`
|
||||
JobStatus int `json:"job_status"`
|
||||
SubmitTime int64 `json:"submit_time"`
|
||||
FromHost string `json:"from_host"`
|
||||
ExecHosts string `json:"exec_hosts"`
|
||||
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
JobRusage Jsonb `json:"job_rusage"`
|
||||
MaxMem float64 `json:"max_mem"`
|
||||
AvgMem float64 `json:"avg_mem"`
|
||||
UsedMem float64 `json:"used_mem"`
|
||||
CPUTime int `json:"cpu_time"`
|
||||
PeakCPUTime int `json:"peak_cpu_time"`
|
||||
PeakCPUDuration float64 `json:"peak_cpu_duration"`
|
||||
MemEfficiency float64 `json:"mem_efficiency"` // Memory efficiency in percentage
|
||||
AvgCPUEfficiency float64 `json:"avg_cpu_efficiency"` // Average CPU efficiency in percentage
|
||||
PeakCPUEfficiency float64 `json:"peak_cpu_efficiency"` // Peak CPU efficiency in percentage
|
||||
NumHosts int `json:"num_hosts"` // Number of hosts used by the job
|
||||
FirstHost string `json:"first_host"` // First host where the job ran
|
||||
AllocSlot string `json:"alloc_slots"` // Allocated slot information
|
||||
PIDInfo Jsonb `json:"pid_info"`
|
||||
Pids []int `json:"pids"` // List of process IDs associated with the job
|
||||
Pgids []int `json:"pgids"` // List of process group IDs associated with the job
|
||||
InteractiveJobURL string `json:"interactive_job_url"`
|
||||
StartTime int64 `json:"start_time"`
|
||||
EndTime int64 `json:"end_time"`
|
||||
JobRusage Jsonb `json:"job_rusage"`
|
||||
MaxMem float64 `json:"max_mem"`
|
||||
AvgMem float64 `json:"avg_mem"`
|
||||
UsedMem float64 `json:"used_mem"`
|
||||
CPUTime int `json:"cpu_time"`
|
||||
PeakCPUTime int `json:"peak_cpu_time"`
|
||||
PeakCPUDuration float64 `json:"peak_cpu_duration"`
|
||||
MemEfficiency float64 `json:"mem_efficiency"` // Memory efficiency in percentage
|
||||
AvgCPUEfficiency float64 `json:"avg_cpu_efficiency"` // Average CPU efficiency in percentage
|
||||
PeakCPUEfficiency float64 `json:"peak_cpu_efficiency"` // Peak CPU efficiency in percentage
|
||||
NumHosts int `json:"num_hosts"` // Number of hosts used by the job
|
||||
FirstHost string `json:"first_host"` // First host where the job ran
|
||||
AllocSlot string `json:"alloc_slots"` // Allocated slot information
|
||||
PIDInfo Jsonb `json:"pid_info"`
|
||||
Pids []int `json:"pids"` // List of process IDs associated with the job
|
||||
Pgids []int `json:"pgids"` // List of process group IDs associated with the job
|
||||
InteractiveJobURL string `json:"interactive_job_url"`
|
||||
// CoreLimit/MemLimit: JobInfo has no equivalent field (these are
|
||||
// submission-time resource limits, not job-state fields), but xcecli's
|
||||
// JobFieldsMap accepts them as valid -o/-l display fields (bug-1674) --
|
||||
|
|
|
|||
|
|
@ -1,139 +1,139 @@
|
|||
package models
|
||||
|
||||
type ValueType int
|
||||
|
||||
const (
|
||||
STRING ValueType = iota // Bool value
|
||||
NUMERIC // Numeric value
|
||||
BOOLEAN // String value
|
||||
)
|
||||
|
||||
// String returns the string representation of ValueType
|
||||
func (v ValueType) String() string {
|
||||
switch v {
|
||||
case BOOLEAN:
|
||||
return "Boolean"
|
||||
case NUMERIC:
|
||||
return "Numeric"
|
||||
case STRING:
|
||||
return "String"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type OrderType int
|
||||
|
||||
const (
|
||||
INCR OrderType = iota
|
||||
DECR
|
||||
NA
|
||||
)
|
||||
|
||||
// String returns the string representation of OrderType
|
||||
func (o OrderType) String() string {
|
||||
switch o {
|
||||
case INCR:
|
||||
return "Incr"
|
||||
case DECR:
|
||||
return "Decr"
|
||||
case NA:
|
||||
return "NA"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
var RESOURCE_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"numeric_value",
|
||||
"location",
|
||||
"is_dynamic",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var ResourceFieldMappings = map[string]string{
|
||||
// API field name → struct field name
|
||||
"value": "numeric_value",
|
||||
}
|
||||
|
||||
var ResourcesAvailableTypes = []string{"static", "dynamic"}
|
||||
|
||||
const (
|
||||
BUILTIN = 0x01
|
||||
DYNAMIC = 0x02
|
||||
RELEASE = 0x20
|
||||
CONSUMABLE = 0x80
|
||||
)
|
||||
|
||||
type FlagValue int
|
||||
|
||||
// ToJSON returns the JSON object representation of FlagValue
|
||||
func (f FlagValue) ToJSON() map[string]bool {
|
||||
return map[string]bool{
|
||||
"builtin": f&BUILTIN != 0,
|
||||
"dynamic": f&DYNAMIC != 0,
|
||||
"release": f&RELEASE != 0,
|
||||
"consumable": f&CONSUMABLE != 0,
|
||||
}
|
||||
}
|
||||
|
||||
type ResourceInfo struct {
|
||||
ResName string
|
||||
Description string
|
||||
ValueType ValueType
|
||||
OrderType OrderType
|
||||
Flag int
|
||||
Interval int
|
||||
}
|
||||
|
||||
// queues info query supported filter
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
"is_dynamic",
|
||||
"location",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
}
|
||||
|
||||
type ResourceDistributionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
IsDynamic bool `json:"is_dynamic"`
|
||||
ValueType int `json:"value_type"`
|
||||
BooleanValue bool `json:"boolean_value"`
|
||||
StringValue string `json:"string_value"`
|
||||
NumericValue float64 `json:"numeric_value"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ResourceDefinitionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
Description string `json:"description"`
|
||||
ValueType int `json:"value_type"`
|
||||
OrderType int `json:"order_type"`
|
||||
Flag int `json:"flag"`
|
||||
Interval int `json:"interval"`
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_SORT = []string{
|
||||
"res_name",
|
||||
}
|
||||
package models
|
||||
|
||||
type ValueType int
|
||||
|
||||
const (
|
||||
STRING ValueType = iota // Bool value
|
||||
NUMERIC // Numeric value
|
||||
BOOLEAN // String value
|
||||
)
|
||||
|
||||
// String returns the string representation of ValueType
|
||||
func (v ValueType) String() string {
|
||||
switch v {
|
||||
case BOOLEAN:
|
||||
return "Boolean"
|
||||
case NUMERIC:
|
||||
return "Numeric"
|
||||
case STRING:
|
||||
return "String"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type OrderType int
|
||||
|
||||
const (
|
||||
INCR OrderType = iota
|
||||
DECR
|
||||
NA
|
||||
)
|
||||
|
||||
// String returns the string representation of OrderType
|
||||
func (o OrderType) String() string {
|
||||
switch o {
|
||||
case INCR:
|
||||
return "Incr"
|
||||
case DECR:
|
||||
return "Decr"
|
||||
case NA:
|
||||
return "NA"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
var RESOURCE_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"numeric_value",
|
||||
"location",
|
||||
"is_dynamic",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var ResourceFieldMappings = map[string]string{
|
||||
// API field name → struct field name
|
||||
"value": "numeric_value",
|
||||
}
|
||||
|
||||
var ResourcesAvailableTypes = []string{"static", "dynamic"}
|
||||
|
||||
const (
|
||||
BUILTIN = 0x01
|
||||
DYNAMIC = 0x02
|
||||
RELEASE = 0x20
|
||||
CONSUMABLE = 0x80
|
||||
)
|
||||
|
||||
type FlagValue int
|
||||
|
||||
// ToJSON returns the JSON object representation of FlagValue
|
||||
func (f FlagValue) ToJSON() map[string]bool {
|
||||
return map[string]bool{
|
||||
"builtin": f&BUILTIN != 0,
|
||||
"dynamic": f&DYNAMIC != 0,
|
||||
"release": f&RELEASE != 0,
|
||||
"consumable": f&CONSUMABLE != 0,
|
||||
}
|
||||
}
|
||||
|
||||
type ResourceInfo struct {
|
||||
ResName string
|
||||
Description string
|
||||
ValueType ValueType
|
||||
OrderType OrderType
|
||||
Flag int
|
||||
Interval int
|
||||
}
|
||||
|
||||
// queues info query supported filter
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
"is_dynamic",
|
||||
"location",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
}
|
||||
|
||||
type ResourceDistributionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
IsDynamic bool `json:"is_dynamic"`
|
||||
ValueType int `json:"value_type"`
|
||||
BooleanValue bool `json:"boolean_value"`
|
||||
StringValue string `json:"string_value"`
|
||||
NumericValue float64 `json:"numeric_value"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ResourceDefinitionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
Description string `json:"description"`
|
||||
ValueType int `json:"value_type"`
|
||||
OrderType int `json:"order_type"`
|
||||
Flag int `json:"flag"`
|
||||
Interval int `json:"interval"`
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_SORT = []string{
|
||||
"res_name",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue