Skip to content

Commit

Permalink
Refactored migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
akgalwas committed Dec 17, 2024
1 parent 7bcbc0e commit 1249724
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions hack/runtime-migrator/cmd/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
runtimev1 "github.com/kyma-project/infrastructure-manager/api/v1"
config2 "github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/config"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/migration"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/runtime"
"github.com/kyma-project/infrastructure-manager/pkg/config"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/kubeconfig"
"github.com/kyma-project/infrastructure-manager/pkg/gardener/shoot/extender/auditlogs"
Expand All @@ -21,8 +20,8 @@ import (
)

type Migration struct {
runtimeMigrator runtime.Migrator
runtimeVerifier runtime.Verifier
runtimeMigrator migration.Migrator
runtimeVerifier migration.Verifier
kcpClient client.Client
shootClient gardener_types.ShootInterface
outputWriter migration.OutputWriter
Expand All @@ -37,8 +36,8 @@ func NewMigration(migratorConfig config2.Config, converterConfig config.Converte
}

return Migration{
runtimeMigrator: runtime.NewMigrator(migratorConfig, kubeconfigProvider, kcpClient),
runtimeVerifier: runtime.NewVerifier(converterConfig, auditLogConfig),
runtimeMigrator: migration.NewMigrator(migratorConfig, kubeconfigProvider, kcpClient),
runtimeVerifier: migration.NewVerifier(converterConfig, auditLogConfig),
kcpClient: kcpClient,
shootClient: shootClient,
outputWriter: outputWriter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package runtime
package migration

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package runtime
package migration

import (
"github.com/stretchr/testify/require"
Expand Down
5 changes: 2 additions & 3 deletions hack/runtime-migrator/internal/migration/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

v1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/kyma-project/infrastructure-manager/hack/runtime-migrator-app/internal/runtime"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -67,7 +66,7 @@ func (ow OutputWriter) SaveRuntimeCR(runtime v1.Runtime) error {
return saveYaml(runtime, fmt.Sprintf("%s/%s.yaml", ow.RuntimeDir, runtime.Name))
}

func (ow OutputWriter) SaveComparisonResult(comparisonResult runtime.ShootComparisonResult) error {
func (ow OutputWriter) SaveComparisonResult(comparisonResult ShootComparisonResult) error {
comparisonResultsForRuntimeDir := path.Join(ow.ComparisonResultsDir, comparisonResult.RuntimeID)
err := os.MkdirAll(comparisonResultsForRuntimeDir, os.ModePerm)
if err != nil {
Expand All @@ -89,7 +88,7 @@ func (ow OutputWriter) SaveComparisonResult(comparisonResult runtime.ShootCompar
return saveYaml(comparisonResult.ConvertedShoot, path.Join(comparisonResultsForRuntimeDir, "converted-shoot.yaml"))
}

func writeResultsToDiffFile(shootName string, difference *runtime.Difference, resultsDir string) error {
func writeResultsToDiffFile(shootName string, difference *Difference, resultsDir string) error {
writeAndCloseFunc := func(filePath string, text string) error {
file, err := os.Create(filePath)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package runtime
package migration

import (
"slices"
Expand Down

0 comments on commit 1249724

Please sign in to comment.