Skip to content

Commit

Permalink
chore(all): fix nil check to value first (#3689)
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee authored Feb 5, 2025
1 parent 98e4cfe commit 3c8f286
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/manifests/manifestutils/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
// new map every time, so that we don't touch the instance's annotations
annotations := map[string]string{}

if nil != instance.ObjectMeta.Annotations {
if instance.ObjectMeta.Annotations != nil {
for k, v := range instance.ObjectMeta.Annotations {
if !IsFilteredSet(k, filterAnnotations) {
annotations[k] = v
Expand All @@ -31,7 +31,7 @@ func Annotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []st
func PodAnnotations(instance v1beta1.OpenTelemetryCollector, filterAnnotations []string) (map[string]string, error) {
// new map every time, so that we don't touch the instance's annotations
podAnnotations := map[string]string{}
if nil != instance.Spec.PodAnnotations {
if instance.Spec.PodAnnotations != nil {
for k, v := range instance.Spec.PodAnnotations {
if !IsFilteredSet(k, filterAnnotations) {
podAnnotations[k] = v
Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/manifestutils/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Labels(instance metav1.ObjectMeta, name string, image string, component str
var versionLabel string
// new map every time, so that we don't touch the instance's label
base := map[string]string{}
if nil != instance.Labels {
if instance.Labels != nil {
for k, v := range instance.Labels {
if !IsFilteredSet(k, filterLabels) {
base[k] = v
Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/opampbridge/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Annotations(instance v1alpha1.OpAMPBridge, configMap *v1.ConfigMap, filterA
for key, value := range instance.Spec.PodAnnotations {
annotations[key] = value
}
if nil != instance.ObjectMeta.Annotations {
if instance.ObjectMeta.Annotations != nil {
for k, v := range instance.ObjectMeta.Annotations {
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
annotations[k] = v
Expand Down
2 changes: 1 addition & 1 deletion internal/manifests/targetallocator/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Annotations(instance v1alpha1.TargetAllocator, configMap *v1.ConfigMap, fil
for key, value := range instance.Spec.PodAnnotations {
annotations[key] = value
}
if nil != instance.ObjectMeta.Annotations {
if instance.ObjectMeta.Annotations != nil {
for k, v := range instance.ObjectMeta.Annotations {
if !manifestutils.IsFilteredSet(k, filterAnnotations) {
annotations[k] = v
Expand Down

0 comments on commit 3c8f286

Please sign in to comment.