Skip to content

Commit 16e925f

Browse files
committed
chore(all): fix nil check to value first
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 80d4ebf commit 16e925f

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
@@ -27,7 +27,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
2727
// new map every time, so that we don't touch the instance's annotations
2828
annotations := map[string]string{}
2929

30-
if nil != instance.ObjectMeta.Annotations {
30+
if instance.ObjectMeta.Annotations != nil {
3131
for k, v := range instance.ObjectMeta.Annotations {
3232
if !IsFilteredSet(k, filterAnnotations) {
3333
annotations[k] = v
@@ -42,7 +42,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
4242
func PodAnnotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []string) (map[string]string, error) {
4343
// new map every time, so that we don't touch the instance's annotations
4444
podAnnotations := map[string]string{}
45-
if nil != instance.Spec.PodAnnotations {
45+
if instance.Spec.PodAnnotations != nil {
4646
for k, v := range instance.Spec.PodAnnotations {
4747
if !IsFilteredSet(k, filterAnnotations) {
4848
podAnnotations[k] = v

internal/manifests/manifestutils/labels.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Labels(instance metav1.ObjectMeta, name string, image string, component str
3939
var versionLabel string
4040
// new map every time, so that we don't touch the instance's label
4141
base := map[string]string{}
42-
if nil != instance.Labels {
42+
if instance.Labels != nil {
4343
for k, v := range instance.Labels {
4444
if !IsFilteredSet(k, filterLabels) {
4545
base[k] = v

internal/manifests/opampbridge/annotations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Annotations(instance v1alpha1.OpAMPBridge, configMap *v1.ConfigMap, filterA
3333
for key, value := range instance.Spec.PodAnnotations {
3434
annotations[key] = value
3535
}
36-
if nil != instance.ObjectMeta.Annotations {
36+
if instance.ObjectMeta.Annotations != nil {
3737
for k, v := range instance.ObjectMeta.Annotations {
3838
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
3939
annotations[k] = v

internal/manifests/targetallocator/annotations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Annotations(instance v1alpha1.TargetAllocator, configMap *v1.ConfigMap, fil
3333
for key, value := range instance.Spec.PodAnnotations {
3434
annotations[key] = value
3535
}
36-
if nil != instance.ObjectMeta.Annotations {
36+
if instance.ObjectMeta.Annotations != nil {
3737
for k, v := range instance.ObjectMeta.Annotations {
3838
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
3939
annotations[k] = v

0 commit comments

Comments
 (0)