7
7
"fmt"
8
8
"net/http"
9
9
"os"
10
- "strconv"
11
10
"strings"
12
11
13
12
sdk "github.com/openshift-online/ocm-sdk-go"
@@ -57,34 +56,10 @@ type SdkClient struct {
57
56
58
57
// New will create a new ocm client by using the path to a config file
59
58
// if no path is provided, it will assume it in the default path
60
- func New (ocmConfigFile string ) (* SdkClient , error ) {
59
+ func New () (* SdkClient , error ) {
61
60
var err error
62
61
client := SdkClient {}
63
62
64
- // The debug environment variable ensures that we will never use
65
- // an ocm config file on a cluster deployment. The debug environment variable
66
- // is only for local cadctl development
67
- debugMode := os .Getenv ("CAD_DEBUG" )
68
-
69
- // strconv.ParseBool raises an error when debugMode is empty, thus
70
- // we have to set it to false if the value is empty.
71
- if debugMode == "" {
72
- debugMode = "false"
73
- }
74
-
75
- debugEnabled , err := strconv .ParseBool (debugMode )
76
- if err != nil {
77
- return nil , fmt .Errorf ("failed to parse CAD_DEBUG value '%s': %w" , debugMode , err )
78
- }
79
-
80
- if debugEnabled {
81
- client .conn , err = newConnectionFromFile (ocmConfigFile )
82
- if err != nil {
83
- return nil , fmt .Errorf ("failed to create connection from ocm.json config file: %w" , err )
84
- }
85
- return & client , nil
86
- }
87
-
88
63
client .conn , err = newConnectionFromClientPair ()
89
64
if err != nil {
90
65
return nil , fmt .Errorf ("failed to create connection from client key pair: %w" , err )
@@ -93,26 +68,6 @@ func New(ocmConfigFile string) (*SdkClient, error) {
93
68
return & client , nil
94
69
}
95
70
96
- // newConnectionFromFile loads the configuration file (ocmConfigFile, ~/.ocm.json, /ocm/ocm.json)
97
- // and creates a connection.
98
- func newConnectionFromFile (ocmConfigFile string ) (* sdk.Connection , error ) {
99
- if ocmConfigFile != "" {
100
- err := os .Setenv ("OCM_CONFIG" , ocmConfigFile )
101
- if err != nil {
102
- return nil , err
103
- }
104
- }
105
- // Load the configuration file from std path
106
- cfg , err := Load ()
107
- if err != nil {
108
- return nil , err
109
- }
110
- if cfg == nil || cfg == (& Config {}) {
111
- return nil , fmt .Errorf ("not logged in" )
112
- }
113
- return cfg .Connection ()
114
- }
115
-
116
71
// newConnectionFromClientPair creates a new connection via set of client ID, client secret
117
72
// and the target OCM API URL.
118
73
func newConnectionFromClientPair () (* sdk.Connection , error ) {
0 commit comments