Ejemplo n.º 1
0
func (identifier ResourceCacheIdentifier) FindOn(logger lager.Logger, workerClient worker.Client) (worker.Volume, bool, error) {
	volumes, err := workerClient.ListVolumes(logger, identifier.initializedVolumeProperties())
	if err != nil {
		return nil, false, err
	}

	switch len(volumes) {
	case 0:
		return nil, false, nil
	case 1:
		return volumes[0], true, nil
	default:
		return selectLowestAlphabeticalVolume(logger, volumes), true, nil
	}
}
Ejemplo n.º 2
0
func (identifier ResourceCacheIdentifier) CreateOn(logger lager.Logger, workerClient worker.Client) (worker.Volume, error) {
	ttl := time.Duration(0)

	if identifier.Version == nil {
		ttl = worker.VolumeTTL
	}

	return workerClient.CreateVolume(
		logger,
		worker.VolumeSpec{
			Strategy: worker.ResourceCacheStrategy{
				ResourceVersion: identifier.Version,
				ResourceHash:    GenerateResourceHash(identifier.Source, string(identifier.Type)),
			},
			Properties: identifier.volumeProperties(),
			Privileged: true,
			TTL:        ttl,
		},
	)
}