diff --git a/pkg/config/config.go b/pkg/config/config.go index 81ce714..ee7c46f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -31,8 +31,8 @@ import ( type Config struct { HTTP Endpoint `yaml:"http"` RequestAggregationDelay time.Duration `yaml:"request_aggregation_delay"` - Provider *string `yaml:"provider"` - Engine *string `yaml:"engine"` + Provider string `yaml:"provider"` + Engine string `yaml:"engine"` PageSize int `yaml:"page_size,omitempty"` SSL *SSL `yaml:"ssl,omitempty"` CredsPath *string `yaml:"credentials_path,omitempty"` diff --git a/pkg/server/engine.go b/pkg/server/engine.go index 0e30050..50f6ab4 100644 --- a/pkg/server/engine.go +++ b/pkg/server/engine.go @@ -30,8 +30,8 @@ import ( "github.com/NVIDIA/topograph/pkg/utils" ) -var providerName *string -var engineName *string +var providerName string +var engineName string type asyncController struct { queue *utils.TrailingDelayQueue @@ -58,9 +58,9 @@ func processTopologyRequest(tr *common.TopologyRequest) ([]byte, *common.HTTPErr // Uses the provider and engine given config if provided, otherwise uses what is given in the topology request. // If neither is given, will throw an error var engName, prvName string - if providerName != nil { - klog.InfoS("Provider set in config as", "provider", *providerName) - prvName = *providerName + if len(providerName) != 0 { + klog.InfoS("Provider set in config as", "provider", providerName) + prvName = providerName } else if len(tr.Provider.Name) != 0 { prvName = tr.Provider.Name } else { @@ -68,9 +68,9 @@ func processTopologyRequest(tr *common.TopologyRequest) ([]byte, *common.HTTPErr klog.Error(errString) return nil, common.NewHTTPError(http.StatusInternalServerError, fmt.Sprint(errString)) } - if engineName != nil { - klog.InfoS("Engine set in config as", "engine", *engineName) - engName = *engineName + if len(engineName) != 0 { + klog.InfoS("Engine set in config as", "engine", engineName) + engName = engineName } else if len(tr.Engine.Name) != 0 { engName = tr.Engine.Name } else { diff --git a/pkg/server/http_server.go b/pkg/server/http_server.go index 2c279bf..6868b05 100644 --- a/pkg/server/http_server.go +++ b/pkg/server/http_server.go @@ -59,12 +59,9 @@ func InitHttpServer(ctx context.Context, cfg *config.Config) { }, } - if cfg.Provider != nil { - providerName = cfg.Provider - } - if cfg.Engine != nil { - engineName = cfg.Engine - } + // Saves the provider and engine config parameters + providerName = cfg.Provider + engineName = cfg.Engine } func GetRunGroup() (func() error, func(error)) {