Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(agent/agentssh): extract EnvInfoer#16603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 4 commits intomainfromcj/agentssh-createcommanddeps
Feb 19, 2025

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedFeb 18, 2025
edited
Loading

Extracts environment-level dependencies ofagentssh.Server.CreateCommand() to an interface to allow alternative implementations to be passed in.

We'll need this so we can pass in an alternative implementation that can reference a running container instead of the agent's environment.

I'm not married to the naming convention and will rename the thing if anyone has a better name.

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Naming aside, changes look good so approving 👍🏻

// UserHomeDir returns the home directory of the current user.
UserHomeDir() (string, error)
// UserShell returns the shell of the given user.
UserShell(username string) (string, error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I feel like all these methods are related to the environment, figuring out the user, env, home and shell, so EnvInfo sounds like a pretty good name to me. Deps is a bit vague IMO and makes me think of dependency injection. 😄


We could also simplify this interface somewhat. All we really need are:

  • User()
  • Environ()

We'd just make sure the returned user has the correct home directory and shell populated. Not sure if that'd be worth the lift, though.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

EnvInfoer it is!

I'd prefer to do the bare minimum here, but we can consolidate + simplify down the line!

@@ -96,7 +96,7 @@ func TestNewServer_ExecuteShebang(t *testing.T) {
t.Run("Args", func(t *testing.T) {
t.Parallel()
cmd, err := s.CreateCommand(ctx, `#!/usr/bin/env bash
echo test`, nil)
echo test`, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps we should add a test for a custom implementation as well?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can do!

@johnstcnjohnstcn merged commit4edd77b intomainFeb 19, 2025
30 checks passed
@johnstcnjohnstcn deleted the cj/agentssh-createcommanddeps branchFebruary 19, 2025 09:04
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 19, 2025
@johnstcnjohnstcn changed the titlechore(agent/agentssh): extract CreateCommandDepschore(agent/agentssh): extract EnvInfoerFeb 19, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@dannykoppingdannykoppingdannykopping approved these changes

@SasSwartSasSwartSasSwart approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@johnstcn@mafredri@dannykopping@SasSwart

[8]ページ先頭

©2009-2025 Movatter.jp