Skip to content

Commit

Permalink
Add deny purge property to stream spec (#186)
Browse files Browse the repository at this point in the history
* allow setting deny_purge on stream

* set denyPurge on stream update
  • Loading branch information
vsinger authored Jul 26, 2024
1 parent 38b4b81 commit d0f520d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/jetstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,16 @@ func createStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
opts = append(opts, jsm.DenyDelete())
}

if spec.DenyPurge {
opts = append(opts, jsm.DenyPurge())
}

if spec.DiscardPerSubject {
opts = append(opts, jsm.DiscardNewPerSubject())
}

if spec.FirstSequence != 0 {
opts = append(opts, jsm.FirstSequence(uint64(spec.FirstSequence)))
opts = append(opts, jsm.FirstSequence(spec.FirstSequence))
}

if spec.Metadata != nil {
Expand Down Expand Up @@ -486,6 +491,7 @@ func updateStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
Duplicates: duplicates,
AllowDirect: spec.AllowDirect,
DenyDelete: spec.DenyDelete,
DenyPurge: spec.DenyPurge,
RollupAllowed: spec.AllowRollup,
FirstSeq: spec.FirstSequence,
SubjectTransform: subjectTransform,
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ spec:
description: When true, restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true.
type: boolean
default: false
denyPurge:
description: When true, restricts the ability to purge a stream via the API. Cannot be changed once set to true.
type: boolean
default: false
discardPerSubject:
description: Allows to discard messages on a subject basis.
type: boolean
Expand Down
1 change: 1 addition & 0 deletions pkg/jetstream/apis/jetstream/v1beta2/streamtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type StreamSpec struct {
AllowRollup bool `json:"allowRollup"`
Creds string `json:"creds"`
DenyDelete bool `json:"denyDelete"`
DenyPurge bool `json:"denyPurge"`
Description string `json:"description"`
DiscardPerSubject bool `json:"discardPerSubject"`
PreventDelete bool `json:"preventDelete"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/jetstream/generated/informers/externalversions/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0f520d

Please sign in to comment.