Skip to content

Commit

Permalink
make deploy operator syncs conditional when local flag is set
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Sep 29, 2023
1 parent 6dcfd40 commit 3ed10ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/go-logr/logr"
"github.com/pluralsh/deployment-operator/pkg/agent"
"github.com/pluralsh/deployment-operator/pkg/sync"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2/klogr"
Expand Down Expand Up @@ -59,6 +60,7 @@ func newCmd(log logr.Logger) *cobra.Command {
cmd.Flags().StringVar(&refreshInterval, "refresh-interval", "1m", "Refresh interval duration")
cmd.Flags().StringVar(&consoleUrl, "console-url", "", "the url of the console api to fetch services from")
cmd.Flags().StringVar(&deployToken, "deploy-token", "", "the deploy token to auth to console api with")
cmd.Flags().BoolVar(&sync.Local, "local", false, "whether you're running the agent locally (and should avoid recreating the deploy operator)")
return &cmd
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/sync/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
package sync

import (
"time"

"k8s.io/klog/v2/klogr"
)

const (
SyncShaAnnotation = "deployments.plural.sh/sync-sha"
SyncAnnotation = "deployments.plural.sh/service-id"
SSAManager = "plural-deployment-agent"
syncDelay = 5 * time.Second
)

var (
Local = false
log = klogr.New()
)
15 changes: 5 additions & 10 deletions pkg/sync/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ import (
"github.com/argoproj/gitops-engine/pkg/sync"
"github.com/argoproj/gitops-engine/pkg/sync/common"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

"k8s.io/klog/v2/klogr"
)

var (
log = klogr.New()
)

const (
syncDelay = 5 * time.Second
)

func (engine *Engine) ControlLoop() {
Expand Down Expand Up @@ -66,6 +56,11 @@ func (engine *Engine) processItem(item interface{}) error {
fmt.Printf("failed to fetch service from cache: %s, ignoring for now", err)
return err
}

if Local && svc.Name == "deploy-operator" {
return nil
}

log.Info("syncing service", "name", svc.Name, "namespace", svc.Namespace)

var manErr error
Expand Down

0 comments on commit 3ed10ed

Please sign in to comment.