Esempio n. 1
0
func (client *clientImpl) SetRefWhenReady(ref string, pin common.Pin) error {
	if err := common.ValidatePackageRef(ref); err != nil {
		return err
	}
	if err := common.ValidatePin(pin); err != nil {
		return err
	}
	client.Logger.Infof("cipd: setting ref of %q: %q => %q", pin.PackageName, ref, pin.InstanceID)
	deadline := client.clock.now().Add(SetRefTimeout)
	for client.clock.now().Before(deadline) {
		err := client.remote.setRef(ref, pin)
		if err == nil {
			return nil
		}
		if _, ok := err.(*pendingProcessingError); ok {
			client.Logger.Warningf("cipd: package instance is not ready yet - %s", err)
			client.clock.sleep(5 * time.Second)
		} else {
			client.Logger.Errorf("cipd: failed to set ref - %s", err)
			return err
		}
	}
	client.Logger.Errorf("cipd: failed set ref - deadline exceeded")
	return ErrSetRefTimeout
}
Esempio n. 2
0
// Set is called by 'flag' package when parsing command line options.
func (refs *Refs) Set(value string) error {
	err := common.ValidatePackageRef(value)
	if err != nil {
		return err
	}
	*refs = append(*refs, value)
	return nil
}
Esempio n. 3
0
func refEndpoint(packageName string, ref string) (string, error) {
	if err := common.ValidatePackageName(packageName); err != nil {
		return "", err
	}
	if err := common.ValidatePackageRef(ref); err != nil {
		return "", err
	}
	params := url.Values{}
	params.Add("package_name", packageName)
	params.Add("ref", ref)
	return "repo/v1/ref?" + params.Encode(), nil
}