diff --git a/Makefile b/Makefile index fb476ab03cc40..e4c17ead06bb0 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,10 @@ server-image: docker build -t $(IMAGE_PREFIX)argocd-server:$(IMAGE_TAG) -f Dockerfile-argocd . @if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocd-server:$(IMAGE_TAG) ; fi +.PHONY: controller +controller: + go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argocd-application-controller ./cmd/argocd-application-controller + .PHONY: lint lint: # CGO_ENABLED=0 required due to: # https://github.com/alecthomas/gometalinter/issues/149#issuecomment-351272924 diff --git a/application/manager.go b/application/manager.go new file mode 100644 index 0000000000000..e55cc117f1232 --- /dev/null +++ b/application/manager.go @@ -0,0 +1,94 @@ +package application + +import ( + "context" + + "io/ioutil" + + "fmt" + + "time" + + "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" + "github.com/argoproj/argo-cd/server/repository" + "github.com/argoproj/argo-cd/util/git" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Manager is responsible to retrieve application spec and compare it to actual application state. +type Manager struct { + gitClient git.Client + repoService repository.RepositoryServiceServer + statusRefreshTimeout time.Duration +} + +// NeedRefreshAppStatus answers if application status needs to be refreshed. Returns true if application never been compared, has changed or comparison result has expired. +func (m *Manager) NeedRefreshAppStatus(app *v1alpha1.Application) bool { + return app.Status.ComparisonResult.Status == v1alpha1.ComparisonStatusUnknown || + !app.Spec.Source.Equals(app.Status.ComparisonResult.ComparedTo) || + app.Status.ComparisonResult.ComparedAt.Add(m.statusRefreshTimeout).Before(time.Now()) +} + +// RefreshAppStatus compares application against actual state in target cluster and returns updated status. +func (m *Manager) RefreshAppStatus(app *v1alpha1.Application) *v1alpha1.ApplicationStatus { + status, err := m.tryRefreshAppStatus(app) + if err != nil { + status = &v1alpha1.ApplicationStatus{ + ComparisonResult: v1alpha1.ComparisonResult{ + Status: v1alpha1.ComparisonStatusError, + ComparisonErrorDetails: fmt.Sprintf("Failed to get application status for application '%s': %+v", app.Name, err), + ComparedTo: app.Spec.Source, + ComparedAt: metav1.Time{Time: time.Now().UTC()}, + }, + } + } + return status +} + +func (m *Manager) tryRefreshAppStatus(app *v1alpha1.Application) (*v1alpha1.ApplicationStatus, error) { + repo, err := m.repoService.Get(context.Background(), &repository.RepoQuery{Repo: app.Spec.Source.RepoURL}) + if err != nil { + return nil, err + } + + appRepoPath, err := ioutil.TempDir("", app.Name) + if err != nil { + return nil, fmt.Errorf("unable to create temp repository directory for app '%s'", app.Name) + } + + err = m.gitClient.CloneOrFetch(repo.Repo, repo.Username, repo.Password, appRepoPath) + if err != nil { + return nil, err + } + + err = m.gitClient.Checkout(appRepoPath, app.Spec.Source.TargetRevision) + if err != nil { + return nil, err + } + comparisonResult, err := m.compareAppState(appRepoPath, app) + if err != nil { + return nil, err + } + return &v1alpha1.ApplicationStatus{ + ComparisonResult: *comparisonResult, + }, nil +} + +func (m *Manager) compareAppState(appRepoPath string, app *v1alpha1.Application) (*v1alpha1.ComparisonResult, error) { + // TODO (amatyushentsev): Implement actual comparison + return &v1alpha1.ComparisonResult{ + Status: v1alpha1.ComparisonStatusEqual, + ComparedTo: app.Spec.Source, + ComparedAt: metav1.Time{Time: time.Now().UTC()}, + }, nil +} + +// NewAppManager creates new instance of app.Manager +func NewAppManager(gitClient git.Client, repoService repository.RepositoryServiceServer, statusRefreshTimeout time.Duration) *Manager { + return &Manager{ + gitClient: gitClient, + repoService: repoService, + statusRefreshTimeout: statusRefreshTimeout, + } +} diff --git a/cmd/argocd/application-controller/main.go b/cmd/argocd-application-controller/main.go similarity index 68% rename from cmd/argocd/application-controller/main.go rename to cmd/argocd-application-controller/main.go index f6df2a44ba7ed..2fd6bf7b043c5 100644 --- a/cmd/argocd/application-controller/main.go +++ b/cmd/argocd-application-controller/main.go @@ -3,13 +3,18 @@ package main import ( "context" "fmt" - "github.com/argoproj/argo-cd/application/controller" + "os" + "time" + + "github.com/argoproj/argo-cd/application" "github.com/argoproj/argo-cd/cmd/argocd/commands" + "github.com/argoproj/argo-cd/controller" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" + "github.com/argoproj/argo-cd/server/repository" + "github.com/argoproj/argo-cd/util/git" "github.com/spf13/cobra" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" - "os" ) const ( @@ -25,13 +30,23 @@ func newCommand() *cobra.Command { var command = cobra.Command{ Use: cliName, Short: "application-controller is a controller to operate on applications CRD", - Run: func(c *cobra.Command, args []string) { + RunE: func(c *cobra.Command, args []string) error { kubeConfig := commands.GetKubeConfig(kubeConfigPath, kubeConfigOverrides) + nativeGitClient, err := git.NewNativeGitClient() + if err != nil { + return err + } kubeClient := kubernetes.NewForConfigOrDie(kubeConfig) appClient := appclientset.NewForConfigOrDie(kubeConfig) - appController := controller.NewApplicationController(kubeClient, appClient) + // TODO (amatyushentsev): Use config map to store controller configuration + namespace := "default" + appResyncPeriod := time.Minute * 10 + + appManager := application.NewAppManager(nativeGitClient, repository.NewServer(namespace, kubeClient, appClient), appResyncPeriod) + + appController := controller.NewApplicationController(kubeClient, appClient, appManager, appResyncPeriod) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/application/controller/controller.go b/controller/controller.go similarity index 56% rename from application/controller/controller.go rename to controller/controller.go index 8b39d14b83d55..ac95fa0c11406 100644 --- a/application/controller/controller.go +++ b/controller/controller.go @@ -3,12 +3,14 @@ package controller import ( "context" + appv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" appinformers "github.com/argoproj/argo-cd/pkg/client/informers/externalversions" log "github.com/sirupsen/logrus" "time" + "github.com/argoproj/argo-cd/application" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" @@ -16,27 +18,29 @@ import ( "k8s.io/client-go/util/workqueue" ) -const ( - appResyncPeriod = 10 * time.Minute -) - // ApplicationController is the controller for application resources. type ApplicationController struct { - kubeclientset kubernetes.Interface - applicationclientset appclientset.Interface - appQueue workqueue.RateLimitingInterface + appManager *application.Manager - appInformer cache.SharedIndexInformer + kubeClientset kubernetes.Interface + applicationClientset appclientset.Interface + appQueue workqueue.RateLimitingInterface + appInformer cache.SharedIndexInformer } // NewApplicationController creates new instance of ApplicationController. -func NewApplicationController(kubeclientset kubernetes.Interface, applicationclientset appclientset.Interface) *ApplicationController { +func NewApplicationController( + kubeClientset kubernetes.Interface, + applicationClientset appclientset.Interface, + appManager *application.Manager, + appResyncPeriod time.Duration) *ApplicationController { appQueue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) return &ApplicationController{ - kubeclientset: kubeclientset, - applicationclientset: applicationclientset, + appManager: appManager, + kubeClientset: kubeClientset, + applicationClientset: applicationClientset, appQueue: appQueue, - appInformer: newApplicationInformer(applicationclientset, appQueue), + appInformer: newApplicationInformer(applicationClientset, appQueue, appResyncPeriod), } } @@ -61,10 +65,33 @@ func (ctrl *ApplicationController) Run(ctx context.Context, appWorkers int) { func (ctrl *ApplicationController) processNextItem() bool { appKey, shutdown := ctrl.appQueue.Get() - defer ctrl.appQueue.Done(appKey) if shutdown { return false } + + defer ctrl.appQueue.Done(appKey) + + obj, exists, err := ctrl.appInformer.GetIndexer().GetByKey(appKey.(string)) + if err != nil { + log.Errorf("Failed to get application '%s' from informer index: %+v", appKey, err) + return true + } + if !exists { + // This happens after app was deleted, but the work queue still had an entry for it. + return true + } + app, ok := obj.(*appv1.Application) + if !ok { + log.Warnf("Key '%s' in index is not an application", appKey) + return true + } + + updatedApp := app.DeepCopy() + if ctrl.appManager.NeedRefreshAppStatus(updatedApp) { + updatedApp.Status = *ctrl.appManager.RefreshAppStatus(updatedApp) + ctrl.persistApp(updatedApp) + } + return true } @@ -73,9 +100,18 @@ func (ctrl *ApplicationController) runWorker() { } } -func newApplicationInformer(appclientset appclientset.Interface, appQueue workqueue.RateLimitingInterface) cache.SharedIndexInformer { +func (ctrl *ApplicationController) persistApp(app *appv1.Application) { + appClient := ctrl.applicationClientset.ArgoprojV1alpha1().Applications(app.ObjectMeta.Namespace) + _, err := appClient.Update(app) + if err != nil { + log.Warnf("Error updating application: %v", err) + } + log.Info("Application update successful") +} + +func newApplicationInformer(appClientset appclientset.Interface, appQueue workqueue.RateLimitingInterface, appResyncPeriod time.Duration) cache.SharedIndexInformer { appInformerFactory := appinformers.NewSharedInformerFactory( - appclientset, + appClientset, appResyncPeriod, ) informer := appInformerFactory.Argoproj().V1alpha1().Applications().Informer() diff --git a/pkg/apis/application/v1alpha1/generated.pb.go b/pkg/apis/application/v1alpha1/generated.pb.go index 3b989c7ac4893..a3d40b56d09fc 100644 --- a/pkg/apis/application/v1alpha1/generated.pb.go +++ b/pkg/apis/application/v1alpha1/generated.pb.go @@ -16,6 +16,7 @@ Cluster ClusterList ClusterSpec + ComparisonResult Repository RepositoryList */ @@ -73,13 +74,17 @@ func (m *ClusterSpec) Reset() { *m = ClusterSpec{} } func (*ClusterSpec) ProtoMessage() {} func (*ClusterSpec) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{7} } +func (m *ComparisonResult) Reset() { *m = ComparisonResult{} } +func (*ComparisonResult) ProtoMessage() {} +func (*ComparisonResult) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{8} } + func (m *Repository) Reset() { *m = Repository{} } func (*Repository) ProtoMessage() {} -func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{8} } +func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{9} } func (m *RepositoryList) Reset() { *m = RepositoryList{} } func (*RepositoryList) ProtoMessage() {} -func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{9} } +func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{10} } func init() { proto.RegisterType((*Application)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application") @@ -90,6 +95,7 @@ func init() { proto.RegisterType((*Cluster)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Cluster") proto.RegisterType((*ClusterList)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ClusterList") proto.RegisterType((*ClusterSpec)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ClusterSpec") + proto.RegisterType((*ComparisonResult)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComparisonResult") proto.RegisterType((*Repository)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Repository") proto.RegisterType((*RepositoryList)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.RepositoryList") } @@ -190,17 +196,17 @@ func (m *ApplicationSource) MarshalTo(dAtA []byte) (int, error) { _ = l dAtA[i] = 0xa i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.GitRepoSecret.Size())) - n5, err := m.GitRepoSecret.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n5 + i = encodeVarintGenerated(dAtA, i, uint64(len(m.TargetRevision))) + i += copy(dAtA[i:], m.TargetRevision) dAtA[i] = 0x12 i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.RepoURL))) + i += copy(dAtA[i:], m.RepoURL) + dAtA[i] = 0x1a + i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Path))) i += copy(dAtA[i:], m.Path) - dAtA[i] = 0x1a + dAtA[i] = 0x22 i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Environment))) i += copy(dAtA[i:], m.Environment) @@ -224,16 +230,12 @@ func (m *ApplicationSpec) MarshalTo(dAtA []byte) (int, error) { _ = l dAtA[i] = 0xa i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.TargetRevision))) - i += copy(dAtA[i:], m.TargetRevision) - dAtA[i] = 0x12 - i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Source.Size())) - n6, err := m.Source.MarshalTo(dAtA[i:]) + n5, err := m.Source.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n6 + i += n5 return i, nil } @@ -254,12 +256,12 @@ func (m *ApplicationStatus) MarshalTo(dAtA []byte) (int, error) { _ = l dAtA[i] = 0xa i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.ComparisonResult))) - i += copy(dAtA[i:], m.ComparisonResult) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.DifferenceDetails))) - i += copy(dAtA[i:], m.DifferenceDetails) + i = encodeVarintGenerated(dAtA, i, uint64(m.ComparisonResult.Size())) + n6, err := m.ComparisonResult.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 return i, nil } @@ -357,6 +359,52 @@ func (m *ClusterSpec) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ComparisonResult) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ComparisonResult) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedAt.Size())) + n10, err := m.ComparedAt.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n10 + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedTo.Size())) + n11, err := m.ComparedTo.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n11 + dAtA[i] = 0x1a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) + i += copy(dAtA[i:], m.Status) + dAtA[i] = 0x22 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.DifferenceDetails))) + i += copy(dAtA[i:], m.DifferenceDetails) + dAtA[i] = 0x2a + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ComparisonErrorDetails))) + i += copy(dAtA[i:], m.ComparisonErrorDetails) + return i, nil +} + func (m *Repository) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -405,11 +453,11 @@ func (m *RepositoryList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n10, err := m.ListMeta.MarshalTo(dAtA[i:]) + n12, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n12 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -463,7 +511,9 @@ func (m *ApplicationList) Size() (n int) { func (m *ApplicationSource) Size() (n int) { var l int _ = l - l = m.GitRepoSecret.Size() + l = len(m.TargetRevision) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.RepoURL) n += 1 + l + sovGenerated(uint64(l)) l = len(m.Path) n += 1 + l + sovGenerated(uint64(l)) @@ -475,8 +525,6 @@ func (m *ApplicationSource) Size() (n int) { func (m *ApplicationSpec) Size() (n int) { var l int _ = l - l = len(m.TargetRevision) - n += 1 + l + sovGenerated(uint64(l)) l = m.Source.Size() n += 1 + l + sovGenerated(uint64(l)) return n @@ -485,9 +533,7 @@ func (m *ApplicationSpec) Size() (n int) { func (m *ApplicationStatus) Size() (n int) { var l int _ = l - l = len(m.ComparisonResult) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.DifferenceDetails) + l = m.ComparisonResult.Size() n += 1 + l + sovGenerated(uint64(l)) return n } @@ -524,6 +570,22 @@ func (m *ClusterSpec) Size() (n int) { return n } +func (m *ComparisonResult) Size() (n int) { + var l int + _ = l + l = m.ComparedAt.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.ComparedTo.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.Status) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.DifferenceDetails) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.ComparisonErrorDetails) + n += 1 + l + sovGenerated(uint64(l)) + return n +} + func (m *Repository) Size() (n int) { var l int _ = l @@ -591,7 +653,8 @@ func (this *ApplicationSource) String() string { return "nil" } s := strings.Join([]string{`&ApplicationSource{`, - `GitRepoSecret:` + strings.Replace(strings.Replace(this.GitRepoSecret.String(), "LocalObjectReference", "k8s_io_api_core_v1.LocalObjectReference", 1), `&`, ``, 1) + `,`, + `TargetRevision:` + fmt.Sprintf("%v", this.TargetRevision) + `,`, + `RepoURL:` + fmt.Sprintf("%v", this.RepoURL) + `,`, `Path:` + fmt.Sprintf("%v", this.Path) + `,`, `Environment:` + fmt.Sprintf("%v", this.Environment) + `,`, `}`, @@ -603,7 +666,6 @@ func (this *ApplicationSpec) String() string { return "nil" } s := strings.Join([]string{`&ApplicationSpec{`, - `TargetRevision:` + fmt.Sprintf("%v", this.TargetRevision) + `,`, `Source:` + strings.Replace(strings.Replace(this.Source.String(), "ApplicationSource", "ApplicationSource", 1), `&`, ``, 1) + `,`, `}`, }, "") @@ -614,8 +676,7 @@ func (this *ApplicationStatus) String() string { return "nil" } s := strings.Join([]string{`&ApplicationStatus{`, - `ComparisonResult:` + fmt.Sprintf("%v", this.ComparisonResult) + `,`, - `DifferenceDetails:` + fmt.Sprintf("%v", this.DifferenceDetails) + `,`, + `ComparisonResult:` + strings.Replace(strings.Replace(this.ComparisonResult.String(), "ComparisonResult", "ComparisonResult", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -652,6 +713,20 @@ func (this *ClusterSpec) String() string { }, "") return s } +func (this *ComparisonResult) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ComparisonResult{`, + `ComparedAt:` + strings.Replace(strings.Replace(this.ComparedAt.String(), "Time", "k8s_io_apimachinery_pkg_apis_meta_v1.Time", 1), `&`, ``, 1) + `,`, + `ComparedTo:` + strings.Replace(strings.Replace(this.ComparedTo.String(), "ApplicationSource", "ApplicationSource", 1), `&`, ``, 1) + `,`, + `Status:` + fmt.Sprintf("%v", this.Status) + `,`, + `DifferenceDetails:` + fmt.Sprintf("%v", this.DifferenceDetails) + `,`, + `ComparisonErrorDetails:` + fmt.Sprintf("%v", this.ComparisonErrorDetails) + `,`, + `}`, + }, "") + return s +} func (this *Repository) String() string { if this == nil { return "nil" @@ -965,9 +1040,9 @@ func (m *ApplicationSource) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GitRepoSecret", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TargetRevision", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -977,23 +1052,51 @@ func (m *ApplicationSource) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + stringLen |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.GitRepoSecret.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.TargetRevision = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RepoURL", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RepoURL = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) } @@ -1022,7 +1125,7 @@ func (m *ApplicationSource) Unmarshal(dAtA []byte) error { } m.Path = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Environment", wireType) } @@ -1102,35 +1205,6 @@ func (m *ApplicationSpec) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TargetRevision", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TargetRevision = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) } @@ -1214,7 +1288,7 @@ func (m *ApplicationStatus) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ComparisonResult", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -1224,49 +1298,21 @@ func (m *ApplicationStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + msglen |= (int(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex > l { return io.ErrUnexpectedEOF } - m.ComparisonResult = ComparisonResult(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DifferenceDetails", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF + if err := m.ComparisonResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - m.DifferenceDetails = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1589,6 +1635,203 @@ func (m *ClusterSpec) Unmarshal(dAtA []byte) error { } return nil } +func (m *ComparisonResult) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ComparisonResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ComparisonResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComparedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ComparedAt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComparedTo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ComparedTo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = ComparisonStatus(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DifferenceDetails", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DifferenceDetails = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComparisonErrorDetails", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ComparisonErrorDetails = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Repository) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1947,56 +2190,60 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 806 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4d, 0x4f, 0xe3, 0x46, - 0x18, 0x8e, 0xf9, 0x6a, 0x98, 0x94, 0x14, 0x5c, 0xb5, 0x4a, 0x39, 0x18, 0xe4, 0x43, 0xc5, 0x01, - 0xc6, 0x85, 0x96, 0xaa, 0xbd, 0x54, 0xaa, 0x81, 0x22, 0x2a, 0xaa, 0xa2, 0xa1, 0x95, 0xaa, 0xaa, - 0x52, 0x3b, 0x38, 0x2f, 0xce, 0x10, 0xdb, 0x63, 0xcd, 0x8c, 0x53, 0x71, 0xeb, 0xb9, 0xa7, 0xfe, - 0x9a, 0xfe, 0x85, 0xe5, 0x88, 0xc4, 0xae, 0x84, 0x56, 0x2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, 0x09, 0x00, 0x00, + // 876 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x8f, 0x1b, 0x35, + 0x18, 0xce, 0xec, 0x67, 0xe2, 0x40, 0xba, 0x6b, 0xa4, 0x55, 0xd8, 0xc3, 0x74, 0x35, 0x07, 0x54, + 0x10, 0xf5, 0xb0, 0x85, 0x22, 0xe0, 0x80, 0xd4, 0x49, 0x17, 0x54, 0x58, 0x44, 0xe5, 0xa6, 0x1c, + 0x10, 0x02, 0xbc, 0x13, 0xef, 0xc4, 0x9b, 0xcc, 0x78, 0x64, 0x7b, 0x82, 0x7a, 0xeb, 0x0d, 0x89, + 0x13, 0xfc, 0x0a, 0xfe, 0xca, 0x1e, 0x2b, 0x3e, 0x44, 0x85, 0x50, 0xc5, 0x86, 0x7f, 0xc1, 0x09, + 0x8d, 0xe3, 0xf9, 0xca, 0x34, 0x62, 0xd5, 0x44, 0x7b, 0x1b, 0xdb, 0xcf, 0xfb, 0x3c, 0xaf, 0x5f, + 0x3f, 0xef, 0x3b, 0xe0, 0x5e, 0xc0, 0xd4, 0x30, 0x39, 0x41, 0x3e, 0x0f, 0x5d, 0x22, 0x02, 0x1e, + 0x0b, 0x7e, 0xa6, 0x3f, 0x6e, 0xfa, 0x03, 0x37, 0x1e, 0x05, 0x2e, 0x89, 0x99, 0x74, 0x49, 0x1c, + 0x8f, 0x99, 0x4f, 0x14, 0xe3, 0x91, 0x3b, 0x39, 0x24, 0xe3, 0x78, 0x48, 0x0e, 0xdd, 0x80, 0x46, + 0x54, 0x10, 0x45, 0x07, 0x28, 0x16, 0x5c, 0x71, 0xf8, 0x7e, 0x41, 0x85, 0x32, 0x2a, 0xfd, 0xf1, + 0x8d, 0x3f, 0x40, 0xf1, 0x28, 0x40, 0x29, 0x15, 0x2a, 0x51, 0xa1, 0x8c, 0x6a, 0xff, 0x66, 0x29, + 0x8b, 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xf8, 0x05, 0xd8, 0x2b, 0xda, 0xee, 0x48, 0x08, 0x2e, 0x32, 0xb6, 0x4d, 0xcd, 0x66, + 0x1b, 0xb6, 0xbd, 0xde, 0x73, 0x51, 0x78, 0x41, 0xb4, 0xf3, 0x83, 0x05, 0x40, 0x3a, 0x5c, 0x25, + 0x53, 0x5c, 0x3c, 0x4a, 0xc7, 0x6a, 0x3a, 0x61, 0x8d, 0x13, 0xf2, 0x9e, 0x48, 0x11, 0x58, 0x9f, + 0xc0, 0x37, 0x41, 0x33, 0x91, 0x54, 0x44, 0x24, 0xa4, 0x66, 0x48, 0xe7, 0x9e, 0x7e, 0x68, 0xf6, + 0x71, 0x8e, 0x48, 0xd1, 0x31, 0x91, 0xf2, 0x3b, 0x2e, 0x06, 0xa6, 0x7a, 0x39, 0xfa, 0xbe, 0xd9, + 0xc7, 0x39, 0xc2, 0xf9, 0xd3, 0x02, 0x9d, 0x22, 0x99, 0x2b, 0x68, 0xb9, 0xb3, 0x6a, 0xcb, 0x1d, + 0x2d, 0xe1, 0xab, 0x22, 0xef, 0xe7, 0x77, 0x9d, 0x87, 0xce, 0x2f, 0xec, 0xc6, 0x93, 0x0b, 0xbb, + 0xf1, 0xf4, 0xc2, 0x6e, 0x3c, 0x9e, 0xda, 0xd6, 0xf9, 0xd4, 0xb6, 0x9e, 0x4c, 0x6d, 0xeb, 0xe9, + 0xd4, 0xb6, 0xfe, 0x9e, 0xda, 0xd6, 0x8f, 0xff, 0xd8, 0x8d, 0x2f, 0x9b, 0x19, 0xe1, 0x7f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x01, 0x64, 0x2d, 0x0e, 0x21, 0x0b, 0x00, 0x00, } diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index 442f4517e7c3e..df8c399751a45 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -5,7 +5,6 @@ syntax = 'proto2'; package github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1; -import "k8s.io/api/core/v1/generated.proto"; import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/generated.proto"; import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; @@ -36,30 +35,26 @@ message ApplicationList { // ApplicationSource contains secret reference which has information about github repository, path within repository and target application environment. message ApplicationSource { - // GitRepoSecret is a secret reference which has information about github repository. - optional k8s.io.api.core.v1.LocalObjectReference gitRepoSecret = 1; + optional string targetRevision = 1; + + // RepoURL is repository URL which contains application project. + optional string repoURL = 2; // Path is a directory path within repository which contains ksonnet project. - optional string path = 2; + optional string path = 3; // Environment is a ksonnet project environment name. - optional string environment = 3; + optional string environment = 4; } // ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision. message ApplicationSpec { - optional string targetRevision = 1; - - optional ApplicationSource source = 2; + optional ApplicationSource source = 1; } // ApplicationStatus contains information about application status in target environment. message ApplicationStatus { - // ComparisonResult is a comparison result of application spec and deployed application. - optional string comparisonResult = 1; - - // DifferenceDetails contains string representation of detected differences between application spec and deployed application. - optional string differenceDetails = 2; + optional ComparisonResult comparisonResult = 1; } // Cluster is the definition of a cluster resource @@ -86,6 +81,19 @@ message ClusterSpec { optional string server = 1; } +// ComparisonResult is a comparison result of application spec and deployed application. +message ComparisonResult { + optional k8s.io.apimachinery.pkg.apis.meta.v1.Time comparedAt = 1; + + optional ApplicationSource comparedTo = 2; + + optional string status = 3; + + optional string differenceDetails = 4; + + optional string comparisonErrorDetails = 5; +} + // Repository is a Git repository holding application configurations message Repository { optional string repo = 1; diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index 21f6d9d91e522..fe77f1262e54e 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -1,7 +1,6 @@ package v1alpha1 import ( - apiv1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -26,37 +25,43 @@ type ApplicationList struct { // ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision. type ApplicationSpec struct { - TargetRevision string `json:"targetRevision" protobuf:"bytes,1,opt,name=targetRevision"` - Source ApplicationSource `json:"source" protobuf:"bytes,2,opt,name=source"` + Source ApplicationSource `json:"source" protobuf:"bytes,1,opt,name=source"` } // ApplicationSource contains secret reference which has information about github repository, path within repository and target application environment. type ApplicationSource struct { - // GitRepoSecret is a secret reference which has information about github repository. - GitRepoSecret apiv1.LocalObjectReference `json:"gitRepoSecret" protobuf:"bytes,1,opt,name=gitRepoSecret"` + TargetRevision string `json:"targetRevision" protobuf:"bytes,1,opt,name=targetRevision"` + // RepoURL is repository URL which contains application project. + RepoURL string `json:"repoURL" protobuf:"bytes,2,opt,name=repoURL"` // Path is a directory path within repository which contains ksonnet project. - Path string `json:"path" protobuf:"bytes,2,opt,name=path"` + Path string `json:"path" protobuf:"bytes,3,opt,name=path"` // Environment is a ksonnet project environment name. - Environment string `json:"environment" protobuf:"bytes,3,opt,name=environment"` + Environment string `json:"environment" protobuf:"bytes,4,opt,name=environment"` } -// ComparisonResult is a comparison result of application spec and deployed application. -type ComparisonResult string +// ComparisonStatus is a type which represents possible comparison results +type ComparisonStatus string // Possible comparison results const ( - ComparisonResultUnknown ComparisonResult = "Unknown" - ComparisonResultError ComparisonResult = "Error" - ComparisonResultEqual ComparisonResult = "Equal" - ComparisonResultDifferent ComparisonResult = "Different" + ComparisonStatusUnknown ComparisonStatus = "" + ComparisonStatusError ComparisonStatus = "Error" + ComparisonStatusEqual ComparisonStatus = "Equal" + ComparisonStatusDifferent ComparisonStatus = "Different" ) // ApplicationStatus contains information about application status in target environment. type ApplicationStatus struct { - // ComparisonResult is a comparison result of application spec and deployed application. - ComparisonResult ComparisonResult `json:"comparisonResult" protobuf:"bytes,1,opt,name=comparisonResult,casttype=ComparisonResult"` - // DifferenceDetails contains string representation of detected differences between application spec and deployed application. - DifferenceDetails string `json:"differenceDetails" protobuf:"bytes,2,opt,name=differenceDetails"` + ComparisonResult ComparisonResult `json:"comparisonResult" protobuf:"bytes,1,opt,name=comparisonResult"` +} + +// ComparisonResult is a comparison result of application spec and deployed application. +type ComparisonResult struct { + ComparedAt metav1.Time `json:"comparedAt" protobuf:"bytes,1,opt,name=comparedAt"` + ComparedTo ApplicationSource `json:"comparedTo" protobuf:"bytes,2,opt,name=comparedTo"` + Status ComparisonStatus `json:"status" protobuf:"bytes,3,opt,name=status,casttype=ComparisonStatus"` + DifferenceDetails string `json:"differenceDetails" protobuf:"bytes,4,opt,name=differenceDetails"` + ComparisonErrorDetails string `json:"comparisonErrorDetails" protobuf:"bytes,5,opt,name=comparisonErrorDetails"` } // Cluster is the definition of a cluster resource @@ -95,3 +100,8 @@ type RepositoryList struct { metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` Items []Repository `json:"items" protobuf:"bytes,2,rep,name=items"` } + +// Equals compares two instances of ApplicationSource and return true if instances are equal. +func (source ApplicationSource) Equals(other ApplicationSource) bool { + return source.TargetRevision == other.TargetRevision && source.RepoURL == other.RepoURL && source.Path == other.Path && source.Environment == other.Environment +} diff --git a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go index 5ec76430d2d98..264e8662cc5dc 100644 --- a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go @@ -14,7 +14,7 @@ func (in *Application) DeepCopyInto(out *Application) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) return } @@ -72,7 +72,6 @@ func (in *ApplicationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ApplicationSource) DeepCopyInto(out *ApplicationSource) { *out = *in - out.GitRepoSecret = in.GitRepoSecret return } @@ -106,6 +105,7 @@ func (in *ApplicationSpec) DeepCopy() *ApplicationSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ApplicationStatus) DeepCopyInto(out *ApplicationStatus) { *out = *in + in.ComparisonResult.DeepCopyInto(&out.ComparisonResult) return } @@ -195,6 +195,24 @@ func (in *ClusterSpec) DeepCopy() *ClusterSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComparisonResult) DeepCopyInto(out *ComparisonResult) { + *out = *in + in.ComparedAt.DeepCopyInto(&out.ComparedAt) + out.ComparedTo = in.ComparedTo + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComparisonResult. +func (in *ComparisonResult) DeepCopy() *ComparisonResult { + if in == nil { + return nil + } + out := new(ComparisonResult) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Repository) DeepCopyInto(out *Repository) { *out = *in diff --git a/test/e2e/functional/app.yaml b/test/e2e/functional/app.yaml index 919ce5bc5d937..a7224f3c19e32 100644 --- a/test/e2e/functional/app.yaml +++ b/test/e2e/functional/app.yaml @@ -3,9 +3,8 @@ kind: Application metadata: name: my-app spec: - targetRevision: abc123 source: - gitRepoSecret: - name: my-git-repo + targetRevision: abc123 + repoURL: http://my-git-repo.git path: apps/elk environment: prod/us-west-2 diff --git a/util/git/client.go b/util/git/client.go new file mode 100644 index 0000000000000..b805424723e2a --- /dev/null +++ b/util/git/client.go @@ -0,0 +1,79 @@ +package git + +import ( + "fmt" + "io/ioutil" + "net/url" + "os" + "os/exec" +) + +// Client is a generic git client interface +type Client interface { + CloneOrFetch(url string, username string, password string, repoPath string) error + Checkout(repoPath string, sha string) error +} + +// NativeGitClient implements Client interface using git CLI +type NativeGitClient struct { + rootDirectoryPath string +} + +// CloneOrFetch either clone or fetch repository into specified directory path. +func (m *NativeGitClient) CloneOrFetch(repo string, username string, password string, repoPath string) error { + var needClone bool + if _, err := os.Stat(repoPath); os.IsNotExist(err) { + needClone = true + } else { + cmd := exec.Command("git", "status") + cmd.Dir = repo + _, err = cmd.Output() + needClone = err != nil + } + if needClone { + repoURL, err := url.ParseRequestURI(repo) + if err != nil { + return err + } + repoURL.User = url.UserPassword(username, password) + _, err = exec.Command("git", "clone", repoURL.String(), repoPath).Output() + if err != nil { + return fmt.Errorf("unable to clone repository %s: %v", repoURL.String(), err) + } + } else { + cmd := exec.Command("git", "fetch") + cmd.Dir = repoPath + _, err := cmd.Output() + if err != nil { + return fmt.Errorf("unable to fetch repo %s: %v", repoPath, err) + } + } + return nil +} + +// Checkout checkout specified git sha +func (m *NativeGitClient) Checkout(repoPath string, sha string) error { + if sha == "" { + sha = "HEAD" + } + cmd := exec.Command("git", "checkout", sha) + cmd.Dir = repoPath + _, err := cmd.Output() + if err != nil { + return fmt.Errorf("unable to checkout revision %s: %v", sha, err) + } + + return nil + +} + +// NewNativeGitClient creates new instance of NativeGitClient +func NewNativeGitClient() (Client, error) { + rootDirPath, err := ioutil.TempDir("", "argo-git") + if err != nil { + return nil, err + } + return &NativeGitClient{ + rootDirectoryPath: rootDirPath, + }, nil +}