Skip to content

Commit

Permalink
Merge pull request #355 from kube-tarian/argocd_create_repo_git_commit
Browse files Browse the repository at this point in the history
added argocd repo and git commit changes
  • Loading branch information
vramk23 authored Dec 30, 2023
2 parents 6e78d4a + 07522dc commit ea673d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions capten/agent/internal/api/plugin_argocd_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (a *Agent) addProjectToArgoCD(ctx context.Context, projectUrl, userID, acce
Insecure: false,
EnableLFS: false,
InsecureIgnoreHostKey: false,
Upsert: true,
ConnectionState: argocd.ConnectionState{
Status: "Connected",
Message: "Repository is connected",
Expand Down
1 change: 1 addition & 0 deletions capten/common-pkg/plugins/argocd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ type Repository struct {
EnableLFS bool `json:"EnableLFS"`
InsecureIgnoreHostKey bool `json:"InsecureIgnoreHostKey"`
ConnectionState ConnectionState `json:"ConnectionState"`
Upsert bool `json:"Upsert"`
}
1 change: 1 addition & 0 deletions capten/common-pkg/plugins/argocd/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (a *ArgoCDClient) CreateRepository(ctx context.Context, repo *Repository) (
Message: repo.ConnectionState.Message,
},
},
Upsert: repo.Upsert,
})
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions capten/common-pkg/plugins/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/intelops/go-common/logging"
)

type GitClient struct {
Expand Down Expand Up @@ -74,6 +75,15 @@ func (g *GitClient) Commit(msg, name, email string) error {
return err
}

status, err := w.Status()
if err != nil {
return err
}

if status.IsClean() {
logging.NewLogger().Info("No commit changes found.")
return nil
}
_, err = w.Commit(msg, &git.CommitOptions{
Author: &object.Signature{
Name: name,
Expand Down

0 comments on commit ea673d7

Please sign in to comment.