Skip to content

Commit 3153a61

Browse files
authored
👻 Better modeling of SCM and maven. (#53)
The Remote currently contains a *api.Repository which is good for the SCM repositories but not relevant for Maven. After this is removed, Remote only provides common _authentication_ attributes/operations. This is the only thing SCM and Maven repositories have in common. --------- Signed-off-by: Jeff Ortel <[email protected]>
1 parent f117cd5 commit 3153a61

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

repository/factory.go

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ func New(destDir string, remote *api.Repository, identities []api.Ref) (r SCM, e
2525
if err != nil {
2626
return
2727
}
28-
r = &Subversion{
29-
Path: destDir,
30-
Remote: Remote{
31-
Repository: remote,
32-
Identities: identities,
33-
Insecure: insecure,
34-
},
35-
}
28+
svn := &Subversion{}
29+
svn.Path = destDir
30+
svn.Remote = *remote
31+
svn.Identities = identities
32+
svn.Insecure = insecure
33+
r = svn
3634
default:
3735
insecure, err = addon.Setting.Bool("git.insecure.enabled")
3836
if err != nil {
3937
return
4038
}
41-
r = &Git{
42-
Path: destDir,
43-
Remote: Remote{
44-
Repository: remote,
45-
Identities: identities,
46-
Insecure: insecure,
47-
},
48-
}
39+
git := &Git{}
40+
git.Path = destDir
41+
git.Remote = *remote
42+
git.Identities = identities
43+
git.Insecure = insecure
44+
r = git
4945
}
5046
err = r.Validate()
5147
return
@@ -60,15 +56,14 @@ type SCM interface {
6056
Head() (commit string, err error)
6157
}
6258

63-
// Remote repository.
64-
type Remote struct {
65-
*api.Repository
59+
// Authenticated repository.
60+
type Authenticated struct {
6661
Identities []api.Ref
6762
Insecure bool
6863
}
6964

7065
// FindIdentity by kind.
71-
func (r *Remote) findIdentity(kind string) (matched *api.Identity, found bool, err error) {
66+
func (r *Authenticated) findIdentity(kind string) (matched *api.Identity, found bool, err error) {
7267
for _, ref := range r.Identities {
7368
identity, nErr := addon.Identity.Get(ref.ID)
7469
if nErr != nil {

repository/git.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import (
1717

1818
// Git repository.
1919
type Git struct {
20-
Remote
21-
Path string
20+
Authenticated
21+
Remote api.Repository
22+
Path string
2223
}
2324

2425
// Validate settings.

repository/maven.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const emptySettings = `
2121

2222
// Maven repository.
2323
type Maven struct {
24-
Remote
24+
Authenticated
2525
BinDir string
2626
M2Dir string
2727
}

repository/subversion.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import (
1818

1919
// Subversion repository.
2020
type Subversion struct {
21-
Remote
22-
Path string
21+
Authenticated
22+
Remote api.Repository
23+
Path string
2324
}
2425

2526
// Validate settings.

0 commit comments

Comments
 (0)