Skip to content

Commit

Permalink
Merge pull request #243 from NikitaSkrynnik/add-policies
Browse files Browse the repository at this point in the history
Add custom policies support
  • Loading branch information
denis-tingaikin authored Dec 18, 2022
2 parents ec0e2cb + 17106d9 commit cb2204c
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ import (

// Config holds configuration parameters from environment variables
type Config struct {
Name string `default:"nse-supplier-k8s" desc:"Name of the Server" split_words:"true"`
ConnectTo url.URL `default:"unix:///var/lib/networkservicemesh/nsm.io.sock" desc:"url to connect to" split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
ServiceName string `default:"nse-supplier-k8s" desc:"Name of providing service" split_words:"true"`
Payload string `default:"ETHERNET" desc:"Name of provided service payload" split_words:"true"`
Labels map[string]string `default:"" desc:"Endpoint labels" split_words:"true"`
PodDescriptionFile string `default:"pod.yaml" desc:"Path to the file that describes pod to be created" split_words:"true"`
Namespace string `default:"default" desc:"Namespace in which new pods will be created" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`
Name string `default:"nse-supplier-k8s" desc:"Name of the Server" split_words:"true"`
ConnectTo url.URL `default:"unix:///var/lib/networkservicemesh/nsm.io.sock" desc:"url to connect to" split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
RegistryClientPolicies []string `default:"etc/nsm/opa/common/.*.rego,etc/nsm/opa/registry/.*.rego,etc/nsm/opa/client/.*.rego" desc:"paths to files and directories that contain registry client policies" split_words:"true"`
ServiceName string `default:"nse-supplier-k8s" desc:"Name of providing service" split_words:"true"`
Payload string `default:"ETHERNET" desc:"Name of provided service payload" split_words:"true"`
Labels map[string]string `default:"" desc:"Endpoint labels" split_words:"true"`
PodDescriptionFile string `default:"pod.yaml" desc:"Path to the file that describes pod to be created" split_words:"true"`
Namespace string `default:"default" desc:"Namespace in which new pods will be created" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
OpenTelemetryEndpoint string `default:"otel-collector.observability.svc.cluster.local:4317" desc:"OpenTelemetry Collector Endpoint"`
}

// Process prints and processes env to config
Expand Down Expand Up @@ -256,7 +257,9 @@ func main() {
clientinfo.NewNetworkServiceEndpointRegistryClient(),
sendfd.NewNetworkServiceEndpointRegistryClient(),
),
registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient()),
registryclient.WithAuthorizeNSERegistryClient(registryauthorize.NewNetworkServiceEndpointRegistryClient(
registryauthorize.WithPolicies(config.RegistryClientPolicies...),
)),
)

nse, err := nseRegistryClient.Register(ctx, &registryapi.NetworkServiceEndpoint{
Expand Down

0 comments on commit cb2204c

Please sign in to comment.