Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
roblaszczak committed Jan 16, 2022
1 parent 1af69e6 commit c3ca2f8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions internal/addresses.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package internal

const DefaultTrainingsServer = "academy-grpc.threedots.tech:443"
const WebsiteAddress = "https://academy.threedots.tech/"
8 changes: 4 additions & 4 deletions tdl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"os"
"time"

"github.com/ThreeDotsLabs/cli/internal"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"

"github.com/ThreeDotsLabs/cli/trainings"
"github.com/ThreeDotsLabs/cli/trainings/web"
)

func main() {
Expand Down Expand Up @@ -58,12 +58,12 @@ var app = &cli.App{
{
Name: "training",
Aliases: []string{"tr"},
Usage: fmt.Sprintf("commands for %s commands", web.Website),
Usage: fmt.Sprintf("commands for %s commands", internal.WebsiteAddress),
Subcommands: []*cli.Command{
{
Name: "configure",
Usage: "connect your environment with platform account",
ArgsUsage: fmt.Sprintf("[token from %s]", web.Website),
ArgsUsage: fmt.Sprintf("[token from %s]", internal.WebsiteAddress),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "server",
Expand Down Expand Up @@ -98,7 +98,7 @@ var app = &cli.App{
},
{
Name: "init",
ArgsUsage: fmt.Sprintf("[trainingID from %s]", web.Website),
ArgsUsage: fmt.Sprintf("[trainingID from %s]", internal.WebsiteAddress),
Usage: "initialise training files in your current directory",
Action: func(c *cli.Context) error {
trainingID := c.Args().First()
Expand Down
7 changes: 2 additions & 5 deletions trainings/config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import (
"github.com/sirupsen/logrus"

"github.com/ThreeDotsLabs/cli/internal"
"github.com/ThreeDotsLabs/cli/trainings/web"
)

const defaultTrainingsServer = "academy-grpc.threedots.tech:443"

type GlobalConfig struct {
Token string `toml:"token"`
ServerAddr string `toml:"server_addr"`
Expand Down Expand Up @@ -50,7 +47,7 @@ func (c Config) GlobalConfig() GlobalConfig {
if !c.dirOrFileExists(c.osFs, configPath) {
panic(errors.Errorf(
"trainings are not configured, please visit %s to get credentials and run %s",
web.Website, internal.SprintCommand("tdl training configure"),
internal.WebsiteAddress, internal.SprintCommand("tdl training configure"),
))
}

Expand All @@ -60,7 +57,7 @@ func (c Config) GlobalConfig() GlobalConfig {
}

if config.ServerAddr == "" {
config.ServerAddr = defaultTrainingsServer
config.ServerAddr = internal.DefaultTrainingsServer
}
if config.Token == "" {
panic(fmt.Sprintf("empty token in %s", configPath))
Expand Down
5 changes: 5 additions & 0 deletions trainings/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"crypto/x509"

"github.com/ThreeDotsLabs/cli/internal"
"github.com/pkg/errors"
"github.com/spf13/afero"
"google.golang.org/grpc"
Expand Down Expand Up @@ -35,6 +36,10 @@ func (h *Handlers) newGrpcClient(ctx context.Context) genproto.ServerClient {
}

func (h *Handlers) newGrpcClientWithAddr(ctx context.Context, addr string, insecure bool) genproto.ServerClient {
if addr == "" {
addr = internal.DefaultTrainingsServer
}

if h.grpcClient == nil {
var opts []grpc.DialOption

Expand Down
4 changes: 2 additions & 2 deletions trainings/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"net/url"
"path"

"github.com/ThreeDotsLabs/cli/internal"
"github.com/fatih/color"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/ThreeDotsLabs/cli/trainings/config"
"github.com/ThreeDotsLabs/cli/trainings/web"
)

func (h *Handlers) Info(ctx context.Context) error {
Expand All @@ -26,7 +26,7 @@ func (h *Handlers) Info(ctx context.Context) error {
trainingConfig := h.config.TrainingConfig(trainingRootFs)
exerciseConfig := h.config.ExerciseConfig(trainingRootFs)

exerciseURL, err := url.Parse(web.Website)
exerciseURL, err := url.Parse(internal.WebsiteAddress)
if err != nil {
logrus.WithError(err).Warn("Can't parse website URL")
}
Expand Down
3 changes: 0 additions & 3 deletions trainings/web/web.go

This file was deleted.

0 comments on commit c3ca2f8

Please sign in to comment.