Merge pull request #4401 from hashicorp/jefferai-linter-fixes
Fix linter warnings, parts 1 and 2
This commit is contained in:
91 files changed
+472
-411
No files matched your search
@@ -54,22 +54,22 @@ func allocDnsName() DnsName {
|
||||
}
|
||||
|
||||
// Clone an DnsName
|
||||
func (c *DnsName) Clone() *DnsName {
|
||||
cp := proto.Clone(c.DnsName)
|
||||
func (dn *DnsName) Clone() *DnsName {
|
||||
cp := proto.Clone(dn.DnsName)
|
||||
return &DnsName{
|
||||
DnsName: cp.(*store.DnsName),
|
||||
}
|
||||
}
|
||||
|
||||
// TableName returns the table name.
|
||||
func (c *DnsName) TableName() string {
|
||||
if c.tableName != "" {
|
||||
return c.tableName
|
||||
func (dn *DnsName) TableName() string {
|
||||
if dn.tableName != "" {
|
||||
return dn.tableName
|
||||
}
|
||||
return defaultDnsNameTableName
|
||||
}
|
||||
|
||||
// SetTableName sets the table name.
|
||||
func (c *DnsName) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
func (dn *DnsName) SetTableName(n string) {
|
||||
dn.tableName = n
|
||||
}
|
||||
@@ -59,22 +59,22 @@ func allocIpAddress() IpAddress {
|
||||
}
|
||||
|
||||
// Clone an IpAddress
|
||||
func (c *IpAddress) Clone() *IpAddress {
|
||||
cp := proto.Clone(c.IpAddress)
|
||||
func (ia *IpAddress) Clone() *IpAddress {
|
||||
cp := proto.Clone(ia.IpAddress)
|
||||
return &IpAddress{
|
||||
IpAddress: cp.(*store.IpAddress),
|
||||
}
|
||||
}
|
||||
|
||||
// TableName returns the table name.
|
||||
func (c *IpAddress) TableName() string {
|
||||
if c.tableName != "" {
|
||||
return c.tableName
|
||||
func (ia *IpAddress) TableName() string {
|
||||
if ia.tableName != "" {
|
||||
return ia.tableName
|
||||
}
|
||||
return defaultIpAddressTableName
|
||||
}
|
||||
|
||||
// SetTableName sets the table name.
|
||||
func (c *IpAddress) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
func (ia *IpAddress) SetTableName(n string) {
|
||||
ia.tableName = n
|
||||
}
|
||||
@@ -78,21 +78,21 @@ func (h *Host) GetAddress() string {
|
||||
}
|
||||
|
||||
// TableName returns the table name for the host set.
|
||||
func (s *Host) TableName() string {
|
||||
if s.tableName != "" {
|
||||
return s.tableName
|
||||
func (h Host) TableName() string {
|
||||
if h.tableName != "" {
|
||||
return h.tableName
|
||||
}
|
||||
return "host_plugin_host"
|
||||
}
|
||||
|
||||
// SetTableName sets the table name. If the caller attempts to
|
||||
// set the name to "" the name will be reset to the default name.
|
||||
func (s *Host) SetTableName(n string) {
|
||||
s.tableName = n
|
||||
func (h *Host) SetTableName(n string) {
|
||||
h.tableName = n
|
||||
}
|
||||
|
||||
// GetResourceType returns the resource type of the Host
|
||||
func (s *Host) GetResourceType() resource.Type {
|
||||
func (h Host) GetResourceType() resource.Type {
|
||||
return resource.Host
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func (r *OrphanedHostCleanupJob) Status() scheduler.JobStatus {
|
||||
// will be returned.
|
||||
func (r *OrphanedHostCleanupJob) Run(ctx context.Context) error {
|
||||
const op = "plugin.(OrphanedHostCleanupJob).Run"
|
||||
if !r.running.CAS(r.running.Load(), true) {
|
||||
if !r.running.CompareAndSwap(r.running.Load(), true) {
|
||||
return errors.New(ctx, errors.JobAlreadyRunning, op, "job already running")
|
||||
}
|
||||
defer r.running.Store(false)
|
||||
|
||||
@@ -87,7 +87,7 @@ func (r *SetSyncJob) Status() scheduler.JobStatus {
|
||||
// will be returned.
|
||||
func (r *SetSyncJob) Run(ctx context.Context) error {
|
||||
const op = "plugin.(SetSyncJob).Run"
|
||||
if !r.running.CAS(r.running.Load(), true) {
|
||||
if !r.running.CompareAndSwap(r.running.Load(), true) {
|
||||
return errors.New(ctx, errors.JobAlreadyRunning, op, "job already running")
|
||||
}
|
||||
defer r.running.Store(false)
|
||||
|
||||
@@ -745,11 +745,11 @@ func (r *Repository) DeleteSet(ctx context.Context, projectId string, publicId s
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
_, err = plgClient.OnDeleteSet(ctx, &plgpb.OnDeleteSetRequest{Catalog: plgHc, Persisted: p, Set: plgHs})
|
||||
if err != nil {
|
||||
// Even if the plugin returns an error, we ignore it and proceed
|
||||
// with deleting the set.
|
||||
}
|
||||
// Even if the plugin returns an error, we ignore it and proceed with
|
||||
// deleting the set, hence we don't check the error here. This is because we
|
||||
// may get errors from the plugin that we can't do anything about (say, it's
|
||||
// already deleted) and we still want to delete the set from the database.
|
||||
_, _ = plgClient.OnDeleteSet(ctx, &plgpb.OnDeleteSetRequest{Catalog: plgHc, Persisted: p, Set: plgHs})
|
||||
|
||||
oplogWrapper, err := r.kms.GetWrapper(ctx, projectId, kms.KeyPurposeOplog)
|
||||
if err != nil {
|
||||
|
||||
@@ -69,22 +69,22 @@ func AllocPreferredEndpoint() *PreferredEndpoint {
|
||||
}
|
||||
|
||||
// Clone a PreferredEndpoint
|
||||
func (c *PreferredEndpoint) Clone() *PreferredEndpoint {
|
||||
cp := proto.Clone(c.PreferredEndpoint)
|
||||
func (pe *PreferredEndpoint) Clone() *PreferredEndpoint {
|
||||
cp := proto.Clone(pe.PreferredEndpoint)
|
||||
return &PreferredEndpoint{
|
||||
PreferredEndpoint: cp.(*store.PreferredEndpoint),
|
||||
}
|
||||
}
|
||||
|
||||
// TableName returns the table name.
|
||||
func (c *PreferredEndpoint) TableName() string {
|
||||
if c.tableName != "" {
|
||||
return c.tableName
|
||||
func (pe *PreferredEndpoint) TableName() string {
|
||||
if pe.tableName != "" {
|
||||
return pe.tableName
|
||||
}
|
||||
return defaultPreferredEndpointTableName
|
||||
}
|
||||
|
||||
// SetTableName sets the table name.
|
||||
func (c *PreferredEndpoint) SetTableName(n string) {
|
||||
c.tableName = n
|
||||
func (pe *PreferredEndpoint) SetTableName(n string) {
|
||||
pe.tableName = n
|
||||
}
|
||||
Reference in new issue
Block a user