|
| 1 | +/* |
| 2 | + * Copyright 2020 Netflix, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.netflix.spinnaker.gate.plugins.publish |
| 17 | + |
| 18 | +import com.netflix.spinnaker.gate.services.internal.Front50Service |
| 19 | +import io.swagger.annotations.ApiOperation |
| 20 | +import org.springframework.web.bind.annotation.PathVariable |
| 21 | +import org.springframework.web.bind.annotation.PostMapping |
| 22 | +import org.springframework.web.bind.annotation.RequestBody |
| 23 | +import org.springframework.web.bind.annotation.RequestMapping |
| 24 | +import org.springframework.web.bind.annotation.RequestParam |
| 25 | +import org.springframework.web.bind.annotation.RestController |
| 26 | +import retrofit.mime.TypedByteArray |
| 27 | +import java.io.InputStream |
| 28 | + |
| 29 | +@RestController |
| 30 | +@RequestMapping("/plugins/upload") |
| 31 | +class PluginBinaryController( |
| 32 | + private val front50Service: Front50Service |
| 33 | +) { |
| 34 | + |
| 35 | + @ApiOperation(value = "Upload a plugin binary") |
| 36 | + @PostMapping( |
| 37 | + "/{pluginId}/{pluginVersion}", |
| 38 | + consumes = ["application/zip", "application/octet-stream"] |
| 39 | + ) |
| 40 | + fun publishBinary( |
| 41 | + @RequestBody body: InputStream, |
| 42 | + @PathVariable pluginId: String, |
| 43 | + @PathVariable pluginVersion: String, |
| 44 | + @RequestParam sha512sum: String |
| 45 | + ) { |
| 46 | + front50Service.uploadPluginBinary( |
| 47 | + pluginId, |
| 48 | + pluginVersion, |
| 49 | + sha512sum, |
| 50 | + TypedByteArray("application/octet-stream", body.readBytes()) |
| 51 | + ) |
| 52 | + } |
| 53 | +} |
0 commit comments