Skip to content

Commit

Permalink
Drop the server-unreleased SubjectTransformDest behaviors
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Oct 2, 2023
1 parent 962b031 commit aa5761f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
25 changes: 14 additions & 11 deletions cli/stream_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ func (c *streamCmd) reportAction(_ *fisk.ParseContext) error {

func (c *streamCmd) renderReplication(stats []streamStat) {
table := newTableWriter("Replication Report")
table.AddHeaders("Stream", "Kind", "API Prefix", "Source Stream", "Filter", "Destination", "Active", "Lag", "Error")
table.AddHeaders("Stream", "Kind", "API Prefix", "Source Stream", "Filters and Transforms", "Active", "Lag", "Error")

for _, s := range stats {
if len(s.Sources) == 0 && s.Mirror == nil {
Expand Down Expand Up @@ -1318,14 +1318,20 @@ func (c *streamCmd) renderReplication(stats []streamStat) {
eApiPrefix = source.External.ApiPrefix
}

if source.SubjectTransformDest != "" && source.FilterSubject == "" {
source.FilterSubject = ">"
filterSubject := []string{}

for _, transform := range source.SubjectTransforms {
filterSubject = append(filterSubject, fmt.Sprintf("%s to %s", transform.Source, transform.Destination))
}

if len(filterSubject) == 0 && source.FilterSubject != "" {
filterSubject = append(filterSubject, fmt.Sprintf("%s untransformed", source.FilterSubject))
}

if c.reportRaw {
table.AddRow(s.Name, "Source", eApiPrefix, source.Name, source.FilterSubject, source.SubjectTransformDest, source.Active, source.Lag, apierr)
table.AddRow(s.Name, "Source", eApiPrefix, source.Name, strings.Join(filterSubject, ", "), source.Active, source.Lag, apierr)
} else {
table.AddRow(s.Name, "Source", eApiPrefix, source.Name, source.FilterSubject, source.SubjectTransformDest, f(source.Active), f(source.Lag), apierr)
table.AddRow(s.Name, "Source", eApiPrefix, source.Name, strings.Join(filterSubject, ", "), f(source.Active), f(source.Lag), apierr)
}

}
Expand Down Expand Up @@ -1968,16 +1974,13 @@ func (c *streamCmd) showStreamInfo(info *api.StreamInfo) {
cols.AddRow("Stream Name", s.Name)

switch {
case s.SubjectTransformDest != "":
case s.FilterSubject != "":
filter := ">"

if s.FilterSubject != "" {
filter = s.FilterSubject
}

cols.AddRowf("Subject Filter and Transform", "%s to %s", filter, s.SubjectTransformDest)
case len(s.SubjectTransforms) == 0:
cols.AddRowIfNotEmpty("Subject Filter", s.FilterSubject)
cols.AddRowf("Subject Filter", filter)
case len(s.SubjectTransforms) > 0:
for i := range s.SubjectTransforms {
t := ""
Expand All @@ -1991,7 +1994,7 @@ func (c *streamCmd) showStreamInfo(info *api.StreamInfo) {
}

if s.SubjectTransforms[i].Destination == "" {
cols.AddRowf(t, "%s to [no transform]", s.SubjectTransforms[i].Source)
cols.AddRowf(t, "%s untransformed", s.SubjectTransforms[i].Source)
} else {
cols.AddRowf(t, "%s to %s", s.SubjectTransforms[i].Source, s.SubjectTransforms[i].Destination)
}
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ go 1.20
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/HdrHistogram/hdrhistogram-go v1.1.2
github.com/choria-io/fisk v0.6.0
github.com/antonmedv/expr v1.15.3
github.com/choria-io/fisk v0.6.1
github.com/dustin/go-humanize v1.0.1
github.com/emicklei/dot v1.6.0
github.com/fatih/color v1.15.0
Expand All @@ -18,9 +19,11 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/klauspost/compress v1.17.0
github.com/mattn/go-isatty v0.0.19
github.com/nats-io/jsm.go v0.1.1-0.20230922064108-bb09405bc2c0
github.com/nats-io/jsm.go v0.1.1-0.20230929093219-c157aaec4932
github.com/nats-io/jwt/v2 v2.5.2
github.com/nats-io/nats-server/v2 v2.10.1
github.com/nats-io/nats.go v1.30.0
github.com/nats-io/nkeys v0.4.5
github.com/nats-io/nuid v1.0.1
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/common v0.44.0
Expand All @@ -32,7 +35,6 @@ require (
)

require (
github.com/antonmedv/expr v1.15.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
Expand All @@ -42,12 +44,9 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/nats-io/jwt/v2 v2.5.2 // indirect
github.com/nats-io/nkeys v0.4.5 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sevlyar/retag v0.0.0-20190429052747-c3f10e304082 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/choria-io/fisk v0.6.0 h1:0x5zLzFR2CHCbSIIeuZUKryCzls/Bduw1i+8w82a1E8=
github.com/choria-io/fisk v0.6.0/go.mod h1:m6kd61ycRGwkyb0SDdgmcQXW9fQJuqeH4DKEjRxJewg=
github.com/choria-io/fisk v0.6.1 h1:umFzmj2Ecttk89AFoxnqCph0exAmChqhJklvE+Id18o=
github.com/choria-io/fisk v0.6.1/go.mod h1:m6kd61ycRGwkyb0SDdgmcQXW9fQJuqeH4DKEjRxJewg=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -80,10 +80,8 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
github.com/nats-io/jsm.go v0.1.1-0.20230921074448-1bbb5650afc8 h1:OKm9e1//rlcl4i9zXQ6QQxj7DJaeL+Oe8WBgAKO4cqI=
github.com/nats-io/jsm.go v0.1.1-0.20230921074448-1bbb5650afc8/go.mod h1:hB4Qd+IKoRvAAWTOI1HkCy4wotjFwOIT+codHCFOZqk=
github.com/nats-io/jsm.go v0.1.1-0.20230922064108-bb09405bc2c0 h1:YrGcddIEq3vsWFO6JKGqHF1NquZCCKXJBJmp61tDRJY=
github.com/nats-io/jsm.go v0.1.1-0.20230922064108-bb09405bc2c0/go.mod h1:hB4Qd+IKoRvAAWTOI1HkCy4wotjFwOIT+codHCFOZqk=
github.com/nats-io/jsm.go v0.1.1-0.20230929093219-c157aaec4932 h1:qZy9YlK9iw6we9cOhwz9KcSXozhuVPkNKlK1ZOA0Jwo=
github.com/nats-io/jsm.go v0.1.1-0.20230929093219-c157aaec4932/go.mod h1:hB4Qd+IKoRvAAWTOI1HkCy4wotjFwOIT+codHCFOZqk=
github.com/nats-io/jwt/v2 v2.5.2 h1:DhGH+nKt+wIkDxM6qnVSKjokq5t59AZV5HRcFW0zJwU=
github.com/nats-io/jwt/v2 v2.5.2/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI=
github.com/nats-io/nats-server/v2 v2.10.1 h1:MIJ614dhOIdo71iSzY8ln78miXwrYvlvXHUyS+XdKZQ=
Expand Down Expand Up @@ -112,8 +110,6 @@ github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4=
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY=
github.com/sevlyar/retag v0.0.0-20190429052747-c3f10e304082 h1:fj05fHX+p6w6xqPfvEjFtdu95JwguF0Kg1cz/sht8+U=
github.com/sevlyar/retag v0.0.0-20190429052747-c3f10e304082/go.mod h1:mOWh3Kdot9kBKCLbKcJTzIBBEPKRJAq2lk03eVVDmco=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down

0 comments on commit aa5761f

Please sign in to comment.