Skip to content

Commit

Permalink
Add stream metadata support
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Sep 22, 2023
1 parent 0e208aa commit 3686f5f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/jetstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ func createStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
opts = append(opts, jsm.FirstSequence(uint64(spec.FirstSequence)))
}

if spec.Metadata != nil {
opts = append(opts, jsm.StreamMetadata(spec.Metadata))
}

_, err = c.NewStream(ctx, spec.Name, opts)
return err
}
Expand Down Expand Up @@ -519,6 +523,10 @@ func updateStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
config.Sources[i] = jss
}

if spec.Metadata != nil {
config.Metadata = spec.Metadata
}

switch spec.Compression {
case "s2":
config.Compression = api.S2Compression
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ spec:
dest:
description: Destination subject.
type: string
metadata:
description: Additional Stream metadata.
type: object
additionalProperties:
type: string
servers:
description: A list of servers for creating stream
type: array
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 @@ -49,6 +49,7 @@ type StreamSpec struct {
SubjectTransform *SubjectTransform `json:"subjectTransform"`
FirstSequence uint64 `json:"firstSequence"`
Compression string `json:"compression"`
Metadata map[string]string `json:"metadata"`
Retention string `json:"retention"`
Servers []string `json:"servers"`
Sources []*StreamSource `json:"sources"`
Expand Down
7 changes: 7 additions & 0 deletions pkg/jetstream/apis/jetstream/v1beta2/zz_generated.deepcopy.go

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

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

0 comments on commit 3686f5f

Please sign in to comment.