Skip to content

Commit

Permalink
Merge pull request #382 from kluctl/fix-back-to-go-git
Browse files Browse the repository at this point in the history
fix: Move back to official go-git
  • Loading branch information
codablock committed Mar 21, 2023
2 parents 8b6df3b + 86335fd commit 6a7c324
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/kluctl/commands/cmd_helm_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package commands
import (
"context"
"fmt"
"github.com/fluxcd/go-git/v5/plumbing/format/index"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/format/index"
"github.com/kluctl/kluctl/v2/cmd/kluctl/args"
git2 "github.com/kluctl/kluctl/v2/pkg/git"
"github.com/kluctl/kluctl/v2/pkg/helm"
Expand Down
4 changes: 2 additions & 2 deletions e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package e2e

import (
"fmt"
"github.com/fluxcd/go-git/v5"
"github.com/fluxcd/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
test_utils "github.com/kluctl/kluctl/v2/e2e/test-utils"
"github.com/kluctl/kluctl/v2/pkg/utils/uo"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion e2e/test-utils/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/fluxcd/go-git/v5"
"github.com/go-git/go-git/v5"
"github.com/huandu/xstrings"
"github.com/jinzhu/copier"
"github.com/kluctl/kluctl/v2/cmd/kluctl/commands"
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ require (
github.com/bitnami-labs/sealed-secrets v0.19.5
github.com/cyphar/filepath-securejoin v0.2.3
github.com/docker/distribution v2.8.1+incompatible
// See https://github.com/fluxcd/pkg/issues/397, especially in regard to skeema/knownhosts breaking compatibility
github.com/fluxcd/go-git/v5 v5.0.0-20221206140629-ec778c2c37df
github.com/fluxcd/pkg/kustomize v0.13.2
github.com/go-playground/validator/v10 v10.11.2
github.com/gobwas/glob v0.2.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions pkg/git/auth/auth_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package auth
import (
"context"
"fmt"
"github.com/fluxcd/go-git/v5/plumbing/transport"
ssh2 "github.com/fluxcd/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/plumbing/transport"
ssh2 "github.com/go-git/go-git/v5/plumbing/transport/ssh"
git_url "github.com/kluctl/kluctl/v2/pkg/git/git-url"
"github.com/kluctl/kluctl/v2/pkg/git/messages"
"golang.org/x/crypto/ssh"
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/auth/git_credentials_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package auth
import (
"bufio"
"context"
"github.com/fluxcd/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/http"
git_url "github.com/kluctl/kluctl/v2/pkg/git/git-url"
"github.com/kluctl/kluctl/v2/pkg/git/git-url/giturls"
"github.com/kluctl/kluctl/v2/pkg/git/messages"
Expand Down
4 changes: 2 additions & 2 deletions pkg/git/auth/list_auth_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package auth

import (
"context"
"github.com/fluxcd/go-git/v5/plumbing/transport/http"
"github.com/fluxcd/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/kluctl/kluctl/v2/pkg/git/git-url"
"github.com/kluctl/kluctl/v2/pkg/git/messages"
ssh2 "golang.org/x/crypto/ssh"
Expand Down
20 changes: 20 additions & 0 deletions pkg/git/auth/ssh_known_hosts.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package auth

import (
"errors"
"fmt"
"github.com/kluctl/kluctl/v2/pkg/git/auth/goph"
"github.com/kluctl/kluctl/v2/pkg/git/messages"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/knownhosts"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -72,6 +74,24 @@ func verifyHost(messageCallbacks messages.MessageCallbacks, host string, remote
files = append(files, tmpFile.Name())
}

if key.Type() == "fake-public-key" {
// this makes us compatible to knownhosts.HostKeyAlgorithms which calls us with a fake public key and expects us
// to return all known keys
var keyErr knownhosts.KeyError
for _, f := range files {
hostFound, err := goph.CheckKnownHost(host, remote, key, f)
if hostFound && err == nil {
return fmt.Errorf("fake-public-key was unexpectadly found")
}
var tmpKeyErr *knownhosts.KeyError
if !errors.As(err, &tmpKeyErr) {
return fmt.Errorf("CheckKnownHost did not return expected KeyError: %v", err)
}
keyErr.Want = append(keyErr.Want, tmpKeyErr.Want...)
}
return &keyErr
}

for _, f := range files {
hostFound, err := goph.CheckKnownHost(host, remote, key, f)
if hostFound && err == nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/git/list_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"bytes"
"context"
"fmt"
"github.com/fluxcd/go-git/v5"
"github.com/fluxcd/go-git/v5/config"
"github.com/fluxcd/go-git/v5/plumbing"
"github.com/fluxcd/go-git/v5/plumbing/protocol/packp"
"github.com/fluxcd/go-git/v5/storage/memory"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/protocol/packp"
"github.com/go-git/go-git/v5/storage/memory"
auth2 "github.com/kluctl/kluctl/v2/pkg/git/auth"
git_url "github.com/kluctl/kluctl/v2/pkg/git/git-url"
ssh_pool "github.com/kluctl/kluctl/v2/pkg/git/ssh-pool"
Expand Down
8 changes: 4 additions & 4 deletions pkg/git/mirrored_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"github.com/fluxcd/go-git/v5"
"github.com/fluxcd/go-git/v5/config"
"github.com/fluxcd/go-git/v5/plumbing"
"github.com/fluxcd/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
auth2 "github.com/kluctl/kluctl/v2/pkg/git/auth"
git_url "github.com/kluctl/kluctl/v2/pkg/git/git-url"
_ "github.com/kluctl/kluctl/v2/pkg/git/ssh-pool"
Expand Down
4 changes: 2 additions & 2 deletions pkg/git/poor_mans_clone.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package git

import (
"github.com/fluxcd/go-git/v5"
"github.com/fluxcd/go-git/v5/config"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
cp "github.com/otiai10/copy"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/ssh-pool/hostport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ssh_pool

import (
"fmt"
"github.com/fluxcd/go-git/v5/plumbing/transport/ssh"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"strconv"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/git/test_git_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"reflect"
"testing"

"github.com/fluxcd/go-git/v5"
"github.com/go-git/go-git/v5"
"github.com/jinzhu/copier"
http_server "github.com/kluctl/kluctl/v2/pkg/git/http-server"
"gopkg.in/yaml.v3"
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package git

import (
"fmt"
"github.com/fluxcd/go-git/v5"
"github.com/go-git/go-git/v5"
"os"
"path/filepath"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/vars/vars_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"
"testing"

git2 "github.com/fluxcd/go-git/v5"
"github.com/fluxcd/go-git/v5/plumbing"
git2 "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/kluctl/kluctl/v2/pkg/git"
"github.com/kluctl/kluctl/v2/pkg/git/auth"
git_url "github.com/kluctl/kluctl/v2/pkg/git/git-url"
Expand Down

0 comments on commit 6a7c324

Please sign in to comment.