Skip to content

Commit

Permalink
Better modeling of SCM and maven.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <jortel@redhat.com>
  • Loading branch information
jortel committed Jan 10, 2024
1 parent 3de14a3 commit 4afc782
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 9 additions & 10 deletions repository/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ func New(destDir string, remote *api.Repository, identities []api.Ref) (r SCM, e
switch remote.Kind {
case "subversion":
r = &Subversion{
Path: destDir,
Remote: Remote{
Repository: remote,
Path: destDir,
Remote: *remote,
Authenticated: Authenticated{
Identities: identities,
},
}
default:
r = &Git{
Path: destDir,
Remote: Remote{
Repository: remote,
Path: destDir,
Remote: *remote,
Authenticated: Authenticated{
Identities: identities,
},
}
Expand All @@ -47,14 +47,13 @@ type SCM interface {
Commit(files []string, msg string) (err error)
}

// Remote repository.
type Remote struct {
*api.Repository
// Authenticated repository.
type Authenticated struct {
Identities []api.Ref
}

// FindIdentity by kind.
func (r *Remote) findIdentity(kind string) (matched *api.Identity, found bool, err error) {
func (r *Authenticated) findIdentity(kind string) (matched *api.Identity, found bool, err error) {
for _, ref := range r.Identities {
identity, nErr := addon.Identity.Get(ref.ID)
if nErr != nil {
Expand Down
5 changes: 3 additions & 2 deletions repository/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (

// Git repository.
type Git struct {
Remote
Path string
Authenticated
Remote api.Repository
Path string
}

// Validate settings.
Expand Down
5 changes: 3 additions & 2 deletions repository/subversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import (

// Subversion repository.
type Subversion struct {
Remote
Path string
Authenticated
Remote api.Repository
Path string
}

// Validate settings.
Expand Down

0 comments on commit 4afc782

Please sign in to comment.