-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapper.go
40 lines (33 loc) · 871 Bytes
/
mapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"strconv"
"github.com/iver-wharf/wharf-api-client-go/v2/pkg/model/request"
"github.com/xanzy/go-gitlab"
)
type mapper struct {
tokenID uint
providerID uint
}
func (m *mapper) mapProjectToWharfEntity(proj gitlab.Project, buildDef string) request.Project {
groupName := ""
if proj.Namespace != nil {
groupName = proj.Namespace.FullPath
}
return request.Project{
Name: proj.Name,
BuildDefinition: buildDef,
Description: proj.Description,
AvatarURL: proj.AvatarURL,
GitURL: proj.SSHURLToRepo,
TokenID: m.tokenID,
ProviderID: m.providerID,
GroupName: groupName,
RemoteProjectID: strconv.Itoa(proj.ID),
}
}
func (m *mapper) mapBranchToWharfEntity(branch gitlab.Branch) request.Branch {
return request.Branch{
Name: branch.Name,
Default: branch.Default,
}
}