Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit cc4bbbb

Browse files
authored
Merge pull request #54 from ovh/fix/connectsingleUrl
fix(connect): allow only URL connects
2 parents c3188a4 + d0c1674 commit cc4bbbb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

spec/doc.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,12 @@ In TSL, we can directly use the Connect method to update the set the backend on
703703
connect("warp10","http://localhost:9090", "TOKEN")
704704
```
705705

706+
or when no Token is needed:
707+
708+
```
709+
connect("warp10","http://localhost:9090")
710+
```
711+
706712
For a prometheus it's
707713
```
708714
connect("prometheus","http://localhost:9090")

tsl/genericParser.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,15 @@ func (p *Parser) parseConnect(tok Token, pos Pos, lit string, instruction *Instr
856856

857857
if instruction.connectStatement.connectType == WARP.String() {
858858

859-
if len(fields) != 3 {
859+
intToken := ""
860+
861+
if len(fields) == 3 {
862+
intToken = fields[2].lit
863+
} else if len(fields) < 2 || len(fields) > 3 {
860864
return nil, p.NewTslError("error", pos)
861865
}
862866
instruction.connectStatement.api = fields[1].lit
863-
instruction.connectStatement.token = fields[2].lit
867+
instruction.connectStatement.token = intToken
864868
}
865869

866870
if instruction.connectStatement.connectType == PROM.String() || instruction.connectStatement.connectType == PROMETHEUS.String() {

0 commit comments

Comments
 (0)