Merge pull request #4403 from MichaelEischer/fix-certificate-env-handling

Fix certificate env handling
This commit is contained in:
Michael Eischer 2023-07-09 14:46:38 +02:00 committed by GitHub
commit 7042190807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -141,6 +141,14 @@ jobs:
run: | run: |
go run build.go go run build.go
- name: Minimal test
run: |
./restic init
./restic backup .
env:
RESTIC_REPOSITORY: ../testrepo
RESTIC_PASSWORD: password
- name: Run local Tests - name: Run local Tests
env: env:
RESTIC_TEST_FUSE: ${{ matrix.test_fuse }} RESTIC_TEST_FUSE: ${{ matrix.test_fuse }}

View file

@ -151,7 +151,9 @@ func init() {
globalOptions.PasswordFile = os.Getenv("RESTIC_PASSWORD_FILE") globalOptions.PasswordFile = os.Getenv("RESTIC_PASSWORD_FILE")
globalOptions.KeyHint = os.Getenv("RESTIC_KEY_HINT") globalOptions.KeyHint = os.Getenv("RESTIC_KEY_HINT")
globalOptions.PasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND") globalOptions.PasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND")
if os.Getenv("RESTIC_CACERT") != "" {
globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",") globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",")
}
globalOptions.TLSClientCertKeyFilename = os.Getenv("RESTIC_TLS_CLIENT_CERT") globalOptions.TLSClientCertKeyFilename = os.Getenv("RESTIC_TLS_CLIENT_CERT")
comp := os.Getenv("RESTIC_COMPRESSION") comp := os.Getenv("RESTIC_COMPRESSION")
if comp != "" { if comp != "" {
@ -582,7 +584,7 @@ func open(ctx context.Context, s string, gopts GlobalOptions, opts options.Optio
rt, err := backend.Transport(globalOptions.TransportOptions) rt, err := backend.Transport(globalOptions.TransportOptions)
if err != nil { if err != nil {
return nil, err return nil, errors.Fatal(err.Error())
} }
// wrap the transport so that the throughput via HTTP is limited // wrap the transport so that the throughput via HTTP is limited
@ -638,7 +640,7 @@ func create(ctx context.Context, s string, gopts GlobalOptions, opts options.Opt
rt, err := backend.Transport(globalOptions.TransportOptions) rt, err := backend.Transport(globalOptions.TransportOptions)
if err != nil { if err != nil {
return nil, err return nil, errors.Fatal(err.Error())
} }
factory := gopts.backends.Lookup(loc.Scheme) factory := gopts.backends.Lookup(loc.Scheme)