Skip to content

Commit

Permalink
Changed some config parameters to be read as value not pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Haase <[email protected]>
  • Loading branch information
henryh2 committed Oct 31, 2024
1 parent fc69b46 commit 1d78912
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
16 changes: 8 additions & 8 deletions pkg/server/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,19 +58,19 @@ 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 {
errString := "No provider given for topology request"
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 {
Expand Down
9 changes: 3 additions & 6 deletions pkg/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 1d78912

Please sign in to comment.