Read service Configs from ziti.NewContextWithConfig(cfg).GetService()

Hi all,

I was wondering if I can get the service configuration from “ziti.NewContextWithConfig(cfg).GetService()”.
Is there any implementation for reading edge.Service.Configs there?

Best Regards,


I don’t know of an example off hand, but the way configurations work is that the SDK must be configured with the configuration types it is interested in. Otherwise, the controller will return an empty array for the Configs field on a service because the client has indicated that they are not interested in any configuration types.

Configuration types are specified in the configuration provided via NewContextWithConfig - which contains a field named ConfigTypes, which is an array of strings. If you want all of the configuration types, all as a string may be specified.

	cfg, err := config.NewFromFile("some.config")
	if err != nil {
        cfg.ConfigTypes = append(cfg.ConfigTypes, "all")
        context := ziti.NewContextWithConfig(cfg)
        svc, ok := context.GetService("myService")
        if ok {
             for k, v := range svc.Configs {
                  // ... deal with map[string]interface{} struct or use a library like gabs
1 Like

Thank you! This is what I was looking for!