Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.clouddriver.docker.registry.controllers
import com.netflix.spinnaker.cats.cache.Cache
import com.netflix.spinnaker.cats.cache.CacheData
import com.netflix.spinnaker.clouddriver.docker.registry.DockerRegistryCloudProvider
import com.netflix.spinnaker.clouddriver.docker.registry.cache.Keys
import com.netflix.spinnaker.clouddriver.docker.registry.provider.DockerRegistryProviderUtils
import com.netflix.spinnaker.clouddriver.docker.registry.security.DockerRegistryNamedAccountCredentials
import com.netflix.spinnaker.clouddriver.security.AccountCredentialsProvider
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.security.access.prepost.PostFilter
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping(["/dockerRegistry/images", "/titus/images"])
class DockerRegistryImageLookupController {
@Autowired
private Cache cacheView
@Autowired
AccountCredentialsProvider accountCredentialsProvider
@RequestMapping(value = "/tags", method = RequestMethod.GET)
@PreAuthorize("hasPermission(#account, 'ACCOUNT', 'READ')")
List getTags(@RequestParam('account') String account, @RequestParam('repository') String repository) {
def credentials = (DockerRegistryNamedAccountCredentials) accountCredentialsProvider.getCredentials(account)
if (!credentials) {
return []
}
return DockerRegistryProviderUtils.getAllMatchingKeyPattern(
cacheView,
Keys.Namespace.TAGGED_IMAGE.ns,
Keys.getTaggedImageKey(account, repository, "*")
).sort { a, b ->
if (credentials.sortTagsByDate) {
b.attributes.date.epochSecond <=> a.attributes.date.epochSecond
} else {
a.id <=> b.id
}
}.collect {
def parse = Keys.parse(it.id)
return (String) parse.tag
}
}
@RequestMapping(value = '/find', method = RequestMethod.GET)
@PostFilter("hasPermission(filterObject['account'], 'ACCOUNT', 'READ')")
List