Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Refactor/config structure update" #47

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/continuous-delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
context: ./
file: ./Dockerfile
target: prod
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/aws90x,linux/arm/v6
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
*.so
*.dylib
tmp
# credential
# profile

# Test binary, built with `go test -c`
*.test
Expand All @@ -27,6 +25,3 @@ go.work

# mc-data-manager binary, built with `go build`
mc-data-manager

# Credential
profile.json
20 changes: 10 additions & 10 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Semi-structured data: json, xml
You must enter the data size in GB.`,
Run: func(_ *cobra.Command, _ []string) {
logrus.SetFormatter(&log.CustomTextFormatter{CmdName: "create", JobName: "dummy create"})
if err := execfunc.DummyCreate(commandTask); err != nil {
if err := execfunc.DummyCreate(datamoldParams); err != nil {
logrus.Errorf("dummy create failed : %v", err)
}
},
Expand All @@ -46,15 +46,15 @@ You must enter the data size in GB.`,
func init() {
rootCmd.AddCommand(createCmd)

createCmd.Flags().StringVarP(&commandTask.DummyPath, "dst-path", "d", "", "Directory path to create dummy data")
createCmd.Flags().StringVarP(&datamoldParams.DstPath, "dst-path", "d", "", "Directory path to create dummy data")
createCmd.MarkFlagRequired("dst-path")

createCmd.Flags().StringVarP(&commandTask.SizeSQL, "sql-size", "s", "0", "Total size of sql files")
createCmd.Flags().StringVarP(&commandTask.SizeCSV, "csv-size", "c", "0", "Total size of csv files")
createCmd.Flags().StringVarP(&commandTask.SizeJSON, "json-size", "j", "0", "Total size of json files")
createCmd.Flags().StringVarP(&commandTask.SizeXML, "xml-size", "x", "0", "Total size of xml files")
createCmd.Flags().StringVarP(&commandTask.SizeTXT, "txt-size", "t", "0", "Total size of txt files")
createCmd.Flags().StringVarP(&commandTask.SizePNG, "png-size", "p", "0", "Total size of png files")
createCmd.Flags().StringVarP(&commandTask.SizeGIF, "gif-size", "g", "0", "Total size of gif files")
createCmd.Flags().StringVarP(&commandTask.SizeZIP, "zip-size", "z", "0", "Total size of zip files")
createCmd.Flags().IntVarP(&datamoldParams.SqlSize, "sql-size", "s", 0, "Total size of sql files")
createCmd.Flags().IntVarP(&datamoldParams.CsvSize, "csv-size", "c", 0, "Total size of csv files")
createCmd.Flags().IntVarP(&datamoldParams.JsonSize, "json-size", "j", 0, "Total size of json files")
createCmd.Flags().IntVarP(&datamoldParams.XmlSize, "xml-size", "x", 0, "Total size of xml files")
createCmd.Flags().IntVarP(&datamoldParams.TxtSize, "txt-size", "t", 0, "Total size of txt files")
createCmd.Flags().IntVarP(&datamoldParams.PngSize, "png-size", "p", 0, "Total size of png files")
createCmd.Flags().IntVarP(&datamoldParams.GifSize, "gif-size", "g", 0, "Total size of gif files")
createCmd.Flags().IntVarP(&datamoldParams.ZipSize, "zip-size", "z", 0, "Total size of zip files")
}
23 changes: 12 additions & 11 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,32 @@ import (
// deleteCmd represents the delete command
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete local data",
Short: "Delete dummy data",
Long: `Delete unstructured, semi-structured, and structured data,
which are CSP or local dummy data`,
}

var deleteLocalCmd = &cobra.Command{
Use: "local",
var deleteDummyCmd = &cobra.Command{
Use: "dummy",

Run: func(cmd *cobra.Command, args []string) {
logrus.SetFormatter(&log.CustomTextFormatter{CmdName: "delete"})
logrus.WithFields(logrus.Fields{"jobName": "local delete"}).Info("start deleting local data")
logrus.WithFields(logrus.Fields{"jobName": "dummy delete"}).Info("start deleting dummy")

if err := os.RemoveAll(commandTask.Directory); err != nil {
logrus.WithFields(logrus.Fields{"jobName": "local delete"}).Errorf("failed to delete local : %v", err)
if err := os.RemoveAll(datamoldParams.DstPath); err != nil {
logrus.WithFields(logrus.Fields{"jobName": "dummy delete"}).Errorf("failed to delete dummy : %v", err)
return
}
logrus.Infof("successfully deleted : %s\n", commandTask.Directory)

logrus.Infof("successfully deleted : %s\n", datamoldParams.DstPath)
return
},
}

func init() {
rootCmd.AddCommand(deleteCmd)
deleteCmd.AddCommand(deleteLocalCmd)
deleteCmd.AddCommand(deleteDummyCmd)

deleteLocalCmd.Flags().StringVarP(&commandTask.Directory, "dst-path", "d", "", "Delete data in directory paths")
deleteLocalCmd.MarkFlagRequired("dst-path")
deleteCmd.PersistentFlags().BoolVarP(&datamoldParams.TaskTarget, "task", "T", false, "Select a destination(src, dst) to work with in the credential-path")
deleteDummyCmd.Flags().StringVarP(&datamoldParams.DstPath, "dst-path", "d", "", "Delete data in directory paths")
deleteDummyCmd.MarkFlagRequired("dst-path")
}
7 changes: 4 additions & 3 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var exportCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(exportCmd)

exportCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
exportCmd.PersistentFlags().StringVarP(&commandTask.Directory, "dst-path", "d", "", "Directory path to export data")
exportCmd.MarkFlagsRequiredTogether("task-file-path", "dst-path")
exportCmd.PersistentFlags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
exportCmd.PersistentFlags().StringVarP(&datamoldParams.DstPath, "dst-path", "d", "", "Directory path to export data")
exportCmd.PersistentFlags().BoolVarP(&datamoldParams.TaskTarget, "task", "T", false, "Select a destination(src, dst) to work with in the credential-path")
exportCmd.MarkFlagsRequiredTogether("credential-path", "dst-path")
}
7 changes: 4 additions & 3 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var importCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(importCmd)

importCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
importCmd.PersistentFlags().StringVarP(&commandTask.Directory, "dst-path", "d", "", "Destination path where dummy data exists")
importCmd.MarkFlagsRequiredTogether("task-file-path", "dst-path")
importCmd.PersistentFlags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
importCmd.PersistentFlags().StringVarP(&datamoldParams.DstPath, "dst-path", "d", "", "Destination path where dummy data exists")
importCmd.PersistentFlags().BoolVarP(&datamoldParams.TaskTarget, "task", "T", false, "Select a destination(src, dst) to work with in the credential-path")
importCmd.MarkFlagsRequiredTogether("credential-path", "dst-path")
}
5 changes: 3 additions & 2 deletions cmd/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var migrationCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(migrationCmd)
migrationCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
migrationCmd.MarkFlagRequired("task-file-path")
migrationCmd.PersistentFlags().BoolVarP(&datamoldParams.TaskTarget, "task", "T", false, "Select a destination(src, dst) to work with in the credential-path")
migrationCmd.PersistentFlags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
migrationCmd.MarkFlagRequired("credential-path")
}
31 changes: 14 additions & 17 deletions cmd/nrdbms.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,38 @@ var importNRDBCmd = &cobra.Command{
Use: "nrdbms",
Aliases: []string{"ndb"},
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("nrdbms", &commandTask, cmd.Parent().Use)
if err := auth.ImportNRDMFunc(&commandTask); err != nil {
auth.PreRun("nrdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.ImportNRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var exportNRDBCmd = &cobra.Command{
Use: "nrdbms",
Aliases: []string{"ndb"},
Use: "nrdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("nrdbms", &commandTask, cmd.Parent().Use)
if err := auth.ExportNRDMFunc(&commandTask); err != nil {
auth.PreRun("nrdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.ExportNRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var migrationNRDBCmd = &cobra.Command{
Use: "nrdbms",
Aliases: []string{"ndb"},
Use: "nrdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("nrdbms", &commandTask, cmd.Parent().Use)
if err := auth.MigrationNRDMFunc(&commandTask); err != nil {
auth.PreRun("nrdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.MigrationNRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var deleteNRDBMSCmd = &cobra.Command{
Use: "nrdbms",
Aliases: []string{"ndb"},
Use: "nrdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("nrdbms", &commandTask, cmd.Parent().Use)
if err := auth.DeleteNRDMFunc(&commandTask); err != nil {
auth.PreRun("nrdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.DeleteNRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -73,7 +70,7 @@ func init() {
migrationCmd.AddCommand(migrationNRDBCmd)
deleteCmd.AddCommand(deleteNRDBMSCmd)

deleteNRDBMSCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
deleteNRDBMSCmd.Flags().StringArrayVarP(&commandTask.DeleteTableList, "delete-table-list", "D", []string{}, "List of table names to delete")
deleteNRDBMSCmd.MarkFlagsRequiredTogether("task-file-path", "delete-table-list")
deleteNRDBMSCmd.Flags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
deleteNRDBMSCmd.Flags().StringArrayVarP(&datamoldParams.DeleteTableList, "delete-table-list", "D", []string{}, "List of table names to delete")
deleteNRDBMSCmd.MarkFlagsRequiredTogether("credential-path", "delete-table-list")
}
32 changes: 14 additions & 18 deletions cmd/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,40 @@ import (
)

var importOSCmd = &cobra.Command{
Use: "objectstorage",
Aliases: []string{"obj"},
Use: "objectstorage",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("objectstorage", &commandTask, cmd.Parent().Use)
if err := auth.ImportOSFunc(&commandTask); err != nil {
auth.PreRun("objectstorage", &datamoldParams, cmd.Parent().Use)
if err := auth.ImportOSFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var exportOSCmd = &cobra.Command{
Use: "objectstorage",
Aliases: []string{"obj"},
Use: "objectstorage",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("objectstorage", &commandTask, cmd.Parent().Use)
if err := auth.ExportOSFunc(&commandTask); err != nil {
auth.PreRun("objectstorage", &datamoldParams, cmd.Parent().Use)
if err := auth.ExportOSFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var migrationOSCmd = &cobra.Command{
Use: "objectstorage",
Aliases: []string{"obj"},
Use: "objectstorage",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("objectstorage", &commandTask, cmd.Parent().Use)
if err := auth.MigrationOSFunc(&commandTask); err != nil {
auth.PreRun("objectstorage", &datamoldParams, cmd.Parent().Use)
if err := auth.MigrationOSFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
}

var deleteOSCmd = &cobra.Command{
Use: "objectstorage",
Aliases: []string{"obj"},
Use: "objectstorage",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("objectstorage", &commandTask, cmd.Parent().Use)
if err := auth.DeleteOSFunc(&commandTask); err != nil {
auth.PreRun("objectstorage", &datamoldParams, cmd.Parent().Use)
if err := auth.DeleteOSFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -72,6 +68,6 @@ func init() {
migrationCmd.AddCommand(migrationOSCmd)
deleteCmd.AddCommand(deleteOSCmd)

deleteOSCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
deleteOSCmd.MarkFlagRequired("task-file-path")
deleteOSCmd.Flags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
deleteOSCmd.MarkFlagRequired("credential-path")
}
22 changes: 11 additions & 11 deletions cmd/rdbms.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
var importRDBCmd = &cobra.Command{
Use: "rdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("rdbms", &commandTask, cmd.Parent().Use)
if err := auth.ImportRDMFunc(&commandTask); err != nil {
auth.PreRun("rdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.ImportRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -36,8 +36,8 @@ var importRDBCmd = &cobra.Command{
var exportRDBCmd = &cobra.Command{
Use: "rdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("rdbms", &commandTask, cmd.Parent().Use)
if err := auth.ExportRDMFunc(&commandTask); err != nil {
auth.PreRun("rdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.ExportRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -46,8 +46,8 @@ var exportRDBCmd = &cobra.Command{
var migrationRDBCmd = &cobra.Command{
Use: "rdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("rdbms", &commandTask, cmd.Parent().Use)
if err := auth.MigrationRDMFunc(&commandTask); err != nil {
auth.PreRun("rdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.MigrationRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -56,8 +56,8 @@ var migrationRDBCmd = &cobra.Command{
var deleteRDBMSCmd = &cobra.Command{
Use: "rdbms",
Run: func(cmd *cobra.Command, args []string) {
auth.PreRun("rdbms", &commandTask, cmd.Parent().Use)
if err := auth.DeleteRDMFunc(&commandTask); err != nil {
auth.PreRun("rdbms", &datamoldParams, cmd.Parent().Use)
if err := auth.DeleteRDMFunc(&datamoldParams); err != nil {
os.Exit(1)
}
},
Expand All @@ -69,7 +69,7 @@ func init() {
migrationCmd.AddCommand(migrationRDBCmd)
deleteCmd.AddCommand(deleteRDBMSCmd)

deleteRDBMSCmd.PersistentFlags().StringVarP(&commandTask.TaskFilePath, "task-file-path", "f", "task.json", "Json file path containing the user's task")
deleteRDBMSCmd.Flags().StringArrayVarP(&commandTask.DeleteDBList, "delete-db-list", "D", []string{}, "List of db names to delete")
deleteRDBMSCmd.MarkFlagsRequiredTogether("task-file-path", "delete-db-list")
deleteRDBMSCmd.Flags().StringVarP(&datamoldParams.CredentialPath, "credential-path", "C", "", "Json file path containing the user's credentials")
deleteRDBMSCmd.Flags().StringArrayVarP(&datamoldParams.DeleteDBList, "delete-db-list", "D", []string{}, "List of db names to delete")
deleteRDBMSCmd.MarkFlagsRequiredTogether("credential-path", "delete-db-list")
}
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package cmd
import (
"os"

"github.com/cloud-barista/mc-data-manager/models"
"github.com/cloud-barista/mc-data-manager/internal/auth"
"github.com/cloud-barista/mc-data-manager/internal/log"
"github.com/spf13/cobra"
)

var commandTask models.CommandTask
var datamoldParams auth.DatamoldParams

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand All @@ -31,6 +32,7 @@ var rootCmd = &cobra.Command{
Long: `It is a tool that builds an environment for verification of data migration technology and
generates test data necessary for data migration.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
log.LogFile()
return nil
},
}
Expand Down
52 changes: 0 additions & 52 deletions cmd/test.go

This file was deleted.

Loading