Skip to content

Commit 143db27

Browse files
committed
Merge branch 'v3' into check-allowed-dir
2 parents dd9b13e + 4029871 commit 143db27

File tree

6 files changed

+54
-9
lines changed

6 files changed

+54
-9
lines changed

.github/workflows/release-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ on:
3838
uploadUrl:
3939
description: 'Location to publish packages to'
4040
required: false
41-
default: "up-ap.nginx.com"
41+
default: "https://up-ap.nginx.com"
4242
workflow_call:
4343
inputs:
4444
githubRelease:
@@ -67,7 +67,7 @@ on:
6767
required: true
6868
uploadUrl:
6969
type: string
70-
default: "up-ap.nginx.com"
70+
default: "https://up-ap.nginx.com"
7171

7272
env:
7373
NFPM_VERSION: 'v2.35.3'

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func getConfigFilePaths() []string {
456456
if err == nil {
457457
paths = append(paths, path)
458458
} else {
459-
slog.Warn("Unable to determine process's current directory")
459+
slog.Warn("Unable to determine process's current directory", "error", err)
460460
}
461461

462462
return paths
@@ -544,7 +544,7 @@ func resolveEnvironmentVariableLabels() map[string]string {
544544
if len(splitLabel) == KeyValueNumber {
545545
envLabels[splitLabel[0]] = splitLabel[1]
546546
} else {
547-
slog.Warn("Unable to parse label: " + label)
547+
slog.Warn("Unable to parse label ", "label", label)
548548
}
549549
}
550550
}

internal/watcher/credentials/credential_watcher_service.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ func (cws *CredentialWatcherService) addWatcher(ctx context.Context, filePath st
107107

108108
if err := cws.watcher.Add(filePath); err != nil {
109109
slog.ErrorContext(ctx, "Failed to add credential watcher", "path", filePath, "error", err)
110-
removeError := cws.watcher.Remove(filePath)
111-
if removeError != nil {
112-
slog.ErrorContext(
113-
ctx, "Failed to remove credential watcher", "path", filePath, "error", removeError)
114-
}
115110

116111
return
117112
}
@@ -183,6 +178,19 @@ func credentialPaths(agentConfig *config.Config) []string {
183178
}
184179
}
185180

181+
// agent's tls certs
182+
if agentConfig.Command.TLS != nil {
183+
if agentConfig.Command.TLS.Ca != "" {
184+
paths = append(paths, agentConfig.Command.TLS.Ca)
185+
}
186+
if agentConfig.Command.TLS.Cert != "" {
187+
paths = append(paths, agentConfig.Command.TLS.Cert)
188+
}
189+
if agentConfig.Command.TLS.Key != "" {
190+
paths = append(paths, agentConfig.Command.TLS.Key)
191+
}
192+
}
193+
186194
return paths
187195
}
188196

internal/watcher/credentials/credential_watcher_service_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ func Test_credentialPaths(t *testing.T) {
211211
agentConfig: types.AgentConfig(),
212212
want: []string{
213213
"/tmp/token",
214+
"ca.pem",
215+
"cert.pem",
216+
"key.pem",
214217
},
215218
},
216219
{
@@ -224,6 +227,27 @@ func Test_credentialPaths(t *testing.T) {
224227
},
225228
want: nil,
226229
},
230+
{
231+
name: "Test 3: Add TLS paths if Command TLS is set",
232+
agentConfig: &config.Config{
233+
Command: &config.Command{
234+
Server: nil,
235+
Auth: nil,
236+
TLS: &config.TLSConfig{
237+
Cert: "/tmp-ca",
238+
Key: "/tmp-token",
239+
Ca: "/tmp-key",
240+
ServerName: "my-server",
241+
SkipVerify: false,
242+
},
243+
},
244+
},
245+
want: []string{
246+
"/tmp-key",
247+
"/tmp-ca",
248+
"/tmp-token",
249+
},
250+
},
227251
}
228252
for _, tt := range tests {
229253
t.Run(tt.name, func(t *testing.T) {

internal/watcher/instance/nginx_config_parser.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ func (ncp *NginxConfigParser) Parse(ctx context.Context, instance *mpi.Instance)
7474
"instance_id", instance.GetInstanceMeta().GetInstanceId(),
7575
)
7676

77+
lua := crossplane.Lua{}
7778
payload, err := crossplane.Parse(configPath,
7879
&crossplane.ParseOptions{
7980
SingleFile: false,
8081
StopParsingOnError: true,
82+
LexOptions: crossplane.LexOptions{
83+
Lexers: []crossplane.RegisterLexer{lua.RegisterLexer()},
84+
},
8185
},
8286
)
8387
if err != nil {

test/config/nginx/nginx-with-multiple-access-logs.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ http {
3232
"\treqtime:$request_time"
3333
"\tapptime:$upstream_response_time";
3434

35+
server {
36+
listen 9093;
37+
server_name lua.example.com;
38+
39+
ssl_certificate_by_lua_block {
40+
print("Test lua block")
41+
}
42+
}
43+
3544
server {
3645
access_log %s ltsv;
3746

0 commit comments

Comments
 (0)