Skip to content

Commit

Permalink
Merge pull request #5 from pbcccBeatBoard/main
Browse files Browse the repository at this point in the history
test docker and edit exception
  • Loading branch information
pbcccbeatboard-strato authored Aug 23, 2024
2 parents cd3eb63 + 5d2a0bf commit b4bcc46
Show file tree
Hide file tree
Showing 52 changed files with 6,562 additions and 5,287 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM openjdk:17-slim
FROM openjdk:17-slim AS prod
COPY ./build/libs/am.jar am.jar
ENTRYPOINT ["java", "-jar","am.jar"]
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ v0.2.0(2024.08)
- 애플리케이션 카탈로그 등록 및 내/외부(artifactHub, dockerHub등) 환경에서의 키워드검색
- workflow-manager를 연동한 멀티 클라우드 인프라에 애플리케이션 배포 기능(to VM)
- workflow-manager를 연동한 배포 외 기타 기능


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
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.session:spring-session-core'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.springframework.boot:spring-boot-starter-validation'

// https://mvnrepository.com/artifact/com.h2database/h2
// 시작 시 drop TABLE관련 버그로 1.4.200 -> 1.4.199
Expand Down Expand Up @@ -90,6 +91,15 @@ dependencies {

testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")

implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation 'org.apache.commons:commons-compress'
implementation 'io.kubernetes:client-java'
implementation 'io.kubernetes:client-java-api'
implementation 'io.kubernetes:client-java-api'
implementation 'io.kubernetes:client-java-extended'


}

tasks.test {
Expand Down
85 changes: 85 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# temp docker-compose
networks:
internal_network:
internal: true
external_network:
driver: bridge

# jenkins - for workflow manager
jenkins:
image: jenkins/jenkins:jdk17
container_name: jenkins
platform: linux/amd64
networks:
- internal_network
- external_network
ports:
- target: 8080
published: 9800
protocol: tcp
volumes:
- ~/:/var/jenkins_home # -v $HOME/mcmp/oss/jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker # -v $(which docker):/usr/bin/docker
environment:
- PROJECT=mcmp
healthcheck: # for application-manager
test: [ "CMD", "curl", "-f", "http://localhost:1024/catalog/software" ]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s

# sonatype nexus - for application manager
sonatype-nexus:
image: sonatype/nexus3:latest
container_name: nexus-repository
platform: linux/amd64
networks:
- internal_network
- external_network
ports:
- target: 8081
published: 8081
protocol: tcp
- target: 5000 # container-repository
published: 5000
protocol: tcp
volumes:
- ~/:/nexus-data/blobs/
environment:
- PROJECT=mcmp
healthcheck: # for application-manager
test: [ "CMD", "curl", "-f", "http://localhost:1024/catalog/software" ]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s

# application-manager
mc-application-manager:
image: pbccc/devops:0.2.5
container_name: cb-mapui
build:
context: ./
dockerfile: Dockerfile
networks:
- external_network
- external_network
ports:
- target: 18084
published: 18084
protocol: tcp
volumes:
- ~/:/nexus-data/blobs/
environment:
- DDL_AUTO=create-drop
- DB_USER=application
- DB_PASS=application!23
- SQL_DATA_INIT=always
healthcheck: # for cb-application-manager
test: ["CMD", "nc", "-vz", "localhost", "1324"]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s
4 changes: 2 additions & 2 deletions docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

#test

nowdate=$(date '+%Y%m%d%H%M%S')

echo $nowdate
Expand Down Expand Up @@ -46,3 +44,5 @@ docker run -d -p 18084:18084 \

echo "docker build image delete"
docker rmi -f $APP_NAME


Binary file added docs/func_tree.xlsx
Binary file not shown.
2 changes: 2 additions & 0 deletions src/main/java/kr/co/mcmp/ApplicationManagerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;

@EnableSwagger2
@SpringBootApplication
@EnableFeignClients
public class ApplicationManagerApplication {

public static void main(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package kr.co.mcmp.api.oss.component;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.co.mcmp.dto.oss.component.CommonComponent;
import kr.co.mcmp.response.ResponseWrapper;
import kr.co.mcmp.service.oss.component.CommonModuleComponentService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Tag(name = "CommonComponentController - 컴포넌트 API 관련")
@RequestMapping("/oss/v1/components")
@RestController
@RequiredArgsConstructor
public class CommonComponentController {

private final CommonModuleComponentService moduleComponentService;

@Operation(summary = "컴포넌트 목록 조회")
@GetMapping("/{module}/list/{name}")
public ResponseEntity<ResponseWrapper<List<CommonComponent.ComponentDto>>> getComponentList(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "레포지토리 이름", required = true) @PathVariable("name") String name) {
List<CommonComponent.ComponentDto> componentList = moduleComponentService.getComponentList(module, name);
return ResponseEntity.ok(new ResponseWrapper<>(componentList));
}

@Operation(summary = "컴포넌트 상세 조회")
@GetMapping("/{module}/detail/{id}")
public ResponseEntity<ResponseWrapper<CommonComponent.ComponentDto>> getComponentDetailByName(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "컴포넌트 식별자", required = true) @PathVariable("id") String id) {
CommonComponent.ComponentDto componentDetailByName = moduleComponentService.getComponentDetailByName(module, id);
return ResponseEntity.ok(new ResponseWrapper<>(componentDetailByName));
}

@Operation(summary = "컴포넌트 삭제")
@DeleteMapping("/{module}/delete/{id}")
public ResponseEntity<ResponseWrapper<String>> deleteComponent(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "컴포넌트 식별자", required = true) @PathVariable("id") String id) {
moduleComponentService.deleteComponent(module, id);
return ResponseEntity.ok(new ResponseWrapper<>("Component delete completed"));
}

@Operation(summary = "컴포넌트 등록")
@PostMapping("/{module}/create/{name}")
public ResponseEntity<ResponseWrapper<String>> createComponent(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "레포지토리 이름", required = true) @PathVariable("name") String name,
@RequestPart(value = "directory", required = false) String directory,
@RequestPart(value = "asset", required = false) List<MultipartFile> files
) {
moduleComponentService.createComponent(module, name, directory, files);
return ResponseEntity.ok(new ResponseWrapper<>("Component create completed"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package kr.co.mcmp.api.oss.repository;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import kr.co.mcmp.dto.oss.repository.CommonRepository;
import kr.co.mcmp.response.ResponseWrapper;
import kr.co.mcmp.service.oss.repository.CommonModuleRepositoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Tag(name = "CommonRepositoryController - 레포지토리 API 관련")
@RequestMapping("/oss/v1/repositories")
@RestController
@RequiredArgsConstructor
public class CommonRepositoryController {

private final CommonModuleRepositoryService moduleRepositoryService;

@Operation(summary = "레포지토리 목록 조회")
@GetMapping("/{module}/list")
public ResponseEntity<ResponseWrapper<List<CommonRepository.RepositoryDto>>> getRepositoryList(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module) {
List<CommonRepository.RepositoryDto> repositoryList = moduleRepositoryService.getRepositoryList(module);
return ResponseEntity.ok(new ResponseWrapper<>(repositoryList));
}

@Operation(summary = "레포지토리 상세 조회")
@GetMapping("/{module}/detail/{name}")
public ResponseEntity<ResponseWrapper<CommonRepository.RepositoryDto>> getRepositoryDetailByName(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "레포지토리 이름", required = true) @PathVariable("name") String name) {
CommonRepository.RepositoryDto repositoryDetailByName = moduleRepositoryService.getRepositoryDetailByName(module, name);
return ResponseEntity.ok(new ResponseWrapper<>(repositoryDetailByName));
}

@Operation(summary = "레포지토리 등록")
@PostMapping("/{module}/create")
public ResponseEntity<ResponseWrapper<String>> createRepository(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@RequestBody @Valid CommonRepository.RepositoryDto repositoryDto) {
moduleRepositoryService.createRepository(module, repositoryDto);
return ResponseEntity.ok(new ResponseWrapper<>("Repository create completed"));
}

@Operation(summary = "레포지토리 수정")
@PutMapping("/{module}/update")
public ResponseEntity<ResponseWrapper<String>> updateRepository(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@RequestBody @Valid CommonRepository.RepositoryDto repositoryDto) {
moduleRepositoryService.updateRepository(module, repositoryDto);
return ResponseEntity.ok(new ResponseWrapper<>("Repository update completed"));
}

@Operation(summary = "레포지토리 삭제")
@DeleteMapping("/{module}/delete/{name}")
public ResponseEntity<ResponseWrapper<String>> deleteRepository(
@Parameter(description = "모듈 타입", required = true, example = "nexus") @PathVariable("module") String module,
@Parameter(description = "레포지토리 이름", required = true) @PathVariable("name") String name) {
moduleRepositoryService.deleteRepository(module, name);
return ResponseEntity.ok(new ResponseWrapper<>("Repository delete completed"));
}
}
4 changes: 1 addition & 3 deletions src/main/java/kr/co/mcmp/api/response/ResponseCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public enum ResponseCode {
Stream.of(values()).collect(Collectors.toMap(ResponseCode::getCode, e -> e));

public static ResponseCode findByCode(int code) {
//test
//return Optional.ofNullable(map.get(code)).orElseThrow(() -> new McmpException(ResponseCode.UNKNOWN_ERROR));
return null;
return Optional.ofNullable(map.get(code)).orElseThrow(() -> new McmpException(String.valueOf(ResponseCode.UNKNOWN_ERROR)));
}
}
29 changes: 14 additions & 15 deletions src/main/java/kr/co/mcmp/catalog/CatalogController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@ public class CatalogController {
@Autowired
CatalogService catalogService;

@ApiOperation(value="software catalog list(all)", notes="software catalog 리스트 불러오기")
@Operation(summary = "get software catalog list")
@GetMapping("/")
public List<CatalogDTO> getCatalogList(){
return catalogService.getCatalogList();
}

// @ApiOperation(value="software catalog list(all)", notes="software catalog 리스트 불러오기")
// @Operation(summary = "get software catalog list")
// @GetMapping("/")
// public List<CatalogDTO> getCatalogList(@RequestParam String title){
// return catalogService.getCatalogList(title);
// public List<CatalogDTO> getCatalogList(){
// return catalogService.getCatalogList();
// }

// @Operation(summary = "search software catalog")
// @ApiOperation(value="software catalog list(keyword search)", notes="software catalog 검색")
// @GetMapping("/list/{keyword}")
// public List<CatalogDTO> getCatalogList(@PathVariable(required = false) String keyword){
// return catalogService.getCatalogListSearch(keyword);
// }
@ApiOperation(value="software catalog list(all)", notes="software catalog 리스트 불러오기")
@Operation(summary = "get software catalog list")
@GetMapping("/")
public List<CatalogDTO> getCatalogList(@RequestParam String title){
if(title != null && title.trim().equals("")){
System.out.println("==================================non title search");
return catalogService.getCatalogList();
}else {
System.out.println("==================================" + title);
return catalogService.getCatalogListSearch(title);
}
}

@Operation(summary = "software catalogd detail(and reference)")
@ApiOperation(value="software catalog detail", notes="software catalog 내용 확인(연결된 정보들까지)")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/kr/co/mcmp/catalog/CatalogRefDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public class CatalogRefDTO {

private Integer catalogRefIdx;
private Integer catalogIdx;
private Integer refernectIdx;
private Integer referncetIdx;
private String referenceValue; // ref url, ref value, etc...
private String referenceDescription;
private String referenceType; // homepage, manifest, workflow, image, etc...

public CatalogRefDTO(CatalogRefEntity crEntity){
this.catalogRefIdx = crEntity.getId();
this.catalogIdx = crEntity.getCatalogId();
this.refernectIdx = crEntity.getRefIdx();
this.referncetIdx = crEntity.getRefIdx();
this.referenceValue = crEntity.getRefValue();
this.referenceDescription = crEntity.getRefDesc();
this.referenceType = crEntity.getRefType();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kr/co/mcmp/catalog/CatalogRefEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CatalogRefEntity {

public CatalogRefEntity(CatalogRefDTO crDto){
this.catalogId = crDto.getCatalogIdx();
this.refIdx = crDto.getRefernectIdx();
this.refIdx = crDto.getReferncetIdx();
this.refValue = crDto.getReferenceValue();
this.refDesc = crDto.getReferenceDescription();
this.refType = crDto.getReferenceType();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/kr/co/mcmp/catalog/CatalogRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CatalogRepository extends JpaRepository<CatalogEntity, Integer> {

void deleteById(Integer catalogIdx);

//List<CatalogEntity> findbyTitle(String title);
List<CatalogEntity> findByTitleLikeIgnoreCase(String title);

}
Loading

0 comments on commit b4bcc46

Please sign in to comment.