Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func adminCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
10 changes: 4 additions & 6 deletions cmd/admin_build_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const unsubstitutedValue = "<no value>"

func adminBuildInstanceCommand(conf *config.ClientConfig) *cli.Command {
var (
optimusHost string
projectName string
assetOutputDir = "/tmp/"
runType = "task"
runName string
Expand All @@ -54,12 +52,12 @@ func adminBuildInstanceCommand(conf *config.ClientConfig) *cli.Command {
cmd.Flags().StringVar(&runName, "name", "", "Name of running instance, e.g., bq2bq/transporter/predator")
cmd.MarkFlagRequired("name")

cmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Name of the optimus project") // TODO: fix overriding conf via args
cmd.Flags().StringVar(&optimusHost, "host", optimusHost, "Optimus service endpoint url") // TODO: fix overriding conf via args
cmd.Flags().StringP("project-name", "p", defaultProjectName, "Name of the optimus project")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change needs a corresponding change in the entrypoint.sh where ever it is referred when the optimus binary is upgraded in the plugins.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted, after we bump the optimus version, we can later update the flag name in endpoint.sh for each plugins

cmd.Flags().String("host", defaultHost, "Optimus service endpoint url")

cmd.RunE = func(c *cli.Command, args []string) error {
projectName = conf.Project.Name
optimusHost = conf.Host
projectName := conf.Project.Name
optimusHost := conf.Host
l := initClientLogger(conf.Log)
jobName := args[0]
l.Info(fmt.Sprintf("Requesting resources for project %s, job %s at %s", projectName, jobName, optimusHost))
Expand Down
2 changes: 1 addition & 1 deletion cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func backupCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/backup_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ func backupListCommand(conf *config.ClientConfig) *cli.Command {
Short: "Get list of backups per project and datastore",
Example: "optimus backup list",
}
project string
)
backupCmd.Flags().StringVarP(&project, "project", "p", project, "project name of optimus managed repository") // TODO: fix overriding conf via args
backupCmd.Flags().StringP("project-name", "p", defaultProjectName, "project name of optimus managed repository")
backupCmd.RunE = func(cmd *cli.Command, args []string) error {
project = conf.Project.Name
project := conf.Project.Name
l := initClientLogger(conf.Log)
dsRepo := models.DatastoreRegistry
availableStorer := []string{}
Expand Down
5 changes: 2 additions & 3 deletions cmd/backup_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ import (

func backupStatusCommand(conf *config.ClientConfig) *cli.Command {
var (
project string
backupCmd = &cli.Command{
Use: "status",
Short: "Get backup info using uuid and datastore",
Example: "optimus backup status <uuid>",
}
)
backupCmd.Flags().StringVarP(&project, "project", "p", project, "Project name of optimus managed repository") // TODO: fix overriding conf via args
backupCmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
backupCmd.RunE = func(cmd *cli.Command, args []string) error {
project = conf.Project.Name
project := conf.Project.Name
l := initClientLogger(conf.Log)
dsRepo := models.DatastoreRegistry
availableStorer := []string{}
Expand Down
5 changes: 5 additions & 0 deletions cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ const (
BackoffDuration = 100 * time.Millisecond
)

const (
defaultProjectName = "sample_project"
defaultHost = "localhost:9100"
)

// JobSpecRepository represents a storage interface for Job specifications locally
type JobSpecRepository interface {
SaveAt(models.JobSpec, string) error
Expand Down
1 change: 0 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
)

const (
defaultHost = "localhost"
defaultFilePermissionMode = 0o655
)

Expand Down
10 changes: 5 additions & 5 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
// deployCommand pushes current repo to optimus service
func deployCommand() *cli.Command {
var (
namespaces []string
namespaceNames []string
ignoreJobs bool
ignoreResources bool
verbose bool
Expand All @@ -48,7 +48,7 @@ func deployCommand() *cli.Command {
}

cmd.Flags().StringVarP(&configFilePath, "config", "c", configFilePath, "File path for client configuration")
cmd.Flags().StringSliceVarP(&namespaces, "namespaces", "N", nil, "Selected namespaces of optimus project")
cmd.Flags().StringSliceVarP(&namespaceNames, "namespace-names", "N", nil, "Selected namespaces of optimus project")
cmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Print details related to deployment stages")
cmd.Flags().BoolVar(&ignoreJobs, "ignore-jobs", false, "Ignore deployment of jobs")
cmd.Flags().BoolVar(&ignoreResources, "ignore-resources", false, "Ignore deployment of resources")
Expand All @@ -57,7 +57,7 @@ func deployCommand() *cli.Command {
pluginRepo := models.PluginRegistry
dsRepo := models.DatastoreRegistry
// TODO: find a way to load the config in one place
conf, err := config.LoadClientConfig(configFilePath)
conf, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand All @@ -75,11 +75,11 @@ func deployCommand() *cli.Command {
l.Info(fmt.Sprintf("Deploying project: %s to %s", conf.Project.Name, conf.Host))
start := time.Now()

if err := validateNamespaces(datastoreSpecFs, namespaces); err != nil {
if err := validateNamespaces(datastoreSpecFs, namespaceNames); err != nil {
return err
}

err = postDeploymentRequest(l, *conf, pluginRepo, dsRepo, datastoreSpecFs, namespaces, ignoreJobs, ignoreResources, verbose)
err = postDeploymentRequest(l, *conf, pluginRepo, dsRepo, datastoreSpecFs, namespaceNames, ignoreJobs, ignoreResources, verbose)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func jobCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
10 changes: 4 additions & 6 deletions cmd/job_run_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ func jobRunListCommand(conf *config.ClientConfig) *cli.Command {
Example: `optimus job runs <sample_job_goes_here> [--project \"project-id\"] [--start_date \"2006-01-02T15:04:05Z07:00\" --end_date \"2006-01-02T15:04:05Z07:00\"]`,
Args: cli.MinimumNArgs(1),
}
var projectName string
var host string
var startDate string
var endDate string
cmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
cmd.Flags().StringVar(&host, "host", host, "Optimus service endpoint url") // TODO: fix overriding conf via args
cmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
cmd.Flags().String("host", defaultHost, "Optimus service endpoint url")
cmd.Flags().StringVar(&startDate, "start_date", "", "start date of job run")
cmd.Flags().StringVar(&endDate, "end_date", "", "end date of job run")
cmd.RunE = func(c *cli.Command, args []string) error {
projectName = conf.Project.Name
host = conf.Host
projectName := conf.Project.Name
host := conf.Host
l := initClientLogger(conf.Log)
jobName := args[0]
l.Info(fmt.Sprintf("Requesting status for project %s, job %s from %s",
Expand Down
2 changes: 1 addition & 1 deletion cmd/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func replayCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/replay_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func replayCreateCommand(conf *config.ClientConfig) *cli.Command {
ignoreDownstream = false
allDownstream = false
skipConfirm = false
projectName string
namespaceName string
)

Expand All @@ -50,7 +49,7 @@ Date ranges are inclusive.
return nil
},
}
reCmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
reCmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
reCmd.Flags().StringVarP(&namespaceName, "namespace", "n", namespaceName, "Namespace of job that needs to be replayed")
reCmd.MarkFlagRequired("namespace")

Expand All @@ -61,7 +60,7 @@ Date ranges are inclusive.
reCmd.Flags().BoolVar(&allDownstream, "all-downstream", allDownstream, "Run replay for all downstream across namespaces")

reCmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
endDate := args[1]
if len(args) >= 3 { //nolint: gomnd
Expand Down
7 changes: 3 additions & 4 deletions cmd/replay_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (

func replayListCommand(conf *config.ClientConfig) *cli.Command {
var (
projectName string
reCmd = &cli.Command{
reCmd = &cli.Command{
Use: "list",
Short: "Get list of a replay mapping to a project",
Example: "optimus replay list",
Expand All @@ -27,9 +26,9 @@ The list command is used to fetch the recent replay in one project.
`,
}
)
reCmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
reCmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
reCmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
dialTimeoutCtx, dialCancel := context.WithTimeout(context.Background(), OptimusDialTimeout)
defer dialCancel()
Expand Down
6 changes: 2 additions & 4 deletions cmd/replay_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
)

func replayStatusCommand(conf *config.ClientConfig) *cli.Command {
var projectName string

reCmd := &cli.Command{
Use: "status",
Short: "Get status of a replay using its ID",
Expand All @@ -33,9 +31,9 @@ It takes one argument, replay ID[required] that gets generated when starting a r
return nil
},
}
reCmd.Flags().StringVarP(&projectName, "project", "p", projectName, "project name of optimus managed repository") // TODO: fix overriding conf via args
reCmd.Flags().StringP("project-name", "p", defaultProjectName, "project name of optimus managed repository")
reCmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
dialTimeoutCtx, dialCancel := context.WithTimeout(context.Background(), OptimusDialTimeout)
defer dialCancel()
Expand Down
2 changes: 1 addition & 1 deletion cmd/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func resourceCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
19 changes: 8 additions & 11 deletions cmd/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func secretCommand() *cli.Command {

cmd.PersistentPreRunE = func(cmd *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
c, err := config.LoadClientConfig(configFilePath)
c, err := config.LoadClientConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand All @@ -58,7 +58,6 @@ func secretCommand() *cli.Command {

func secretSetSubCommand(conf *config.ClientConfig) *cli.Command {
var (
projectName string
namespaceName string
filePath string
encoded bool
Expand All @@ -76,15 +75,15 @@ Secret value can be either provided in second argument or through file flag.
Use base64 flag if the value has been encoded.
`,
}
secretCmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
secretCmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
secretCmd.Flags().StringVarP(&namespaceName, "namespace", "n", namespaceName, "Namespace of deployee")
secretCmd.Flags().BoolVar(&encoded, "base64", false, "Create secret with value that has been encoded")
secretCmd.Flags().BoolVar(&updateOnly, "update-only", false, "Only update existing secret, do not create new")
secretCmd.Flags().StringVarP(&filePath, "file", "f", filePath, "Provide file path to create secret from file instead")
secretCmd.Flags().BoolVar(&skipConfirm, "confirm", false, "Skip asking for confirmation")

secretCmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
secretName, err := getSecretName(args)
if err != nil {
Expand Down Expand Up @@ -144,18 +143,16 @@ Use base64 flag if the value has been encoded.
}

func secretListSubCommand(conf *config.ClientConfig) *cli.Command {
var projectName string

secretListCmd := &cli.Command{
Use: "list",
Short: "Show all the secrets registered with optimus",
Example: "optimus secret list",
Long: `This operation shows the secrets for project.`,
}
secretListCmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
secretListCmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")

secretListCmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
updateSecretRequest := &pb.ListSecretsRequest{
ProjectName: projectName,
Expand All @@ -166,19 +163,19 @@ func secretListSubCommand(conf *config.ClientConfig) *cli.Command {
}

func secretDeleteSubCommand(conf *config.ClientConfig) *cli.Command {
var projectName, namespaceName string
var namespaceName string

cmd := &cli.Command{
Use: "delete",
Short: "Delete a secrets registered with optimus",
Example: "optimus secret delete <secret_name>",
Long: `This operation deletes a secret registered with optimus.`,
}
cmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Project name of optimus managed repository") // TODO: fix overriding conf via args
cmd.Flags().StringP("project-name", "p", defaultProjectName, "Project name of optimus managed repository")
cmd.Flags().StringVarP(&namespaceName, "namespace", "n", namespaceName, "Namespace name of optimus managed repository")

cmd.RunE = func(cmd *cli.Command, args []string) error {
projectName = conf.Project.Name
projectName := conf.Project.Name
l := initClientLogger(conf.Log)
secretName, err := getSecretName(args)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func serveCommand() *cli.Command {

cmd.RunE = func(c *cli.Command, args []string) error {
// TODO: find a way to load the config in one place
conf, err := config.LoadServerConfig(configFilePath)
conf, err := config.LoadServerConfig(configFilePath, cmd.Flags())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func versionCommand() *cli.Command {
// Print server version
if isWithServer {
// TODO: find a way to load the config in one place
conf, err := config.LoadClientConfig(configFilePath)
conf, err := config.LoadClientConfig(configFilePath, c.Flags())
if err != nil {
return err
}
Expand Down
Loading