github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/service/common/service.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package common 5 6 import ( 7 "github.com/juju/errors" 8 "github.com/juju/utils/shell" 9 ) 10 11 // Service is the base type for application.Service implementations. 12 type Service struct { 13 // Name is the name of the service. 14 Name string 15 16 // Conf holds the info used to build an init system conf. 17 Conf Conf 18 } 19 20 // NoConf checks whether or not Conf has been set. 21 func (s Service) NoConf() bool { 22 return s.Conf.IsZero() 23 } 24 25 // Validate checks the service's values for correctness. 26 func (s Service) Validate(renderer shell.Renderer) error { 27 if s.Name == "" { 28 return errors.New("missing Name") 29 } 30 31 if err := s.Conf.Validate(renderer); err != nil { 32 return errors.Trace(err) 33 } 34 35 return nil 36 } 37 38 // UpdateConfig implements service.Service. 39 func (s *Service) UpdateConfig(conf Conf) { 40 s.Conf = conf 41 }