Skip to content

Commit

Permalink
changes to job logs url formatting (#121)
Browse files Browse the repository at this point in the history
* changes to job logs url formatting

fixes local dev,

also looks more correct (host/path/etc)

* remove-debug-print
  • Loading branch information
scott-cotton authored Jun 4, 2024
1 parent 9a91295 commit 51f20ae
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions internal/command/logs/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/url"

"github.com/r3labs/sse/v2"
"github.com/signadot/cli/internal/config"
"github.com/spf13/cobra"
"io"
"net/url"
"path"
"strings"
)

func New(api *config.API) *cobra.Command {
Expand All @@ -34,12 +33,12 @@ func list(cfg *config.Logs, out io.Writer) error {
if err := cfg.InitAPIConfig(); err != nil {
return err
}

u := url.URL{
Scheme: "https",
Path: path.Join(strings.TrimPrefix(cfg.APIURL, "https://"), "api/v2/orgs", cfg.Org, "/jobs", cfg.Job, "/attempts/0/logs/stream"),
RawQuery: "type=" + cfg.Stream,
u, err := url.Parse(cfg.APIURL)
if err != nil {
return err
}
u.Path = "/api/v2/orgs/" + cfg.Org + "/jobs/" + cfg.Job + "/attempts/0/logs/stream"
u.RawQuery = "type=" + cfg.Stream

events := make(chan *sse.Event)

Expand All @@ -48,7 +47,7 @@ func list(cfg *config.Logs, out io.Writer) error {
"Signadot-Api-Key": cfg.ApiKey,
}

err := client.SubscribeChan("", events)
err = client.SubscribeChan("", events)
if err != nil {
return err
}
Expand Down

0 comments on commit 51f20ae

Please sign in to comment.