Beispiel #1
0
func inspectInstance(inst local.PackageInstance, listFiles bool) {
	log.Infof("Instance: %s", inst.Pin())
	if listFiles {
		log.Infof("Package files:")
		for _, f := range inst.Files() {
			if f.Symlink() {
				target, err := f.SymlinkTarget()
				if err != nil {
					log.Infof(" E %s (%s)", f.Name(), err)
				} else {
					log.Infof(" S %s -> %s", f.Name(), target)
				}
			} else {
				log.Infof(" F %s", f.Name())
			}
		}
	}
}
Beispiel #2
0
func (client *clientImpl) RegisterInstance(instance local.PackageInstance) error {
	// Attempt to register.
	client.Logger.Infof("cipd: registering %s", instance.Pin())
	result, err := client.remote.registerInstance(instance.Pin())
	if err != nil {
		return err
	}

	// Asked to upload the package file to CAS first?
	if result.uploadSession != nil {
		err = client.UploadToCAS(instance.Pin().InstanceID, instance.DataReader(), result.uploadSession)
		if err != nil {
			return err
		}
		// Try again, now that file is uploaded.
		client.Logger.Infof("cipd: registering %s", instance.Pin())
		result, err = client.remote.registerInstance(instance.Pin())
		if err != nil {
			return err
		}
		if result.uploadSession != nil {
			return ErrBadUpload
		}
	}

	if result.alreadyRegistered {
		client.Logger.Infof(
			"cipd: instance %s is already registered by %s on %s",
			instance.Pin(), result.registeredBy, result.registeredTs)
	} else {
		client.Logger.Infof("cipd: instance %s was successfully registered", instance.Pin())
	}

	return nil
}