Skip to content

Commit

Permalink
Merge pull request #4 from pbcccBeatBoard/main
Browse files Browse the repository at this point in the history
pull request test from pbcccBeatBoard
  • Loading branch information
pbcccbeatboard-strato authored Aug 22, 2024
2 parents b63da2d + 78b391e commit f0cc786
Show file tree
Hide file tree
Showing 41 changed files with 1,997 additions and 17 deletions.
3 changes: 0 additions & 3 deletions Dockerfile

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ v.0.3.0(2024.10)
- workflow-manager를 연동한 멀티 클라우드 인프라에 애플리케이션 배포 기능(to k8s)
- k8s에 배포 시 필요한 일부 yaml generate 기능(deployment, service, pod, configmap 등)
- repository 관련 제어(nexus 등)
- 기타


## 목차

1. [mc-application-manager 실행 및 개발 환경]
1. [mc-application-manager 실행 및 개발 환경]
2. [mc-application-manager실행 방법]
3. [mc-application-manager 소스 빌드 및 실행 방법 상세]
4. [mc-application-manager 기여 방법]
Expand Down
36 changes: 28 additions & 8 deletions src/main/java/kr/co/mcmp/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,38 @@
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableAutoConfiguration
@OpenAPIDefinition(info = @Info(title = "M-CMP API", version = "v1"))
public class SwaggerConfig {

public static final String AUTHORIZATION = "Authorization";

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("kr.co.strato.jmeter.jmeter"))
.paths(PathSelectors.any())
.build();
public OpenAPI getApi() {
SecurityRequirement securityRequirement = new SecurityRequirement().addList(AUTHORIZATION);
Components components = new Components()
.addSecuritySchemes(AUTHORIZATION, new SecurityScheme()
.name(AUTHORIZATION)
.in(SecurityScheme.In.HEADER)
.type(SecurityScheme.Type.APIKEY));

return new OpenAPI()
.addSecurityItem(securityRequirement)
.components(components);
}
}
}
18 changes: 18 additions & 0 deletions src/main/java/kr/co/mcmp/config/oss/RestTemplateConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kr.co.mcmp.config.oss;

import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {

@Bean(name = "customRestTemplate")
public RestTemplate restTemplate() {
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(HttpClientBuilder.create().setMaxConnTotal(50).setMaxConnPerRoute(50).build());
return new RestTemplate(factory);
}
}
22 changes: 22 additions & 0 deletions src/main/java/kr/co/mcmp/config/oss/RestTemplateProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package kr.co.mcmp.config.oss;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class RestTemplateProvider implements ApplicationContextAware {

private static ApplicationContext applicationContext;

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}

public static RestTemplate get() {
return applicationContext.getBean("customRestTemplate", RestTemplate.class);
}
}
20 changes: 20 additions & 0 deletions src/main/java/kr/co/mcmp/dto/oss/NexusFormatType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kr.co.mcmp.dto.oss;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class NexusFormatType {

@Schema(title = "레포지토리 포맷 유형")
private String format;

@Schema(title = "레포지토리 타입 유형")
private String type;
}
193 changes: 193 additions & 0 deletions src/main/java/kr/co/mcmp/dto/oss/NexusRepositoryDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
package kr.co.mcmp.dto.oss;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Getter
public class NexusRepositoryDto {

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ResGetRepositoryDto {
@Schema(title = "레포지토리 이름", required = true)
@NotBlank
private String name;

@Schema(title = "레포지토리 포맷 유형", required = true)
@NotBlank
private String format;

@Schema(title = "레포지토리 타입 유형", required = true)
@NotBlank
private String type;

@Schema(title = "레포지토리 접근 url", required = true)
@NotBlank
private String url;

@Schema(title = "레포지토리 사용자 접근 가능 여부", required = true)
@NotNull
private Boolean online;

@Valid
private ResGetStorageDto storage;

@Valid
private ResGetDockerDto docker;

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ResGetStorageDto {
@Schema(title = "아티팩트를 저장하는 물리적 저장소 이름", required = true, example = "default")
@NotBlank
private String blobStoreName;

@Schema(title = "저장되는 아티팩트 유형 일치 여부 검증", required = true)
@NotNull
private Boolean strictContentTypeValidation;

@Schema(title = "레포지토리 읽기/쓰기 설정", required = true, example = "allow, allow_once, read_only")
@NotBlank
private String writePolicy;
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ResGetDockerDto {
@Schema(title = "도커 registry 버전 지원(false: v2 지원)", required = true)
@NotNull
private Boolean v1Enabled;

@Schema(title = "도커 클라이언트가 레포지토리에 접근할 때 기본 인증 사용 여부", required = true)
@NotNull
private Boolean forceBasicAuth;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 http 포트")
private Integer httpPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 https 포트")
private Integer httpsPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 서브도메인")
private String subdomain;
}
}

@Getter
public static class ReqCreateRepositoryDto {
@Schema(title = "레포지토리 이름", required = true)
@NotBlank
private String name;

@Schema(title = "레포지토리 사용자 접근 가능 여부", required = true)
@NotNull
private Boolean online;

@Valid
private ReqCreateStorageDto storage;

@Valid
private ReqCreateDockerDto docker;

@Getter
public static class ReqCreateStorageDto {
@Schema(title = "아티팩트를 저장하는 물리적 저장소 이름", required = true, example = "default")
@NotBlank
private String blobStoreName;

@Schema(title = "저장되는 아티팩트 유형 일치 여부 검증", required = true)
@NotNull
private Boolean strictContentTypeValidation;

@Schema(title = "레포지토리 읽기/쓰기 설정", required = true, example = "allow, allow_once, read_only")
@NotBlank
private String writePolicy;
}

@Getter
public static class ReqCreateDockerDto {
@Schema(title = "도커 registry 버전 지원(false: v2 지원)", required = true)
@NotNull
private Boolean v1Enabled;

@Schema(title = "도커 클라이언트가 레포지토리에 접근할 때 기본 인증 사용 여부", required = true)
@NotNull
private Boolean forceBasicAuth;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 http 포트")
private Integer httpPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 https 포트")
private Integer httpsPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 서브도메인")
private String subdomain;
}
}

@Getter
public static class ReqUpdateRepositoryDto {
@Schema(title = "레포지토리 이름", required = true)
@JsonIgnore
private String name;

@Schema(title = "레포지토리 사용자 접근 가능 여부", required = true)
@NotNull
private Boolean online;

@Valid
private ReqUpdateStorageDto storage;

@Valid
private ReqUpdateDockerDto docker;

@Getter
public static class ReqUpdateStorageDto {
@Schema(title = "아티팩트를 저장하는 물리적 저장소 이름", required = true, example = "default")
@JsonIgnore
private String blobStoreName;

@Schema(title = "저장되는 아티팩트 유형 일치 여부 검증", required = true)
@NotNull
private Boolean strictContentTypeValidation;

@Schema(title = "레포지토리 읽기/쓰기 설정", required = true, example = "allow, allow_once, read_only")
@NotBlank
private String writePolicy;
}

@Getter
public static class ReqUpdateDockerDto {
@Schema(title = "도커 registry 버전 지원(false: v2 지원)", required = true)
@NotNull
private Boolean v1Enabled;

@Schema(title = "도커 클라이언트가 레포지토리에 접근할 때 기본 인증 사용 여부", required = true)
@NotNull
private Boolean forceBasicAuth;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 http 포트")
private Integer httpPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 https 포트")
private Integer httpsPort;

@Schema(title = "도커 레포지토리에 접근할 때 사용할 서브도메인")
private String subdomain;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.co.mcmp.exception;

import kr.co.mcmp.api.response.ResponseCode;
import kr.co.mcmp.response.ResponseCode;
import lombok.Getter;

@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.co.mcmp.exception;

import kr.co.mcmp.api.response.ResponseWrapper;
import kr.co.mcmp.response.ResponseWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kr/co/mcmp/exception/McmpException.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kr.co.mcmp.exception;

import kr.co.mcmp.api.response.ResponseCode;
import kr.co.mcmp.response.ResponseCode;
import lombok.Getter;

@Getter
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/kr/co/mcmp/exception/NexusClientException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package kr.co.mcmp.exception;

import kr.co.mcmp.response.ResponseCode;
import lombok.Getter;

@Getter
public class NexusClientException extends RuntimeException {

private static final long serialVersionUID = -7883846160384968138L;

ResponseCode responseCode = ResponseCode.NEXUS_CLIENT_ERROR;
private String detail;

public NexusClientException() {
this(ResponseCode.NEXUS_CLIENT_ERROR);
}

public NexusClientException(ResponseCode responseCode) {
this.responseCode = responseCode;
}

public NexusClientException(ResponseCode responseCode, String detail) {
this.responseCode = responseCode;
this.detail = detail;
}

public NexusClientException(String detail) {
this.detail = detail;
}

public NexusClientException(Throwable cause) {
super(cause);
this.detail = cause.getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.co.mcmp.api.response.ResponseWrapper;
import kr.co.mcmp.externalrepo.model.ArtifactHubPackage;
import kr.co.mcmp.externalrepo.model.DockerHubCatalog;
import kr.co.mcmp.response.ResponseWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Loading

0 comments on commit f0cc786

Please sign in to comment.