Skip to content

Commit a93919a

Browse files
author
anton.voskresensky
committed
refactor
1 parent deb1dac commit a93919a

14 files changed

+16
-36
lines changed

commands/coldstorage.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func runColdStorage(cmd *cobra.Command, args []string) error {
3434
logger := logging.NewLogger()
3535
logger.Info(fmt.Sprintf("Starting cold storage migration hotCount=%d coldAttribute=%s dryRun=%t", hotCount, coldAttribute, dryRun))
3636

37-
client, err := utils.NewOSClientFromCommandConfig(cfg)
37+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
3838
if err != nil {
3939
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4040
}
@@ -55,7 +55,7 @@ func runColdStorage(cmd *cobra.Command, args []string) error {
5555

5656
var candidates []string
5757
for _, index := range allIndices {
58-
if shouldMoveToColdStorage(index.Index, cutoffDate, dateFormat) {
58+
if utils.IsOlderThanCutoff(index.Index, cutoffDate, dateFormat) {
5959
candidates = append(candidates, index.Index)
6060
}
6161
}
@@ -112,7 +112,3 @@ func runColdStorage(cmd *cobra.Command, args []string) error {
112112
logger.Info(fmt.Sprintf("Cold storage migration completed processed=%d skipped_already_cold=%d", len(coldIndices), len(alreadyCold)))
113113
return nil
114114
}
115-
116-
func shouldMoveToColdStorage(index, cutoffDate, dateFormat string) bool {
117-
return utils.IsOlderThanCutoff(index, cutoffDate, dateFormat)
118-
}

commands/danglingchecker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func runDanglingChecker(cmd *cobra.Command, args []string) error {
3535
}
3636

3737
logger := logging.NewLogger()
38-
client, err := utils.NewOSClientFromCommandConfig(cfg)
38+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
3939
if err != nil {
4040
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4141
}

commands/datasource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func runDataSource(cmd *cobra.Command, args []string) error {
4747

4848
logger := logging.NewLogger()
4949
dryRun := cfg.GetDryRun()
50-
_, err := utils.NewOSClientFromCommandConfig(cfg)
50+
_, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
5151
if err != nil {
5252
return fmt.Errorf("failed to create OpenSearch client: %v", err)
5353
}

commands/dereplicator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func runDereplicator(cmd *cobra.Command, args []string) error {
4040
logger := logging.NewLogger()
4141
logger.Info(fmt.Sprintf("Starting dereplication process daysCount=%d useSnapshot=%t snapRepo=%s dryRun=%t", daysCount, useSnapshot, snapRepo, dryRun))
4242

43-
client, err := utils.NewOSClientFromCommandConfig(cfg)
43+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
4444
if err != nil {
4545
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4646
}

commands/extracteddelete.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func runExtractedDelete(cmd *cobra.Command, args []string) error {
3030
dryRun := cfg.GetDryRun()
3131

3232
logger := logging.NewLogger()
33-
client, err := utils.NewOSClientFromCommandConfigWithError(cfg, cfg.GetOpenSearchRecovererURL())
33+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchRecovererURL())
3434
if err != nil {
3535
return err
3636
}
@@ -57,7 +57,7 @@ func runExtractedDelete(cmd *cobra.Command, args []string) error {
5757

5858
var extractedIndices []string
5959
for _, index := range allIndices {
60-
if shouldDeleteExtractedIndex(index.Index, cutoffDate, dateFormat) {
60+
if utils.IsOlderThanCutoff(index.Index, cutoffDate, dateFormat) {
6161
extractedIndices = append(extractedIndices, index.Index)
6262
}
6363
}
@@ -88,7 +88,3 @@ func runExtractedDelete(cmd *cobra.Command, args []string) error {
8888
logger.Info(fmt.Sprintf("Extracted indices deletion completed processed=%d", len(extractedIndices)))
8989
return nil
9090
}
91-
92-
func shouldDeleteExtractedIndex(index, cutoffDate, dateFormat string) bool {
93-
return utils.IsOlderThanCutoff(index, cutoffDate, dateFormat)
94-
}

commands/indexpatterns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func runIndexPatterns(cmd *cobra.Command, args []string) error {
3737
dryRun := cfg.GetDryRun()
3838

3939
logger := logging.NewLogger()
40-
osClient, err := utils.NewOSClientFromCommandConfig(cfg)
40+
osClient, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
4141
if err != nil {
4242
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4343
}

commands/indicesdelete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func runIndicesDelete(cmd *cobra.Command, args []string) error {
3535

3636
logger.Info(fmt.Sprintf("Starting indices deletion indicesCount=%d unknownDays=%d", len(indicesConfig), unknownConfig.DaysCount))
3737

38-
client, err := utils.NewOSClientFromCommandConfig(cfg)
38+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
3939
if err != nil {
4040
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4141
}

commands/retention.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func runRetention(cmd *cobra.Command, args []string) error {
4040
logger := logging.NewLogger()
4141
logger.Info(fmt.Sprintf("Starting retention process threshold=%.2f snapRepo=%s dryRun=%t", threshold, snapRepo, dryRun))
4242

43-
client, err := utils.NewOSClientFromCommandConfig(cfg)
43+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
4444
if err != nil {
4545
return fmt.Errorf("failed to create OpenSearch client: %v", err)
4646
}

commands/sharding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func runSharding(cmd *cobra.Command, args []string) error {
3232

3333
logger := logging.NewLogger()
3434
dryRun := cfg.GetDryRun()
35-
client, err := utils.NewOSClientFromCommandConfig(cfg)
35+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
3636
if err != nil {
3737
return fmt.Errorf("failed to create OpenSearch client: %v", err)
3838
}

commands/snapshot-manual.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func runSnapshotManual(cmd *cobra.Command, args []string) error {
4343

4444
logger.Info(fmt.Sprintf("Starting manual snapshot creation kind=%s value=%s name=%s system=%t", kind, value, name, system))
4545

46-
client, err := utils.NewOSClientFromConfig(cfg)
46+
client, err := utils.NewOSClientWithURL(cfg, cfg.GetOpenSearchURL())
4747
if err != nil {
4848
return err
4949
}

0 commit comments

Comments
 (0)