generated from bilalcaliskan/golang-cli-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from bilalcaliskan/devel
Devel
- Loading branch information
Showing
18 changed files
with
1,446 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
- [x] versioning | ||
- [x] search/file | ||
- [x] tags | ||
- [NO] storageclass | ||
- [NO] encryption | ||
- [ ] search/text (all files, single file etc.) | ||
- [ ] bucketpolicy | ||
- [ ] objectlock | ||
- [x] search/text (all files, single file etc.) | ||
- [x] bucketpolicy | ||
- [x] transferacceleration | ||
- [ ] mfadelete | ||
- [ ] re-enable prompt/select logic | ||
- [ ] fix code smells | ||
- [ ] fix duplications | ||
- [ ] ~~storageclass~~ | ||
- [ ] ~~encryption~~ | ||
- [ ] ~~objectlock~~ |
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,50 @@ | ||
package options | ||
|
||
import ( | ||
"github.com/bilalcaliskan/s3-manager/cmd/root/options" | ||
) | ||
|
||
type TransferAccelerationOptsKey struct{} | ||
|
||
var ( | ||
//substringRunner prompt.PromptRunner = prompt.GetPromptRunner("Provide text to search", nil) | ||
//extensionRunner prompt.PromptRunner = prompt.GetPromptRunner("Provide target file extensions (comma seperated)", nil) | ||
transferAccelerationOpts = &TransferAccelerationOptions{} | ||
) | ||
|
||
// TransferAccelerationOptions contains frequent command line and application options. | ||
type TransferAccelerationOptions struct { | ||
// ActualState is state | ||
ActualState string | ||
// DesiredState is state | ||
DesiredState string | ||
*options.RootOptions | ||
} | ||
|
||
// GetTransferAccelerationOptions returns the pointer of FindOptions | ||
func GetTransferAccelerationOptions() *TransferAccelerationOptions { | ||
return transferAccelerationOpts | ||
} | ||
|
||
func (opts *TransferAccelerationOptions) SetZeroValues() { | ||
opts.ActualState = "Enabled" | ||
opts.DesiredState = "enabled" | ||
opts.RootOptions.SetZeroValues() | ||
} | ||
|
||
/*func (opts *ConfigureOptions) PromptInteractiveValues() error { | ||
res, err := substringRunner.Run() | ||
if err != nil { | ||
return err | ||
} | ||
opts.Foo = res | ||
res, err = extensionRunner.Run() | ||
if err != nil { | ||
return err | ||
} | ||
opts.FileExtensions = res | ||
return nil | ||
} | ||
*/ |
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,23 @@ | ||
package options | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/bilalcaliskan/s3-manager/cmd/root/options" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetTransferAccelerationOptions(t *testing.T) { | ||
opts := GetTransferAccelerationOptions() | ||
assert.NotNil(t, opts) | ||
} | ||
|
||
func TestTransferAccelerationOptions_SetZeroValues(t *testing.T) { | ||
rootOpts := options.GetRootOptions() | ||
opts := GetTransferAccelerationOptions() | ||
opts.RootOptions = rootOpts | ||
assert.NotNil(t, opts) | ||
|
||
opts.SetZeroValues() | ||
} |
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,62 @@ | ||
package disabled | ||
|
||
import ( | ||
options2 "github.com/bilalcaliskan/s3-manager/cmd/transferacceleration/options" | ||
"github.com/bilalcaliskan/s3-manager/cmd/transferacceleration/utils" | ||
|
||
"github.com/aws/aws-sdk-go/service/s3/s3iface" | ||
"github.com/bilalcaliskan/s3-manager/internal/aws" | ||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
transferAccelerationOpts = options2.GetTransferAccelerationOptions() | ||
} | ||
|
||
var ( | ||
svc s3iface.S3API | ||
logger zerolog.Logger | ||
transferAccelerationOpts *options2.TransferAccelerationOptions | ||
DisabledCmd = &cobra.Command{ | ||
Use: "disabled", | ||
Short: "", | ||
SilenceUsage: true, | ||
SilenceErrors: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
svc, transferAccelerationOpts, logger = utils.PrepareConstants(cmd, transferAccelerationOpts) | ||
|
||
if err := utils.CheckArgs(args); err != nil { | ||
logger.Error(). | ||
Msg(err.Error()) | ||
return err | ||
} | ||
|
||
transferAccelerationOpts.DesiredState = "disabled" | ||
res, err := aws.GetTransferAcceleration(svc, transferAccelerationOpts) | ||
if err != nil { | ||
logger.Error().Msg(err.Error()) | ||
return err | ||
} | ||
|
||
if err := utils.DecideActualState(res, transferAccelerationOpts); err != nil { | ||
logger.Error().Msg(err.Error()) | ||
return err | ||
} | ||
|
||
if transferAccelerationOpts.DesiredState == transferAccelerationOpts.ActualState { | ||
logger.Warn().Msg("transferr acceleration configuration is already at desired state") | ||
return nil | ||
} | ||
|
||
if _, err := aws.SetTransferAcceleration(svc, transferAccelerationOpts); err != nil { | ||
logger.Error().Msg(err.Error()) | ||
return err | ||
} | ||
|
||
logger.Info().Msg("successfully set transfer acceleration as disabled") | ||
|
||
return nil | ||
}, | ||
} | ||
) |
Oops, something went wrong.