// QueryState implements plan.Resource.
QueryState implements plan.Resource.
// QueryState implements plan . Resource .
func (p *Service) QueryState(r plan.Runner) (plan.State, error) {
	output, err := systemd(r, "show %s -p ActiveState", p.Name)
	if err != nil {
		return plan.EmptyState, err
	}
	status := keyval(output, "ActiveState")
	if status == "" {
		return plan.EmptyState, errors.Wrapf(err, "service %s: query: could not query active state", p.Name)
	}
	output, err = systemd(r, "is-enabled %s", p.Name)
	if err != nil && line(output) != "disabled" {
		return plan.EmptyState, errors.Wrapf(err, "service %s: query: could not query enabled state", p.Name)
	}
	enabled := line(output) == "enabled"
	service := Service{
		Name:    p.Name,
		Status:  status,
		Enabled: enabled,
	}
	return service.State(), nil
}
func ( p * Service ) QueryState ( r plan . Runner ) ( plan . State , error ) { output , err := systemd ( r , " " , p . Name ) if err != nil { return plan . EmptyState , err } status := keyval ( output , " " ) if status == " " { return plan . EmptyState , errors . Wrapf ( err , " " , p . Name ) } output , err = systemd ( r , " " , p . Name ) if err != nil && line ( output ) != " " { return plan . EmptyState , errors . Wrapf ( err , " " , p . Name ) } enabled := line ( output ) == " " service := Service { Name : p . Name , Status : status , Enabled : enabled , } return service . State ( ) , nil }
QueryState implements plan.Resource.
QueryState implements plan . Resource .
// See https://bugzilla.redhat.com/show_bug.cgi?id=1073481#c11 // is-enabled exits with non-zero status when the unit is disabled.