// CmdDomain prints out the namespace plus domain of the given environment func CmdDomain(envID string, ie environments.IEnvironments, is services.IServices, isites sites.ISites) error { env, err := ie.Retrieve(envID) if err != nil { return err } serviceProxy, err := is.RetrieveByLabel("service_proxy") if err != nil { return err } sites, err := isites.List(serviceProxy.ID) if err != nil { return err } domain := "" for _, site := range *sites { if strings.HasPrefix(site.Name, env.Namespace) { domain = site.Name } } if domain == "" { return errors.New("Could not determine the temporary domain name of your environment") } logrus.Println(domain) return nil }
func CmdStatus(envID string, is IStatus, ie environments.IEnvironments, iservices services.IServices) error { env, err := ie.Retrieve(envID) if err != nil { return err } svcs, err := iservices.ListByEnvID(env.ID, env.Pod) if err != nil { return err } return is.Status(env, svcs) }
// CmdLogs is a way to stream logs from Kibana to your local terminal. This is // useful because Kibana is hard to look at because it splits every single // log statement into a separate block that spans multiple lines so it's // not very cohesive. This is intended to be similar to the `heroku logs` // command. func CmdLogs(queryString string, follow bool, hours, minutes, seconds int, envID string, settings *models.Settings, il ILogs, ip prompts.IPrompts, ie environments.IEnvironments, is services.IServices, isites sites.ISites) error { if follow && (hours > 0 || minutes > 0 || seconds > 0) { logrus.Warnln("Specifying \"logs -f\" in combination with \"--hours\", \"--minutes\", or \"--seconds\" has been deprecated!") logrus.Warnln("Please specify either \"-f\" or use \"--hours\", \"--minutes\", \"--seconds\" but not both. Support for \"-f\" and a specified time frame will be removed in a later version.") } env, err := ie.Retrieve(envID) if err != nil { return err } serviceProxy, err := is.RetrieveByLabel("service_proxy") if err != nil { return err } sites, err := isites.List(serviceProxy.ID) if err != nil { return err } domain := "" for _, site := range *sites { if strings.HasPrefix(site.Name, env.Namespace) { domain = site.Name break } } if domain == "" { return errors.New("Could not determine the fully qualified domain name of your environment. Please contact Catalyze Support at [email protected] with this error message to resolve this issue.") } if follow { if err := il.Watch(queryString, domain, settings.SessionToken); err != nil { logrus.Debugf("Error attempting to stream logs from logwatch: %s", err) } else { return nil } } from := 0 offset := time.Duration(hours)*time.Hour + time.Duration(minutes)*time.Minute + time.Duration(seconds)*time.Second timestamp := time.Now().In(time.UTC).Add(-1 * offset) from, timestamp, err = il.Output(queryString, settings.SessionToken, domain, follow, hours, minutes, seconds, from, timestamp, time.Now(), env) if err != nil { return err } if follow { return il.Stream(queryString, settings.SessionToken, domain, follow, hours, minutes, seconds, from, timestamp, env) } return nil }
func CmdRedeploy(envID, svcName string, ij jobs.IJobs, is services.IServices, ie environments.IEnvironments) error { env, err := ie.Retrieve(envID) if err != nil { return err } service, err := is.RetrieveByLabel(svcName) if err != nil { return err } if service == nil { return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"catalyze services\" command.", svcName) } logrus.Printf("Redeploying service %s (ID = %s) in environment %s (ID = %s)", svcName, service.ID, env.Name, env.ID) err = ij.Redeploy(service.ID) if err != nil { return err } logrus.Println("Redeploy successful! Check the status with \"catalyze status\" and your logging dashboard for updates") return nil }