func (identifier ResourceCacheIdentifier) CreateOn(logger lager.Logger, vm baggageclaim.Client) (baggageclaim.Volume, error) { return vm.CreateVolume(logger, baggageclaim.VolumeSpec{ Properties: identifier.volumeProperties(), TTL: resourceCacheTTL, Privileged: true, }) }
func (container *gardenWorkerContainer) setVolumes( logger lager.Logger, handlesJSON string, baggageclaimClient baggageclaim.Client, volumeFactory VolumeFactory, ) (map[string]Volume, error) { volumesByHandle := map[string]Volume{} var handles []string err := json.Unmarshal([]byte(handlesJSON), &handles) if err != nil { return nil, err } volumes := []Volume{} for _, h := range handles { volumeLogger := logger.Session("volume", lager.Data{ "handle": h, }) baggageClaimVolume, volumeFound, err := baggageclaimClient.LookupVolume(logger, h) if err != nil { volumeLogger.Error("failed-to-lookup-volume", err) return nil, err } if !volumeFound { volumeLogger.Error("volume-is-missing-on-worker", ErrMissingVolume) return nil, ErrMissingVolume } volume, volumeFound, err := volumeFactory.Build(volumeLogger, baggageClaimVolume) if err != nil { volumeLogger.Error("failed-to-build-volume", nil) return nil, err } if !volumeFound { volumeLogger.Error("volume-is-missing-in-database", ErrMissingVolume) return nil, ErrMissingVolume } volumes = append(volumes, volume) volumesByHandle[h] = volume } container.volumes = volumes return volumesByHandle, nil }
func (identifier ResourceCacheIdentifier) FindOn(logger lager.Logger, vm baggageclaim.Client) (baggageclaim.Volume, bool, error) { volumes, err := vm.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 } }