// CheckLease is part of the lease.Secretary interface.
504742
func (s SingularSecretary) CheckLease(key lease.Key) error {
	if key.Lease != s.ControllerUUID && key.Lease != key.ModelUUID {
		return errors.New("expected controller or model UUID")
	}
	return nil
}
997984
func (e Event) Check() error {
	if len(e.Title) == 0 {
		return fmt.Errorf("statsd.Event title is required")
	}
	if len(e.Text) == 0 {
		return fmt.Errorf("statsd.Event text is required")
	}
	return nil
}
1000860
func (m *ExpirationManager) lockLease(leaseID string) {
	locksutil.LockForKey(m.restoreLocks, leaseID).Lock()
}
856791
func LookupLease(coll mongo.Collection, namespace, name string) (leaseDoc, error) {
	var doc leaseDoc
	err := coll.FindId(leaseDocId(namespace, name)).One(&doc)
	if err != nil {
		return leaseDoc{}, err
	}
	return doc, nil
}
977193
func (c *KBFSContext) CheckService() error {
	// Trying to dial the service seems like the best
	// platform-agnostic way of seeing if the service is up.
	// Stat-ing the socket file, for example, doesn't work for
	// Windows named pipes.
	s, err := libkb.NewSocket(c.g)
	if err != nil {
		return err
	}
	conn, err := s.DialSocket()
	if err != nil {
		if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
			return errors.New(
				"keybase isn't running; open the Keybase app")
		}
		return errors.New(
			"keybase isn't running; try `run_keybase`")
	}
	err = conn.Close()
	if err != nil {
		return err
	}
	return nil
}
64666
func ValidateLeaseUpdate(lease, oldLease *coordination.Lease) field.ErrorList {
	allErrs := validation.ValidateObjectMetaUpdate(&lease.ObjectMeta, &oldLease.ObjectMeta, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidateLeaseSpec(&lease.Spec, field.NewPath("spec"))...)
	return allErrs
}
209650
func (m *Miniredis) CheckGet(t T, key, expected string) {
	found, err := m.Get(key)
	if err != nil {
		lError(t, "GET error, key %#v: %v", key, err)
		return
	}
	if found != expected {
		lError(t, "GET error, key %#v: Expected %#v, got %#v", key, expected, found)
		return
	}
}
855954
func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) {
	errorList = []error{}

	// The "Well-known SID" of Administrator group is S-1-5-32-544
	// The following powershell will return "True" if run as an administrator, "False" otherwise
	// See https://msdn.microsoft.com/en-us/library/cc980032.aspx
	args := []string{"[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match \"S-1-5-32-544\")"}
	isAdmin, err := exec.Command("powershell", args...).Output()

	if err != nil {
		errorList = append(errorList, errors.Wrap(err, "unable to determine if user is running as administrator"))
	} else if strings.EqualFold(strings.TrimSpace(string(isAdmin)), "false") {
		errorList = append(errorList, errors.New("user is not running as administrator"))
	}

	return nil, errorList
}
259259
func (c *sendOptions) Check() error {
	if strings.TrimSpace(c.Recipient) == "" {
		return ErrRecipientMissing
	}
	if strings.TrimSpace(c.Amount) == "" {
		return ErrAmountMissing
	}
	namt, err := stellarnet.ParseStellarAmount(c.Amount)
	if err != nil {
		return ErrInvalidAmount
	}
	if namt < 0 {
		return ErrInvalidAmount
	}

	if c.FromAccountID != "" {
		_, err := strkey.Decode(strkey.VersionByteAccountID, c.FromAccountID)
		if err != nil {
			return ErrInvalidAccountID
		}
	}
	if len(c.Message) > libkb.MaxStellarPaymentNoteLength {
		return ErrMessageTooLong
	}

	return nil
}
1257436
func CheckURL(s string) (string, error) {
	u, err := url.Parse(s)
	if err != nil {
		return "", err
	}
	if u.Scheme == "" {
		s = "https://" + s
		u.Scheme = "https"
	}
	if u.Scheme != "https" && u.Scheme != "http" {
		return "", errors.New("Only http:// or https:// scheme is accepted.")
	}
	if u.Scheme != "https" && hostRequiresSSL(u.Host) {
		return "", errors.New("only https:// scheme is accepted for appspot hosts, it can be omitted")
	}
	if _, err = url.Parse(s); err != nil {
		return "", err
	}
	return s, nil
}
1297939
func CheckStorable(inDoc interface{}) error {
	// Normalise document to bson.M
	bytes, err := bson.Marshal(inDoc)
	if err != nil {
		return errors.Annotate(err, "marshalling")
	}
	var doc bson.M
	if err := bson.Unmarshal(bytes, &doc); err != nil {
		return errors.Annotate(err, "unmarshalling")
	}
	// Check it.
	return errors.Trace(checkDoc(doc))
}
97578
func (b *backend) Lease(ctx context.Context, s logical.Storage) (*configLease, error) {
	entry, err := s.Get(ctx, "config/lease")
	if err != nil {
		return nil, err
	}
	if entry == nil {
		return nil, nil
	}

	var result configLease
	if err := entry.DecodeJSON(&result); err != nil {
		return nil, err
	}

	return &result, nil
}
198348
func (c *inflationOptions) Check() error {
	_, err := strkey.Decode(strkey.VersionByteAccountID, c.AccountID)
	if err != nil {
		return ErrInvalidAccountID
	}
	if c.Destination == "" {
		return ErrDestinationMissing
	}

	return nil
}
332080
func CheckFile(name string) (bool, error) {
	f, err := os.Open(name)
	if err != nil {
		if os.IsNotExist(err) {
			f, err = os.Create(name)
			if err != nil {
				return false, err
			}
			return false, f.Chmod(0600)
		}
		return false, err
	}
	defer f.Close()

	fi, err := f.Stat()
	if err != nil {
		return false, err
	}

	return fi.Size() > 0, nil
}
1297060
func (c *controller) ensureLease() (*coordv1beta1.Lease, bool, error) {
	lease, err := c.leaseClient.Get(c.holderIdentity, metav1.GetOptions{})
	if apierrors.IsNotFound(err) {
		// lease does not exist, create it
		lease, err := c.leaseClient.Create(c.newLease(nil))
		if err != nil {
			return nil, false, err
		}
		return lease, true, nil
	} else if err != nil {
		// unexpected error getting lease
		return nil, false, err
	}
	// lease already existed
	return lease, false, nil
}
429965
func (m *ExpirationManager) unlockLease(leaseID string) {
	locksutil.LockForKey(m.restoreLocks, leaseID).Unlock()
}
397199
func (v *Repository) CheckoutHead(opts *CheckoutOpts) error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	cOpts := opts.toC()
	defer freeCheckoutOpts(cOpts)

	ret := C.git_checkout_head(v.ptr, cOpts)
	runtime.KeepAlive(v)
	if ret < 0 {
		return MakeGitError(ret)
	}

	return nil
}