github.com/jcarley/cli@v0.0.0-20180201210820-966d90434c30/commands/redeploy/redeploy.go (about)

     1  package redeploy
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Sirupsen/logrus"
     7  	"github.com/daticahealth/cli/commands/environments"
     8  	"github.com/daticahealth/cli/commands/services"
     9  	"github.com/daticahealth/cli/lib/jobs"
    10  )
    11  
    12  func CmdRedeploy(envID, svcName string, ij jobs.IJobs, is services.IServices, ie environments.IEnvironments) error {
    13  	env, err := ie.Retrieve(envID)
    14  	if err != nil {
    15  		return err
    16  	}
    17  	service, err := is.RetrieveByLabel(svcName)
    18  	if err != nil {
    19  		return err
    20  	}
    21  	if service == nil {
    22  		return fmt.Errorf("Could not find a service with the label \"%s\". You can list services with the \"datica services list\" command.", svcName)
    23  	}
    24  	logrus.Printf("Redeploying service %s (ID = %s) in environment %s (ID = %s)", svcName, service.ID, env.Name, env.ID)
    25  	err = ij.Redeploy(service.ID)
    26  	if err != nil {
    27  		return err
    28  	}
    29  	logrus.Println("Redeploy successful! Check the status with \"datica status\" and your logging dashboard for updates")
    30  	return nil
    31  }