cloud-barista / cm-beetle

Apache License 2.0
4 stars 6 forks source link

It seems that external structs are not recognized when executing `swag init`. #33

Closed yunkon-kim closed 3 weeks ago

yunkon-kim commented 10 months ago

It seems that external structs are not recognized when executing swag init.

What I've done

  1. Get CM-Honeybee's infra package
go get -u github.com/cloud-barista/cm-honeybee/model/infra

go: downloading github.com/cloud-barista/cm-honeybee v0.0.0-20231208055314-9d736a30aa55
go: downloading github.com/libvirt/libvirt-go-xml v7.4.0+incompatible
go: downloading github.com/NeowayLabs/drm v0.0.0-20190824133025-4939fc0ad345
go: downloading github.com/jollaman999/utils v1.0.10
go: downloading golang.org/x/net v0.19.0
go: downloading golang.org/x/tools v0.16.0
go: downloading github.com/google/uuid v1.4.0
go: downloading github.com/labstack/echo/v4 v4.11.3
go: downloading github.com/labstack/gommon v0.4.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
go: downloading golang.org/x/crypto v0.16.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/libc v1.37.0
go: downloading modernc.org/mathutil v1.6.0
go: downloading modernc.org/memory v1.7.2
go: downloading modernc.org/sqlite v1.27.0
go: added github.com/NeowayLabs/drm v0.0.0-20190824133025-4939fc0ad345
go: added github.com/cloud-barista/cm-honeybee v0.0.0-20231208055314-9d736a30aa55
go: added github.com/jollaman999/utils v1.0.10
go: upgraded github.com/labstack/echo/v4 v4.11.2 => v4.11.3
go: upgraded github.com/labstack/gommon v0.4.0 => v0.4.1
go: added github.com/libvirt/libvirt-go-xml v7.4.0+incompatible
go: upgraded golang.org/x/crypto v0.14.0 => v0.16.0
go: upgraded golang.org/x/net v0.17.0 => v0.19.0
go: upgraded golang.org/x/tools v0.7.0 => v0.16.0
  1. Import a package
    
    package controller

import ( "fmt" "net/http"

"github.com/cloud-barista/cm-honeybee/model/infra"
"github.com/labstack/echo/v4"

)


3. Embedding Infra struct to RecommendInfraRequest (i.e, request body)

```go
type RecommendInfraRequest struct {
    infra.Infra
}
Click to see full source code ```go // Package common is to handle REST API for common funcitonalities package controller import ( "fmt" "net/http" "github.com/cloud-barista/cm-honeybee/model/infra" "github.com/labstack/echo/v4" ) type Infrastructure struct { Network string Disk string Compute string SecurityGroup string VirtualMachine string } type RecommendInfraRequest struct { infra.Infra } type RecommendInfraResponse struct { Infrastructure } // RecommendInfra godoc // @Summary Recommend an appropriate infrastructure for cloud migration // @Description It recommends a cloud infrastructure most similar to the input. Infrastructure includes network, storage, compute, and so on. // @Tags [Recommendation] Infrastructure // @Accept json // @Produce json // @Param UserInfrastructure body RecommendInfraRequest true "Specify network, disk, compute, security group, virtual machine, etc." // @Success 200 {object} RecommendInfraResponse "Successfully recommended an appropriate infrastructure for cloud migration" // @Failure 404 {object} common.SimpleMsg // @Failure 500 {object} common.SimpleMsg // @Router /recommendation/infra [post] func RecommendInfra(c echo.Context) error { // Input req := &RecommendInfraRequest{} if err := c.Bind(req); err != nil { return err } fmt.Print(req) fmt.Print(req.Compute) fmt.Print(req.Network) fmt.Print(req.GPU) res := &RecommendInfraResponse{} // Process // Ouput // if err != nil { // common.CBLog.Error(err) // mapA := map[string]string{"message": err.Error()} // return c.JSON(http.StatusInternalServerError, &mapA) // } return c.JSON(http.StatusOK, res) } ```
  1. Execute swag init

I encountered the below message.

make swag

2023/12/10 23:07:05 Error parsing type definition 'controller.RecommendInfraRequest': : cannot find type definition: infra.Infra
2023/12/10 23:07:05 Skipping 'controller.RecommendInfraRequest', recursion detected.
Click to see full message ```bash make swag cd pkg/ && make swag make[1]: Entering directory '/mnt/d/dev/cloud-barista/cm-beetle/pkg' ~/go/bin/swag i -g ./api/rest/server/server.go -o ./api/rest/docs 2023/12/10 23:07:05 Generate swagger docs.... 2023/12/10 23:07:05 Generate general API Info, search dir:./ 2023/12/10 23:07:05 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /mnt/d/dev/cloud-barista/cm-beetle/pkg 2023/12/10 23:07:05 Generating common.ConfigInfo 2023/12/10 23:07:05 Generating common.SimpleMsg 2023/12/10 23:07:05 Generating common.RestGetAllConfigResponse 2023/12/10 23:07:05 Generating common.ConfigReq 2023/12/10 23:07:05 Generating common.JSONResult 2023/12/10 23:07:05 Generating common.RestGetAllNsResponse 2023/12/10 23:07:05 Generating common.NsInfo 2023/12/10 23:07:05 Generating common.IdList 2023/12/10 23:07:05 Generating common.NsReq 2023/12/10 23:07:05 Generating controller.MigrateInfraRequest 2023/12/10 23:07:05 Generating model.TbMcisDynamicReq 2023/12/10 23:07:05 Generating model.TbVmDynamicReq 2023/12/10 23:07:05 Generating controller.MigrateInfraResponse 2023/12/10 23:07:05 Generating model.TbMcisInfo 2023/12/10 23:07:05 Generating model.StatusCountInfo 2023/12/10 23:07:05 Generating model.TbVmInfo 2023/12/10 23:07:05 Generating common.GeoLocation 2023/12/10 23:07:05 Generating model.RegionInfo 2023/12/10 23:07:05 Generating common.ConnConfig 2023/12/10 23:07:05 Generating model.SpiderVMInfo 2023/12/10 23:07:05 Generating common.IID 2023/12/10 23:07:05 Generating common.KeyValue 2023/12/10 23:07:05 Generating controller.MigrateNetworkRequest 2023/12/10 23:07:05 Generating model.DummyNetwork 2023/12/10 23:07:05 Generating model.Network 2023/12/10 23:07:05 Generating model.Subnet 2023/12/10 23:07:05 Generating controller.MigrateNetworkResponse 2023/12/10 23:07:05 Generating controller.MigrateStorageRequest 2023/12/10 23:07:05 Generating model.DummyStorage 2023/12/10 23:07:05 Generating model.Storage 2023/12/10 23:07:05 Generating controller.MigrateStorageResponse 2023/12/10 23:07:05 Generating controller.MigrateInstanceRequest 2023/12/10 23:07:05 Generating model.DummyInstance 2023/12/10 23:07:05 Generating model.Instance 2023/12/10 23:07:05 Generating controller.MigrateInstanceResponse 2023/12/10 23:07:05 Generating controller.RecommendInfraRequest 2023/12/10 23:07:05 Error parsing type definition 'controller.RecommendInfraRequest': : cannot find type definition: infra.Infra 2023/12/10 23:07:05 Skipping 'controller.RecommendInfraRequest', recursion detected. 2023/12/10 23:07:05 Generating controller.RecommendInfraResponse 2023/12/10 23:07:05 Generating controller.Infrastructure 2023/12/10 23:07:05 Generating controller.GetUsersResponse 2023/12/10 23:07:05 Generating model.MyUser 2023/12/10 23:07:05 Generating controller.GetUserResponse 2023/12/10 23:07:05 Generating controller.CreateUserRequest 2023/12/10 23:07:05 Generating controller.UpdateUserRequest 2023/12/10 23:07:05 Generating controller.UpdateUserResponse 2023/12/10 23:07:05 Generating controller.PatchUserRequest 2023/12/10 23:07:05 Generating controller.PatchUserResponse 2023/12/10 23:07:05 create docs.go at api/rest/docs/docs.go 2023/12/10 23:07:05 create swagger.json at api/rest/docs/swagger.json 2023/12/10 23:07:05 create swagger.yaml at api/rest/docs/swagger.yaml make[1]: Leaving directory '/mnt/d/dev/cloud-barista/cm-beetle/pkg' ```
yunkon-kim commented 10 months ago

I tried the type alias below but encountered the same error.

Type alias

// Type Aliases to recognize external structs
type Infra = infra.Infra

type RecommendInfraRequest struct {
    Infra
}
yunkon-kim commented 10 months ago

Until a repository that manages only models is set up, the get-source-models.sh script will be used.

Then, we could replace the script with git submodule.

yunkon-kim commented 10 months ago

@niconicodex 안녕하세요.

이후 CM-Honeybee에서 Swagger documenation을 적용하실 때에도 아래 이슈가 동일하게 발생할 것 같아 공유를 드립니다.

외부 저장소 package 를 임포트한 후, 해당 package의 struct를 사용하실 경우에 발생하는 이슈입니다.

Go 에서는 이슈가 되지 않으나, swag init시에 프로젝트 내에 실제 소스파일이 없어 발생하는 이슈로 판단됩니다. 참고하시기 바랍니다.

2023/12/13 17:46:43 Error parsing type definition 'network.LibvirtDomain': interfaces: cannot find type definition: libvirtxml.DomainInterface
2023/12/13 17:46:43 Error parsing type definition 'network.LibvirtNet': domains: LibvirtDomain: interfaces: cannot find type definition: libvirtxml.DomainInterface
2023/12/13 17:46:43 Error parsing type definition 'network.VirtualNetwork': libvirt_net: LibvirtNet: domains: LibvirtDomain: interfaces: cannot find type definition: libvirtxml.DomainInterface
2023/12/13 17:46:43 Error parsing type definition 'network.Network': virtual_network: VirtualNetwork: libvirt_net: LibvirtNet: domains: LibvirtDomain: interfaces: cannot find type definition: libvirtxml.DomainInterface
2023/12/13 17:46:43 Error parsing type definition 'infra.Infra': network: network.Network: virtual_network: VirtualNetwork: libvirt_net: LibvirtNet: domains: LibvirtDomain: interfaces: cannot find type definition: libvirtxml.DomainInterface
2023/12/13 17:46:43 Error parsing type definition 'controller.RecommendInfraRequest': : infra.Infra: network: network.Network: virtual_network: VirtualNetwork: libvirt_net: LibvirtNet: domains: LibvirtDomain: interfaces: cannot find type definition: libvirtxml.DomainInterface
yunkon-kim commented 10 months ago

참고 - 이슈가 있는 두 항목을 주석 처리후, swag init시 이슈 없음

type Infra struct {
    Compute Compute `json:"compute"`
    // Network network.Network `json:"network"`
    // GPU GPU `json:"gpu"`
}

참고 - Swagger UI

image

yunkon-kim commented 5 months ago

사전 수행사항:

: 온프레미스 모델 동기화 스크립트(get-onprem-models.sh) 사용하여 cm-honeybee의 모델 파일들을 cm-beetle로 동기화

이슈 1

: swag init 시 다음 에러 발생

Error parsing type definition 'controller.RecommendInfraRequest': : cannot find type definition: onpremmodel.Infra

: (원인) 아래와 같이 모델 pkg를 import 및 alias 적용 한 경우 이를 참조하지 못하기 때문 : infraonpremmodel로 alias

import (
    onpremmodel "github.com/cloud-barista/cm-beetle/pkg/api/rest/model/onprem/infra"
)

type RecommendInfraRequest struct {
    onpremmodel.Infra
}

type RecommendInfraResponse struct {
    cloudmodel.TbMcisDynamicReq
}

// RecommendInfra godoc
// @Summary Recommend an appropriate infrastructure for cloud migration
// @Description It recommends a cloud infrastructure most similar to the input. Infrastructure includes network, storage, compute, and so on.
// @Tags [Recommendation] Infrastructure
// @Accept  json
// @Produce  json
// @Param UserInfrastructure body RecommendInfraRequest true "Specify network, disk, compute, security group, virtual machine, etc."
// @Success 200 {object} RecommendInfraResponse "Successfully recommended an appropriate infrastructure for cloud migration"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /recommendation/infra [post]
func RecommendInfra(c echo.Context) error {
   ...
}

📌 의견: : API로 제공되는 모델에 대해서는 pkg import시 alias 적용이 불가할 것으로 판단됨

이슈 2

: swag init시 다음 에러 발생

Error parsing type definition 'infra.GPU': nvidia: cannot find type definition: nvidia.NVIDIA
Error parsing type definition 'infra.Infra': gpu: GPU: nvidia: cannot find type definition: nvidia.NVIDIA
Error parsing type definition 'controller.RecommendInfraRequest': : infra.Infra: gpu: GPU: nvidia: cannot find type definition: nvidia.NVIDIA

: (원인) 해당 스트럭트가 동기화 되지 않았기 때문

package infra

import (
    "github.com/cloud-barista/cm-honeybee/agent/gpu/drm"
    "github.com/cloud-barista/cm-honeybee/agent/gpu/nvidia"
)

type GPU struct {
    NVIDIA []nvidia.NVIDIA `json:"nvidia"`
    DRM    []drm.DRM       `json:"drm"`
}

📌 의견: : GPU 관련 모델도 model/onprem 또는 하위 경로 상에 위치해야할 것으로 보임 (from) https://github.com/cloud-barista/cm-honeybee/tree/main/agent/gpu (to) https://github.com/cloud-barista/cm-honeybee/tree/main/agent/pkg/api/rest/model/onprem

ish-hcc commented 5 months ago

해당 커밋에 의해 말씀하신 문제 수정되었습니다. 감사합니다. https://github.com/cloud-barista/cm-honeybee/commit/0963d03537a4bd0eaaf504cb30965b3137a79834

powerkimhub commented 4 months ago

@yunkon-kim @seokho-son


[개요]

make swag

2023/12/10 23:07:05 Error parsing type definition 'controller.RecommendInfraRequest': : cannot find type definition: infra.Infra 2023/12/10 23:07:05 Skipping 'controller.RecommendInfraRequest', recursion detected.


[방안]

swag init --parseDependency


[세부]


[기타]

yunkon-kim commented 4 months ago

@powerkimhub

외부 패키지 활용 및 API docs 생성 방안을 공유해주셔서 감사드립니다.

먼저, 소스 컴퓨팅 인프라 형상 정보 메트릭, 소스 모델(온프레미스 모델), 목표 모델(클라우드 모델), API 요청/응답 바디 구조체 등에 실 적용 및 테스트를 진행하고요. 이후에 플랫폼 전체에 확대 적용하는 것으로 추진해보겠습니다. (행사 이후 추진)

공유해주신 아래 내용에 대해 한가지 질문이 있습니다. 기존에 설정되어 있는 GOPATHGOROOT를 특정 디렉토리로 변경해야하는 것으로 보이는데요. 10627 디렉토리가 고정되어 있는 디렉토리인지 문의드립니다. 혹시 go get 등으로 패키지를 업데이트 하는 경우에도 동일 디렉토리를 활용해도 괜찮을까요?

다음 설정 후 실행하면 에러 메시지도 안보입니다.

# 환경 확인 
go env |grep GOPATH
GOPATH='/home/ubuntu/go'

go env | grep GOROOT
GOROOT='/snap/go/10627'
# 환경 설정
export GOPATH='/home/ubuntu/go'
export GOROOT='/snap/go/10627'
powerkimhub commented 4 months ago

@yunkon-kim


공유해주신 아래 내용에 대해 한가지 질문이 있습니다. 기존에 설정되어 있는 GOPATHGOROOT를 특정 디렉토리로 변경해야하는 것으로 보이는데요. 10627 디렉토리가 고정되어 있는 디렉토리인지 문의드립니다. 혹시 go get 등으로 패키지를 업데이트 하는 경우에도 동일 디렉토리를 활용해도 괜찮을까요?


yunkon-kim commented 4 months ago

@powerkimhub

네 알겠습니다. 설명 감사드립니다.

yunkon-kim commented 3 months ago

@powerkimhub @seokho-son

CM-Beetle에서 아래 둘을 import 하는 방식으로 테스트를 진행해 봤습니다.

결론부터 공유드립니다.


이후는 테스트 결과입니다. 살펴보시면 될 것 같습니다.

사전에, CM-Beetle에서는 'Swagger general API info'를 server.go 상단에 기재하고 있음을 말씀드립니다. : 참고 - Swagger general API info

// @title CM-Beetle REST API
// @version latest
// @description CM-Beetle REST API

// @contact.name API Support
// @contact.url http://cloud-barista.github.io
// @contact.email contact-to-cloud-barista@googlegroups.com

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @BasePath /beetle

// @securityDefinitions.basic BasicAuth

이를 바탕으로 몇 가지 케이스를 통해 현황을 공유드립니다.

server.go, go.mod, main.go의 위치에 따라 문서가 다른 결과를 보이고 있습니다.

Case 1: 외부 pkg import 방식으로 수정, --parseDependency 옵션 추가, swag init 수행

: 관련 디렉토리 및 파일 구조

.
├── cmd
│   └── cm-beetle
│       └── main.go
├── go.mod
├── go.sum
├── go.work
├── go.work.sum
└── pkg
     └── api
          └── rest
              ├── common
              ├── controller
              ├── middlewares
              ├── model
              ├── route
              └── server.go

: swag init 명령어

~/go/bin/swag i \
--parseDependency \
--generalInfo ./pkg/api/rest/server.go \
--dir ./ \
--output ./api

: 결과 - import 된 패키지 포함하여 API 문서 생성 성공, CM-Beetle 내부의 패키지에 대해서는 _가 나타나기 시작 (곤란함...)

2024/07/18 10:35:46 Generate swagger docs....
2024/07/18 10:35:46 Generate general API Info, search dir:./
2024/07/18 10:35:46 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /home/ubuntu/dev/cloud-barista/cm-beetle
2024/07/18 10:35:50 Generating pkg_api_rest_common.SimpleMessage
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg
2024/07/18 10:35:50 Generating pkg_api_rest_controller.MigrateInfraRequest
2024/07/18 10:35:50 Generating mcis.TbMcisDynamicReq
2024/07/18 10:35:50 Generating mcis.TbVmDynamicReq
2024/07/18 10:35:50 Generating pkg_api_rest_controller.MigrateInfraResponse
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_api_rest_model_beetle.Response
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.RestGetAllNsResponse
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.NsReq
2024/07/18 10:35:50 Generating pkg_api_rest_controller.RecommendInfraRequest
2024/07/18 10:35:50 Generating infra.Infra
2024/07/18 10:35:50 Generating infra.Compute
2024/07/18 10:35:50 Generating infra.System
2024/07/18 10:35:50 Generating infra.OS
2024/07/18 10:35:50 Generating infra.Kernel
2024/07/18 10:35:50 Generating infra.Node
2024/07/18 10:35:50 Generating infra.ComputeResource
2024/07/18 10:35:50 Generating infra.CPU
2024/07/18 10:35:50 Generating infra.Memory
2024/07/18 10:35:50 Generating infra.Disk
2024/07/18 10:35:50 Generating infra.Connection
2024/07/18 10:35:50 Generating infra.Keypair
2024/07/18 10:35:50 Generating network.Network
2024/07/18 10:35:50 Generating network.Host
2024/07/18 10:35:50 Generating network.NIC
2024/07/18 10:35:50 Generating network.DNS
2024/07/18 10:35:50 Generating network.Route
2024/07/18 10:35:50 Generating network.FirewallRule
2024/07/18 10:35:50 Generating network.CSP
2024/07/18 10:35:50 Generating network.VPC
2024/07/18 10:35:50 Generating network.Subnet
2024/07/18 10:35:50 Generating network.NLB
2024/07/18 10:35:50 Generating network.SecurityGroup
2024/07/18 10:35:50 Generating infra.GPU
2024/07/18 10:35:50 Generating infra.NVIDIA
2024/07/18 10:35:50 Generating infra.NVIDIADeviceAttribute
2024/07/18 10:35:50 Generating infra.NVIDIAPerformance
2024/07/18 10:35:50 Generating infra.DRM
2024/07/18 10:35:50 Generating infra.Storage
2024/07/18 10:35:50 Generating infra.MountPoint
2024/07/18 10:35:50 Generating infra.MountedInformation
2024/07/18 10:35:50 Generating pkg_api_rest_controller.RecommendInfraResponse
2024/07/18 10:35:50 Generating pkg_api_rest_controller.GetUsersResponse
2024/07/18 10:35:50 Generating github_com_cloud-barista_cm-beetle_pkg_api_rest_model.MyUser
2024/07/18 10:35:50 Generating pkg_api_rest_controller.GetUserResponse
2024/07/18 10:35:50 Generating pkg_api_rest_controller.CreateUserRequest
2024/07/18 10:35:50 Generating pkg_api_rest_controller.UpdateUserRequest
2024/07/18 10:35:50 Generating pkg_api_rest_controller.UpdateUserResponse
2024/07/18 10:35:50 Generating pkg_api_rest_controller.PatchUserRequest
2024/07/18 10:35:50 Generating pkg_api_rest_controller.PatchUserResponse
2024/07/18 10:35:50 create docs.go at api/docs.go
2024/07/18 10:35:50 create swagger.json at api/swagger.json
2024/07/18 10:35:50 create swagger.yaml at api/swagger.yaml

:결과 - UI 상에서 외부 패키지는 일반적으로 출력됙, 내부 패키지가 곤란하게 출력됨 image image

Case 2: server.go 상단의 'Swagger general API info'를 main.go로 이동, swag init 수행

: 관련 디렉토리 및 파일 구조 Case 1과 동일

: swag init 명령어

~/go/bin/swag i \
--parseDependency \
--generalInfo ./cmd/cm-beetle/main.go \
--dir ./ \
--output ./api

: 결과 - Case 1과 동일 (생략)

Case 3: main.go을 Project root로 이동, swag init 수행 : 관련 디렉토리 및 파일 구조

.
├── cmd
│   └── cm-beetle
├── main.go
├── go.mod
├── go.sum
├── go.work
├── go.work.sum
└── pkg
     └── api
          └── rest
              ├── common
              ├── controller
              ├── middlewares
              ├── model
              ├── route
              └── server.go

: swag init 명령어

~/go/bin/swag i \
--parseDependency \
--generalInfo ./main.go \
--dir ./ \
--output ./api

: 결과 - 일부 개선됨, CM-Beetle 내부의 패키지에 대해서는 _가 나타나는 상황이 줄어듬, : 2024/07/18 10:48:11 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg 등은 여전히 개선되지 않음

2024/07/18 10:48:05 Generate swagger docs....
2024/07/18 10:48:05 Generate general API Info, search dir:./
2024/07/18 10:48:11 Generating common.SimpleMessage
2024/07/18 10:48:11 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg
2024/07/18 10:48:11 Generating controller.MigrateInfraRequest
2024/07/18 10:48:11 Generating mcis.TbMcisDynamicReq
2024/07/18 10:48:11 Generating mcis.TbVmDynamicReq
2024/07/18 10:48:11 Generating controller.MigrateInfraResponse
2024/07/18 10:48:11 Generating model.Response
2024/07/18 10:48:11 Generating common.RestGetAllNsResponse
2024/07/18 10:48:11 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.NsInfo
2024/07/18 10:48:11 Generating github_com_cloud-barista_cm-beetle_pkg_core_common.NsReq
2024/07/18 10:48:11 Generating controller.RecommendInfraRequest
2024/07/18 10:48:11 Generating infra.Infra
2024/07/18 10:48:11 Generating infra.Compute
2024/07/18 10:48:11 Generating infra.System
2024/07/18 10:48:11 Generating infra.OS
2024/07/18 10:48:11 Generating infra.Kernel
2024/07/18 10:48:11 Generating infra.Node
2024/07/18 10:48:11 Generating infra.ComputeResource
2024/07/18 10:48:11 Generating infra.CPU
2024/07/18 10:48:11 Generating infra.Memory
2024/07/18 10:48:11 Generating infra.Disk
2024/07/18 10:48:11 Generating infra.Connection
2024/07/18 10:48:11 Generating infra.Keypair
2024/07/18 10:48:11 Generating network.Network
2024/07/18 10:48:11 Generating network.Host
2024/07/18 10:48:11 Generating network.NIC
2024/07/18 10:48:11 Generating network.DNS
2024/07/18 10:48:11 Generating network.Route
2024/07/18 10:48:11 Generating network.FirewallRule
2024/07/18 10:48:11 Generating network.CSP
2024/07/18 10:48:11 Generating network.VPC
2024/07/18 10:48:11 Generating network.Subnet
2024/07/18 10:48:11 Generating network.NLB
2024/07/18 10:48:11 Generating network.SecurityGroup
2024/07/18 10:48:11 Generating infra.GPU
2024/07/18 10:48:11 Generating infra.NVIDIA
2024/07/18 10:48:11 Generating infra.NVIDIADeviceAttribute
2024/07/18 10:48:11 Generating infra.NVIDIAPerformance
2024/07/18 10:48:11 Generating infra.DRM
2024/07/18 10:48:11 Generating infra.Storage
2024/07/18 10:48:11 Generating infra.MountPoint
2024/07/18 10:48:11 Generating infra.MountedInformation
2024/07/18 10:48:11 Generating controller.RecommendInfraResponse
2024/07/18 10:48:11 Generating controller.GetUsersResponse
2024/07/18 10:48:11 Generating model.MyUser
2024/07/18 10:48:11 Generating controller.GetUserResponse
2024/07/18 10:48:11 Generating controller.CreateUserRequest
2024/07/18 10:48:11 Generating controller.UpdateUserRequest
2024/07/18 10:48:11 Generating controller.UpdateUserResponse
2024/07/18 10:48:11 Generating controller.PatchUserRequest
2024/07/18 10:48:11 Generating controller.PatchUserResponse
2024/07/18 10:48:11 create docs.go at api/docs.go
2024/07/18 10:48:11 create swagger.json at api/swagger.json
2024/07/18 10:48:11 create swagger.yaml at api/swagger.yaml

:결과 - UI 상에서도 개선됨 image image

: github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg 해소 관련

: 참고 - 재정의/명시

type SimpleMessage struct {
    common.SimpleMsg
}

: 결과 - SimpleMessage 사용 image

: 결과 - common.SimpleMsg 사용 image

yunkon-kim commented 3 months ago

@innodreamer CM-Damselfly 측면에서 한번 살펴봐 주시면 좋을 것 같습니다.

yunkon-kim commented 1 month ago

최근 pkg들을 정리한 이후, 내부 패키지 및 구조체의 명칭에 _ 가 붙었던 증상이 해소되어 공유차원에서 남겨 놓습니다.

증상 참고: github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg

현황: CB-Tumblebug 및 cm-model 저장소의 pkg 를 import해서 활용 중이고, 결과가 아래와 같습니다.

Generating Swagger API documentation...
2024/09/09 19:02:13 Generate swagger docs....
2024/09/09 19:02:13 Generate general API Info, search dir:./
2024/09/09 19:02:21 Generating common.SimpleMessage
2024/09/09 19:02:21 Generating common.SimpleMsg
2024/09/09 19:02:21 Generating controller.MigrateInfraRequest
2024/09/09 19:02:21 Generating model.TbMciDynamicReq
2024/09/09 19:02:21 Generating model.TbVmDynamicReq
2024/09/09 19:02:21 Generating controller.MigrateInfraResponse
2024/09/09 19:02:21 Generating model.Response
2024/09/09 19:02:21 Generating controller.RecommendInfraRequest
2024/09/09 19:02:21 Generating onprem.OnPremInfra
2024/09/09 19:02:21 Generating onprem.NetworkProperty
2024/09/09 19:02:21 Generating onprem.ServerProperty
2024/09/09 19:02:21 Generating onprem.CpuProperty
2024/09/09 19:02:21 Generating onprem.MemoryProperty
2024/09/09 19:02:21 Generating onprem.DiskProperty
2024/09/09 19:02:21 Generating onprem.NetworkInterfaceProperty
2024/09/09 19:02:21 Generating onprem.OsProperty
2024/09/09 19:02:21 Generating controller.RecommendInfraResponse
2024/09/09 19:02:21 Generating recommendation.RecommendedInfraInfo
2024/09/09 19:02:21 Generating controller.GetUsersResponse
2024/09/09 19:02:21 Generating model.MyUser
2024/09/09 19:02:21 Generating controller.GetUserResponse
2024/09/09 19:02:21 Generating controller.CreateUserRequest
2024/09/09 19:02:21 Generating controller.UpdateUserRequest
2024/09/09 19:02:21 Generating controller.UpdateUserResponse
2024/09/09 19:02:21 Generating controller.PatchUserRequest
2024/09/09 19:02:21 Generating controller.PatchUserResponse
2024/09/09 19:02:21 create docs.go at api/docs.go
2024/09/09 19:02:21 create swagger.json at api/swagger.json
2024/09/09 19:02:21 create swagger.yaml at api/swagger.yaml
Generated Swagger API documentation!
yunkon-kim commented 3 weeks ago

@powerkimhub @seokho-son @innodreamer @ish-hcc

관련 사항이 충분한 테스트 되었고, 모델(Go struct) import 및 swag init 방법도 자리를 잡아가고 있어 Close 합니다.