Skip to content

Commit

Permalink
add branch and ca
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Steffen <[email protected]>
  • Loading branch information
jastBytes committed Jul 11, 2022
1 parent 590af21 commit 12802a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/k8sauthzreactor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

es "github.com/finleap-connect/monoskope/pkg/eventsourcing"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -97,10 +98,15 @@ func NewConfigFromFile(data []byte) (*GitRepoReconcilerConfig, error) {
return nil, ErrIntervalIsRequired
}

if len(repo.Branch) == 0 {
return nil, ErrBranchIsRequired
}

// Set default values
if repo.Timeout == nil {
repo.Timeout = &DefaultTimeout
}

}

return conf, nil
Expand All @@ -109,7 +115,12 @@ func NewConfigFromFile(data []byte) (*GitRepoReconcilerConfig, error) {
// parseCloneOptions parses the configuration using the git library to validate.
func (c *GitRepoReconcilerConfig) parseCloneOptions(repo *GitRepository) error {
cloneOptions := &git.CloneOptions{
URL: repo.URL,
URL: repo.URL,
ReferenceName: plumbing.NewBranchReferenceName(repo.Branch),
SingleBranch: true,
NoCheckout: false,
Depth: 1,
CABundle: []byte(repo.CA),
}

// Configure basic auth optionally
Expand Down
1 change: 1 addition & 0 deletions internal/k8sauthzreactor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ import "errors"

var (
ErrIntervalIsRequired = errors.New("interval is required")
ErrBranchIsRequired = errors.New("branch is required")
)
2 changes: 2 additions & 0 deletions internal/k8sauthzreactor/test_config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
repositories:
- url: https://monoskope.io/test1.git
branch: main
caCert: dGhpcy1pcy1hLWNhLWNlcnQ=
basicAuth:
username: test1
password: testpw
allClusters: true
interval: 5m
- url: https://monoskope.io/test2.git
branch: test
interval: 5m
sshAuth:
privateKeyPath: testkey.pem
Expand Down

0 comments on commit 12802a7

Please sign in to comment.