Skip to content

Commit a492379

Browse files
committed
run 'make fix-golangci-lint'
Signed-off-by: Tim Ramlot <[email protected]>
1 parent db456d0 commit a492379

File tree

18 files changed

+181
-189
lines changed

18 files changed

+181
-189
lines changed

api/datareading.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ type DataReadingsPost struct {
2222
type DataReading struct {
2323
// ClusterID is optional as it can be inferred from the agent
2424
// token when using basic authentication.
25-
ClusterID string `json:"cluster_id,omitempty"`
26-
DataGatherer string `json:"data-gatherer"`
27-
Timestamp Time `json:"timestamp"`
28-
Data interface{} `json:"data"`
29-
SchemaVersion string `json:"schema_version"`
25+
ClusterID string `json:"cluster_id,omitempty"`
26+
DataGatherer string `json:"data-gatherer"`
27+
Timestamp Time `json:"timestamp"`
28+
Data any `json:"data"`
29+
SchemaVersion string `json:"schema_version"`
3030
}
3131

3232
// UnmarshalJSON implements the json.Unmarshaler interface for DataReading.
@@ -61,11 +61,11 @@ func (o *DataReading) UnmarshalJSON(data []byte) error {
6161

6262
// Define a list of decoding attempts with prioritized types
6363
dataTypes := []struct {
64-
target interface{}
65-
assign func(interface{})
64+
target any
65+
assign func(any)
6666
}{
67-
{&DiscoveryData{}, func(v interface{}) { o.Data = v.(*DiscoveryData) }},
68-
{&DynamicData{}, func(v interface{}) { o.Data = v.(*DynamicData) }},
67+
{&DiscoveryData{}, func(v any) { o.Data = v.(*DiscoveryData) }},
68+
{&DynamicData{}, func(v any) { o.Data = v.(*DynamicData) }},
6969
}
7070

7171
// Attempt to decode the Data field into each type
@@ -82,7 +82,7 @@ func (o *DataReading) UnmarshalJSON(data []byte) error {
8282

8383
// jsonUnmarshalStrict unmarshals JSON data into the provided interface,
8484
// disallowing unknown fields to ensure strict adherence to the expected structure.
85-
func jsonUnmarshalStrict(data []byte, v interface{}) error {
85+
func jsonUnmarshalStrict(data []byte, v any) error {
8686
decoder := json.NewDecoder(bytes.NewReader(data))
8787
decoder.DisallowUnknownFields()
8888
return decoder.Decode(v)
@@ -92,8 +92,8 @@ func jsonUnmarshalStrict(data []byte, v interface{}) error {
9292
type GatheredResource struct {
9393
// Resource is a reference to a k8s object that was found by the informer
9494
// should be of type unstructured.Unstructured, raw Object
95-
Resource interface{} `json:"resource"`
96-
DeletedAt Time `json:"deleted_at,omitempty"`
95+
Resource any `json:"resource"`
96+
DeletedAt Time `json:"deleted_at,omitempty"`
9797
}
9898

9999
func (v GatheredResource) MarshalJSON() ([]byte, error) {
@@ -103,8 +103,8 @@ func (v GatheredResource) MarshalJSON() ([]byte, error) {
103103
}
104104

105105
data := struct {
106-
Resource interface{} `json:"resource"`
107-
DeletedAt string `json:"deleted_at,omitempty"`
106+
Resource any `json:"resource"`
107+
DeletedAt string `json:"deleted_at,omitempty"`
108108
}{
109109
Resource: v.Resource,
110110
DeletedAt: dateString,

api/datareading_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestDataReading_UnmarshalJSON(t *testing.T) {
4343
tests := []struct {
4444
name string
4545
input string
46-
wantDataType interface{}
46+
wantDataType any
4747
expectError string
4848
}{
4949
{

internal/cyberark/servicediscovery/discovery.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ func New(httpClient *http.Client) *Client {
5858
// DiscoveryResponse represents the full JSON response returned by the CyberArk api/tenant-discovery/public API
5959
// The API is documented here https://ca-il-confluence.il.cyber-ark.com/spaces/EV/pages/575618345/Updated+PD+APIs+doc
6060
type DiscoveryResponse struct {
61-
Region string `json:"region"`
62-
DRRegion string `json:"dr_region"`
63-
Subdomain string `json:"subdomain"`
64-
TenantID string `json:"tenant_id"`
65-
PlatformID string `json:"platform_id"`
66-
IdentityID string `json:"identity_id"`
67-
DefaultURL string `json:"default_url"`
68-
TenantFlags map[string]interface{} `json:"tenant_flags"`
69-
Services []Service `json:"services"`
61+
Region string `json:"region"`
62+
DRRegion string `json:"dr_region"`
63+
Subdomain string `json:"subdomain"`
64+
TenantID string `json:"tenant_id"`
65+
PlatformID string `json:"platform_id"`
66+
IdentityID string `json:"identity_id"`
67+
DefaultURL string `json:"default_url"`
68+
TenantFlags map[string]any `json:"tenant_flags"`
69+
Services []Service `json:"services"`
7070
}
7171

7272
type Service struct {

pkg/agent/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ func getInClusterNamespace() (string, error) {
860860
return "", fmt.Errorf("POD_NAMESPACE env var not set, meaning that you are probably not running in cluster. Please use --install-namespace or POD_NAMESPACE to specify the namespace in which the agent is running.")
861861
}
862862

863-
func reMarshal(rawConfig interface{}, config datagatherer.Config) error {
863+
func reMarshal(rawConfig any, config datagatherer.Config) error {
864864
bb, err := yaml.Marshal(rawConfig)
865865
if err != nil {
866866
return nil
@@ -875,12 +875,12 @@ func reMarshal(rawConfig interface{}, config datagatherer.Config) error {
875875
}
876876

877877
// UnmarshalYAML unmarshals a dataGatherer resolving the type according to Kind.
878-
func (dg *DataGatherer) UnmarshalYAML(unmarshal func(interface{}) error) error {
878+
func (dg *DataGatherer) UnmarshalYAML(unmarshal func(any) error) error {
879879
aux := struct {
880-
Kind string `yaml:"kind"`
881-
Name string `yaml:"name"`
882-
DataPath string `yaml:"data-path,omitempty"`
883-
RawConfig interface{} `yaml:"config"`
880+
Kind string `yaml:"kind"`
881+
Name string `yaml:"name"`
882+
DataPath string `yaml:"data-path,omitempty"`
883+
RawConfig any `yaml:"config"`
884884
}{}
885885
err := unmarshal(&aux)
886886
if err != nil {

pkg/agent/dummy_data_gatherer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (g *dummyDataGatherer) WaitForCacheSync(ctx context.Context) error {
3939
return nil
4040
}
4141

42-
func (c *dummyDataGatherer) Fetch() (interface{}, int, error) {
42+
func (c *dummyDataGatherer) Fetch() (any, int, error) {
4343
var err error
4444
if c.attemptNumber < c.FailedAttempts {
4545
err = fmt.Errorf("First %d attempts will fail", c.FailedAttempts)

pkg/agent/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func newEventf(log logr.Logger) (Eventf, error) {
271271
"reason", "The agent does not appear to be running in a Kubernetes cluster.",
272272
"detail", "When running in a Kubernetes cluster the following environment variables must be set: POD_NAME, POD_NODE, POD_UID, POD_NAMESPACE",
273273
)
274-
return func(eventType, reason, msg string, args ...interface{}) {}, nil
274+
return func(eventType, reason, msg string, args ...any) {}, nil
275275
}
276276
restcfg, err := kubeconfig.LoadRESTConfig("")
277277
if err != nil {
@@ -289,7 +289,7 @@ func newEventf(log logr.Logger) (Eventf, error) {
289289
broadcaster := record.NewBroadcaster()
290290
broadcaster.StartRecordingToSink(&clientgocorev1.EventSinkImpl{Interface: eventClient.CoreV1().Events(podNamespace)})
291291
eventRec := broadcaster.NewRecorder(scheme, corev1.EventSource{Component: "venafi-kubernetes-agent", Host: podNode})
292-
eventf = func(eventType, reason, msg string, args ...interface{}) {
292+
eventf = func(eventType, reason, msg string, args ...any) {
293293
eventRec.Eventf(&corev1.Pod{ObjectMeta: v1.ObjectMeta{Name: podName, Namespace: podNamespace, UID: types.UID(podUID)}}, eventType, reason, msg, args...)
294294

295295
}
@@ -298,7 +298,7 @@ func newEventf(log logr.Logger) (Eventf, error) {
298298
}
299299

300300
// Like Printf but for sending events to the agent's Pod object.
301-
type Eventf func(eventType, reason, msg string, args ...interface{})
301+
type Eventf func(eventType, reason, msg string, args ...any)
302302

303303
func gatherAndOutputData(ctx context.Context, eventf Eventf, config CombinedConfig, preflightClient client.Client, dataGatherers map[string]datagatherer.DataGatherer) error {
304304
log := klog.FromContext(ctx).WithName("gatherAndOutputData")

pkg/client/client_cyberark.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/pem"
88
"fmt"
99
"net/http"
10+
"slices"
1011

1112
"github.com/go-logr/logr"
1213
corev1 "k8s.io/api/core/v1"
@@ -304,7 +305,7 @@ func isExcludableSecret(log logr.Logger, obj runtime.Object) bool {
304305
// isExcludableTLSSecret checks if a TLS Secret contains a client certificate.
305306
// It returns true if the Secret is a TLS Secret and its tls.crt does not
306307
// contain a client certificate.
307-
func isExcludableTLSSecret(log logr.Logger, dataMap map[string]interface{}) bool {
308+
func isExcludableTLSSecret(log logr.Logger, dataMap map[string]any) bool {
308309
tlsCrtRaw, found := dataMap[corev1.TLSCertKey]
309310
if !found {
310311
log.Info("TLS Secret does not contain tls.crt key")
@@ -378,10 +379,5 @@ func isClientCertificate(cert *x509.Certificate) bool {
378379
return false
379380
}
380381
// Check if the certificate has the ClientAuth EKU
381-
for _, eku := range cert.ExtKeyUsage {
382-
if eku == x509.ExtKeyUsageClientAuth {
383-
return true
384-
}
385-
}
386-
return false
382+
return slices.Contains(cert.ExtKeyUsage, x509.ExtKeyUsageClientAuth)
387383
}

pkg/client/client_cyberark_convertdatareadings_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ func TestExtractResourceListFromReading(t *testing.T) {
198198
Items: []*api.GatheredResource{
199199
{
200200
Resource: &unstructured.Unstructured{
201-
Object: map[string]interface{}{
201+
Object: map[string]any{
202202
"kind": "Namespace",
203-
"metadata": map[string]interface{}{
203+
"metadata": map[string]any{
204204
"name": "default",
205205
"uid": "uid-default",
206206
},
@@ -209,9 +209,9 @@ func TestExtractResourceListFromReading(t *testing.T) {
209209
},
210210
{
211211
Resource: &unstructured.Unstructured{
212-
Object: map[string]interface{}{
212+
Object: map[string]any{
213213
"kind": "Namespace",
214-
"metadata": map[string]interface{}{
214+
"metadata": map[string]any{
215215
"name": "kube-system",
216216
"uid": "uid-kube-system",
217217
},
@@ -222,9 +222,9 @@ func TestExtractResourceListFromReading(t *testing.T) {
222222
{
223223
DeletedAt: api.Time{Time: time.Now()},
224224
Resource: &unstructured.Unstructured{
225-
Object: map[string]interface{}{
225+
Object: map[string]any{
226226
"kind": "Namespace",
227-
"metadata": map[string]interface{}{
227+
"metadata": map[string]any{
228228
"name": "kube-system",
229229
"uid": "uid-kube-system",
230230
},
@@ -384,10 +384,10 @@ func TestMinimizeSnapshot(t *testing.T) {
384384
secretWithoutClientCert := newTLSSecret("tls-secret-without-client", sampleCertificateChain(t, x509.ExtKeyUsageServerAuth))
385385
opaqueSecret := newOpaqueSecret("opaque-secret")
386386
serviceAccount := &unstructured.Unstructured{
387-
Object: map[string]interface{}{
387+
Object: map[string]any{
388388
"apiVersion": "v1",
389389
"kind": "ServiceAccount",
390-
"metadata": map[string]interface{}{
390+
"metadata": map[string]any{
391391
"name": "my-service-account",
392392
"namespace": "default",
393393
},
@@ -491,10 +491,10 @@ func TestIsExcludableSecret(t *testing.T) {
491491
{
492492
name: "Non-secret",
493493
secret: &unstructured.Unstructured{
494-
Object: map[string]interface{}{
494+
Object: map[string]any{
495495
"apiVersion": "cert-manager/v1",
496496
"kind": "Certificate",
497-
"metadata": map[string]interface{}{
497+
"metadata": map[string]any{
498498
"name": "non-secret",
499499
"namespace": "default",
500500
},
@@ -541,16 +541,16 @@ func TestIsExcludableSecret(t *testing.T) {
541541

542542
// newTLSSecret creates a Kubernetes TLS secret with the given name and certificate data.
543543
// If crt is nil, the secret will not contain a "tls.crt" entry.
544-
func newTLSSecret(name string, crt interface{}) *unstructured.Unstructured {
545-
data := map[string]interface{}{"tls.key": "dummy-key"}
544+
func newTLSSecret(name string, crt any) *unstructured.Unstructured {
545+
data := map[string]any{"tls.key": "dummy-key"}
546546
if crt != nil {
547547
data["tls.crt"] = crt
548548
}
549549
return &unstructured.Unstructured{
550-
Object: map[string]interface{}{
550+
Object: map[string]any{
551551
"apiVersion": "v1",
552552
"kind": "Secret",
553-
"metadata": map[string]interface{}{
553+
"metadata": map[string]any{
554554
"name": name,
555555
"namespace": "default",
556556
},
@@ -563,15 +563,15 @@ func newTLSSecret(name string, crt interface{}) *unstructured.Unstructured {
563563
// newOpaqueSecret creates a Kubernetes Opaque secret with the given name.
564564
func newOpaqueSecret(name string) *unstructured.Unstructured {
565565
return &unstructured.Unstructured{
566-
Object: map[string]interface{}{
566+
Object: map[string]any{
567567
"apiVersion": "v1",
568568
"kind": "Secret",
569-
"metadata": map[string]interface{}{
569+
"metadata": map[string]any{
570570
"name": name,
571571
"namespace": "default",
572572
},
573573
"type": "Opaque",
574-
"data": map[string]interface{}{
574+
"data": map[string]any{
575575
"key": "value",
576576
},
577577
},

pkg/client/client_venafi_cloud.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func (c *VenafiCloudClient) updateAccessToken(ctx context.Context) error {
307307
return nil
308308
}
309309

310-
func (c *VenafiCloudClient) sendHTTPRequest(request *http.Request, responseObject interface{}) error {
310+
func (c *VenafiCloudClient) sendHTTPRequest(request *http.Request, responseObject any) error {
311311
response, err := c.Client.Do(request)
312312
if err != nil {
313313
return err

pkg/datagatherer/datagatherer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type DataGatherer interface {
1414
// Fetch retrieves data.
1515
// count is the number of items that were discovered. A negative count means the number
1616
// of items was indeterminate.
17-
Fetch() (data interface{}, count int, err error)
17+
Fetch() (data any, count int, err error)
1818
// Run starts the data gatherer's informers for resource collection.
1919
// Returns error if the data gatherer informer wasn't initialized
2020
Run(ctx context.Context) error

0 commit comments

Comments
 (0)