Skip to content

Commit

Permalink
Merge pull request #3 from port-labs/PORT-1997-k-8-s-exporter-add-res…
Browse files Browse the repository at this point in the history
…ync-flag

Add resync interval flag
  • Loading branch information
talsabagport authored Nov 23, 2022
2 parents a6a4dc0 + 851b68c commit 7d941c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (
"k8s.io/client-go/dynamic/dynamicinformer"
"k8s.io/klog/v2"
"os"
"time"
)

var (
configFilePath string
resyncInterval uint
portBaseURL string
portClientId string
portClientSecret string
Expand Down Expand Up @@ -42,7 +44,8 @@ func main() {
klog.Fatalf("Error building Port client: %s", err.Error())
}

informersFactory := dynamicinformer.NewDynamicSharedInformerFactory(k8sClient.DynamicClient, 0)
resync := time.Minute * time.Duration(resyncInterval)
informersFactory := dynamicinformer.NewDynamicSharedInformerFactory(k8sClient.DynamicClient, resync)
controllers := make([]*k8s.Controller, 0, len(exporterConfig.Resources))

for _, resource := range exporterConfig.Resources {
Expand Down Expand Up @@ -76,6 +79,7 @@ func main() {

func init() {
flag.StringVar(&configFilePath, "config", "", "Path to Port K8s Exporter config file. Required.")
flag.UintVar(&resyncInterval, "resync-interval", 0, "The re-sync interval in minutes. Optional.")
flag.StringVar(&portBaseURL, "port-base-url", "https://api.getport.io", "Port base URL. Optional.")
portClientId = os.Getenv("PORT_CLIENT_ID")
portClientSecret = os.Getenv("PORT_CLIENT_SECRET")
Expand Down

0 comments on commit 7d941c1

Please sign in to comment.