Compare commits
8 Commits
main
...
storage_cf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2e09688db | ||
|
|
62b466ca39 | ||
|
|
57ee18c847 | ||
|
|
d740c6a633 | ||
|
|
c0d1df211b | ||
|
|
ba5f917c00 | ||
|
|
6774fa2312 | ||
|
|
c17f5dd1f5 |
12
.github/workflows/longevity_test.yml
vendored
12
.github/workflows/longevity_test.yml
vendored
@ -352,14 +352,14 @@ jobs:
|
|||||||
# - x - index blobs
|
# - x - index blobs
|
||||||
./s3checker \
|
./s3checker \
|
||||||
--bucket ${{ secrets.CI_RETENTION_TESTS_S3_BUCKET }} \
|
--bucket ${{ secrets.CI_RETENTION_TESTS_S3_BUCKET }} \
|
||||||
--bucket-prefix ${{ env.PREFIX }} \
|
--prefix ${{ env.PREFIX }} \
|
||||||
--retention-mode ${{ env.RETENTION_MODE }} \
|
--retention-mode ${{ env.RETENTION_MODE }} \
|
||||||
--live-retention-duration "$((${{ env.RETENTION_DURATION }}-1))h" \
|
--live-retention-duration "$((${{ env.RETENTION_DURATION }}-1))h" \
|
||||||
--prefix "kopia.blobcfg" \
|
--object-prefix "kopia.blobcfg" \
|
||||||
--prefix "kopia.repository" \
|
--object-prefix "kopia.repository" \
|
||||||
--prefix "p" \
|
--object-prefix "p" \
|
||||||
--prefix "q" \
|
--object-prefix "q" \
|
||||||
--prefix "x"
|
--object-prefix "x"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -291,7 +290,7 @@ func genericDeleteCommand(
|
|||||||
|
|
||||||
ctx := clues.Add(cmd.Context(), "delete_backup_id", bID)
|
ctx := clues.Add(cmd.Context(), "delete_backup_id", bID)
|
||||||
|
|
||||||
r, _, _, _, err := utils.GetAccountAndConnect(ctx, pst, repo.S3Overrides(cmd))
|
r, _, _, _, err := utils.GetAccountAndConnect(ctx, pst, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -317,7 +316,7 @@ func genericListCommand(
|
|||||||
) error {
|
) error {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
r, _, _, _, err := utils.GetAccountAndConnect(ctx, service, repo.S3Overrides(cmd))
|
r, _, _, _, err := utils.GetAccountAndConnect(ctx, service, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
@ -168,7 +167,7 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.ExchangeService, repo.S3Overrides(cmd))
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.ExchangeService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -277,7 +276,7 @@ func detailsExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
opts := utils.MakeExchangeOpts(cmd)
|
opts := utils.MakeExchangeOpts(cmd)
|
||||||
|
|
||||||
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.ExchangeService, repo.S3Overrides(cmd))
|
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.ExchangeService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -152,7 +151,7 @@ func createGroupsCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.GroupsService, repo.S3Overrides(cmd))
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.GroupsService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -224,7 +223,7 @@ func detailsGroupsCmd(cmd *cobra.Command, args []string) error {
|
|||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
opts := utils.MakeGroupsOpts(cmd)
|
opts := utils.MakeGroupsOpts(cmd)
|
||||||
|
|
||||||
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.GroupsService, repo.S3Overrides(cmd))
|
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.GroupsService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
@ -149,7 +148,7 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.OneDriveService, repo.S3Overrides(cmd))
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.OneDriveService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -235,7 +234,7 @@ func detailsOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
opts := utils.MakeOneDriveOpts(cmd)
|
opts := utils.MakeOneDriveOpts(cmd)
|
||||||
|
|
||||||
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.OneDriveService, repo.S3Overrides(cmd))
|
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.OneDriveService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -159,7 +158,7 @@ func createSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.SharePointService, repo.S3Overrides(cmd))
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.SharePointService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -319,7 +318,7 @@ func detailsSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
opts := utils.MakeSharePointOpts(cmd)
|
opts := utils.MakeSharePointOpts(cmd)
|
||||||
|
|
||||||
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.SharePointService, repo.S3Overrides(cmd))
|
r, _, _, ctrlOpts, err := utils.GetAccountAndConnect(ctx, path.SharePointService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common/idname"
|
"github.com/alcionai/corso/src/internal/common/idname"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -148,7 +147,7 @@ func createTeamsCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.GroupsService, repo.S3Overrides(cmd))
|
r, acct, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.GroupsService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ func preRun(cc *cobra.Command, args []string) error {
|
|||||||
ctx := cc.Context()
|
ctx := cc.Context()
|
||||||
log := logger.Ctx(ctx)
|
log := logger.Ctx(ctx)
|
||||||
|
|
||||||
fs := flags.GetPopulatedFlags(cc)
|
fs := flags.GetPopulatedFlags(cc.Flags())
|
||||||
flagSl := make([]string, 0, len(fs))
|
flagSl := make([]string, 0, len(fs))
|
||||||
|
|
||||||
// currently only tracking flag names to avoid pii leakage.
|
// currently only tracking flag names to avoid pii leakage.
|
||||||
@ -70,9 +70,7 @@ func preRun(cc *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !slices.Contains(avoidTheseDescription, cc.Short) {
|
if !slices.Contains(avoidTheseDescription, cc.Short) {
|
||||||
overrides := repo.S3Overrides(cc)
|
cfg, err := config.GetConfigRepoDetails(ctx, true, false, cc.Flags())
|
||||||
|
|
||||||
cfg, err := config.GetConfigRepoDetails(ctx, true, false, overrides)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error while getting config info to run command: ", cc.Use)
|
log.Error("Error while getting config info to run command: ", cc.Use)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
@ -265,12 +266,12 @@ func GetConfigRepoDetails(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
readFromFile bool,
|
readFromFile bool,
|
||||||
mustMatchFromConfig bool,
|
mustMatchFromConfig bool,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (
|
) (
|
||||||
RepoDetails,
|
RepoDetails,
|
||||||
error,
|
error,
|
||||||
) {
|
) {
|
||||||
config, err := getStorageAndAccountWithViper(GetViper(ctx), readFromFile, mustMatchFromConfig, overrides)
|
config, err := getStorageAndAccountWithViper(GetViper(ctx), readFromFile, mustMatchFromConfig, pfs)
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ func getStorageAndAccountWithViper(
|
|||||||
vpr *viper.Viper,
|
vpr *viper.Viper,
|
||||||
readFromFile bool,
|
readFromFile bool,
|
||||||
mustMatchFromConfig bool,
|
mustMatchFromConfig bool,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (
|
) (
|
||||||
RepoDetails,
|
RepoDetails,
|
||||||
error,
|
error,
|
||||||
@ -290,6 +291,8 @@ func getStorageAndAccountWithViper(
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//overrides := repo.S3Overrides(pfs)
|
||||||
|
overrides := make(map[string]string)
|
||||||
readConfigFromViper := readFromFile
|
readConfigFromViper := readFromFile
|
||||||
|
|
||||||
// possibly read the prior config from a .corso file
|
// possibly read the prior config from a .corso file
|
||||||
@ -307,12 +310,12 @@ func getStorageAndAccountWithViper(
|
|||||||
config.RepoID = vpr.GetString(RepoID)
|
config.RepoID = vpr.GetString(RepoID)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, overrides)
|
config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, clues.Wrap(err, "retrieving account configuration details")
|
return config, clues.Wrap(err, "retrieving account configuration details")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Storage, err = configureStorage(vpr, readConfigFromViper, mustMatchFromConfig, overrides)
|
config.Storage, err = configureStorage(vpr, readConfigFromViper, mustMatchFromConfig, pfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, clues.Wrap(err, "retrieving storage provider details")
|
return config, clues.Wrap(err, "retrieving storage provider details")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,11 +7,13 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/aws/aws-sdk-go/aws/defaults"
|
"github.com/aws/aws-sdk-go/aws/defaults"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/str"
|
"github.com/alcionai/corso/src/internal/common/str"
|
||||||
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
"github.com/alcionai/corso/src/pkg/credentials"
|
"github.com/alcionai/corso/src/pkg/credentials"
|
||||||
"github.com/alcionai/corso/src/pkg/storage"
|
"github.com/alcionai/corso/src/pkg/storage"
|
||||||
)
|
)
|
||||||
@ -38,6 +40,7 @@ func s3CredsFromViper(vpr *viper.Viper, s3Config storage.S3Config) (storage.S3Co
|
|||||||
return s3Config, nil
|
return s3Config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rename this
|
||||||
func s3Overrides(in map[string]string) map[string]string {
|
func s3Overrides(in map[string]string) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
storage.Bucket: in[storage.Bucket],
|
storage.Bucket: in[storage.Bucket],
|
||||||
@ -49,13 +52,59 @@ func s3Overrides(in map[string]string) map[string]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Moved from repo/s3.go pkg
|
||||||
|
func S3Overrides(pfs *pflag.FlagSet) map[string]string {
|
||||||
|
fs := flags.GetPopulatedFlags(pfs)
|
||||||
|
return PopulateS3Flags(fs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func PopulateS3Flags(flagset flags.PopulatedFlags) map[string]string {
|
||||||
|
s3Overrides := make(map[string]string)
|
||||||
|
s3Overrides[AccountProviderTypeKey] = account.ProviderM365.String()
|
||||||
|
s3Overrides[StorageProviderTypeKey] = storage.ProviderS3.String()
|
||||||
|
|
||||||
|
if _, ok := flagset[flags.AWSAccessKeyFN]; ok {
|
||||||
|
s3Overrides[credentials.AWSAccessKeyID] = flags.AWSAccessKeyFV
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[flags.AWSSecretAccessKeyFN]; ok {
|
||||||
|
s3Overrides[credentials.AWSSecretAccessKey] = flags.AWSSecretAccessKeyFV
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[flags.AWSSessionTokenFN]; ok {
|
||||||
|
s3Overrides[credentials.AWSSessionToken] = flags.AWSSessionTokenFV
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[flags.BucketFN]; ok {
|
||||||
|
s3Overrides[storage.Bucket] = bucket
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[prefixFN]; ok {
|
||||||
|
s3Overrides[storage.Prefix] = prefix
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[doNotUseTLSFN]; ok {
|
||||||
|
s3Overrides[storage.DoNotUseTLS] = strconv.FormatBool(doNotUseTLS)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[doNotVerifyTLSFN]; ok {
|
||||||
|
s3Overrides[storage.DoNotVerifyTLS] = strconv.FormatBool(doNotVerifyTLS)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := flagset[endpointFN]; ok {
|
||||||
|
s3Overrides[storage.Endpoint] = endpoint
|
||||||
|
}
|
||||||
|
|
||||||
|
return s3Overrides
|
||||||
|
}
|
||||||
|
|
||||||
// configureStorage builds a complete storage configuration from a mix of
|
// configureStorage builds a complete storage configuration from a mix of
|
||||||
// viper properties and manual overrides.
|
// viper properties and manual overrides.
|
||||||
func configureStorage(
|
func configureStorage(
|
||||||
vpr *viper.Viper,
|
vpr *viper.Viper,
|
||||||
readConfigFromViper bool,
|
readConfigFromViper bool,
|
||||||
matchFromConfig bool,
|
matchFromConfig bool,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (storage.Storage, error) {
|
) (storage.Storage, error) {
|
||||||
var (
|
var (
|
||||||
s3Cfg storage.S3Config
|
s3Cfg storage.S3Config
|
||||||
@ -63,6 +112,8 @@ func configureStorage(
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Read storage provider first
|
||||||
|
|
||||||
if readConfigFromViper {
|
if readConfigFromViper {
|
||||||
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
||||||
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
||||||
@ -92,7 +143,6 @@ func configureStorage(
|
|||||||
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
||||||
}
|
}
|
||||||
|
|
||||||
s3Overrides(overrides)
|
|
||||||
aws := credentials.GetAWS(overrides)
|
aws := credentials.GetAWS(overrides)
|
||||||
|
|
||||||
if len(aws.AccessKey) <= 0 || len(aws.SecretKey) <= 0 {
|
if len(aws.AccessKey) <= 0 || len(aws.SecretKey) <= 0 {
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -71,7 +70,7 @@ func runExport(
|
|||||||
sel selectors.Selector,
|
sel selectors.Selector,
|
||||||
backupID, serviceName string,
|
backupID, serviceName string,
|
||||||
) error {
|
) error {
|
||||||
r, _, _, _, err := utils.GetAccountAndConnect(ctx, sel.PathService(), repo.S3Overrides(cmd))
|
r, _, _, _, err := utils.GetAccountAndConnect(ctx, sel.PathService(), cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package flags
|
package flags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,15 +21,15 @@ func (fs PopulatedFlags) populate(pf *pflag.Flag) {
|
|||||||
// GetPopulatedFlags returns a map of flags that have been
|
// GetPopulatedFlags returns a map of flags that have been
|
||||||
// populated by the user. Entry keys match the flag's long
|
// populated by the user. Entry keys match the flag's long
|
||||||
// name. Values are empty.
|
// name. Values are empty.
|
||||||
func GetPopulatedFlags(cmd *cobra.Command) PopulatedFlags {
|
func GetPopulatedFlags(pfs *pflag.FlagSet) PopulatedFlags {
|
||||||
pop := PopulatedFlags{}
|
pop := PopulatedFlags{}
|
||||||
|
|
||||||
fs := cmd.Flags()
|
//fs := cmd.Flags()
|
||||||
if fs == nil {
|
if pfs == nil {
|
||||||
return pop
|
return pop
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.VisitAll(pop.populate)
|
pfs.VisitAll(pop.populate)
|
||||||
|
|
||||||
return pop
|
return pop
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,15 @@ const (
|
|||||||
CorsoPassphraseFN = "passphrase"
|
CorsoPassphraseFN = "passphrase"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// s3 bucket flags
|
||||||
|
const (
|
||||||
|
BucketFN = "bucket"
|
||||||
|
EndpointFN = "endpoint"
|
||||||
|
PrefixFN = "prefix"
|
||||||
|
DoNotUseTLSFN = "disable-tls"
|
||||||
|
DoNotVerifyTLSFN = "disable-tls-verification"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
BackupIDFV string
|
BackupIDFV string
|
||||||
AWSAccessKeyFV string
|
AWSAccessKeyFV string
|
||||||
|
|||||||
41
src/cli/flags/s3.go
Normal file
41
src/cli/flags/s3.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package flags
|
||||||
|
|
||||||
|
import "github.com/spf13/cobra"
|
||||||
|
|
||||||
|
// S3 bucket flags
|
||||||
|
const (
|
||||||
|
BucketFN = "bucket"
|
||||||
|
EndpointFN = "endpoint"
|
||||||
|
PrefixFN = "prefix"
|
||||||
|
DoNotUseTLSFN = "disable-tls"
|
||||||
|
DoNotVerifyTLSFN = "disable-tls-verification"
|
||||||
|
SucceedIfExistsFN = "succeed-if-exists"
|
||||||
|
)
|
||||||
|
|
||||||
|
// S3 bucket flag values
|
||||||
|
var (
|
||||||
|
BucketFV string
|
||||||
|
EndpointFV string
|
||||||
|
PrefixFV string
|
||||||
|
DoNotUseTLSFV bool
|
||||||
|
DoNotVerifyTLSFV bool
|
||||||
|
SucceedIfExistsFV bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// S3 bucket flags
|
||||||
|
func AddS3BucketFlags(cmd *cobra.Command) {
|
||||||
|
fs := cmd.Flags()
|
||||||
|
|
||||||
|
// Flags addition ordering should follow the order we want them to appear in help and docs:
|
||||||
|
// More generic and more frequently used flags take precedence.
|
||||||
|
fs.StringVar(&BucketFV, BucketFN, "", "Name of S3 bucket for repo. (required)")
|
||||||
|
fs.StringVar(&PrefixFV, PrefixFN, "", "Repo prefix within bucket.")
|
||||||
|
fs.StringVar(&EndpointFV, EndpointFN, "", "S3 service endpoint.")
|
||||||
|
fs.BoolVar(&DoNotUseTLSFV, DoNotUseTLSFN, false, "Disable TLS (HTTPS)")
|
||||||
|
fs.BoolVar(&DoNotVerifyTLSFV, DoNotVerifyTLSFN, false, "Disable TLS (HTTPS) certificate verification.")
|
||||||
|
|
||||||
|
// In general, we don't want to expose this flag to users and have them mistake it
|
||||||
|
// for a broad-scale idempotency solution. We can un-hide it later the need arises.
|
||||||
|
fs.BoolVar(&SucceedIfExistsFV, SucceedIfExistsFN, false, "Exit with success if the repo has already been initialized.")
|
||||||
|
cobra.CheckErr(fs.MarkHidden("succeed-if-exists"))
|
||||||
|
}
|
||||||
@ -121,7 +121,7 @@ func handleMaintenanceCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.UnknownService, S3Overrides(cmd))
|
r, _, err := utils.AccountConnectAndWriteRepoConfig(ctx, path.UnknownService, cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return print.Only(ctx, err)
|
return print.Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +1,18 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/events"
|
"github.com/alcionai/corso/src/internal/events"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
|
||||||
"github.com/alcionai/corso/src/pkg/credentials"
|
|
||||||
"github.com/alcionai/corso/src/pkg/repository"
|
"github.com/alcionai/corso/src/pkg/repository"
|
||||||
"github.com/alcionai/corso/src/pkg/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// s3 bucket info from flags
|
// s3 bucket info from flags
|
||||||
@ -30,31 +25,18 @@ var (
|
|||||||
doNotVerifyTLS bool
|
doNotVerifyTLS bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// s3 bucket flags
|
|
||||||
const (
|
|
||||||
succeedIfExistsFN = "succeedIfExists"
|
|
||||||
bucketFN = "bucket"
|
|
||||||
endpointFN = "endpoint"
|
|
||||||
prefixFN = "prefix"
|
|
||||||
doNotUseTLSFN = "disable-tls"
|
|
||||||
doNotVerifyTLSFN = "disable-tls-verification"
|
|
||||||
)
|
|
||||||
|
|
||||||
// called by repo.go to map subcommands to provider-specific handling.
|
// called by repo.go to map subcommands to provider-specific handling.
|
||||||
func addS3Commands(cmd *cobra.Command) *cobra.Command {
|
func addS3Commands(cmd *cobra.Command) *cobra.Command {
|
||||||
var (
|
var c *cobra.Command
|
||||||
c *cobra.Command
|
|
||||||
fs *pflag.FlagSet
|
|
||||||
)
|
|
||||||
|
|
||||||
switch cmd.Use {
|
switch cmd.Use {
|
||||||
case initCommand:
|
case initCommand:
|
||||||
init := s3InitCmd()
|
init := s3InitCmd()
|
||||||
flags.AddRetentionConfigFlags(init)
|
flags.AddRetentionConfigFlags(init)
|
||||||
c, fs = utils.AddCommand(cmd, init)
|
c, _ = utils.AddCommand(cmd, init)
|
||||||
|
|
||||||
case connectCommand:
|
case connectCommand:
|
||||||
c, fs = utils.AddCommand(cmd, s3ConnectCmd())
|
c, _ = utils.AddCommand(cmd, s3ConnectCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Use = c.Use + " " + s3ProviderCommandUseSuffix
|
c.Use = c.Use + " " + s3ProviderCommandUseSuffix
|
||||||
@ -66,11 +48,11 @@ func addS3Commands(cmd *cobra.Command) *cobra.Command {
|
|||||||
|
|
||||||
// Flags addition ordering should follow the order we want them to appear in help and docs:
|
// Flags addition ordering should follow the order we want them to appear in help and docs:
|
||||||
// More generic and more frequently used flags take precedence.
|
// More generic and more frequently used flags take precedence.
|
||||||
fs.StringVar(&bucket, bucketFN, "", "Name of S3 bucket for repo. (required)")
|
fs.StringVar(&bucket, flags.BucketFN, "", "Name of S3 bucket for repo. (required)")
|
||||||
fs.StringVar(&prefix, prefixFN, "", "Repo prefix within bucket.")
|
fs.StringVar(&prefix, flags.PrefixFN, "", "Repo prefix within bucket.")
|
||||||
fs.StringVar(&endpoint, endpointFN, "", "S3 service endpoint.")
|
fs.StringVar(&endpoint, flags.EndpointFN, "", "S3 service endpoint.")
|
||||||
fs.BoolVar(&doNotUseTLS, doNotUseTLSFN, false, "Disable TLS (HTTPS)")
|
fs.BoolVar(&doNotUseTLS, flags.DoNotUseTLSFN, false, "Disable TLS (HTTPS)")
|
||||||
fs.BoolVar(&doNotVerifyTLS, doNotVerifyTLSFN, false, "Disable TLS (HTTPS) certificate verification.")
|
fs.BoolVar(&doNotVerifyTLS, flags.DoNotVerifyTLSFN, false, "Disable TLS (HTTPS) certificate verification.")
|
||||||
|
|
||||||
// In general, we don't want to expose this flag to users and have them mistake it
|
// In general, we don't want to expose this flag to users and have them mistake it
|
||||||
// for a broad-scale idempotency solution. We can un-hide it later the need arises.
|
// for a broad-scale idempotency solution. We can un-hide it later the need arises.
|
||||||
@ -125,10 +107,7 @@ func s3InitCmd() *cobra.Command {
|
|||||||
func initS3Cmd(cmd *cobra.Command, args []string) error {
|
func initS3Cmd(cmd *cobra.Command, args []string) error {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
// s3 values from flags
|
cfg, err := config.GetConfigRepoDetails(ctx, true, false, cmd.Flags())
|
||||||
s3Override := S3Overrides(cmd)
|
|
||||||
|
|
||||||
cfg, err := config.GetConfigRepoDetails(ctx, true, false, s3Override)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -173,7 +152,7 @@ func initS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
opt,
|
opt,
|
||||||
retentionOpts)
|
retentionOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if succeedIfExists && errors.Is(err, repository.ErrorRepoAlreadyExists) {
|
if flags.SucceedIfExistsFV && errors.Is(err, repository.ErrorRepoAlreadyExists) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,10 +190,7 @@ func s3ConnectCmd() *cobra.Command {
|
|||||||
func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
// s3 values from flags
|
cfg, err := config.GetConfigRepoDetails(ctx, true, true, cmd.Flags())
|
||||||
s3Override := S3Overrides(cmd)
|
|
||||||
|
|
||||||
cfg, err := config.GetConfigRepoDetails(ctx, true, true, s3Override)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
@ -263,48 +239,3 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func S3Overrides(cmd *cobra.Command) map[string]string {
|
|
||||||
fs := flags.GetPopulatedFlags(cmd)
|
|
||||||
return PopulateS3Flags(fs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func PopulateS3Flags(flagset flags.PopulatedFlags) map[string]string {
|
|
||||||
s3Overrides := make(map[string]string)
|
|
||||||
s3Overrides[config.AccountProviderTypeKey] = account.ProviderM365.String()
|
|
||||||
s3Overrides[config.StorageProviderTypeKey] = storage.ProviderS3.String()
|
|
||||||
|
|
||||||
if _, ok := flagset[flags.AWSAccessKeyFN]; ok {
|
|
||||||
s3Overrides[credentials.AWSAccessKeyID] = flags.AWSAccessKeyFV
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[flags.AWSSecretAccessKeyFN]; ok {
|
|
||||||
s3Overrides[credentials.AWSSecretAccessKey] = flags.AWSSecretAccessKeyFV
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[flags.AWSSessionTokenFN]; ok {
|
|
||||||
s3Overrides[credentials.AWSSessionToken] = flags.AWSSessionTokenFV
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[bucketFN]; ok {
|
|
||||||
s3Overrides[storage.Bucket] = bucket
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[prefixFN]; ok {
|
|
||||||
s3Overrides[storage.Prefix] = prefix
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[doNotUseTLSFN]; ok {
|
|
||||||
s3Overrides[storage.DoNotUseTLS] = strconv.FormatBool(doNotUseTLS)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[doNotVerifyTLSFN]; ok {
|
|
||||||
s3Overrides[storage.DoNotVerifyTLS] = strconv.FormatBool(doNotVerifyTLS)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := flagset[endpointFN]; ok {
|
|
||||||
s3Overrides[storage.Endpoint] = endpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
return s3Overrides
|
|
||||||
}
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
"github.com/alcionai/corso/src/cli/flags"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/repo"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/pkg/count"
|
"github.com/alcionai/corso/src/pkg/count"
|
||||||
@ -104,7 +103,7 @@ func runRestore(
|
|||||||
sel selectors.Selector,
|
sel selectors.Selector,
|
||||||
backupID, serviceName string,
|
backupID, serviceName string,
|
||||||
) error {
|
) error {
|
||||||
r, _, _, _, err := utils.GetAccountAndConnect(ctx, sel.PathService(), repo.S3Overrides(cmd))
|
r, _, _, _, err := utils.GetAccountAndConnect(ctx, sel.PathService(), cmd.Flags())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, err)
|
return Only(ctx, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ func MakeExchangeOpts(cmd *cobra.Command) ExchangeOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ func makeExportCfgOpts(cmd *cobra.Command) ExportCfgOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,3 +91,34 @@ func (suite *FlagUnitSuite) TestAddCorsoPassphraseFlags() {
|
|||||||
err := cmd.Execute()
|
err := cmd.Execute()
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *FlagUnitSuite) TestAddS3BucketFlags() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "test",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
assert.Equal(t, "bucket1", flags.BucketFV, flags.BucketFN)
|
||||||
|
assert.Equal(t, "endpoint1", flags.EndpointFV, flags.EndpointFN)
|
||||||
|
assert.Equal(t, "prefix1", flags.PrefixFV, flags.PrefixFN)
|
||||||
|
assert.Equal(t, true, flags.DoNotUseTLSFV, flags.DoNotUseTLSFN)
|
||||||
|
assert.Equal(t, true, flags.DoNotVerifyTLSFV, flags.DoNotVerifyTLSFN)
|
||||||
|
assert.Equal(t, true, flags.SucceedIfExistsFV, flags.SucceedIfExistsFN)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.AddS3BucketFlags(cmd)
|
||||||
|
// Test arg parsing for few args
|
||||||
|
cmd.SetArgs([]string{
|
||||||
|
"test",
|
||||||
|
"--" + flags.BucketFN, "bucket1",
|
||||||
|
"--" + flags.EndpointFN, "endpoint1",
|
||||||
|
"--" + flags.PrefixFN, "prefix1",
|
||||||
|
"--" + flags.DoNotUseTLSFN,
|
||||||
|
"--" + flags.DoNotVerifyTLSFN,
|
||||||
|
"--" + flags.SucceedIfExistsFN,
|
||||||
|
})
|
||||||
|
|
||||||
|
err := cmd.Execute()
|
||||||
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ func MakeGroupsOpts(cmd *cobra.Command) GroupsOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ func MakeOneDriveOpts(cmd *cobra.Command) OneDriveOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ func makeRestoreCfgOpts(cmd *cobra.Command) RestoreCfgOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ func makeRetentionCfgOpts(cmd *cobra.Command) retentionCfgOpts {
|
|||||||
// Populated contains the list of flags that appear in the command,
|
// Populated contains the list of flags that appear in the command,
|
||||||
// according to pflags. Use this to differentiate between an "empty" and a
|
// according to pflags. Use this to differentiate between an "empty" and a
|
||||||
// "missing" value.
|
// "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ func MakeSharePointOpts(cmd *cobra.Command) SharePointOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,6 @@ func MakeTeamsOpts(cmd *cobra.Command) TeamsOpts {
|
|||||||
// populated contains the list of flags that appear in the
|
// populated contains the list of flags that appear in the
|
||||||
// command, according to pflags. Use this to differentiate
|
// command, according to pflags. Use this to differentiate
|
||||||
// between an "empty" and a "missing" value.
|
// between an "empty" and a "missing" value.
|
||||||
Populated: flags.GetPopulatedFlags(cmd),
|
Populated: flags.GetPopulatedFlags(cmd.Flags()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,9 @@ var ErrNotYetImplemented = clues.New("not yet implemented")
|
|||||||
func GetAccountAndConnect(
|
func GetAccountAndConnect(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
pst path.ServiceType,
|
pst path.ServiceType,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (repository.Repository, *storage.Storage, *account.Account, *control.Options, error) {
|
) (repository.Repository, *storage.Storage, *account.Account, *control.Options, error) {
|
||||||
cfg, err := config.GetConfigRepoDetails(ctx, true, true, overrides)
|
cfg, err := config.GetConfigRepoDetails(ctx, true, true, pfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
@ -55,9 +55,9 @@ func GetAccountAndConnect(
|
|||||||
func AccountConnectAndWriteRepoConfig(
|
func AccountConnectAndWriteRepoConfig(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
pst path.ServiceType,
|
pst path.ServiceType,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (repository.Repository, *account.Account, error) {
|
) (repository.Repository, *account.Account, error) {
|
||||||
r, stg, acc, opts, err := GetAccountAndConnect(ctx, pst, overrides)
|
r, stg, acc, opts, err := GetAccountAndConnect(ctx, pst, pfs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.CtxErr(ctx, err).Info("getting and connecting account")
|
logger.CtxErr(ctx, err).Info("getting and connecting account")
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/cmd/s3checker/pkg/s3"
|
"github.com/alcionai/corso/src/cmd/s3checker/pkg/s3"
|
||||||
"github.com/alcionai/corso/src/internal/common/crash"
|
"github.com/alcionai/corso/src/internal/common/crash"
|
||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/alcionai/corso/src/pkg/storage"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Matches other definitions of this const.
|
// Matches other definitions of this const.
|
||||||
@ -52,12 +51,12 @@ func checkerCommand() (*cobra.Command, error) {
|
|||||||
"Name of bucket to check")
|
"Name of bucket to check")
|
||||||
fs.StringVar(
|
fs.StringVar(
|
||||||
&f.bucketPrefix,
|
&f.bucketPrefix,
|
||||||
"bucket-prefix",
|
"prefix",
|
||||||
"",
|
"",
|
||||||
"Prefix to add to all object lookups")
|
"Prefix to add to all object lookups")
|
||||||
fs.StringSliceVar(
|
fs.StringSliceVar(
|
||||||
&f.prefixes,
|
&f.prefixes,
|
||||||
"prefix",
|
"object-prefix",
|
||||||
nil,
|
nil,
|
||||||
"Set of object prefixes to check. Pass multiple times for multiple prefixes")
|
"Set of object prefixes to check. Pass multiple times for multiple prefixes")
|
||||||
|
|
||||||
@ -181,13 +180,7 @@ func handleCheckerCommand(cmd *cobra.Command, args []string, f flags) error {
|
|||||||
|
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
|
||||||
// Scavenged from src/internal/kopia/s3/s3.go.
|
repoDetails, err := config.GetConfigRepoDetails(ctx, false, false, cmd.Flags())
|
||||||
overrides := map[string]string{
|
|
||||||
storage.Bucket: f.bucket,
|
|
||||||
storage.Prefix: f.bucketPrefix,
|
|
||||||
}
|
|
||||||
|
|
||||||
repoDetails, err := config.GetConfigRepoDetails(ctx, false, false, overrides)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return clues.Wrap(err, "getting storage config")
|
return clues.Wrap(err, "getting storage config")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,12 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type storageProvider int
|
type StorageProvider int
|
||||||
|
|
||||||
//go:generate stringer -type=storageProvider -linecomment
|
//go:generate stringer -type=StorageProvider -linecomment
|
||||||
const (
|
const (
|
||||||
ProviderUnknown storageProvider = 0 // Unknown Provider
|
ProviderUnknown StorageProvider = 0 // Unknown Provider
|
||||||
ProviderS3 storageProvider = 1 // S3
|
ProviderS3 StorageProvider = 1 // S3
|
||||||
)
|
)
|
||||||
|
|
||||||
// storage parsing errors
|
// storage parsing errors
|
||||||
@ -24,7 +24,7 @@ var (
|
|||||||
// Storage defines a storage provider, along with any configuration
|
// Storage defines a storage provider, along with any configuration
|
||||||
// required to set up or communicate with that provider.
|
// required to set up or communicate with that provider.
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
Provider storageProvider
|
Provider StorageProvider
|
||||||
Config map[string]string
|
Config map[string]string
|
||||||
// TODO: These are AWS S3 specific -> move these out
|
// TODO: These are AWS S3 specific -> move these out
|
||||||
SessionTags map[string]string
|
SessionTags map[string]string
|
||||||
@ -34,7 +34,7 @@ type Storage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage aggregates all the supplied configurations into a single configuration.
|
// NewStorage aggregates all the supplied configurations into a single configuration.
|
||||||
func NewStorage(p storageProvider, cfgs ...common.StringConfigurer) (Storage, error) {
|
func NewStorage(p StorageProvider, cfgs ...common.StringConfigurer) (Storage, error) {
|
||||||
cs, err := common.UnionStringConfigs(cfgs...)
|
cs, err := common.UnionStringConfigs(cfgs...)
|
||||||
|
|
||||||
return Storage{
|
return Storage{
|
||||||
@ -46,7 +46,7 @@ func NewStorage(p storageProvider, cfgs ...common.StringConfigurer) (Storage, er
|
|||||||
// NewStorageUsingRole supports specifying an AWS IAM role the storage provider
|
// NewStorageUsingRole supports specifying an AWS IAM role the storage provider
|
||||||
// should assume.
|
// should assume.
|
||||||
func NewStorageUsingRole(
|
func NewStorageUsingRole(
|
||||||
p storageProvider,
|
p StorageProvider,
|
||||||
roleARN string,
|
roleARN string,
|
||||||
sessionName string,
|
sessionName string,
|
||||||
sessionTags map[string]string,
|
sessionTags map[string]string,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=storageProvider -linecomment"; DO NOT EDIT.
|
// Code generated by "stringer -type=StorageProvider -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package storage
|
package storage
|
||||||
|
|
||||||
@ -12,13 +12,13 @@ func _() {
|
|||||||
_ = x[ProviderS3-1]
|
_ = x[ProviderS3-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _storageProvider_name = "Unknown ProviderS3"
|
const _StorageProvider_name = "Unknown ProviderS3"
|
||||||
|
|
||||||
var _storageProvider_index = [...]uint8{0, 16, 18}
|
var _StorageProvider_index = [...]uint8{0, 16, 18}
|
||||||
|
|
||||||
func (i storageProvider) String() string {
|
func (i StorageProvider) String() string {
|
||||||
if i < 0 || i >= storageProvider(len(_storageProvider_index)-1) {
|
if i < 0 || i >= StorageProvider(len(_StorageProvider_index)-1) {
|
||||||
return "storageProvider(" + strconv.FormatInt(int64(i), 10) + ")"
|
return "StorageProvider(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
}
|
}
|
||||||
return _storageProvider_name[_storageProvider_index[i]:_storageProvider_index[i+1]]
|
return _StorageProvider_name[_StorageProvider_index[i]:_StorageProvider_index[i+1]]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user