Skip to content

Commit

Permalink
Merge pull request #25 from aman-agrawal/OES-1.30.1
Browse files Browse the repository at this point in the history
Springfox to Springdoc Upgrade
  • Loading branch information
sanopsmx authored Feb 29, 2024
2 parents 003325b + 6b6f223 commit 9e6939d
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 69 deletions.
4 changes: 0 additions & 4 deletions rosco-core/rosco-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ dependencies {
api "io.spinnaker.kork:kork-artifacts"
api "io.spinnaker.kork:kork-plugins"
api "org.apache.groovy:groovy:4.0.9"
/* api("io.springfox:springfox-swagger-ui:2.9.2")
api("io.springfox:springfox-swagger2:2.9.2")*/
implementation ("io.springfox:springfox-boot-starter:3.0.0")
implementation("io.swagger.core.v3:swagger-annotations:2.2.8")
implementation "com.netflix.frigga:frigga:0.26.0"
implementation "io.spinnaker.kork:kork-jedis"
implementation "io.spinnaker.kork:kork-retrofit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.fasterxml.jackson.annotation.JsonInclude
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import io.swagger.annotations.ApiModelProperty
import com.netflix.spinnaker.kork.artifacts.model.Artifact
import io.swagger.v3.oas.annotations.media.Schema

/**
* The details of a completed bake.
Expand All @@ -32,7 +32,7 @@ import com.netflix.spinnaker.kork.artifacts.model.Artifact
@EqualsAndHashCode(includes = "id")
@ToString(includeNames = true)
class Bake {
@ApiModelProperty(value="The id of the bake job.")
@Schema(description = "The id of the bake job.")
String id
String ami
String image_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,38 @@ import com.netflix.spinnaker.rosco.providers.util.packagespecific.NupkgPackageUt
import com.netflix.spinnaker.rosco.providers.util.packagespecific.RpmPackageUtil
import groovy.transform.CompileStatic
import groovy.transform.Immutable
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema

@Immutable(copyWith = true)
@CompileStatic
class BakeRequest {

// A generated uuid which will identify the request and be used as the jobId when running the bake
@ApiModelProperty(value = "A generated UUID which will be used to identify the effective packer bake", readOnly = true)
@Schema(description = "A generated UUID which will be used to identify the effective packer bake",
accessMode = Schema.AccessMode.READ_ONLY)
String request_id = UUID.randomUUID().toString()
String user
@ApiModelProperty("The package(s) to install, as a space-delimited string") @JsonProperty("package") @SerializedName("package")
@Schema(description = "The package(s) to install, as a space-delimited string") @JsonProperty("package") @SerializedName("package")
String package_name
@ApiModelProperty("The package(s) to install, as Spinnaker artifacts")
@Schema(description = "The package(s) to install, as Spinnaker artifacts")
List<Artifact> package_artifacts
@ApiModelProperty("The CI server")
@Schema(description = "The CI server")
String build_host
@ApiModelProperty("The CI job")
@Schema(description = "The CI job")
String job
@ApiModelProperty("The CI build number")
@Schema(description = "The CI build number")
String build_number
@ApiModelProperty("The commit hash of the CI build")
@Schema(description = "The commit hash of the CI build")
String commit_hash
@ApiModelProperty("The CI Build Url")
@Schema(description = "The CI Build Url")
String build_info_url
@ApiModelProperty("The target platform")
@Schema(description = "The target platform")
CloudProviderType cloud_provider_type
Label base_label
@ApiModelProperty("The named base image to resolve from rosco's configuration")
@Schema(description = "The named base image to resolve from rosco's configuration")
String base_os
String base_name
@ApiModelProperty("The explicit machine image to use, instead of resolving one from rosco's configuration")
@Schema(description = "The explicit machine image to use, instead of resolving one from rosco's configuration")
String base_ami
VmType vm_type
StoreType store_type
Expand All @@ -49,17 +50,17 @@ class BakeRequest {
String ami_suffix
Boolean upgrade
String instance_type
@ApiModelProperty("The image owner organization")
@Schema(description = "The image owner organization")
String organization

@ApiModelProperty("The explicit packer template to use, instead of resolving one from rosco's configuration")
@Schema(description = "The explicit packer template to use, instead of resolving one from rosco's configuration")
String template_file_name
@ApiModelProperty("A map of key/value pairs to add to the packer command")
@Schema(description = "A map of key/value pairs to add to the packer command")
Map extended_attributes
@ApiModelProperty("The name of a json file containing key/value pairs to add to the packer command (must be in the same location as the template file)")
@Schema(description = "The name of a json file containing key/value pairs to add to the packer command (must be in the same location as the template file)")
String var_file_name

@ApiModelProperty("The name of a configured account to use when baking the image")
@Schema(description = "The name of a configured account to use when baking the image")
String account_name

String spinnaker_execution_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema

/**
* The state of a bake as returned by the Bakery API when a bake is created. Once complete it provides a link to the
Expand All @@ -34,7 +34,7 @@ class BakeStatus implements Serializable {
/**
* The bake status id.
*/
@ApiModelProperty(value="The id of the bake request.")
@Schema(description ="The id of the bake request.")
String id

State state
Expand All @@ -46,7 +46,7 @@ class BakeStatus implements Serializable {
*
* @see BakeryController#lookupBake
*/
@ApiModelProperty(value="The id of the bake job. Can be passed to lookupBake() to retrieve the details of the newly-baked image.")
@Schema(description="The id of the bake job. Can be passed to lookupBake() to retrieve the details of the newly-baked image.")
String resource_id

@JsonIgnore
Expand Down
12 changes: 8 additions & 4 deletions rosco-web/config/rosco.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,11 @@ swagger:
- /api/v2.*
- /bakeOptions.*
- /status.*
springfox:
documentation:
swagger-ui:
enabled:true
springdoc:
writer-with-default-pretty-printer: true
swagger-ui:
display-request-duration: true
disable-swagger-default-url: true
url: /v3/api-docs.yaml
api-docs:
version: openapi_3_0
27 changes: 1 addition & 26 deletions rosco-web/rosco-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ dependencies {
implementation project(":rosco-core")
implementation project(":rosco-manifests")
implementation "io.spinnaker.kork:kork-web"
implementation "io.swagger.core.v3:swagger-annotations:2.2.8"
implementation "io.spinnaker.kork:kork-swagger"
implementation "org.springframework.boot:spring-boot-starter-web"

implementation "org.springframework.boot:spring-boot-starter-security"
implementation "org.springframework.security:spring-security-core"
compileOnly "org.springframework.boot:spring-boot-starter-actuator"
implementation "io.spinnaker.kork:kork-config"
compileOnly 'org.apache.tomcat:tomcat-servlet-api:11.0.0-M4'
//implementation "io.swagger:swagger-annotations:1.5.20"
//implementation "io.springfox:springfox-swagger-ui:3.0.0"
implementation "io.springfox:springfox-boot-starter:3.0.0"
implementation('io.springfox:springfox-swagger2:3.0.0')
implementation('io.springfox:springfox-swagger-ui:3.0.0')

api "org.apache.groovy:groovy:4.0.9"
implementation "io.spinnaker.kork:kork-artifacts"
Expand All @@ -41,26 +36,6 @@ dependencies {
testImplementation "org.spockframework:spock-core"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.objenesis:objenesis:3.2"
/*
testImplementation("com.netflix.spectator:spectator-api:1.6.1")
testImplementation("com.netflix.spectator:spectator-ext-aws:1.6.1")
testImplementation("com.netflix.spectator:spectator-ext-gc:1.6.1")
testImplementation("com.netflix.spectator:spectator-ext-jvm:1.6.1")
testImplementation("com.netflix.spectator:spectator-nflx-plugin:1.6.1")
testImplementation("com.netflix.spectator:spectator-reg-atlas:1.6.1")
testImplementation("com.netflix.spectator:spectator-web-spring:1.6.1")
testImplementation("com.netflix.spectator:spectator-reg-micrometer:1.6.1")
implementation("com.netflix.spectator:spectator-api:1.6.1")
implementation("com.netflix.spectator:spectator-ext-aws:1.6.1")
implementation("com.netflix.spectator:spectator-ext-gc:1.6.1")
implementation("com.netflix.spectator:spectator-ext-jvm:1.6.1")
implementation("com.netflix.spectator:spectator-nflx-plugin:1.6.1")
implementation("com.netflix.spectator:spectator-reg-atlas:1.6.1")
implementation("com.netflix.spectator:spectator-web-spring:1.6.1")
implementation("com.netflix.spectator:spectator-reg-micrometer:1.6.1")*/


}

ospackage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class WebConfig implements WebMvcConfigurer {
String baseUrl = StringUtils.trimTrailingCharacter(this.baseUrl, '/' as char);
registry.
addResourceHandler(baseUrl + "/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
.addResourceLocations("classpath:/META-INF/resources/webjars/springdoc-swagger-ui/")
.resourceChain(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ import com.netflix.spinnaker.rosco.providers.registry.CloudProviderBakeHandlerRe
import com.netflix.spinnaker.security.AuthenticatedRequest
import groovy.transform.InheritConstructors
import groovy.util.logging.Slf4j
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.*
import org.springframework.web.method.annotation.RequestHeaderMapMethodArgumentResolver

import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -222,10 +221,10 @@ class BakeryController {
}
}

@ApiOperation(value = "Look up bake request status")
@Operation(summary = "Look up bake request status")
@RequestMapping(value = "/api/v1/{region}/status/{statusId}", method = RequestMethod.GET)
BakeStatus lookupStatus(@ApiParam(value = "The region of the bake request to lookup", required = true) @PathVariable("region") String region,
@ApiParam(value = "The id of the bake request to lookup", required = true) @PathVariable("statusId") String statusId) {
BakeStatus lookupStatus(@Parameter(description = "The region of the bake request to lookup", required = true) @PathVariable("region") String region,
@Parameter(description = "The id of the bake request to lookup", required = true) @PathVariable("statusId") String statusId) {
def bakeStatus = bakeStore.retrieveBakeStatusById(statusId)

if (bakeStatus) {
Expand All @@ -235,10 +234,10 @@ class BakeryController {
throw new IllegalArgumentException("Unable to retrieve status for '$statusId'.")
}

@ApiOperation(value = "Look up bake details")
@Operation(summary = "Look up bake details")
@RequestMapping(value = "/api/v1/{region}/bake/{bakeId}", method = RequestMethod.GET)
Bake lookupBake(@ApiParam(value = "The region of the bake to lookup", required = true) @PathVariable("region") String region,
@ApiParam(value = "The id of the bake to lookup", required = true) @PathVariable("bakeId") String bakeId) {
Bake lookupBake(@Parameter(description = "The region of the bake to lookup", required = true) @PathVariable("region") String region,
@Parameter(description = "The id of the bake to lookup", required = true) @PathVariable("bakeId") String bakeId) {
def bake = bakeStore.retrieveBakeDetailsById(bakeId)

if (bake) {
Expand Down Expand Up @@ -317,10 +316,10 @@ class BakeryController {
}

// TODO(duftler): Synchronize this with existing bakery api.
@ApiOperation(value = "Cancel bake request")
@Operation(summary = "Cancel bake request")
@RequestMapping(value = "/api/v1/{region}/cancel/{statusId}", method = RequestMethod.GET)
String cancelBake(@ApiParam(value = "The region of the bake request to cancel", required = true) @PathVariable("region") String region,
@ApiParam(value = "The id of the bake request to cancel", required = true) @PathVariable("statusId") String statusId) {
String cancelBake(@Parameter(description = "The region of the bake request to cancel", required = true) @PathVariable("region") String region,
@Parameter(description = "The id of the bake request to cancel", required = true) @PathVariable("statusId") String statusId) {
if (bakeStore.cancelBakeById(statusId)) {
jobExecutor.cancelJob(statusId)

Expand Down

0 comments on commit 9e6939d

Please sign in to comment.