Skip to content

Commit

Permalink
moved dependent and create missing to the app config
Browse files Browse the repository at this point in the history
  • Loading branch information
yairsimantov20 committed Dec 13, 2023
1 parent 296e170 commit 2c21603
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func initiateHandler(exporterConfig *port.Config, k8sClient *k8s.Client, portCli
klog.Fatalf("Error getting K8s integration config: %s", err.Error())
}

cli.WithDeleteDependents(deleteDependents)(portClient)
cli.WithCreateMissingRelatedEntities(createMissingRelatedEntities)(portClient)

newHandler := handlers.NewControllersHandler(exporterConfig, apiConfig, k8sClient, portClient)
newHandler.Handle()

Expand All @@ -55,7 +58,6 @@ func main() {

portClient, err := cli.New(portBaseURL,
cli.WithClientID(portClientId), cli.WithClientSecret(portClientSecret),
cli.WithDeleteDependents(deleteDependents), cli.WithCreateMissingRelatedEntities(createMissingRelatedEntities),
cli.WithHeader("User-Agent", fmt.Sprintf("port-k8s-exporter/0.1 (statekey/%s)", stateKey)),
)

Expand Down Expand Up @@ -95,15 +97,11 @@ func init() {
configFilePath = config.NewString("config", "", "Path to Port K8s Exporter config file. Required.")
stateKey = config.NewString("state-key", "", "Port K8s Exporter state key id. Required.")

// change to the app config
//config.NewBoolean("delete-dependents", false, "Flag to enable deletion of dependent Port Entities. Optional.")
//config.NewBoolean("create-missing-related-entities", false, "Flag to enable creation of missing related Port entities. Optional.")

resyncInterval = config.NewUInt("resync-interval", 0, "The re-sync interval in minutes. Optional.")
portBaseURL = config.NewString("port-base-url", "https://api.getport.io", "Port base URL. Optional.")

portClientId = config.NewString("port-client-id", "", "Port client id. Required.")
portClientSecret = config.NewString("port-client-secret", "", "Port client secret. Required.")

config.NewString("event-listener-type", "POLLING", "Event listener type. Optional.")
eventListenerType = config.NewString("event-listener-type", "POLLING", "Event listener type. Optional.")
}
4 changes: 3 additions & 1 deletion pkg/port/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ type AggregatedResource struct {
}

type AppConfig struct {
Resources []Resource `json:"resources"`
DeleteDependents bool `json:"deleteDependents,omitempty"`
CreateMissingRelatedEntities bool `json:"createMissingRelatedEntities,omitempty"`
Resources []Resource `json:"resources"`
}

type Config struct {
Expand Down

0 comments on commit 2c21603

Please sign in to comment.