velero/pkg/restic
Bridget McErlean 9ffffda11e
Use Credential from BSL for restic commands (#3489)
* Use Credential from BSL for restic commands

This change introduces support for restic to make use of per-BSL
credentials. It makes use of the `credentials.FileStore` introduced in
PR #3442 to write the BSL credentials to disk. To support per-BSL
credentials for restic, the environment for the restic commands needs to
be modified for each provider to ensure that the credentials are
provided via the correct provider specific environment variables.
This change introduces a new function `restic.CmdEnv` to check the BSL
provider and create the correct mapping of environment variables for
each provider.

Previously, AWS and GCP could rely on the environment variables in the
Velero deployments to obtain the credentials file, but now these
environment variables need to be set with the path to the serialized
credentials file if a credential is set on the BSL.

For Azure, the credentials file in the environment was loaded and parsed
to set the environment variables for restic. Now, we check if the BSL
has a credential, and if it does, load and parse that file instead.

This change also introduces a few other small improvements. Now that we
are fetching the BSL to check for the `Credential` field, we can use the
BSL directly to get the `CACert` which means that we can remove the
`GetCACert` function. Also, now that we have a way to serialize secrets
to disk, we can use the `credentials.FileStore` to get a temp file for
the restic repo password and remove the `restic.TempCredentialsFile`
function.

Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>

* Add documentation for per-BSL credentials

Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>

* Address review feedback

Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>

* Address review comments

Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
2021-03-11 13:10:51 -05:00
..
mocks Updates for org move to vmware-tanzu (#1920) 2019-09-30 17:26:56 -04:00
aws.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
aws_test.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
azure.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
azure_test.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
backupper.go k8s 1.18 import (#2651) 2020-07-16 12:21:37 -04:00
backupper_test.go k8s 1.18 import (#2651) 2020-07-16 12:21:37 -04:00
command.go fix copyright boilerplate 2020-06-18 14:14:15 -07:00
command_factory.go record restic restore progress in PodVolumeRestore (#1854) 2019-09-10 15:50:57 -06:00
command_factory_test.go record restic restore progress in PodVolumeRestore (#1854) 2019-09-10 15:50:57 -06:00
command_test.go fix copyright boilerplate 2020-06-18 14:14:15 -07:00
common.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
common_test.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
config.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
config_test.go Updates for org move to vmware-tanzu (#1920) 2019-09-30 17:26:56 -04:00
exec_commands.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
exec_commands_test.go properly handle empty restic stdout during progress updates (#2231) 2020-02-03 12:49:23 -07:00
gcp.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
gcp_test.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
repo_locker.go update license headers to Velero contributors (#1302) 2019-03-20 12:32:48 -07:00
repository_ensurer.go k8s 1.18 import (#2651) 2020-07-16 12:21:37 -04:00
repository_keys.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
repository_keys_test.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
repository_manager.go Use Credential from BSL for restic commands (#3489) 2021-03-11 13:10:51 -05:00
restorer.go Use pod namespace from backup when matching PVBs (#3475) 2021-02-22 11:16:00 -08:00