summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Wereski <m.wereski@partner.samsung.com>2017-03-07 14:38:51 +0100
committerMaciej Wereski <m.wereski@partner.samsung.com>2017-08-17 08:53:00 +0200
commit9c6b6ee0c7abea51b2d3526e634a515b4e993689 (patch)
treed5e60d60296b64432a4be76487b18f7c4ff77b6e
parent55a6a5107ab60579f94af53ac2844f97add4f5d8 (diff)
downloadsnapsync-9c6b6ee0c7abea51b2d3526e634a515b4e993689.tar.gz
snapsync-9c6b6ee0c7abea51b2d3526e634a515b4e993689.tar.bz2
snapsync-9c6b6ee0c7abea51b2d3526e634a515b4e993689.zip
Add ssh username setting
Change-Id: I054d46a99f841c252387f1cf3a2f88d2674a904f Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
-rw-r--r--config/config.go11
-rw-r--r--snapsync.conf3
-rw-r--r--snapsync.go12
3 files changed, 25 insertions, 1 deletions
diff --git a/config/config.go b/config/config.go
index c13ae30..913f120 100644
--- a/config/config.go
+++ b/config/config.go
@@ -39,6 +39,12 @@ type General struct {
Editor string
}
+// User represents User section in config file.
+// It contains all information required to push via ssh.
+type User struct {
+ Username string
+}
+
// Repos represents Repos section in config file.
// It contains all information required to get metadata and sources.
type Repos struct {
@@ -53,6 +59,7 @@ type Repos struct {
// Settings contains all config sections.
type Settings struct {
G General
+ U User
R Repos
}
@@ -96,6 +103,10 @@ func LoadSettings(fpath string) (*Settings, error) {
if err != nil {
return nil, err
}
+ err = cfg.Section("User").MapTo(&s.U)
+ if err != nil {
+ return nil, err
+ }
err = cfg.Section("Repos").MapTo(&s.R)
if err != nil {
return nil, err
diff --git a/snapsync.conf b/snapsync.conf
index 664f706..f672b38 100644
--- a/snapsync.conf
+++ b/snapsync.conf
@@ -4,6 +4,9 @@ timeout = 3s
blacklist = /usr/share/snapsync/blacklist
editor = vim
+[User]
+username = tizenre
+
[Repos]
sourceURL = http://download.tizen.org/snapshots/tizen/
targetURL = http://download.tizen.org/snapshots/tizen/
diff --git a/snapsync.go b/snapsync.go
index 11ed8c9..ff46d0a 100644
--- a/snapsync.go
+++ b/snapsync.go
@@ -67,6 +67,9 @@ var (
// editor which will be used to edit report
editor string
+ // username for ssh git
+ username string
+
// number of Git Job workers
numWorkers int
// timeout for Git Manager to acquire lock
@@ -254,6 +257,12 @@ func setup() error {
}
editor = getValue(settings.G.Editor, os.Getenv("EDITOR"), false)
+ // User
+ username = settings.U.Username
+ if username == "" {
+ return fmt.Errorf("Username must be set")
+ }
+
// Repos
target = getValue(target, settings.R.Target, true)
if source == "" {
@@ -332,11 +341,12 @@ func main() {
if target == "" {
status = gitMgr.New
}
+ addr := sshURL.Scheme + "://" + username + "@" + sshURL.Host + "/"
for repoName, commit := range repoList {
repos[repoName] = &gitMgr.GitRepo{
Repo: repoName,
RemoteName: "snapsync",
- RemoteURL: sshURL.String() + repoName,
+ RemoteURL: addr + repoName,
SourceCommit: commit,
TargetCommit: submitted[repoName],
Status: status,