File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ func (in *S3Spec) String() string {
147147
148148// RestoreEnvVars returns the env vars for this backend when using Restore jobs.
149149func (in * S3Spec ) RestoreEnvVars () map [string ]* corev1.EnvVar {
150+ if in == nil {
151+ return nil
152+ }
150153 vars := make (map [string ]* corev1.EnvVar )
151154 if in .AccessKeyIDSecretRef != nil {
152155 vars [cfg .RestoreS3AccessKeyIDEnvName ] = & corev1.EnvVar {
Original file line number Diff line number Diff line change 1+ package v1
2+
3+ import (
4+ "testing"
5+
6+ "github.com/stretchr/testify/assert"
7+ )
8+
9+ func TestS3SpecRestoreEnvVarsWithNilReceiver (t * testing.T ) {
10+ // When a user specifies "s3:" with a nil value in YAML,
11+ // S3 is nil but RestoreMethod is not.
12+ // Calling RestoreEnvVars() on nil S3Spec must not panic.
13+ var s3 * S3Spec
14+ assert .NotPanics (t , func () {
15+ result := s3 .RestoreEnvVars ()
16+ assert .Nil (t , result )
17+ })
18+ }
You can’t perform that action at this time.
0 commit comments