Skip to content

Commit

Permalink
Merge pull request nicolastakashi#13 from nicolastakashi/feat/repo-da…
Browse files Browse the repository at this point in the history
…shboard-path

[FEAT] adding repo dash path flag
  • Loading branch information
nicolastakashi authored Nov 6, 2021
2 parents 5004b1f + b5c9931 commit 455c7f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func init() {
syncCmd.Flags().StringVar(&serverPort, "http.port", ":9754", "listem port for http endpoints")
syncCmd.Flags().StringVar(&pcmd.Repository.Url, "repository.url", "", "git repository url")
syncCmd.Flags().StringVar(&pcmd.Repository.Path, "repository.path", "", "path to clone the git repository")
syncCmd.Flags().StringVar(&pcmd.Repository.DashboardPath, "repository.dashboard-path", "", "path where the dashboards are places in git repository")
syncCmd.Flags().StringVar(&pcmd.Repository.Auth.Username, "repository.auth.username", "", "username to perform authentication")
syncCmd.Flags().StringVar(&pcmd.Repository.Auth.Password, "repository.auth.password", "", "password to perform authentication")
syncCmd.Flags().StringVar(&pcmd.Repository.Branch, "repository.branch", "main", "path to clone the git repository")
Expand Down
2 changes: 1 addition & 1 deletion internal/gitana/gitana.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func start(ctx context.Context, pcmd command.Sync) error {
return err
}

dashboards, err := dashboardloader.Load(pcmd.Repository.Path)
dashboards, err := dashboardloader.Load(pcmd.Repository.GetPath())

if err != nil {
return err
Expand Down
17 changes: 13 additions & 4 deletions internal/gitmanager/gitmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"os"
"path/filepath"

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
Expand All @@ -13,10 +14,11 @@ import (
)

type Repository struct {
Url string
Path string
Branch string
Auth RepositoryAuth
Url string
Path string
Branch string
DashboardPath string
Auth RepositoryAuth
}

type RepositoryAuth struct {
Expand Down Expand Up @@ -116,3 +118,10 @@ func (r Repository) getAuth() transport.AuthMethod {
}
return nil
}

func (r Repository) GetPath() string {
if r.DashboardPath != "" {
return filepath.Join(r.Path, r.DashboardPath)
}
return r.Path
}

0 comments on commit 455c7f1

Please sign in to comment.