Skip to content

Commit

Permalink
Make mathx and table parser publicly available
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Nov 14, 2023
1 parent 5b396bf commit 1b81f07
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/executor/thread-mate/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"

"github.com/kubeshop/botkube/internal/executor/x/mathx"
"github.com/kubeshop/botkube/internal/loggerx"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/api/executor"
"github.com/kubeshop/botkube/pkg/mathx"
)

const (
Expand Down
14 changes: 7 additions & 7 deletions internal/executor/x/output/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"github.com/sirupsen/logrus"

"github.com/kubeshop/botkube/internal/executor/x"
"github.com/kubeshop/botkube/internal/executor/x/parser"
"github.com/kubeshop/botkube/internal/executor/x/state"
"github.com/kubeshop/botkube/internal/executor/x/template"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/formatx"
)

// Parser defines
type Parser interface {
TableSeparated(in string) parser.TableOutput
TableSeparated(in string) formatx.TableOutput
}

// TableCommandParser allows to render table command output into interactive message based on registered templates.
Expand All @@ -32,7 +32,7 @@ func NewTableCommandParser(log logrus.FieldLogger) *TableCommandParser {
return &TableCommandParser{
log: log,
parsers: map[string]Parser{
"space": &parser.TableSpace{},
"space": &formatx.TableSpace{},
},
}
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func (p *TableCommandParser) RenderMessage(cmd, output string, state *state.Cont
}, nil
}

func (p *TableCommandParser) renderActions(msgCtx template.ParseMessage, table parser.Table, cmd string, idx int) (api.Section, error) {
func (p *TableCommandParser) renderActions(msgCtx template.ParseMessage, table formatx.Table, cmd string, idx int) (api.Section, error) {
if idx >= len(table.Rows) {
idx = len(table.Rows) - 1
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func (p *TableCommandParser) renderActions(msgCtx template.ParseMessage, table p
}, nil
}

func (p *TableCommandParser) renderPreview(msgCtx template.ParseMessage, out parser.TableOutput, requestedRow int) (api.Section, error) {
func (p *TableCommandParser) renderPreview(msgCtx template.ParseMessage, out formatx.TableOutput, requestedRow int) (api.Section, error) {
headerLine := out.Lines[0]

if requestedRow >= len(out.Table.Rows) {
Expand Down Expand Up @@ -161,7 +161,7 @@ func (*TableCommandParser) getPreviewLine(lines []string, idx int) string {
return lines[1] // otherwise default first line
}

func (p *TableCommandParser) renderDropdowns(selects []template.Select, commandData parser.Table, cmd string, state *state.Container) (api.Section, int) {
func (p *TableCommandParser) renderDropdowns(selects []template.Select, commandData formatx.Table, cmd string, state *state.Container) (api.Section, int) {
var (
dropdowns []api.Select
lastSelectedIdx int
Expand All @@ -187,7 +187,7 @@ func (p *TableCommandParser) renderDropdowns(selects []template.Select, commandD
}, lastSelectedIdx
}

func (p *TableCommandParser) selectDropdown(name, cmd, keyTpl string, table parser.Table, state *state.Container) (*api.Select, int) {
func (p *TableCommandParser) selectDropdown(name, cmd, keyTpl string, table formatx.Table, state *state.Container) (*api.Select, int) {
log := p.log.WithField("selectName", name)
var options []api.OptionItem
for idx, row := range table.Rows {
Expand Down
2 changes: 1 addition & 1 deletion internal/executor/x/output/message_tutorial.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"

"github.com/kubeshop/botkube/internal/executor/x"
"github.com/kubeshop/botkube/internal/executor/x/mathx"
"github.com/kubeshop/botkube/internal/executor/x/state"
"github.com/kubeshop/botkube/internal/executor/x/template"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/mathx"
)

// TutorialWrapper allows constructing interactive message with predefined steps.
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/executor/grpc_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/kubeshop/botkube/internal/executor/x/mathx"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/mathx"
)

const maxMessageNumberForSingleCommandExecution = 15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package parser
package formatx

import (
"bufio"
"strings"
"unicode"

"github.com/kubeshop/botkube/internal/executor/x/mathx"
"github.com/kubeshop/botkube/pkg/mathx"
)

// Table holds table data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser
package formatx

import (
"testing"
Expand Down
File renamed without changes.

0 comments on commit 1b81f07

Please sign in to comment.