Skip to content

Commit

Permalink
addresses codereview comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pastuxso committed Nov 1, 2023
1 parent c6a3db6 commit f0d5e01
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
9 changes: 9 additions & 0 deletions examples/grpc-client/hello.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Heading L1

```sh { id=01HE2XR0Z3WD9A89XR5XA959QP name=id-present interpreter=bash terminalRows=2 }
echo "Existent ID"
```

```sh { name=id-missing interpreter=bash terminalRows=2 }
echo "Without ID"
```
2 changes: 1 addition & 1 deletion internal/utils/id.go → internal/idgen/id.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package utils contains utility functions for the application
package utils
package idgen

import (
"io"
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/id_test.go → internal/idgen/id_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package idgen

import (
"sync"
Expand Down
4 changes: 2 additions & 2 deletions internal/runner/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/creack/pty"
"github.com/pkg/errors"
"github.com/stateful/runme/internal/utils"
"github.com/stateful/runme/internal/idgen"
"go.uber.org/multierr"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -198,7 +198,7 @@ func newCommand(cfg *commandConfig) (*command, error) {
extraArgs = append(extraArgs, "-c", script)
case CommandModeTempFile:
for {
id := utils.GenerateID()
id := idgen.GenerateID()
tempScriptFile = filepath.Join(cfg.Directory, fmt.Sprintf(".runme-script-%s", id))

if fileExtension != "" {
Expand Down
4 changes: 2 additions & 2 deletions internal/runner/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/pkg/errors"
"github.com/stateful/runme/internal/env"
runnerv1 "github.com/stateful/runme/internal/gen/proto/go/runme/runner/v1"
"github.com/stateful/runme/internal/idgen"
"github.com/stateful/runme/internal/rbuffer"
"github.com/stateful/runme/internal/utils"
"github.com/stateful/runme/pkg/project"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -155,7 +155,7 @@ func ConvertRunnerProject(runnerProj *runnerv1.Project) (project.Project, error)
}

func (r *runnerService) Execute(srv runnerv1.RunnerService_ExecuteServer) error {
logger := r.logger.With(zap.String("_id", utils.GenerateID()))
logger := r.logger.With(zap.String("_id", idgen.GenerateID()))

logger.Info("running Execute in runnerService")

Expand Down
4 changes: 2 additions & 2 deletions internal/runner/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

lru "github.com/hashicorp/golang-lru/v2"
"github.com/stateful/runme/internal/utils"
"github.com/stateful/runme/internal/idgen"
"github.com/stateful/runme/pkg/project"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -36,7 +36,7 @@ func NewSession(envs []string, proj project.Project, logger *zap.Logger) (*Sessi
}

s := &Session{
ID: utils.GenerateID(),
ID: idgen.GenerateID(),

envStore: newEnvStore(sessionEnvs...),
logger: logger,
Expand Down
4 changes: 2 additions & 2 deletions internal/runner/shell_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/creack/pty"
"github.com/pkg/errors"
"github.com/stateful/runme/internal/idgen"
xpty "github.com/stateful/runme/internal/pty"
"github.com/stateful/runme/internal/utils"
"golang.org/x/term"
)

Expand All @@ -25,7 +25,7 @@ type ShellSession struct {
}

func NewShellSession(command string) (*ShellSession, error) {
id := utils.GenerateID()
id := idgen.GenerateID()

cmd := exec.Command(command)
cmd.Env = append(os.Environ(), "RUNMESHELL="+id)
Expand Down

0 comments on commit f0d5e01

Please sign in to comment.