Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config update #668

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .osc-patches/2022-09-22-add-missing-parameters.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
From ab07cc51fc1e484d834cdba432c363ffd0586742 Mon Sep 17 00:00:00 2001
From: outscale_hmi <[email protected]>
Date: Thu, 22 Sep 2022 11:11:01 +0000
Subject: [PATCH] add parameters to configEnv

Signed-off-by: outscale_hmi <[email protected]>
---
v2/config_env.go | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/v2/config_env.go b/v2/config_env.go
index f41fe3ff..773a9720 100644
--- a/v2/config_env.go
+++ b/v2/config_env.go
@@ -12,6 +12,8 @@ type ConfigEnv struct {
OutscaleApiEndpoint *string
ProfileName *string
Region *string
+ X509ClientCert *string
+ X509ClientKey *string
}

func NewConfigEnv() *ConfigEnv {
@@ -31,13 +33,22 @@ func NewConfigEnv() *ConfigEnv {
if value, present := os.LookupEnv("OSC_REGION"); present {
configEnv.Region = &value
}
+ if value, present := os.LookupEnv("OSC_X509_CLIENT_CERT"); present {
+ configEnv.X509ClientCert = &value
+ }
+ if value, present := os.LookupEnv("OSC_X509_CLIENT_KEY"); present {
+ configEnv.X509ClientKey = &value
+ }
return &configEnv
}

func (configEnv *ConfigEnv) Configuration() (*Configuration, error) {
var config *Configuration

- if configEnv.ProfileName != nil {
+ if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
+ if configEnv.ProfileName == nil {
+ *configEnv.ProfileName = "Default"
+ }
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
@@ -83,7 +94,10 @@ func (configEnv *ConfigEnv) Context(ctx context.Context) (context.Context, error
var accessKey *string
var secretKey *string

- if configEnv.ProfileName != nil {
+ if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
+ if configEnv.ProfileName == nil {
+ *configEnv.ProfileName = "Default"
+ }
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
--
2.25.1

18 changes: 16 additions & 2 deletions v2/config_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type ConfigEnv struct {
OutscaleApiEndpoint *string
ProfileName *string
Region *string
X509ClientCert *string
X509ClientKey *string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice to support (and needed in outscale/osc-bsu-csi-driver#355) but those options need to be passed to client configuration to really use client certificates.

}

func NewConfigEnv() *ConfigEnv {
Expand All @@ -31,13 +33,22 @@ func NewConfigEnv() *ConfigEnv {
if value, present := os.LookupEnv("OSC_REGION"); present {
configEnv.Region = &value
}
if value, present := os.LookupEnv("OSC_X509_CLIENT_CERT"); present {
configEnv.X509ClientCert = &value
}
if value, present := os.LookupEnv("OSC_X509_CLIENT_KEY"); present {
configEnv.X509ClientKey = &value
}
return &configEnv
}

func (configEnv *ConfigEnv) Configuration() (*Configuration, error) {
var config *Configuration

if configEnv.ProfileName != nil {
if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
if configEnv.ProfileName == nil {
*configEnv.ProfileName = "Default"
}
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
Expand Down Expand Up @@ -83,7 +94,10 @@ func (configEnv *ConfigEnv) Context(ctx context.Context) (context.Context, error
var accessKey *string
var secretKey *string

if configEnv.ProfileName != nil {
if configEnv.AccessKey == nil && configEnv.SecretKey == nil {
if configEnv.ProfileName == nil {
*configEnv.ProfileName = "Default"
}
configFile, err := LoadDefaultConfigFile()
if err != nil {
return nil, err
Expand Down