Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/brevdev/brev-cli/pkg/cmd/healthcheck"
"github.com/brevdev/brev-cli/pkg/cmd/hello"
"github.com/brevdev/brev-cli/pkg/cmd/importideconfig"
"github.com/brevdev/brev-cli/pkg/cmd/initfile"
"github.com/brevdev/brev-cli/pkg/cmd/invite"
"github.com/brevdev/brev-cli/pkg/cmd/login"
"github.com/brevdev/brev-cli/pkg/cmd/logout"
Expand Down Expand Up @@ -281,7 +280,6 @@ func createCmdTree(cmd *cobra.Command, t *terminal.Terminal, loginCmdStore *stor
cmd.AddCommand(logout.NewCmdLogout(loginAuth, noLoginCmdStore))
cmd.AddCommand(tasks.NewCmdTasks(t, noLoginCmdStore))
cmd.AddCommand(tasks.NewCmdConfigure(t, noLoginCmdStore))
cmd.AddCommand(initfile.NewCmdInitFile(t, noLoginCmdStore))
cmd.AddCommand(hello.NewCmdHello(t, noLoginCmdStore))
cmd.AddCommand(notebook.NewCmdNotebook(noLoginCmdStore, t))
// dev feature toggle
Expand Down
31 changes: 0 additions & 31 deletions pkg/cmd/initfile/initfile.go

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/cmd/refresh/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,6 @@ func NewCmdRefresh(t *terminal.Terminal, store RefreshStore) *cobra.Command {
return cmd
}

func RunRefreshBetter(store RefreshStore) error {
if err := GetCloudflare(store).DownloadCloudflaredBinaryIfItDNE(); err != nil {
return breverrors.WrapAndTrace(err)
}

cu, err := GetConfigUpdater(store)
if err != nil {
return breverrors.WrapAndTrace(err)
}

err = cu.Run()
if err != nil {
return breverrors.WrapAndTrace(err)
}

privateKeyPath, err := store.GetPrivateKeyPath()
if err != nil {
return breverrors.WrapAndTrace(err)
}
err = store.Chmod(privateKeyPath, 0o600)
if err != nil {
return breverrors.WrapAndTrace(err)
}

return nil
}

func RunRefresh(store RefreshStore) error {
cl := GetCloudflare(store)
err := cl.DownloadCloudflaredBinaryIfItDNE()
Expand Down
50 changes: 6 additions & 44 deletions pkg/cmd/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
breverrors "github.com/brevdev/brev-cli/pkg/errors"
"github.com/brevdev/brev-cli/pkg/featureflag"
"github.com/brevdev/brev-cli/pkg/instancetypes"
"github.com/brevdev/brev-cli/pkg/mergeshells"
"github.com/brevdev/brev-cli/pkg/store"
"github.com/brevdev/brev-cli/pkg/terminal"
"github.com/brevdev/brev-cli/pkg/util"
Expand Down Expand Up @@ -225,7 +224,7 @@ func maybeStartStoppedOrJoin(t *terminal.Terminal, user *entity.User, apiKeyAuth

func maybeStartFromGitURL(t *terminal.Terminal, user *entity.User, apiKeyAuth bool, options StartOptions, startStore StartStore) (bool, error) {
if util.IsGitURL(options.RepoOrPathOrNameOrID) { // todo this is function is not complete, some cloneable urls are not identified
err := createNewWorkspaceFromGit(user, apiKeyAuth, t, options.SetupScript, options, startStore)
err := createNewWorkspaceFromGit(user, apiKeyAuth, t, options, startStore)
if err != nil {
return true, breverrors.WrapAndTrace(err)
}
Expand Down Expand Up @@ -272,21 +271,11 @@ func startWorkspaceFromPath(user *entity.User, apiKeyAuth bool, t *terminal.Term
}
gitParts := strings.Split(gitURL, "/")
options.Name = strings.Split(gitParts[len(gitParts)-1], ".")[0]
localSetupPath := filepath.Join(options.RepoOrPathOrNameOrID, ".brev", "setup.sh")
if options.RepoOrPathOrNameOrID == "." {
localSetupPath = filepath.Join(".brev", "setup.sh")
}
if !util.DoesPathExist(localSetupPath) {
fmt.Println(strings.Join([]string{"Generating setup script at", localSetupPath}, "\n"))
mergeshells.ImportPath(t, options.RepoOrPathOrNameOrID, startStore)
fmt.Println("setup script generated.")
}

// createNewWorkspaceFromGit expects this field to be a git url, but above
// logic wants it to be the directory path, so set it only before calling
// createNewWorkspaceFromGit
options.RepoOrPathOrNameOrID = gitURL
err := createNewWorkspaceFromGit(user, apiKeyAuth, t, localSetupPath, options, startStore)
err := createNewWorkspaceFromGit(user, apiKeyAuth, t, options, startStore)
if err != nil {
return breverrors.WrapAndTrace(err)
}
Expand Down Expand Up @@ -491,34 +480,7 @@ func IsURL(str string) bool {
return err == nil && u.Scheme != "" && u.Host != ""
}

func createNewWorkspaceFromGit(user *entity.User, apiKeyAuth bool, t *terminal.Terminal, setupScriptURLOrPath string, startOptions StartOptions, startStore StartStore) error {
// https://gist.githubusercontent.com/naderkhalil/4a45d4d293dc3a9eb330adcd5440e148/raw/3ab4889803080c3be94a7d141c7f53e286e81592/setup.sh
// fetch contents of file
// todo: read contents of file

var setupScriptContents string
var err error
if len(startOptions.RepoOrPathOrNameOrID) > 0 && len(startOptions.SetupPath) > 0 {
// STUFF HERE
} else if len(setupScriptURLOrPath) > 0 {
if IsURL(setupScriptURLOrPath) {
contents, err1 := startStore.GetSetupScriptContentsByURL(setupScriptURLOrPath)
if err1 != nil {
t.Vprintf("%s", t.Red("Couldn't fetch setup script from %s\n", setupScriptURLOrPath)+t.Yellow("Continuing with default setup script 👍"))
return breverrors.WrapAndTrace(err1)
}
setupScriptContents += "\n" + contents
} else {
// ERROR: not sure what this use case is for
var err2 error
setupScriptContents, err2 = startStore.GetFileAsString(setupScriptURLOrPath)
if err2 != nil {
return breverrors.WrapAndTrace(err2)
}
}
}
_ = setupScriptContents

func createNewWorkspaceFromGit(user *entity.User, apiKeyAuth bool, t *terminal.Terminal, startOptions StartOptions, startStore StartStore) error {
newWorkspace := MakeNewWorkspaceFromURL(startOptions.RepoOrPathOrNameOrID)

if (startOptions.Name) != "" {
Expand All @@ -531,7 +493,7 @@ func createNewWorkspaceFromGit(user *entity.User, apiKeyAuth bool, t *terminal.T
if startOptions.OrgName == "" {
activeorg, err2 := startStore.GetActiveOrganizationOrDefault()
if err2 != nil {
return breverrors.WrapAndTrace(err)
return breverrors.WrapAndTrace(err2)
}
if activeorg == nil {
return breverrors.NewValidationError("no org exist")
Expand All @@ -540,7 +502,7 @@ func createNewWorkspaceFromGit(user *entity.User, apiKeyAuth bool, t *terminal.T
} else {
orgs, err2 := startStore.GetOrganizations(&store.GetOrganizationsOptions{Name: startOptions.OrgName})
if err2 != nil {
return breverrors.WrapAndTrace(err)
return breverrors.WrapAndTrace(err2)
}
if len(orgs) == 0 {
return breverrors.NewValidationError(fmt.Sprintf("no org with name %s", startOptions.OrgName))
Expand All @@ -550,7 +512,7 @@ func createNewWorkspaceFromGit(user *entity.User, apiKeyAuth bool, t *terminal.T
orgID = orgs[0].ID
}

err = createWorkspace(user, apiKeyAuth, t, newWorkspace, orgID, startStore, startOptions)
err := createWorkspace(user, apiKeyAuth, t, newWorkspace, orgID, startStore, startOptions)
if err != nil {
return breverrors.WrapAndTrace(err)
}
Expand Down
Loading
Loading