diff --git a/api/component/component.go b/api/component/component.go index ef423099..0b5ef0dd 100644 --- a/api/component/component.go +++ b/api/component/component.go @@ -9,7 +9,7 @@ type Component struct { Deployment interface{} `yaml:"deployment_config,omitempty" json:"deployment_config,omitempty"` Scaling interface{} `yaml:"scaling_config,omitempty" json:"scaling_config,omitempty"` Discovery interface{} `yaml:"discovery_config,omitempty" json:"discovery_config,omitempty"` - DeploymentPlatformMapping interface{} `yaml:"deployment_platform_mapping,omitempty" json:"deployment_platform_mapping,omitempty"` + DeploymentPlatformMapping interface{} `yaml:"behaviour,omitempty" json:"behaviour,omitempty"` } // Type interface @@ -25,7 +25,7 @@ type Type struct { Deployment interface{} `yaml:"deployment_config,omitempty" json:"deployment_config,omitempty"` Scaling interface{} `yaml:"scaling_config,omitempty" json:"scaling_config,omitempty"` Discovery interface{} `yaml:"discovery_config,omitempty" json:"discovery_config,omitempty"` - DeploymentPlatformMapping interface{} `yaml:"deployment_platform_mapping,omitempty" json:"deployment_platform_mapping,omitempty"` + DeploymentPlatformMapping interface{} `yaml:"behaviour,omitempty" json:"behaviour,omitempty"` } // ListTypeResponse interface diff --git a/api/environment/env.go b/api/environment/env.go index 9deae7fc..7d692fb2 100644 --- a/api/environment/env.go +++ b/api/environment/env.go @@ -64,10 +64,12 @@ type EnvServiceStatus struct { LastDeployedAt string `yaml:"lastDeployedAt,omitempty" json:"lastDeployedAt,omitempty"` Version string `yaml:"version,omitempty" json:"version,omitempty"` Components []Status `yaml:"components,omitempty" json:"components,omitempty"` + Status string `yaml:"status,omitempty" json:"status,omitempty"` } type EnvStatus struct { ServiceStatus []EnvStatusPerService `yaml:"services,omitempty" json:"services,omitempty"` + Status string `yaml:"status,omitempty" json:"status,omitempty"` } type EnvStatusPerService struct { diff --git a/api/service/service.go b/api/service/service.go index 50a7ae2d..8d75f676 100644 --- a/api/service/service.go +++ b/api/service/service.go @@ -8,6 +8,7 @@ import ( type Service struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` Version string `yaml:"version,omitempty" json:"version,omitempty"` + Platform string `yaml:"platform,omitempty" json:"platform,omitempty"` Team []string `yaml:"team,omitempty" json:"team,omitempty"` Description string `yaml:"description,omitempty" json:"description,omitempty"` Mature *bool `yaml:"isMature,omitempty" json:"isMature,omitempty"` @@ -32,9 +33,9 @@ type DetailResponse struct { // Status interface type Status struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - Ec2 string `yaml:"ec2,omitempty" json:"ec2,omitempty"` - Docker string `yaml:"docker,omitempty" json:"docker,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty"` + VM string `yaml:"vm,omitempty" json:"vm,omitempty"` + Container string `yaml:"container,omitempty" json:"container,omitempty"` } // StatusResponse interface diff --git a/app/app.go b/app/app.go index d2891f2f..c2b04db4 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.0.0-alpha", + Version: "1.0.1-alpha", } diff --git a/internal/backend/service.go b/internal/backend/service.go index 24d28804..f192a3ab 100644 --- a/internal/backend/service.go +++ b/internal/backend/service.go @@ -91,11 +91,12 @@ func (s *Service) MarkMature(service, version string) { } // DeployService : deploy a service -func (s *Service) DeployService(service, version, env string, force, rebuild bool) { +func (s *Service) DeployService(service, version, env, platform string, force, rebuild bool) { client := newApiClient() client.QueryParams["env_name"] = env client.QueryParams["force"] = fmt.Sprintf("%v", force) client.QueryParams["rebuild"] = fmt.Sprintf("%v", rebuild) + client.QueryParams["platform"] = platform response := client.action(path.Join(serviceEntity, "deploy", service, "versions", version)+"/", "POST", nil) response.Process(true) diff --git a/internal/command/commands/command.go b/internal/command/commands/command.go index 42ffd982..87aec987 100644 --- a/internal/command/commands/command.go +++ b/internal/command/commands/command.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "sort" "strings" odin "github.com/dream11/odin/app" @@ -56,5 +57,6 @@ func emptyParameters(params map[string]string) string { emptyParameters = append(emptyParameters, key) } } + sort.Strings(emptyParameters) return strings.Join(emptyParameters, ", ") } diff --git a/internal/command/commands/componentType.go b/internal/command/commands/componentType.go index ce6d7e3b..cfe15f90 100644 --- a/internal/command/commands/componentType.go +++ b/internal/command/commands/componentType.go @@ -81,7 +81,7 @@ func (c *ComponentType) Run(args []string) int { return 1 } - c.Logger.Output(string(details)) + c.Logger.Output(fmt.Sprintf("\n%s", details)) return 0 } diff --git a/internal/command/commands/env.go b/internal/command/commands/env.go index 5f3a44cd..71dfc49b 100644 --- a/internal/command/commands/env.go +++ b/internal/command/commands/env.go @@ -29,7 +29,7 @@ func (e *Env) Run(args []string) int { name := flagSet.String("name", "", "name of environment") team := flagSet.String("team", "", "display environments created by a team") purpose := flagSet.String("purpose", "", "reason to create environment") - env := flagSet.String("env-type", "kube", "environment to attach with environment") + env := flagSet.String("env-type", "dev", "environment to attach with environment") service := flagSet.String("service", "", "service name to filter out describe environment") component := flagSet.String("component", "", "component name to filter out describe environment") providerAccount := flagSet.String("account", "", "account name to provision the environment in") @@ -72,10 +72,9 @@ func (e *Env) Run(args []string) int { if e.Status { emptyParameters := emptyParameters(map[string]string{"--name": *name}) if len(emptyParameters) == 0 { - e.Logger.Info("Fetching status for environment: " + *name + ", service: " + *service) if *service != "" { - + e.Logger.Info(fmt.Sprintf("Fetching status for service: %s in environment: %s", *service, *name)) envServiceStatus, err := envClient.EnvServiceStatus(*name, *service) if err != nil { e.Logger.Error(err.Error()) @@ -84,6 +83,7 @@ func (e *Env) Run(args []string) int { relativeDeployedSinceTime := datetime.DateTimeFromNow(envServiceStatus.LastDeployedAt) e.Logger.Output("Service version: " + string(envServiceStatus.Version)) + e.Logger.Output("Service Status: " + string(envServiceStatus.Status)) e.Logger.Output("Last deployed: " + relativeDeployedSinceTime) e.Logger.Output("Component details: ") @@ -105,16 +105,16 @@ func (e *Env) Run(args []string) int { } } else { - + e.Logger.Info(fmt.Sprintf("Fetching status for environment: %s", *name)) envStatus, err := envClient.EnvStatus(*name) if err != nil { e.Logger.Error(err.Error()) return 1 } - + e.Logger.Output(fmt.Sprintf("Environment Status: %s\n", envStatus.Status)) tableHeaders := []string{"Name", "Version", "Status", "Last deployed"} var tableData [][]interface{} - + e.Logger.Output("Services:") for _, serviceStatus := range envStatus.ServiceStatus { relativeDeployedSinceTime := datetime.DateTimeFromNow(serviceStatus.LastDeployedAt) tableData = append(tableData, []interface{}{ @@ -193,7 +193,7 @@ func (e *Env) Run(args []string) int { return 1 } - e.Logger.Output(string(details)) + e.Logger.Output(fmt.Sprintf("\n%s", details)) if *service == "" && *component == "" { e.Logger.Output("\nCommand to descibe env") e.Logger.ItalicEmphasize(fmt.Sprintf("odin describe env --name %s --service --component ", *name)) @@ -245,9 +245,9 @@ func (e *Env) Run(args []string) int { if e.Delete { emptyParameters := emptyParameters(map[string]string{"--name": *name}) if len(emptyParameters) == 0 { - e.Logger.Warn("Deleting environment:" + *name) + e.Logger.Info("Deleting environment: " + *name) envClient.DeleteEnv(*name) - + e.Logger.Success(fmt.Sprintf("Deletion started: %s", *name)) return 0 } @@ -265,13 +265,14 @@ func (e *Env) Run(args []string) int { return 1 } - tableHeaders := []string{"ID", "Action", "Resource Details", "Modified by", "Last Modified"} + tableHeaders := []string{"ID", "State", "Action", "Resource Details", "Modified by", "Last Modified"} var tableData [][]interface{} for _, env := range envResp { relativeCreationTimestamp := datetime.DateTimeFromNow(env.CreatedAt) tableData = append(tableData, []interface{}{ env.ID, + env.State, env.Action, env.ResourceDetails, env.CreatedBy, diff --git a/internal/command/commands/service.go b/internal/command/commands/service.go index d551746c..82e2b0ee 100644 --- a/internal/command/commands/service.go +++ b/internal/command/commands/service.go @@ -32,6 +32,7 @@ func (s *Service) Run(args []string) int { isMature := flagSet.Bool("mature", false, "mark service version as matured") 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") err := flagSet.Parse(args) if err != nil { @@ -77,11 +78,12 @@ func (s *Service) Run(args []string) int { s.Logger.Error("Unrecognized file format") return 1 } - + serviceDataMap := parsedConfig.(map[string]interface{}) serviceClient.CreateService(parsedConfig) + s.Logger.Success(fmt.Sprintf("Service creation started for %s@%s ", serviceDataMap["name"], serviceDataMap["version"])) s.Logger.Output("Command to check status of images") - s.Logger.ItalicEmphasize("odin status service --name --version ") + s.Logger.ItalicEmphasize(fmt.Sprintf("odin status service --name %s --version %s", serviceDataMap["name"], serviceDataMap["version"])) return 0 } @@ -109,7 +111,7 @@ func (s *Service) Run(args []string) int { return 1 } - s.Logger.Output(string(details)) + s.Logger.Output(fmt.Sprintf("\n%s", details)) if len(*component) == 0 { s.Logger.Output("Command to get component details") s.Logger.ItalicEmphasize(fmt.Sprintf("odin describe service --name %s --version --component ", *serviceName)) @@ -128,8 +130,12 @@ func (s *Service) Run(args []string) int { s.Logger.Error(err.Error()) return 1 } - - tableHeaders := []string{"Name", "Version", "Description", "Team", "Mature"} + var tableHeaders []string + if len(*serviceName) == 0 { + tableHeaders = []string{"Name", "Latest Version", "Description", "Team", "Mature"} + } else { + tableHeaders = []string{"Name", "Version", "Description", "Team", "Mature"} + } var tableData [][]interface{} for _, service := range serviceList { @@ -177,8 +183,9 @@ 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("Deploying service: " + *serviceName + "@" + *serviceVersion + " in " + *envName) + serviceClient.DeployService(*serviceName, *serviceVersion, *envName, *platform, *force, *rebuild) - serviceClient.DeployService(*serviceName, *serviceVersion, *envName, *force, *rebuild) + s.Logger.Success(fmt.Sprintf("Deployment of service %s@%s is started on env %s", *serviceName, *serviceVersion, *envName)) return 0 } @@ -190,7 +197,7 @@ func (s *Service) Run(args []string) int { if s.Undeploy { emptyParameters := emptyParameters(map[string]string{"--name": *serviceName, "--env": *envName}) if len(emptyParameters) == 0 { - s.Logger.Info("Undeploying service: " + *serviceName + " from environment" + *envName) + s.Logger.Info("Undeploying service: " + *serviceName + " from environment " + *envName) serviceClient.UndeployService(*serviceName, *envName) s.Logger.Success("Job Triggered to undeploy your service " + *serviceName + " from the env " + *envName) @@ -229,8 +236,8 @@ func (s *Service) Run(args []string) int { for _, componentStatus := range serviceStatus { tableData = append(tableData, []interface{}{ componentStatus.Name, - componentStatus.Ec2, - componentStatus.Docker, + componentStatus.VM, + componentStatus.Container, }) } @@ -270,10 +277,10 @@ func (s *Service) Help() string { if s.List { return commandHelper("list", "service", []string{ - "--team=name of team", + "--name=name of service", "--version=version of services to be listed", + "--team=name of team", "--mature (mature marked service versions)", - "--detailed (get a detailed view)", }) }