Skip to content

Commit

Permalink
!1071 容器流程优化:完善helmchart相关接口
Browse files Browse the repository at this point in the history
Merge pull request !1071 from helongfei/master
  • Loading branch information
zhanghailong22 authored and gitee-org committed Nov 22, 2021
2 parents d5add94 + 527c632 commit d42af41
Show file tree
Hide file tree
Showing 15 changed files with 756 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
import java.util.List;
import javax.validation.constraints.Pattern;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.edgegallery.developer.common.ResponseConsts;
import org.edgegallery.developer.exception.EntityNotFoundException;
import org.edgegallery.developer.model.application.container.HelmChart;
import org.edgegallery.developer.model.application.container.ModifyFileContentDto;
import org.edgegallery.developer.response.ErrorRespDto;
import org.edgegallery.developer.service.application.container.ContainerAppHelmChartService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -49,6 +55,8 @@
public class ContainerAppHelmChartCtl {
private static final String REGEX_UUID = "[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}";

private static final Logger LOGGER = LoggerFactory.getLogger(ContainerAppHelmChartCtl.class);

@Autowired
private ContainerAppHelmChartService containerAppHelmChartService;

Expand Down Expand Up @@ -140,7 +148,16 @@ public ResponseEntity<byte[]> downloadHelmChartsPackage(
@ApiParam(value = "applicationId", required = true) @PathVariable("applicationId") String applicationId,
@Pattern(regexp = REGEX_UUID, message = "fileId must be in UUID format")
@ApiParam(value = "helmchartId", required = true) @PathVariable("helmchartId") String helmChartId) {
return ResponseEntity.ok(containerAppHelmChartService.downloadHelmChart(applicationId, helmChartId));
HelmChart helmChart = containerAppHelmChartService.getHelmChartById(applicationId, helmChartId);
if (helmChart == null) {
LOGGER.error("can not find helm chart {}", helmChartId);
throw new EntityNotFoundException("query HelmChart is empty!", ResponseConsts.RET_QUERY_DATA_EMPTY);
}
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/octet-stream");
headers.add("Content-Disposition", "attachment; filename=" + helmChart.getName());
byte[] data = containerAppHelmChartService.downloadHelmChart(applicationId, helmChartId);
return ResponseEntity.ok().headers(headers).body(data);
}

/**
Expand Down Expand Up @@ -182,6 +199,6 @@ public ResponseEntity<Boolean> modifyFileContentByFilePath(
@ApiParam(value = "helmchartId", required = true) @PathVariable("helmchartId") String helmChartId,
@RequestBody ModifyFileContentDto content) {
return ResponseEntity
.ok(containerAppHelmChartService.modifyFileContentByFilePath(applicationId, helmChartId, content));
.ok(containerAppHelmChartService.modifyFileContent(applicationId, helmChartId, content));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public interface HelmChartMapper {

HelmChart getHelmChartByFileId(@Param("fileId") String fileId);

int deleteFileAndImage(@Param("id") String id, @Param("helmChartId") String helmChartId,
@Param("applicationId") String applicationId);
int deleteHelmChart(@Param("id") String id, @Param("helmChartId") String helmChartId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public class HelmChart {

private String applicationId;

private List<HelmChartFile> filesList;
private List<HelmChartFile> helmChartFileList;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* the License.
*/

package org.edgegallery.developer.controller.application.container;
package org.edgegallery.developer.model.application.container;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.edgegallery.developer.service.application.container;

import java.util.List;
import org.edgegallery.developer.controller.application.container.ModifyFileContentDto;
import org.edgegallery.developer.model.application.container.HelmChart;
import org.edgegallery.developer.model.application.container.ModifyFileContentDto;
import org.springframework.web.multipart.MultipartFile;

public interface ContainerAppHelmChartService {
Expand All @@ -27,8 +27,6 @@ public interface ContainerAppHelmChartService {

Boolean uploadHelmChartYaml(MultipartFile helmTemplateYaml, String applicationId);

Boolean createHelmCharts(MultipartFile helmChartFile, String applicationId);

List<HelmChart> getHelmChartList(String applicationId);

HelmChart getHelmChartById(String applicationId, String helmChartId);
Expand All @@ -37,7 +35,7 @@ public interface ContainerAppHelmChartService {

byte[] downloadHelmChart(String applicationId, String helmChartId);

String getFileContentByFilePath(String application, String helmChartId, String filePath);
String getFileContentByFilePath(String applicationId, String helmChartId, String filePath);

Boolean modifyFileContentByFilePath(String application, String helmChartId, ModifyFileContentDto content);
Boolean modifyFileContent(String applicationId, String helmChartId, ModifyFileContentDto content);
}
Loading

0 comments on commit d42af41

Please sign in to comment.