Skip to content

Commit 9746bb2

Browse files
committed
Update from file contains to has prefix
1 parent e1aac81 commit 9746bb2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

internal/controller/nginx/agent/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (d *Deployment) SetFiles(files []File, volumeMounts []v1.VolumeMount) *broa
202202
volumeIgnoreFiles := make([]string, 0, len(d.latestFileNames))
203203
for _, f := range d.latestFileNames {
204204
for _, vm := range volumeMounts {
205-
if strings.Contains(f, vm.MountPath) {
205+
if strings.HasPrefix(f, vm.MountPath) {
206206
volumeIgnoreFiles = append(volumeIgnoreFiles, f)
207207
}
208208
}

internal/controller/nginx/agent/deployment_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func TestSetAndGetFiles_VolumeIgnoreFiles(t *testing.T) {
8181
"/var/log/nginx/error.log",
8282
"/etc/ssl/certs/cert.pem",
8383
"/etc/nginx/conf.d/default.conf", // This won't match any volume mount
84+
"/one/two/three/etc/ssl", // This won't match any volume mount either
8485
}
8586

8687
files := []File{
@@ -135,6 +136,7 @@ func TestSetAndGetFiles_VolumeIgnoreFiles(t *testing.T) {
135136

136137
// Should NOT contain file that doesn't match volume mount paths
137138
g.Expect(unmanagedFiles).ToNot(ContainElement("/etc/nginx/conf.d/default.conf"))
139+
g.Expect(unmanagedFiles).ToNot(ContainElement("/one/two/three/etc/ssl"))
138140

139141
invalidFile, _ := deployment.GetFile("invalid", "12345")
140142
g.Expect(invalidFile).To(BeNil())

0 commit comments

Comments
 (0)