Skip to content

Commit 3328259

Browse files
tonystarkjr3Anupam PokharelallmightyspiffedsonariosAerex
authoredMar 14, 2024
Feat: Add config SSO option (#377) and bump version (#396)
* Feat: Add config SSO option (#377) * added sso style entry * style to type for SSO * setBasicAuth * Win unit test (#355) * Fixed unit tests so they work in windows environments * Removed dead imports * adding Connection close header in http requests of our golang client (#372) Co-authored-by: Anupam Pokharel <apokharel@ibm.com> * Adds PrintCsv() function and unit tests to bluemix/terminal/table (#352) * added PrintCsv() function and unit tests to bluemix/terminal/table * Added handled errors to function PrintCsv * Added unit test for empty table in function PrintCsv * Added translations for error message and returned it --------- Co-authored-by: Aerex <noamfo@aerex.me> * chore: add csv messages to i18n (#373) * chore: bump version to 1.1.0 (#374) * Add recommendation to use Cobra (#368) * Add recommendation to use Cobra * dummy commit --------- Co-authored-by: steveclay <steveclay@users.noreply.github.com> * chore: bump packages for vulnerabilities (#376) * docs: added building section for building architectures * docs: improved description on building architectures * docs: Removed extraneous info for architecture requirements * chore(security): resolved vulnerability by updating golang.org/x/net * chore: bumped to 1.1.1 (#380) --------- Co-authored-by: Anupam Pokharel <apokharel@ibm.com> Co-authored-by: Christopher Gallo <chrisagallo@gmail.com> Co-authored-by: edsonarios <edsonrios9@gmail.com> Co-authored-by: Aerex <noamfo@aerex.me> Co-authored-by: steveclay <steveclay@users.noreply.github.com> Co-authored-by: lmosca <lmosca@users.noreply.github.com> * bump version (#398) --------- Co-authored-by: Anupam Pokharel <apokharel@ibm.com> Co-authored-by: Christopher Gallo <chrisagallo@gmail.com> Co-authored-by: edsonarios <edsonrios9@gmail.com> Co-authored-by: Aerex <noamfo@aerex.me> Co-authored-by: steveclay <steveclay@users.noreply.github.com> Co-authored-by: lmosca <lmosca@users.noreply.github.com>
1 parent 2346bb3 commit 3328259

File tree

4 files changed

+69
-33
lines changed

4 files changed

+69
-33
lines changed
 

‎bluemix/configuration/core_config/bx_config.go

+14
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type BXConfigData struct {
5555
Trace string
5656
ColorEnabled string
5757
HTTPTimeout int
58+
TypeOfSSO string
5859
CLIInfoEndpoint string // overwrite the cli info endpoint
5960
CheckCLIVersionDisabled bool
6061
UsageStatsDisabled bool // deprecated: use UsageStatsEnabled
@@ -412,6 +413,13 @@ func (c *bxConfig) ColorEnabled() (enabled string) {
412413
return
413414
}
414415

416+
func (c *bxConfig) TypeOfSSO() (style string) {
417+
c.read(func() {
418+
style = c.data.TypeOfSSO
419+
})
420+
return
421+
}
422+
415423
func (c *bxConfig) HTTPTimeout() (timeout int) {
416424
c.read(func() {
417425
timeout = c.data.HTTPTimeout
@@ -639,6 +647,12 @@ func (c *bxConfig) SetHTTPTimeout(timeout int) {
639647
})
640648
}
641649

650+
func (c *bxConfig) SetTypeOfSSO(style string) {
651+
c.write(func() {
652+
c.data.TypeOfSSO = style
653+
})
654+
}
655+
642656
func (c *bxConfig) SetCheckCLIVersionDisabled(disabled bool) {
643657
c.write(func() {
644658
c.data.CheckCLIVersionDisabled = disabled

‎bluemix/configuration/core_config/repository.go

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type Repository interface {
5151
PluginRepos() []models.PluginRepo
5252
PluginRepo(string) (models.PluginRepo, bool)
5353
IsSSLDisabled() bool
54+
TypeOfSSO() string
5455
HTTPTimeout() int
5556
CLIInfoEndpoint() string
5657
CheckCLIVersionDisabled() bool
@@ -99,6 +100,7 @@ type Repository interface {
99100
SetPluginRepo(models.PluginRepo)
100101
UnsetPluginRepo(string)
101102
SetSSLDisabled(bool)
103+
SetTypeOfSSO(string)
102104
SetHTTPTimeout(int)
103105
// SetUsageSatsDisabled disable or enable usage statistics data collection
104106
// Deprecated: use SetUsageSatsEnabled instead

‎bluemix/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package bluemix
33
import "fmt"
44

55
// Version is the SDK version
6-
var Version = VersionType{Major: 1, Minor: 2, Build: 0}
6+
var Version = VersionType{Major: 1, Minor: 3, Build: 0}
77

88
// VersionType describe version info
99
type VersionType struct {

‎common/rest/request.go

+52-32
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
// Request examples:
2-
// // create a simple GET request
3-
// req := GetRequest("http://www.example.com")
42
//
5-
// // set header
6-
// req.Set("Accept", "application/json")
3+
// // create a simple GET request
4+
// req := GetRequest("http://www.example.com")
75
//
8-
// // set query parameters
9-
// req.Query("foo1", "bar1")
10-
// req.Query("foo2", "bar2")
6+
// // set header
7+
// req.Set("Accept", "application/json")
118
//
12-
// // Build to a HTTP request
13-
// req.Build()
9+
// // set query parameters
10+
// req.Query("foo1", "bar1")
11+
// req.Query("foo2", "bar2")
1412
//
15-
// // method chaining is also supported
16-
// // the above is equal to:
17-
// GetRequest("http://www.example.com").
18-
// Set("Accept", "application/json").
19-
// Query("foo1", "bar1").
20-
// Query("foo2", "bar2").
21-
// Build()
13+
// // Build to a HTTP request
14+
// req.Build()
2215
//
23-
// // struct body
24-
// foo = Foo{Bar: "val"}
25-
// PostRequest("http://www.example.com").
26-
// Body(foo)
16+
// // method chaining is also supported
17+
// // the above is equal to:
18+
// GetRequest("http://www.example.com").
19+
// Set("Accept", "application/json").
20+
// Query("foo1", "bar1").
21+
// Query("foo2", "bar2").
22+
// Build()
2723
//
28-
// // String body
29-
// PostRequest("http://www.example.com").
30-
// Body("{\"bar\": \"val\"}")
24+
// // struct body
25+
// foo = Foo{Bar: "val"}
26+
// PostRequest("http://www.example.com").
27+
// Body(foo)
3128
//
32-
// // Stream body
33-
// PostRequest("http://www.example.com").
34-
// Body(strings.NewReader("abcde"))
29+
// // String body
30+
// PostRequest("http://www.example.com").
31+
// Body("{\"bar\": \"val\"}")
3532
//
36-
// // Multipart POST request
37-
// var f *os.File
38-
// PostRequest("http://www.example.com").
39-
// Field("foo", "bar").
40-
// File("file1", File{Name: f.Name(), Content: f}).
41-
// File("file2", File{Name: "1.txt", Content: []byte("abcde"), Type: "text/plain"})
33+
// // Stream body
34+
// PostRequest("http://www.example.com").
35+
// Body(strings.NewReader("abcde"))
36+
//
37+
// // Multipart POST request
38+
// var f *os.File
39+
// PostRequest("http://www.example.com").
40+
// Field("foo", "bar").
41+
// File("file1", File{Name: f.Name(), Content: f}).
42+
// File("file2", File{Name: "1.txt", Content: []byte("abcde"), Type: "text/plain"})
4243
package rest
4344

4445
import (
@@ -79,13 +80,20 @@ type Request struct {
7980
queryParams url.Values
8081
formParams url.Values
8182

83+
basicAuthn *BasicAuthInfo
84+
8285
// files to upload
8386
files map[string][]File
8487

8588
// custom request body
8689
body interface{}
8790
}
8891

92+
type BasicAuthInfo struct {
93+
user string
94+
pass string
95+
}
96+
8997
// NewRequest creates a new request with a given rawUrl.
9098
func NewRequest(rawUrl string) *Request {
9199
return &Request{
@@ -165,6 +173,14 @@ func (r *Request) Set(key string, value string) *Request {
165173
return r
166174
}
167175

176+
func (r *Request) SetBasicAuth(user string, pass string) *Request {
177+
r.basicAuthn = &BasicAuthInfo{
178+
user: user,
179+
pass: pass,
180+
}
181+
return r
182+
}
183+
168184
// Query appends the key, value pair to the request query which will be
169185
// encoded as url query parameters on HTTP request's url.
170186
func (r *Request) Query(key string, value string) *Request {
@@ -210,6 +226,10 @@ func (r *Request) Build() (*http.Request, error) {
210226
return req, err
211227
}
212228

229+
if r.basicAuthn != nil {
230+
req.SetBasicAuth(r.basicAuthn.user, r.basicAuthn.pass)
231+
}
232+
213233
for k, vs := range r.header {
214234
for _, v := range vs {
215235
req.Header.Add(k, v)

0 commit comments

Comments
 (0)
Failed to load comments.