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

refactor(agent/agentssh): move parsing of magic session and create type#16630

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
mafredri merged 3 commits intomainfrommafredri/refactor-agentssh-magictype
Feb 19, 2025

Conversation

@mafredri
Copy link
Member

This change refactors the parsing of MagicSessionEnvs in the agentssh package and moves the logic to an earlier stage. Also intoduces enums for MagicSessionType.

In preparation of further changes for#15139.

I'm relying on current tests to verify this behavior, will add more test coverage in later PRs.

@mafredrimafredri self-assigned thisFeb 19, 2025
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

I don't have any blocking concerns 👍 some comments below.

mafredri reacted with heart emoji
Comment on lines +272 to +298
funcextractMagicSessionType(env []string) (magicTypeMagicSessionType,rawTypestring,filteredEnv []string) {
for_,kv:=rangeenv {
if!strings.HasPrefix(kv,MagicSessionTypeEnvironmentVariable) {
continue
}

rawType=strings.TrimPrefix(kv,MagicSessionTypeEnvironmentVariable+"=")
// Keep going, we'll use the last instance of the env.
}

// Always force lowercase checking to be case-insensitive.
switchMagicSessionType(strings.ToLower(rawType)) {
caseMagicSessionTypeVSCode:
magicType=MagicSessionTypeVSCode
caseMagicSessionTypeJetBrains:
magicType=MagicSessionTypeJetBrains
case"",MagicSessionTypeSSH:
magicType=MagicSessionTypeSSH
default:
magicType=MagicSessionTypeUnknown
}

returnmagicType,rawType,slices.DeleteFunc(env,func(kvstring)bool {
returnstrings.HasPrefix(kv,MagicSessionTypeEnvironmentVariable+"=")
})
}

Copy link
Member

Choose a reason for hiding this comment

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

suggestion:extractMagicSessionType(env []string) (MagicSessionType, filteredEnv, error) and return error in case of unknown magic session type?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I kind of like the suggestion, but I don't like returning valid data from a function that returns an error. Essentially we'd still want to filter the env in the case of an error parsing the magic session type. (We only warn log currently if it's invalid.)

johnstcn reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Fair!

}

func(s*Server)handleSignal(logger slog.Logger,ssig ssh.Signal,signalerinterface{Signal(os.Signal)error },magicTypeLabelstring) {
funchandleSignal(logger slog.Logger,ssig ssh.Signal,signalerinterface{Signal(os.Signal)error },metrics*sshServerMetrics,magicTypeLabelstring) {
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines -78 to -79
case"":
magicType="ssh"
Copy link
Member

Choose a reason for hiding this comment

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

This smells like some cutover compatibility logic here.

mafredri reacted with laugh emoji
@mafredrimafredri merged commit9f5ad23 intomainFeb 19, 2025
30 checks passed
@mafredrimafredri deleted the mafredri/refactor-agentssh-magictype branchFebruary 19, 2025 20:18
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 19, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@mafredrimafredri

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp