From b754a310cdff466e5a2d29bfcb97337e1454c439 Mon Sep 17 00:00:00 2001 From: Harshit Sharma Date: Mon, 9 May 2022 17:39:55 +0530 Subject: [PATCH] feat: make synchronous logs default for supporting commands (#81) --- app/app.go | 2 +- internal/command/commands/env.go | 24 ++---------------------- internal/command/commands/service.go | 19 +++---------------- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/app/app.go b/app/app.go index 7a6784b3..5000c0c0 100644 --- a/app/app.go +++ b/app/app.go @@ -8,5 +8,5 @@ type application struct { // App (Application) interface var App application = application{ Name: "odin", - Version: "1.1.0-alpha", + Version: "1.1.1-alpha", } diff --git a/internal/command/commands/env.go b/internal/command/commands/env.go index ca7b88d1..670a0874 100644 --- a/internal/command/commands/env.go +++ b/internal/command/commands/env.go @@ -35,7 +35,6 @@ func (e *Env) Run(args []string) int { providerAccount := flagSet.String("account", "", "account name to provision the environment in") filePath := flagSet.String("file", "environment.yaml", "file to read environment config") id := flagSet.Int("id", 0, "unique id of a changelog of an env") - tail := flagSet.Bool("tail", false, "enable synchronous logging of creation events") err := flagSet.Parse(args) if err != nil { @@ -54,17 +53,7 @@ func (e *Env) Run(args []string) int { Account: *providerAccount, } - if *tail { - envClient.CreateEnvStream(envConfig) - } else { - response, err := envClient.CreateEnv(envConfig) - if err != nil { - e.Logger.Error(err.Error()) - return 1 - } - - e.Logger.Success("Env: " + response.Name + " created!") - } + envClient.CreateEnvStream(envConfig) return 0 } @@ -250,14 +239,7 @@ func (e *Env) Run(args []string) int { if e.Delete { emptyParameters := emptyParameters(map[string]string{"--name": *name}) if len(emptyParameters) == 0 { - if *tail { - envClient.DeleteEnvStream(*name) - } else { - e.Logger.Info("Initiating environment deletion: " + *name) - envClient.DeleteEnv(*name) - e.Logger.Success(fmt.Sprintf("Deletion started: %s", *name)) - } - + envClient.DeleteEnvStream(*name) return 0 } @@ -350,7 +332,6 @@ func (e *Env) Help() string { "--purpose=reason to create environment", "--env-type=type of environment", "--account=account name to provision the environment in (optional)", - "--tail enable synchronous logging of creation events", }) } @@ -381,7 +362,6 @@ func (e *Env) Help() string { if e.Delete { return commandHelper("delete", "environment", []string{ "--name=name of environment to delete", - "--tail enable synchronous logging of deletion events", }) } diff --git a/internal/command/commands/service.go b/internal/command/commands/service.go index 55e2327d..3e1f2251 100644 --- a/internal/command/commands/service.go +++ b/internal/command/commands/service.go @@ -33,7 +33,6 @@ func (s *Service) Run(args []string) int { rebuild := flagSet.Bool("rebuild", false, "rebuild executor for creating images or deploying services") component := flagSet.String("component", "", "name of service component") platform := flagSet.String("platform", "", "platform to deploy the service in") - tail := flagSet.Bool("tail", false, "enable synchronous logging of creation events") err := flagSet.Parse(args) if err != nil { @@ -184,13 +183,7 @@ func (s *Service) Run(args []string) int { emptyParameters := emptyParameters(map[string]string{"--name": *serviceName, "--version": *serviceVersion, "--env": *envName}) if len(emptyParameters) == 0 { s.Logger.Info("Initiating service deployment: " + *serviceName + "@" + *serviceVersion + " in " + *envName) - - if *tail { - serviceClient.DeployServiceStream(*serviceName, *serviceVersion, *envName, *platform, *force, *rebuild) - } else { - serviceClient.DeployService(*serviceName, *serviceVersion, *envName, *platform, *force, *rebuild) - s.Logger.Success(fmt.Sprintf("Deployment of service %s@%s is started on env %s", *serviceName, *serviceVersion, *envName)) - } + serviceClient.DeployServiceStream(*serviceName, *serviceVersion, *envName, *platform, *force, *rebuild) return 0 } @@ -203,12 +196,7 @@ func (s *Service) Run(args []string) int { emptyParameters := emptyParameters(map[string]string{"--name": *serviceName, "--env": *envName}) if len(emptyParameters) == 0 { s.Logger.Info("Initiating service un-deploy: " + *serviceName + " from environment " + *envName) - if *tail { - serviceClient.UnDeployServiceStream(*serviceName, *envName) - } else { - serviceClient.UndeployService(*serviceName, *envName) - s.Logger.Success("Job Triggered to undeploy your service " + *serviceName + " from the env " + *envName) - } + serviceClient.UnDeployServiceStream(*serviceName, *envName) return 0 } @@ -310,15 +298,14 @@ func (s *Service) Help() string { "--force=forcefully deploy your service", "--rebuild=rebuild your executor job again for service deployment", "--env=name of environment to deploy service in", - "--tail=enable synchronous logging of deploy events", "--platform= platform to deploy the service in", }) } + if s.Undeploy { return commandHelper("deploy", "service", []string{ "--name=name of service to undeploy", "--env=name of environment to undeploy service in", - "--tail enable synchronous logging of un-deploy events", }) }