Skip to content

Commit

Permalink
Rename Git packages to implementations
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hello@hidde.co>
  • Loading branch information
hiddeco committed Feb 8, 2021
1 parent aaee433 commit 7e63ef8
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 24 deletions.
5 changes: 3 additions & 2 deletions api/v1beta1/gitrepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import (
const (
// GitRepositoryKind is the string representation of a GitRepository.
GitRepositoryKind = "GitRepository"
// GoGitImplementation represents the go-git git implementation kind.

// GoGitImplementation represents the go-git Git implementation kind.
GoGitImplementation = "go-git"
// LibGit2Implementation represents the gi2go git implementation kind.
// LibGit2Implementation represents the git2go Git implementation kind.
LibGit2Implementation = "libgit2"
)

Expand Down
16 changes: 6 additions & 10 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ import (

sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/fluxcd/source-controller/pkg/git/common"
gitv1 "github.com/fluxcd/source-controller/pkg/git/v1"
gitv2 "github.com/fluxcd/source-controller/pkg/git/v2"
)

const (
defaultBranch = "master"
"github.com/fluxcd/source-controller/pkg/git/gogit"
"github.com/fluxcd/source-controller/pkg/git/libgit2"
)

func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef, gitImplementation string) (common.CheckoutStrategy, error) {
switch gitImplementation {
case sourcev1.GoGitImplementation:
return gitv1.CheckoutStrategyForRef(ref), nil
return gogit.CheckoutStrategyForRef(ref), nil
case sourcev1.LibGit2Implementation:
return gitv2.CheckoutStrategyForRef(ref), nil
return libgit2.CheckoutStrategyForRef(ref), nil
default:
return nil, fmt.Errorf("invalid git implementation %s", gitImplementation)
}
Expand All @@ -43,9 +39,9 @@ func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef, gitImplementation st
func AuthSecretStrategyForURL(url string, gitImplementation string) (common.AuthSecretStrategy, error) {
switch gitImplementation {
case sourcev1.GoGitImplementation:
return gitv1.AuthSecretStrategyForURL(url)
return gogit.AuthSecretStrategyForURL(url)
case sourcev1.LibGit2Implementation:
return gitv2.AuthSecretStrategyForURL(url)
return libgit2.AuthSecretStrategyForURL(url)
default:
return nil, fmt.Errorf("invalid git implementation %s", gitImplementation)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/git/v1/checkout.go → pkg/git/gogit/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package gogit

import (
"context"
Expand All @@ -27,6 +27,7 @@ import (
"github.com/go-git/go-git/v5/plumbing"

"github.com/fluxcd/pkg/version"

sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/fluxcd/source-controller/pkg/git/common"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package gogit

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/v1/commit.go → pkg/git/gogit/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package gogit

import (
"fmt"
Expand Down
3 changes: 2 additions & 1 deletion pkg/git/v1/transport.go → pkg/git/gogit/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package gogit

import (
"fmt"
Expand All @@ -25,6 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"

"github.com/fluxcd/pkg/ssh/knownhosts"

"github.com/fluxcd/source-controller/pkg/git/common"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1
package gogit

import (
"reflect"
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/v2/checkout.go → pkg/git/libgit2/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package libgit2

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package libgit2

import (
"context"
Expand Down
5 changes: 3 additions & 2 deletions pkg/git/v2/commit.go → pkg/git/libgit2/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package libgit2

import (
"bytes"
"fmt"
"golang.org/x/crypto/openpgp"
"strings"

"golang.org/x/crypto/openpgp"

git2go "github.com/libgit2/git2go/v31"
corev1 "k8s.io/api/core/v1"
)
Expand Down
5 changes: 3 additions & 2 deletions pkg/git/v2/transport.go → pkg/git/libgit2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package libgit2

import (
"bufio"
Expand All @@ -27,9 +27,10 @@ import (

"golang.org/x/crypto/ssh"

"github.com/fluxcd/source-controller/pkg/git/common"
git2go "github.com/libgit2/git2go/v31"
corev1 "k8s.io/api/core/v1"

"github.com/fluxcd/source-controller/pkg/git/common"
)

func AuthSecretStrategyForURL(URL string) (common.AuthSecretStrategy, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v2
package libgit2

import (
"reflect"
Expand Down

0 comments on commit 7e63ef8

Please sign in to comment.