mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 08:29:23 +00:00
reduce type conversion and correct variable name
Kubernetes-commit: 13468442bfbdf69a6e6690497fce427317cff790
This commit is contained in:
parent
67e1ce8f65
commit
fa1e013ed0
@ -52,13 +52,14 @@ func (cml *ConfigMapLock) Get(ctx context.Context) (*LeaderElectionRecord, []byt
|
|||||||
if cml.cm.Annotations == nil {
|
if cml.cm.Annotations == nil {
|
||||||
cml.cm.Annotations = make(map[string]string)
|
cml.cm.Annotations = make(map[string]string)
|
||||||
}
|
}
|
||||||
recordBytes, found := cml.cm.Annotations[LeaderElectionRecordAnnotationKey]
|
recordStr, found := cml.cm.Annotations[LeaderElectionRecordAnnotationKey]
|
||||||
|
recordBytes := []byte(recordStr)
|
||||||
if found {
|
if found {
|
||||||
if err := json.Unmarshal([]byte(recordBytes), &record); err != nil {
|
if err := json.Unmarshal(recordBytes, &record); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &record, []byte(recordBytes), nil
|
return &record, recordBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create attempts to create a LeaderElectionRecord annotation
|
// Create attempts to create a LeaderElectionRecord annotation
|
||||||
|
@ -47,13 +47,14 @@ func (el *EndpointsLock) Get(ctx context.Context) (*LeaderElectionRecord, []byte
|
|||||||
if el.e.Annotations == nil {
|
if el.e.Annotations == nil {
|
||||||
el.e.Annotations = make(map[string]string)
|
el.e.Annotations = make(map[string]string)
|
||||||
}
|
}
|
||||||
recordBytes, found := el.e.Annotations[LeaderElectionRecordAnnotationKey]
|
recordStr, found := el.e.Annotations[LeaderElectionRecordAnnotationKey]
|
||||||
|
recordBytes := []byte(recordStr)
|
||||||
if found {
|
if found {
|
||||||
if err := json.Unmarshal([]byte(recordBytes), &record); err != nil {
|
if err := json.Unmarshal(recordBytes, &record); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &record, []byte(recordBytes), nil
|
return &record, recordBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create attempts to create a LeaderElectionRecord annotation
|
// Create attempts to create a LeaderElectionRecord annotation
|
||||||
|
Loading…
Reference in New Issue
Block a user