Rename Git packages to implementations

Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
Hidde Beydals 2021-01-28 11:55:45 +01:00
parent aaee43338e
commit 7e63ef841c
12 changed files with 25 additions and 24 deletions

View File

@ -25,9 +25,10 @@ import (
const ( const (
// GitRepositoryKind is the string representation of a GitRepository. // GitRepositoryKind is the string representation of a GitRepository.
GitRepositoryKind = "GitRepository" GitRepositoryKind = "GitRepository"
// GoGitImplementation represents the go-git git implementation kind.
// GoGitImplementation represents the go-git Git implementation kind.
GoGitImplementation = "go-git" GoGitImplementation = "go-git"
// LibGit2Implementation represents the gi2go git implementation kind. // LibGit2Implementation represents the git2go Git implementation kind.
LibGit2Implementation = "libgit2" LibGit2Implementation = "libgit2"
) )

View File

@ -21,20 +21,16 @@ import (
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/fluxcd/source-controller/pkg/git/common" "github.com/fluxcd/source-controller/pkg/git/common"
gitv1 "github.com/fluxcd/source-controller/pkg/git/v1" "github.com/fluxcd/source-controller/pkg/git/gogit"
gitv2 "github.com/fluxcd/source-controller/pkg/git/v2" "github.com/fluxcd/source-controller/pkg/git/libgit2"
)
const (
defaultBranch = "master"
) )
func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef, gitImplementation string) (common.CheckoutStrategy, error) { func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef, gitImplementation string) (common.CheckoutStrategy, error) {
switch gitImplementation { switch gitImplementation {
case sourcev1.GoGitImplementation: case sourcev1.GoGitImplementation:
return gitv1.CheckoutStrategyForRef(ref), nil return gogit.CheckoutStrategyForRef(ref), nil
case sourcev1.LibGit2Implementation: case sourcev1.LibGit2Implementation:
return gitv2.CheckoutStrategyForRef(ref), nil return libgit2.CheckoutStrategyForRef(ref), nil
default: default:
return nil, fmt.Errorf("invalid git implementation %s", gitImplementation) return nil, fmt.Errorf("invalid git implementation %s", gitImplementation)
} }
@ -43,9 +39,9 @@ func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef, gitImplementation st
func AuthSecretStrategyForURL(url string, gitImplementation string) (common.AuthSecretStrategy, error) { func AuthSecretStrategyForURL(url string, gitImplementation string) (common.AuthSecretStrategy, error) {
switch gitImplementation { switch gitImplementation {
case sourcev1.GoGitImplementation: case sourcev1.GoGitImplementation:
return gitv1.AuthSecretStrategyForURL(url) return gogit.AuthSecretStrategyForURL(url)
case sourcev1.LibGit2Implementation: case sourcev1.LibGit2Implementation:
return gitv2.AuthSecretStrategyForURL(url) return libgit2.AuthSecretStrategyForURL(url)
default: default:
return nil, fmt.Errorf("invalid git implementation %s", gitImplementation) return nil, fmt.Errorf("invalid git implementation %s", gitImplementation)
} }

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1 package gogit
import ( import (
"context" "context"
@ -27,6 +27,7 @@ import (
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/fluxcd/pkg/version" "github.com/fluxcd/pkg/version"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
"github.com/fluxcd/source-controller/pkg/git/common" "github.com/fluxcd/source-controller/pkg/git/common"
) )

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1 package gogit
import ( import (
"context" "context"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1 package gogit
import ( import (
"fmt" "fmt"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1 package gogit
import ( import (
"fmt" "fmt"
@ -25,6 +25,7 @@ import (
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"github.com/fluxcd/pkg/ssh/knownhosts" "github.com/fluxcd/pkg/ssh/knownhosts"
"github.com/fluxcd/source-controller/pkg/git/common" "github.com/fluxcd/source-controller/pkg/git/common"
) )

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v1 package gogit
import ( import (
"reflect" "reflect"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v2 package libgit2
import ( import (
"context" "context"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v2 package libgit2
import ( import (
"context" "context"

View File

@ -14,14 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v2 package libgit2
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"golang.org/x/crypto/openpgp"
"strings" "strings"
"golang.org/x/crypto/openpgp"
git2go "github.com/libgit2/git2go/v31" git2go "github.com/libgit2/git2go/v31"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
) )

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v2 package libgit2
import ( import (
"bufio" "bufio"
@ -27,9 +27,10 @@ import (
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"github.com/fluxcd/source-controller/pkg/git/common"
git2go "github.com/libgit2/git2go/v31" git2go "github.com/libgit2/git2go/v31"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"github.com/fluxcd/source-controller/pkg/git/common"
) )
func AuthSecretStrategyForURL(URL string) (common.AuthSecretStrategy, error) { func AuthSecretStrategyForURL(URL string) (common.AuthSecretStrategy, error) {

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package v2 package libgit2
import ( import (
"reflect" "reflect"