Skip to content

Commit

Permalink
Merge pull request #462 from Juniper/feat/461
Browse files Browse the repository at this point in the history
add code to support experimental flag
  • Loading branch information
rajagopalans authored Nov 21, 2023
2 parents 118e813 + 6bfbeca commit 5a62ced
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions apstra/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import (
)

const (
EnvApstraUrl = "APSTRA_URL"
EnvApstraUsername = "APSTRA_USER"
EnvApstraPassword = "APSTRA_PASS"
envApstraLogfile = "APSTRA_LOG"
envTlsKeyLogFile = "SSLKEYLOGFILE"
EnvApstraUrl = "APSTRA_URL"
EnvApstraUsername = "APSTRA_USER"
EnvApstraPassword = "APSTRA_PASS"
EnvApstraLogfile = "APSTRA_LOG"
EnvApstraExperimental = "APSTRA_EXPERIMENTAL"
EnvTlsKeyLogFile = "SSLKEYLOGFILE"

urlEncodeMsg = `
Note that when the Username or Password fields contain special characters and are
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewClientConfig(apstraUrl string) (*apstra.ClientCfg, error) {

// Set up a logger.
var logger *log.Logger
if logFileName, ok := os.LookupEnv(envApstraLogfile); ok {
if logFileName, ok := os.LookupEnv(EnvApstraLogfile); ok {
logFile, err := os.OpenFile(logFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
return nil, err
Expand All @@ -93,7 +94,7 @@ func NewClientConfig(apstraUrl string) (*apstra.ClientCfg, error) {

// Set up the TLS session key log.
var klw io.Writer
if fileName, ok := os.LookupEnv(envTlsKeyLogFile); ok {
if fileName, ok := os.LookupEnv(EnvTlsKeyLogFile); ok {
klw, err = newKeyLogWriter(fileName)
if err != nil {
return nil, err
Expand All @@ -109,12 +110,15 @@ func NewClientConfig(apstraUrl string) (*apstra.ClientCfg, error) {
},
}

_, experimental := os.LookupEnv(EnvApstraExperimental)

// Create the clientCfg
return &apstra.ClientCfg{
Url: parsedUrl.String(),
User: user,
Pass: pass,
Logger: logger,
HttpClient: httpClient,
Url: parsedUrl.String(),
User: user,
Pass: pass,
Logger: logger,
HttpClient: httpClient,
Experimental: experimental,
}, nil
}

0 comments on commit 5a62ced

Please sign in to comment.