-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
578 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ jobs: | |
"api/mysql", | ||
"api/cockroach", | ||
"api/cache", | ||
"api/cachetls", | ||
"fs/git", | ||
"fs/local", | ||
"fs/s3", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ jobs: | |
run: mage dagger:run "test:unit" | ||
|
||
- name: Upload Coverage | ||
uses: codecov/[email protected].0 | ||
uses: codecov/[email protected].1 | ||
|
||
test-darwin: | ||
name: "Tests (Go - Darwin)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package redis | ||
|
||
import ( | ||
"crypto/tls" | ||
"crypto/x509" | ||
"fmt" | ||
"os" | ||
|
||
goredis "github.com/redis/go-redis/v9" | ||
"go.flipt.io/flipt/internal/config" | ||
) | ||
|
||
func NewClient(cfg config.RedisCacheConfig) (*goredis.Client, error) { | ||
var tlsConfig *tls.Config | ||
if cfg.RequireTLS { | ||
tlsConfig = &tls.Config{MinVersion: tls.VersionTLS12} | ||
tlsConfig.InsecureSkipVerify = cfg.InsecureSkipTLS | ||
caBundle, err := caBundle(cfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(caBundle) > 0 { | ||
rootCAs, err := x509.SystemCertPool() | ||
if err != nil { | ||
return nil, err | ||
} | ||
rootCAs.AppendCertsFromPEM(caBundle) | ||
tlsConfig.RootCAs = rootCAs | ||
} | ||
} | ||
|
||
rdb := goredis.NewClient(&goredis.Options{ | ||
Addr: fmt.Sprintf("%s:%d", cfg.Host, cfg.Port), | ||
TLSConfig: tlsConfig, | ||
Username: cfg.Username, | ||
Password: cfg.Password, | ||
DB: cfg.DB, | ||
PoolSize: cfg.PoolSize, | ||
MinIdleConns: cfg.MinIdleConn, | ||
ConnMaxIdleTime: cfg.ConnMaxIdleTime, | ||
DialTimeout: cfg.NetTimeout, | ||
ReadTimeout: cfg.NetTimeout * 2, | ||
WriteTimeout: cfg.NetTimeout * 2, | ||
PoolTimeout: cfg.NetTimeout * 2, | ||
}) | ||
return rdb, nil | ||
} | ||
|
||
func caBundle(cfg config.RedisCacheConfig) ([]byte, error) { | ||
if cfg.CaCertBytes != "" { | ||
return []byte(cfg.CaCertBytes), nil | ||
} | ||
if cfg.CaCertPath != "" { | ||
bytes, err := os.ReadFile(cfg.CaCertPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return bytes, nil | ||
} | ||
return []byte{}, nil | ||
} |
Oops, something went wrong.