Skip to content

Commit

Permalink
OP-21802 Upgrade springfox to springdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-agrawal committed Jun 13, 2024
1 parent 9cca22d commit fdcca38
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
2 changes: 2 additions & 0 deletions clouddriver-kubernetes/clouddriver-kubernetes.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ dependencies {
implementation "io.spinnaker.kork:kork-moniker"
implementation "io.spinnaker.kork:kork-secrets"
implementation "io.spinnaker.kork:kork-security"
implementation "io.spinnaker.kork:kork-swagger"

implementation ("io.kubernetes:client-java:17.0.2") {
force = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.netflix.spinnaker.clouddriver.kubernetes.controllers;

import com.netflix.spinnaker.clouddriver.kubernetes.provider.view.KubernetesJobProvider;
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 java.util.Collections;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -38,18 +38,25 @@ public PodController(KubernetesJobProvider jobProvider) {

@PreAuthorize(
"hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
@ApiOperation(value = "Collect a file from a pod", notes = "Collects the file result of a pod.")
@Operation(
summary = "Collect a file from a pod",
description = "Collects the file result of a pod.")
@RequestMapping(
value = "/{account}/{namespace}/{podName}/{fileName:.+}",
method = RequestMethod.GET)
Map<String, Object> getFileContents(
@ApiParam(value = "Application name", required = true) @PathVariable String application,
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
@ApiParam(value = "Namespace in which the pod is running in", required = true) @PathVariable
@Parameter(description = "Application name", required = true) @PathVariable
String application,
@Parameter(description = "Account job was created by", required = true) @PathVariable
String account,
@Parameter(description = "Namespace in which the pod is running in", required = true)
@PathVariable
String namespace,
@ApiParam(value = "Unique identifier of pod being looked up", required = true) @PathVariable
@Parameter(description = "Unique identifier of pod being looked up", required = true)
@PathVariable
String podName,
@ApiParam(value = "File name to look up", required = true) @PathVariable String fileName) {
@Parameter(description = "File name to look up", required = true) @PathVariable
String fileName) {
Map<String, Object> results =
kubernetesJobProvider.getFileContentsFromPod(account, namespace, podName, fileName);

Expand Down
1 change: 1 addition & 0 deletions clouddriver-web/clouddriver-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation "io.spinnaker.kork:kork-web"
implementation("io.spinnaker.kork:kork-plugins")
implementation "io.spinnaker.kork:kork-moniker"
implementation "io.spinnaker.kork:kork-swagger"
implementation "commons-io:commons-io"
implementation "io.reactivex.rxjava3:rxjava:3.1.6"
implementation "io.swagger:swagger-annotations:1.5.20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package com.netflix.spinnaker.clouddriver.controllers
import com.netflix.spinnaker.clouddriver.model.JobProvider
import com.netflix.spinnaker.clouddriver.model.JobStatus
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException
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.context.MessageSource
import org.springframework.security.access.prepost.PreAuthorize
Expand All @@ -42,12 +42,12 @@ class JobController {
MessageSource messageSource

@PreAuthorize("hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
@ApiOperation(value = "Collect a JobStatus", notes = "Collects the output of the job.")
@Operation(summary = "Collect a JobStatus", description = "Collects the output of the job.")
@RequestMapping(value = "/{account}/{location}/{id:.+}", method = RequestMethod.GET)
JobStatus collectJob(@ApiParam(value = "Application name", required = true) @PathVariable String application,
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@ApiParam(value = "Unique identifier of job being looked up", required = true) @PathVariable String id) {
JobStatus collectJob(@Parameter(description = "Application name", required = true) @PathVariable String application,
@Parameter(description = "Account job was created by", required = true) @PathVariable String account,
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@Parameter(description = "Unique identifier of job being looked up", required = true) @PathVariable String id) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Collection<JobStatus> jobMatches = jobProviders.findResults {
return it.collectJob(account, location, id)
Expand All @@ -59,26 +59,26 @@ class JobController {
}

@PreAuthorize("hasPermission(#application, 'APPLICATION', 'EXECUTE') and hasPermission(#account, 'ACCOUNT', 'WRITE')")
@ApiOperation(value = "Cancel a Job", notes = "Cancels the job.")
@Operation(summary = "Cancel a Job", description = "Cancels the job.")
@RequestMapping(value = "/{account}/{location}/{id:.+}", method = RequestMethod.DELETE)
void cancelJob(@ApiParam(value = "Application name", required = true) @PathVariable String application,
@ApiParam(value = "Account job is running in", required = true) @PathVariable String account,
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@ApiParam(value = "Unique identifier of job to be canceled", required = true) @PathVariable String id) {
void cancelJob(@Parameter(description = "Application name", required = true) @PathVariable String application,
@Parameter(description = "Account job is running in", required = true) @PathVariable String account,
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@Parameter(description = "Unique identifier of job to be canceled", required = true) @PathVariable String id) {
jobProviders.forEach {
it.cancelJob(account, location, id)
}
}

@PreAuthorize("hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
@ApiOperation(value = "Collect a file from a job", notes = "Collects the file result of a job.")
@Operation(summary = "Collect a file from a job", description = "Collects the file result of a job.")
@RequestMapping(value = "/{account}/{location}/{id}/{fileName:.+}", method = RequestMethod.GET)
Map<String, Object> getFileContents(
@ApiParam(value = "Application name", required = true) @PathVariable String application,
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@ApiParam(value = "Unique identifier of job being looked up", required = true) @PathVariable String id,
@ApiParam(value = "File name to look up", required = true) @PathVariable String fileName
@Parameter(description = "Application name", required = true) @PathVariable String application,
@Parameter(description = "Account job was created by", required = true) @PathVariable String account,
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
@Parameter(description = "Unique identifier of job being looked up", required = true) @PathVariable String id,
@Parameter(description = "File name to look up", required = true) @PathVariable String fileName
) {
Collection<Map<String, Object>> results = jobProviders.findResults {
it.getFileContents(account, location, id, fileName)
Expand Down

0 comments on commit fdcca38

Please sign in to comment.