mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
ci: Update golangci-lint to v2 and fix highlighted issues. (#26334)
This commit is contained in:
@@ -156,7 +156,7 @@ func (a *Agent) Members() (*ServerMembers, error) {
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Members is used to query all of the known server members
|
||||
// MembersOpts is used to query all of the known server members
|
||||
// with the ability to set QueryOptions
|
||||
func (a *Agent) MembersOpts(opts *QueryOptions) (*ServerMembers, error) {
|
||||
var resp *ServerMembers
|
||||
|
||||
22
api/csi.go
22
api/csi.go
@@ -102,10 +102,11 @@ func (v *CSIVolumes) Create(vol *CSIVolume, w *WriteOptions) ([]*CSIVolume, *Wri
|
||||
return resp.Volumes, meta, err
|
||||
}
|
||||
|
||||
// DEPRECATED: will be removed in Nomad 1.4.0
|
||||
// Delete deletes a CSI volume from an external storage provider. The ID
|
||||
// passed as an argument here is for the storage provider's ID, so a volume
|
||||
// that's already been deregistered can be deleted.
|
||||
//
|
||||
// Deprecated: will be removed in Nomad 1.4.0
|
||||
func (v *CSIVolumes) Delete(externalVolID string, w *WriteOptions) error {
|
||||
_, err := v.client.delete(fmt.Sprintf("/v1/volume/csi/%v/delete", url.PathEscape(externalVolID)), nil, nil, w)
|
||||
return err
|
||||
@@ -184,8 +185,9 @@ func (v *CSIVolumes) ListSnapshotsOpts(req *CSISnapshotListRequest) (*CSISnapsho
|
||||
return resp, qm, nil
|
||||
}
|
||||
|
||||
// DEPRECATED: will be removed in Nomad 1.4.0
|
||||
// ListSnapshots lists external storage volume snapshots.
|
||||
//
|
||||
// Deprecated: will be removed in Nomad 1.4.0
|
||||
func (v *CSIVolumes) ListSnapshots(pluginID string, secrets string, q *QueryOptions) (*CSISnapshotListResponse, *QueryMeta, error) {
|
||||
var resp *CSISnapshotListResponse
|
||||
|
||||
@@ -269,26 +271,26 @@ func (o *CSIMountOptions) Merge(p *CSIMountOptions) {
|
||||
// API or in Nomad's logs.
|
||||
type CSISecrets map[string]string
|
||||
|
||||
func (q *QueryOptions) SetHeadersFromCSISecrets(secrets CSISecrets) {
|
||||
func (o *QueryOptions) SetHeadersFromCSISecrets(secrets CSISecrets) {
|
||||
pairs := []string{}
|
||||
for k, v := range secrets {
|
||||
pairs = append(pairs, fmt.Sprintf("%v=%v", k, v))
|
||||
}
|
||||
if q.Headers == nil {
|
||||
q.Headers = map[string]string{}
|
||||
if o.Headers == nil {
|
||||
o.Headers = map[string]string{}
|
||||
}
|
||||
q.Headers["X-Nomad-CSI-Secrets"] = strings.Join(pairs, ",")
|
||||
o.Headers["X-Nomad-CSI-Secrets"] = strings.Join(pairs, ",")
|
||||
}
|
||||
|
||||
func (w *WriteOptions) SetHeadersFromCSISecrets(secrets CSISecrets) {
|
||||
func (o *WriteOptions) SetHeadersFromCSISecrets(secrets CSISecrets) {
|
||||
pairs := []string{}
|
||||
for k, v := range secrets {
|
||||
pairs = append(pairs, fmt.Sprintf("%v=%v", k, v))
|
||||
}
|
||||
if w.Headers == nil {
|
||||
w.Headers = map[string]string{}
|
||||
if o.Headers == nil {
|
||||
o.Headers = map[string]string{}
|
||||
}
|
||||
w.Headers["X-Nomad-CSI-Secrets"] = strings.Join(pairs, ",")
|
||||
o.Headers["X-Nomad-CSI-Secrets"] = strings.Join(pairs, ",")
|
||||
}
|
||||
|
||||
// CSIVolume is used for serialization, see also nomad/structs/csi.go
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Checks the current executable, then $GOPATH/bin, and finally the CWD, in that
|
||||
// order. If it can't be found, an error is returned.
|
||||
// NomadExecutable checks the current executable, then $GOPATH/bin, and finally
|
||||
// the CWD, in that order. If it can't be found, an error is returned.
|
||||
func NomadExecutable() (string, error) {
|
||||
nomadExe := "nomad"
|
||||
if runtime.GOOS == "windows" {
|
||||
|
||||
@@ -176,7 +176,7 @@ func (j *Jobs) List(q *QueryOptions) ([]*JobListStub, *QueryMeta, error) {
|
||||
return j.ListOptions(nil, q)
|
||||
}
|
||||
|
||||
// List is used to list all of the existing jobs.
|
||||
// ListOptions is used to list all of the existing jobs.
|
||||
func (j *Jobs) ListOptions(opts *JobListOptions, q *QueryOptions) ([]*JobListStub, *QueryMeta, error) {
|
||||
var resp []*JobListStub
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ func (n *Nodes) UpdateDrain(nodeID string, spec *DrainSpec, markEligible bool, q
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// UpdateDrainWithMeta is used to update the drain strategy for a given node. If
|
||||
// UpdateDrainOpts is used to update the drain strategy for a given node. If
|
||||
// markEligible is true and the drain is being removed, the node will be marked
|
||||
// as having its scheduling being eligible
|
||||
func (n *Nodes) UpdateDrainOpts(nodeID string, opts *DrainOptions, q *WriteOptions) (*NodeDrainUpdateResponse,
|
||||
@@ -478,7 +478,7 @@ func (n *Nodes) GC(nodeID string, q *QueryOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO Add tests
|
||||
// GcAlloc - TODO Add tests
|
||||
func (n *Nodes) GcAlloc(allocID string, q *QueryOptions) error {
|
||||
path := fmt.Sprintf("/v1/client/allocation/%s/gc", allocID)
|
||||
_, err := n.client.query(path, nil, q)
|
||||
|
||||
@@ -51,7 +51,7 @@ func (q *Quotas) ListUsage(qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error)
|
||||
return resp, qm, nil
|
||||
}
|
||||
|
||||
// PrefixList is used to do a PrefixList search over quota usages
|
||||
// PrefixListUsage is used to do a PrefixList search over quota usages
|
||||
func (q *Quotas) PrefixListUsage(prefix string, qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
|
||||
if qo == nil {
|
||||
qo = &QueryOptions{Prefix: prefix}
|
||||
|
||||
@@ -181,8 +181,10 @@ type NetworkResource struct {
|
||||
CNI *CNIConfig `hcl:"cni,block"`
|
||||
}
|
||||
|
||||
// Megabits should not be used.
|
||||
//
|
||||
// COMPAT(0.13)
|
||||
// XXX Deprecated. Please do not use. The method will be removed in Nomad
|
||||
// Deprecated. Please do not use. The method will be removed in Nomad
|
||||
// 0.13 and is only being kept to allow any references to be removed before
|
||||
// then.
|
||||
func (n *NetworkResource) Megabits() int {
|
||||
|
||||
20
api/tasks.go
20
api/tasks.go
@@ -310,14 +310,14 @@ func (r *ReschedulePolicy) Copy() *ReschedulePolicy {
|
||||
return nrp
|
||||
}
|
||||
|
||||
func (p *ReschedulePolicy) String() string {
|
||||
if p == nil {
|
||||
func (r *ReschedulePolicy) String() string {
|
||||
if r == nil {
|
||||
return ""
|
||||
}
|
||||
if *p.Unlimited {
|
||||
return fmt.Sprintf("unlimited with %v delay, max_delay = %v", *p.DelayFunction, *p.MaxDelay)
|
||||
if *r.Unlimited {
|
||||
return fmt.Sprintf("unlimited with %v delay, max_delay = %v", *r.DelayFunction, *r.MaxDelay)
|
||||
}
|
||||
return fmt.Sprintf("%v in %v with %v delay, max_delay = %v", *p.Attempts, *p.Interval, *p.DelayFunction, *p.MaxDelay)
|
||||
return fmt.Sprintf("%v in %v with %v delay, max_delay = %v", *r.Attempts, *r.Interval, *r.DelayFunction, *r.MaxDelay)
|
||||
}
|
||||
|
||||
// Spread is used to serialize task group allocation spread preferences
|
||||
@@ -664,7 +664,7 @@ func (g *TaskGroup) Constrain(c *Constraint) *TaskGroup {
|
||||
return g
|
||||
}
|
||||
|
||||
// AddMeta is used to add a meta k/v pair to a task group
|
||||
// SetMeta is used to add a meta k/v pair to a task group
|
||||
func (g *TaskGroup) SetMeta(key, val string) *TaskGroup {
|
||||
if g.Meta == nil {
|
||||
g.Meta = make(map[string]string)
|
||||
@@ -697,7 +697,7 @@ func (g *TaskGroup) AddSpread(s *Spread) *TaskGroup {
|
||||
return g
|
||||
}
|
||||
|
||||
// AddSpread is used to add a new spread preference to a task group.
|
||||
// ScalingPolicy is used to add a new scaling policy to a task group.
|
||||
func (g *TaskGroup) ScalingPolicy(sp *ScalingPolicy) *TaskGroup {
|
||||
g.Scaling = sp
|
||||
return g
|
||||
@@ -751,7 +751,7 @@ type TaskLifecycle struct {
|
||||
Sidecar bool `mapstructure:"sidecar" hcl:"sidecar,optional"`
|
||||
}
|
||||
|
||||
// Determine if lifecycle has user-input values
|
||||
// Empty determines if lifecycle has user-input values
|
||||
func (l *TaskLifecycle) Empty() bool {
|
||||
return l == nil
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ func NewTask(name, driver string) *Task {
|
||||
}
|
||||
}
|
||||
|
||||
// Configure is used to configure a single k/v pair on
|
||||
// SetConfig is used to configure a single k/v pair on
|
||||
// the task.
|
||||
func (t *Task) SetConfig(key string, val interface{}) *Task {
|
||||
if t.Config == nil {
|
||||
@@ -1073,7 +1073,7 @@ func (t *Task) Require(r *Resources) *Task {
|
||||
return t
|
||||
}
|
||||
|
||||
// Constraint adds a new constraints to a single task.
|
||||
// Constrain adds a new constraints to a single task.
|
||||
func (t *Task) Constrain(c *Constraint) *Task {
|
||||
t.Constraints = append(t.Constraints, c)
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user