-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHub proxy part 6.5: tsh git ssh/clone/config #50044
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9d38794
GitHub proxy part 6.5: tsh git ssh/clone/config
greedy52 6a17f4d
review comments
greedy52 f028e9a
fix test
greedy52 7dd690a
fix ut for lookpath
greedy52 4c88bed
Merge branch 'master' of github.com:gravitational/teleport into STeve…
greedy52 683d82a
fix logger and update dependency version
greedy52 8a089af
go mod tidy for integrations
greedy52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package common | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alecthomas/kingpin/v2" | ||
"github.com/gravitational/trace" | ||
) | ||
|
||
// gitCloneCommand implements `tsh git clone`. | ||
// | ||
// This command internally executes `git clone` while setting `core.sshcommand`. | ||
// You can generally assume the user has `git` binary installed (otherwise there | ||
// is no point using the `git` proxy feature). | ||
// | ||
// TODO(greedy52) investigate using `go-git` library instead of calling `git | ||
// clone`. | ||
type gitCloneCommand struct { | ||
*kingpin.CmdClause | ||
|
||
repository string | ||
directory string | ||
} | ||
|
||
func newGitCloneCommand(parent *kingpin.CmdClause) *gitCloneCommand { | ||
cmd := &gitCloneCommand{ | ||
CmdClause: parent.Command("clone", "Clone a Git repository."), | ||
} | ||
|
||
cmd.Arg("repository", "Git URL of the repository to clone.").Required().StringVar(&cmd.repository) | ||
cmd.Arg("directory", "The name of a new directory to clone into.").StringVar(&cmd.directory) | ||
// TODO(greedy52) support passing extra args to git like --branch/--depth. | ||
return cmd | ||
} | ||
|
||
func (c *gitCloneCommand) run(cf *CLIConf) error { | ||
u, err := parseGitSSHURL(c.repository) | ||
if err != nil { | ||
return trace.Wrap(err) | ||
} | ||
if !u.isGitHub() { | ||
return trace.BadParameter("%s is not a GitHub repository", c.repository) | ||
} | ||
|
||
sshCommand := makeGitCoreSSHCommand(cf.executablePath, u.owner()) | ||
args := []string{ | ||
"clone", | ||
"--config", fmt.Sprintf("%s=%s", gitCoreSSHCommand, sshCommand), | ||
c.repository, | ||
} | ||
if c.directory != "" { | ||
args = append(args, c.directory) | ||
} | ||
return trace.Wrap(execGit(cf, args...)) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go-git
will be used for theteleport
as well.local mac build
tsh
increased about 200k (out of 106MB) after importing it.