github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/providers/gcloud/stop_instance.go (about) 1 package gcloud 2 3 import ( 4 "github.com/emc-advanced-dev/pkg/errors" 5 ) 6 7 func (p *GcloudProvider) StopInstance(id string) error { 8 instance, err := p.GetInstance(id) 9 if err != nil { 10 return errors.New("retrieving instance "+id, err) 11 } 12 if _, err := p.compute().Instances.Stop(p.config.ProjectID, p.config.Zone, instance.Name).Do(); err != nil { 13 return errors.New("failed to stop instance "+instance.Id, err) 14 } 15 return nil 16 }