Skip to content

Commit

Permalink
acr controller
Browse files Browse the repository at this point in the history
  • Loading branch information
pasha-codefresh committed Sep 23, 2024
1 parent 1e76193 commit 544d111
Show file tree
Hide file tree
Showing 14 changed files with 1,744 additions and 1,455 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ define run-in-test-client
-e GITHUB_TOKEN \
-e GOCACHE=/tmp/go-build-cache \
-e ARGOCD_LINT_GOGC=$(ARGOCD_LINT_GOGC) \
-e GOSUMDB=off \
-v ${DOCKER_SRC_MOUNT} \
-v ${GOPATH}/pkg/mod:/go/pkg/mod${VOLUME_MOUNT} \
-v ${GOCACHE}:/tmp/go-build-cache${VOLUME_MOUNT} \
Expand Down Expand Up @@ -231,7 +232,7 @@ clidocsgen:


.PHONY: codegen-local
codegen-local: mod-vendor-local gogen protogen clientgen openapigen clidocsgen manifests-local
codegen-local: mod-vendor-local protogen clientgen openapigen clidocsgen manifests-local
rm -rf vendor/

.PHONY: codegen-local-fast
Expand Down
5 changes: 3 additions & 2 deletions acr_controller/application/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"google.golang.org/grpc"
"io"
"net/http"
"strings"
"time"

appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"google.golang.org/grpc"
)

//go:generate go run github.com/vektra/mockery/[email protected] --name=ApplicationClient
Expand Down
225 changes: 0 additions & 225 deletions acr_controller/application/mocks/ApplicationClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions acr_controller/controller/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *subscriber) matches(event *appv1.ApplicationWatchEvent) bool {
// Broadcaster is an interface for broadcasting application informer watch events to multiple subscribers.
type Broadcaster interface {
Subscribe(ch chan *appv1.ApplicationWatchEvent, filters ...func(event *appv1.ApplicationWatchEvent) bool) func()
OnAdd(interface{})
OnAdd(interface{}, bool)
OnUpdate(interface{}, interface{})
OnDelete(interface{})
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func (b *broadcasterHandler) Subscribe(ch chan *appv1.ApplicationWatchEvent, fil
}
}

func (b *broadcasterHandler) OnAdd(obj interface{}) {
func (b *broadcasterHandler) OnAdd(obj interface{}, isInInitialList bool) {
if app, ok := obj.(*appv1.Application); ok {
b.notify(&appv1.ApplicationWatchEvent{Application: *app, Type: watch.Added})
}
Expand Down
9 changes: 4 additions & 5 deletions acr_controller/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/tls"
"fmt"
appclient "github.com/argoproj/argo-cd/v2/acr_controller/application"
application_change_revision_controller "github.com/argoproj/argo-cd/v2/acr_controller/controller"
acr_controller "github.com/argoproj/argo-cd/v2/acr_controller/controller"
"github.com/argoproj/argo-cd/v2/event_reporter/reporter"
"net"
"net/http"
Expand Down Expand Up @@ -57,8 +57,7 @@ type ACRServer struct {
featureManager *reporter.FeatureManager
}

type ACRServerSet struct {
}
type ACRServerSet struct{}

type ACRServerOpts struct {
ListenPort int
Expand Down Expand Up @@ -123,7 +122,7 @@ func (a *ACRServer) Init(ctx context.Context) {
}

func (a *ACRServer) RunController(ctx context.Context) {
controller := application_change_revision_controller.NewApplicationChangeRevisionController(a.appInformer, a.Cache, a.settingsMgr, a.ApplicationServiceClient, a.appLister, a.applicationClientset)
controller := acr_controller.NewApplicationChangeRevisionController(a.appInformer, a.Cache, a.settingsMgr, a.ApplicationServiceClient, a.appLister, a.applicationClientset)
go controller.Run(ctx)
}

Expand Down Expand Up @@ -182,7 +181,7 @@ func (a *ACRServer) Listen() (*Listeners, error) {
// k8s.io/ go-to-protobuf uses protoc-gen-gogo, which comes from gogo/protobuf (a fork of
// golang/protobuf).
func (a *ACRServer) Run(ctx context.Context, lns *Listeners) {
var httpS = a.newHTTPServer(ctx, a.ListenPort)
httpS := a.newHTTPServer(ctx, a.ListenPort)
tlsConfig := tls.Config{}
tlsConfig.GetCertificate = func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
return a.settings.Certificate, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package commands
import (
"context"
"fmt"
"time"

acr "github.com/argoproj/argo-cd/v2/acr_controller"
cacheutil "github.com/argoproj/argo-cd/v2/util/cache"
"time"

appclient "github.com/argoproj/argo-cd/v2/acr_controller/application"
"github.com/argoproj/pkg/stats"
"github.com/redis/go-redis/v9"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

appclient "github.com/argoproj/argo-cd/v2/acr_controller/application"

cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
Expand Down Expand Up @@ -60,7 +62,7 @@ func NewCommand() *cobra.Command {
argocdToken string
rootpath string
)
var command = &cobra.Command{
command := &cobra.Command{
Use: cliName,
Short: "Run the Change Revision Controller server",
Long: "The Change Revision Controller is a service that listens for application events and updates the application's revision in the application CRD",
Expand Down
2 changes: 1 addition & 1 deletion hack/update-openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ openapi-gen \
[ -L ./v2 ] && rm -rf v2

export GO111MODULE=on
go build -o ./dist/gen-crd-spec "${PROJECT_ROOT}/hack/gen-crd-spec"
go build -o -buildvcs=false ./dist/gen-crd-spec "${PROJECT_ROOT}/hack/gen-crd-spec"
./dist/gen-crd-spec
Loading

0 comments on commit 544d111

Please sign in to comment.