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

feat(cli): support header and header-command in config-ssh#10413

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 10 commits intocoder:mainfromJoshVee:joshvee-ssh-header-command
Feb 7, 2024

Conversation

JoshVee
Copy link
Contributor

This PR modifies theconfig-ssh command so that it includes any provided--header-command \CODER_HEADER_COMMAND in the generated SSHProxyCommand.

This ensures that any custom headers are also available when runningssh coder.workspace.

The avoids the need to always rely on having theCODER_HEADER_COMMAND environment variable set globally.

MrPeacockNLB reacted with thumbs up emoji
@cdr-botcdr-botbot added the communityPull Requests and issues created by the community. labelOct 30, 2023
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelNov 7, 2023
@matifalimatifali removed the staleThis issue is like stale bread. labelNov 7, 2023
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelNov 15, 2023
@spikecurtisspikecurtis removed the staleThis issue is like stale bread. labelNov 21, 2023
@mafredri
Copy link
Member

mafredri commentedNov 21, 2023
edited
Loading

Hey@JoshVee, thanks for the PR and sorry for the long wait-time.

I think this PR looks good, but there's a change I'd like to see before we merge it, and that's support for serializing the header command into the options.

For instance, compare these two:

./coder config-ssh --header-command'echo foo=bar'>The following changes will be made to your SSH configuration:    * Update the coder section in /home/coder/.ssh/coder  Continue? (yes/no)yes

Versus:

./coder config-ssh --header-command'echo foo=bar' -o ForwardAgent=yes>New options differ from previous options:  New options:    * ssh-option: ForwardAgent=yes  Previous options: none              (<- should list header command)  Use new options? (yes/no)yes>The following changes will be made to your SSH configuration:    * Use new options    * Update the coder section in /home/coder/.ssh/coder  Continue? (yes/no)yes

Now let's say we forget about the header command next run, there's only going to be a cryptic change to the SSH config, and users may be left wondering why SSH isn't working afterwards (the update removes the header command, but doesn't say that the options/settings have changed):

./coder config-ssh -o ForwardAgent=yes>The following changes will be made to your SSH configuration:    * Update the coder section in /home/coder/.ssh/coder  Continue? (yes/no)

The options are serialized under# Last config-ssh options::

# ------------START-CODER-----------# This section is managed by coder. DO NOT EDIT.## You should not hand-edit this section unless you are removing it, all# changes will be lost when running "coder config-ssh".## Last config-ssh options:# :ssh-option=ForwardAgent=yes#

I would suggest something like# :header-command=printf h1=v1.

Emyrk reacted with thumbs up emoji

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelNov 29, 2023
@mafredrimafredri reopened thisDec 3, 2023
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelDec 4, 2023
@mafredrimafredri removed their request for reviewDecember 7, 2023 14:30
@mafredri
Copy link
Member

@JoshVee are you still interested in working on this PR? If not, we can see if someone on the team has the bandwidth to tackle it.

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelDec 15, 2023
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelDec 21, 2023
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJan 2, 2024
@matifalimatifali removed the staleThis issue is like stale bread. labelJan 2, 2024
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJan 10, 2024
@mafredrimafredri reopened thisJan 16, 2024
@mafredrimafredri removed the staleThis issue is like stale bread. labelJan 16, 2024
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJan 24, 2024
@mafredrimafredri reopened thisJan 28, 2024
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelJan 29, 2024
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelFeb 5, 2024
@mafredrimafredri removed the staleThis issue is like stale bread. labelFeb 5, 2024
@mafredrimafredri changed the titlefeat(cli): add provided header command to the SSH configfeat(cli): add support for header and header-command to config-sshFeb 5, 2024
rootFlags += fmt.Sprintf(" --header %q", h)
}
if sshConfigOpts.headerCommand != "" {
rootFlags += fmt.Sprintf(" --header-command %q", sshConfigOpts.headerCommand)
Copy link
Member

Choose a reason for hiding this comment

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

Review: We shouldn't need to do special escaping here like we do for the coder binary, that's because we're simply passing a string argument to coder.

mtojek reacted with thumbs up emoji
@mafredri
Copy link
Member

Updated the PR with changes to support serialization, while I was at it, I included support for--header, too.

./coder config-ssh --header-command'echo "foo=bar"' -o ForwardAgent=yes>New options differ from previous options:  New options:    * ssh-option: ForwardAgent=yes    * header-command: echo "foo=bar"  Previous options:    * ssh-option: ForwardAgent=yes    * header: foo=bar

Ready for review@Emyrk.

Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +120 to +123
a = slices.Clone(a)
slices.Sort(a)
b = slices.Clone(b)
slices.Sort(b)
Copy link
Member

Choose a reason for hiding this comment

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

nit: curious, can we replaceslices.Clone with a simple copy to omit cloning and just operate on same objects?

Copy link
Member

Choose a reason for hiding this comment

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

// Clone returns a copy of the slice.
// The elements are copied using assignment, so this is a shallow clone.

It's actually just a simple copy, so I think it's fine.

mtojek reacted with thumbs up emoji
@mafredrimafredri changed the titlefeat(cli): add support for header and header-command to config-sshfeat(cli): support header and header-command in config-sshFeb 7, 2024
@mafredrimafredri merged commitd3ccb07 intocoder:mainFeb 7, 2024
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsFeb 7, 2024
@mafredri
Copy link
Member

Thanks for your contribution@JoshVee, this finally went in!

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri left review comments

@mtojekmtojekmtojek approved these changes

@EmyrkEmyrkAwaiting requested review from Emyrk

Assignees

@mafredrimafredri

@JoshVeeJoshVee

Labels
communityPull Requests and issues created by the community.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@JoshVee@mafredri@mtojek@spikecurtis@matifali

[8]ページ先頭

©2009-2025 Movatter.jp