Skip to content

Commit f118159

Browse files
author
Akshay Chawla
committed
Fixing Null pointer exception
1 parent 5723f91 commit f118159

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

internal/collector/otelcol.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ receivers:
8181
url: "{{- .StubStatus.URL -}}"
8282
listen: "{{- .StubStatus.Listen -}}"
8383
location: "{{- .StubStatus.Location -}}"
84+
ca: "{{- .StubStatus.Ca -}}"
8485
{{- if .CollectionInterval }}
8586
collection_interval: {{ .CollectionInterval }}
8687
{{- end }}
@@ -98,6 +99,7 @@ receivers:
9899
url: "{{- .PlusAPI.URL -}}"
99100
listen: "{{- .PlusAPI.Listen -}}"
100101
location: "{{- .PlusAPI.Location -}}"
102+
ca: "{{- .PlusAPI.Ca -}}"
101103
{{- if .CollectionInterval }}
102104
collection_interval: {{ .CollectionInterval }}
103105
{{- end }}

internal/datasource/config/nginx_config_parser.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,18 +740,31 @@ func (ncp *NginxConfigParser) isPort(value string) bool {
740740
return err == nil && port >= 1 && port <= 65535
741741
}
742742

743+
// hasSSLArgument checks if any of the arguments contain "ssl".
744+
func (ncp *NginxConfigParser) hasSSLArgument(args []string) bool {
745+
for i := 1; i < len(args); i++ {
746+
if args[i] == "ssl" {
747+
return true
748+
}
749+
}
750+
751+
return false
752+
}
753+
754+
// isSSLListenDirective checks if a directive is a listen directive with ssl enabled.
755+
func (ncp *NginxConfigParser) isSSLListenDirective(dir *crossplane.Directive) bool {
756+
return dir.Directive == "listen" && ncp.hasSSLArgument(dir.Args)
757+
}
758+
759+
// isSSLEnabled checks if SSL is enabled for a given server block.
743760
func (ncp *NginxConfigParser) isSSLEnabled(serverBlock *crossplane.Directive) bool {
744-
if serverBlock == nil || serverBlock.Block == nil {
761+
if serverBlock == nil {
745762
return false
746763
}
747764

748765
for _, dir := range serverBlock.Block {
749-
if dir.Directive == "listen" {
750-
for _, arg := range dir.Args[1:] {
751-
if arg == "ssl" {
752-
return true
753-
}
754-
}
766+
if ncp.isSSLListenDirective(dir) {
767+
return true
755768
}
756769
}
757770

0 commit comments

Comments
 (0)