Skip to content

Commit 3c8f286

Browse files
authored
chore(all): fix nil check to value first (#3689)
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 98e4cfe commit 3c8f286

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

internal/manifests/manifestutils/annotations.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
1616
// new map every time, so that we don't touch the instance's annotations
1717
annotations := map[string]string{}
1818

19-
if nil != instance.ObjectMeta.Annotations {
19+
if instance.ObjectMeta.Annotations != nil {
2020
for k, v := range instance.ObjectMeta.Annotations {
2121
if !IsFilteredSet(k, filterAnnotations) {
2222
annotations[k] = v
@@ -31,7 +31,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
3131
func PodAnnotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []string) (map[string]string, error) {
3232
// new map every time, so that we don't touch the instance's annotations
3333
podAnnotations := map[string]string{}
34-
if nil != instance.Spec.PodAnnotations {
34+
if instance.Spec.PodAnnotations != nil {
3535
for k, v := range instance.Spec.PodAnnotations {
3636
if !IsFilteredSet(k, filterAnnotations) {
3737
podAnnotations[k] = v

internal/manifests/manifestutils/labels.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func Labels(instance metav1.ObjectMeta, name string, image string, component str
2828
var versionLabel string
2929
// new map every time, so that we don't touch the instance's label
3030
base := map[string]string{}
31-
if nil != instance.Labels {
31+
if instance.Labels != nil {
3232
for k, v := range instance.Labels {
3333
if !IsFilteredSet(k, filterLabels) {
3434
base[k] = v

internal/manifests/opampbridge/annotations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Annotations(instance v1alpha1.OpAMPBridge, configMap *v1.ConfigMap, filterA
2222
for key, value := range instance.Spec.PodAnnotations {
2323
annotations[key] = value
2424
}
25-
if nil != instance.ObjectMeta.Annotations {
25+
if instance.ObjectMeta.Annotations != nil {
2626
for k, v := range instance.ObjectMeta.Annotations {
2727
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
2828
annotations[k] = v

internal/manifests/targetallocator/annotations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func Annotations(instance v1alpha1.TargetAllocator, configMap *v1.ConfigMap, fil
2222
for key, value := range instance.Spec.PodAnnotations {
2323
annotations[key] = value
2424
}
25-
if nil != instance.ObjectMeta.Annotations {
25+
if instance.ObjectMeta.Annotations != nil {
2626
for k, v := range instance.ObjectMeta.Annotations {
2727
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
2828
annotations[k] = v

0 commit comments

Comments
 (0)