@@ -22,19 +22,19 @@ var contextCache *theine.Cache[string, string]
22
22
// a unique cache key SHA. It is used when
23
23
// `cluster-context-enabled=false`.
24
24
type key struct {
25
- // Kind is a kubernetes resource kind
26
- Kind types.ResourceKind
25
+ // kind is a kubernetes resource kind
26
+ kind types.ResourceKind
27
27
28
- // Namespaces is a kubernetes resource namespace
29
- Namespace string
28
+ // namespace is a kubernetes resource namespace
29
+ namespace string
30
30
31
31
// Opts is a list options object used by the kubernetes client.
32
- Opts metav1.ListOptions
32
+ opts metav1.ListOptions
33
33
}
34
34
35
35
// SHA calculates sha based on the internal key fields.
36
36
func (k key ) SHA () (string , error ) {
37
- k .Opts = metav1.ListOptions {LabelSelector : k .Opts .LabelSelector , FieldSelector : k .Opts .FieldSelector }
37
+ k .opts = metav1.ListOptions {LabelSelector : k .opts .LabelSelector , FieldSelector : k .opts .FieldSelector }
38
38
return helpers .HashObject (k )
39
39
}
40
40
@@ -44,8 +44,8 @@ func (k key) SHA() (string, error) {
44
44
type Key struct {
45
45
key
46
46
47
- // Token is an auth token used to exchange it for the context ID.
48
- Token string
47
+ // token is an auth token used to exchange it for the context ID.
48
+ token string
49
49
50
50
// context is an internal identifier used in conjunction with the key
51
51
// structure fields to create a cache key SHA that will be unique across
@@ -62,28 +62,25 @@ func (k Key) SHA() (sha string, err error) {
62
62
return k .key .SHA ()
63
63
}
64
64
65
- contextKey , exists := contextCache .Get (k .Token )
65
+ contextKey , exists := contextCache .Get (k .token )
66
66
if ! exists {
67
- contextKey , err = exchangeToken (k .Token )
67
+ contextKey , err = exchangeToken (k .token )
68
68
if err != nil {
69
69
return "" , err
70
70
}
71
71
72
- contextCache .SetWithTTL (k .Token , contextKey , 1 , args .CacheTTL ())
72
+ contextCache .SetWithTTL (k .token , contextKey , 1 , args .CacheTTL ())
73
73
}
74
74
75
- k .Opts = metav1.ListOptions {LabelSelector : k .Opts .LabelSelector , FieldSelector : k .Opts .FieldSelector }
76
- k .Token = ""
75
+ k .opts = metav1.ListOptions {LabelSelector : k .opts .LabelSelector , FieldSelector : k .opts .FieldSelector }
76
+ k .token = ""
77
77
k .context = contextKey
78
78
return helpers .HashObject (k )
79
79
}
80
80
81
81
// NewKey creates a new cache Key.
82
82
func NewKey (kind types.ResourceKind , namespace , token string , opts metav1.ListOptions ) Key {
83
- return Key {
84
- key : key {Kind : kind , Namespace : namespace , Opts : opts },
85
- Token : token ,
86
- }
83
+ return Key {key : key {kind , namespace , opts }, token : token }
87
84
}
88
85
89
86
type tokenExchangeTransport struct {
0 commit comments