From 031a16515c62e8c10c3459f51fdffdd5ea3d7057 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Sun, 21 Jan 2024 08:57:42 +0000 Subject: [PATCH 1/2] fix: handle deleted streams --- controllers/jetstream/stream.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/controllers/jetstream/stream.go b/controllers/jetstream/stream.go index b43059f4..51d8bc5d 100644 --- a/controllers/jetstream/stream.go +++ b/controllers/jetstream/stream.go @@ -92,7 +92,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e // Write this to the cacheDir. accDir := filepath.Join(c.cacheDir, ns, spec.Account) - if err := os.MkdirAll(accDir, 0755); err != nil { + if err := os.MkdirAll(accDir, 0o755); err != nil { return err } @@ -101,7 +101,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e remoteRootCA = filepath.Join(accDir, acc.Spec.TLS.RootCAs) for k, v := range secret.Data { - if err := os.WriteFile(filepath.Join(accDir, k), v, 0644); err != nil { + if err := os.WriteFile(filepath.Join(accDir, k), v, 0o644); err != nil { return err } } @@ -116,13 +116,13 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e // Write the user credentials to the cache dir. accDir := filepath.Join(c.cacheDir, ns, spec.Account) - if err := os.MkdirAll(accDir, 0755); err != nil { + if err := os.MkdirAll(accDir, 0o755); err != nil { return err } for k, v := range secret.Data { if k == acc.Spec.Creds.File { accUserCreds = filepath.Join(c.cacheDir, ns, spec.Account, k) - if err := os.WriteFile(filepath.Join(accDir, k), v, 0644); err != nil { + if err := os.WriteFile(filepath.Join(accDir, k), v, 0o644); err != nil { return err } } @@ -207,7 +207,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e return err } updateOK := (strOK && !deleteOK && newGeneration) - createOK := (!strOK && !deleteOK && newGeneration) + createOK := (!strOK && !deleteOK) || (!deleteOK && newGeneration) switch { case createOK: From 0d9c222bca1bde1912db169628695a6ac6673bd6 Mon Sep 17 00:00:00 2001 From: Parham Alvani Date: Sun, 21 Jan 2024 10:59:36 +0000 Subject: [PATCH 2/2] fix: correct tests --- controllers/jetstream/stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/jetstream/stream.go b/controllers/jetstream/stream.go index 51d8bc5d..f87277c8 100644 --- a/controllers/jetstream/stream.go +++ b/controllers/jetstream/stream.go @@ -207,7 +207,7 @@ func (c *Controller) processStreamObject(str *apis.Stream, jsm jsmClientFunc) (e return err } updateOK := (strOK && !deleteOK && newGeneration) - createOK := (!strOK && !deleteOK) || (!deleteOK && newGeneration) + createOK := (!strOK && !deleteOK) || (!updateOK && !deleteOK && newGeneration) switch { case createOK: