Skip to content

Commit

Permalink
Applicationのcomponents.DataSourceからDeploySourceへの変更の対応 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
hekki authored Nov 15, 2024
1 parent aff47b6 commit eafc651
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 85 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func main() {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down
13 changes: 7 additions & 6 deletions acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func TestApplicationAPI(t *testing.T) {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down Expand Up @@ -144,8 +144,9 @@ func TestVersionAPI(t *testing.T) {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{

DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down Expand Up @@ -212,8 +213,8 @@ func TestTrafficAPI(t *testing.T) {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down
42 changes: 21 additions & 21 deletions apis/v1/spec/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ info:
"name": "Component01",
"max_cpu": "0.1",
"max_memory": "256Mi",
"datasource": {
"deploy_source": {
"container_registry": {
"image": "my-app.sakuracr.jp/my-app:latest"
}
Expand Down Expand Up @@ -191,7 +191,7 @@ info:
"name": "Component01 updated",
"max_cpu": "0.1",
"max_memory": "256Mi",
"datasource": {
"deploy_source": {
"container_registry": {
"image": "my-app.sakuracr.jp/my-app-v2:latest"
}
Expand Down Expand Up @@ -300,7 +300,7 @@ paths:
schema:
$ref: "#/components/schemas/model.defaultError"
"404":
description: さくらのAppRunにユーザーが存在しません
description: さくらのAppRunにユーザーが存在しません
content:
application/json:
schema:
Expand Down Expand Up @@ -1314,7 +1314,7 @@ components:
- name
- max_cpu
- max_memory
- datasource
- deploy_source
properties:
name:
description: コンポーネント名
Expand Down Expand Up @@ -1346,9 +1346,9 @@ components:
- 512Mi
- 1Gi
- 2Gi
datasource:
deploy_source:
description: コンポーネントを構成するソース
$ref: "#/components/schemas/postApplicationBodyComponentDataSource"
$ref: "#/components/schemas/postApplicationBodyComponentDeploySource"
env:
description: コンポーネントに渡す環境変数
type: array
Expand All @@ -1358,13 +1358,13 @@ components:
probe:
description: コンポーネントのプローブ設定
$ref: "#/components/schemas/postApplicationBodyComponentProbe"
postApplicationBodyComponentDataSource:
postApplicationBodyComponentDeploySource:
type: object
properties:
container_registry:
description: コンテナレジストリ
$ref: "#/components/schemas/postApplicationBodyComponentDataSourceContainerRegistry"
postApplicationBodyComponentDataSourceContainerRegistry:
$ref: "#/components/schemas/postApplicationBodyComponentDeploySourceContainerRegistry"
postApplicationBodyComponentDeploySourceContainerRegistry:
type: object
required:
- image
Expand Down Expand Up @@ -1494,7 +1494,7 @@ components:
- name
- max_cpu
- max_memory
- datasource
- deploy_source
properties:
name:
description: コンポーネント名
Expand Down Expand Up @@ -1526,22 +1526,22 @@ components:
- 512Mi
- 1Gi
- 2Gi
datasource:
deploy_source:
description: コンポーネントを構成するソース
$ref: "#/components/schemas/patchApplicationBodyComponentDataSource"
$ref: "#/components/schemas/patchApplicationBodyComponentDeploySource"
env:
description: コンポーネントに渡す環境変数
$ref: "#/components/schemas/patchApplicationBodyComponentEnv"
probe:
description: コンポーネントのプローブ設定
$ref: "#/components/schemas/patchApplicationBodyComponentProbe"
patchApplicationBodyComponentDataSource:
patchApplicationBodyComponentDeploySource:
type: object
properties:
container_registry:
description: コンテナレジストリ
$ref: "#/components/schemas/patchApplicationBodyComponentDataSourceContainerRegistry"
patchApplicationBodyComponentDataSourceContainerRegistry:
$ref: "#/components/schemas/patchApplicationBodyComponentDeploySourceContainerRegistry"
patchApplicationBodyComponentDeploySourceContainerRegistry:
type: object
required:
- image
Expand Down Expand Up @@ -1692,7 +1692,7 @@ components:
- name
- max_cpu
- max_memory
- datasource
- deploy_source
properties:
name:
description: コンポーネント名
Expand All @@ -1706,9 +1706,9 @@ components:
description: コンポーネントの最大メモリ
type: string
example: 256Mi
datasource:
deploy_source:
description: コンポーネントを構成するソース
$ref: "#/components/schemas/handler.ApplicationComponentDataSource"
$ref: "#/components/schemas/handler.ApplicationComponentDeploySource"
env:
description: コンポーネントに渡す環境変数
type: array
Expand All @@ -1717,13 +1717,13 @@ components:
probe:
description: コンポーネントのプローブ設定
$ref: "#/components/schemas/handler.ApplicationComponentProbe"
handler.ApplicationComponentDataSource:
handler.ApplicationComponentDeploySource:
type: object
properties:
container_registry:
description: コンテナレジストリ
$ref: "#/components/schemas/handler.ApplicationComponentDataSourceContainerRegistry"
handler.ApplicationComponentDataSourceContainerRegistry:
$ref: "#/components/schemas/handler.ApplicationComponentDeploySourceContainerRegistry"
handler.ApplicationComponentDeploySourceContainerRegistry:
type: object
required:
- image
Expand Down
28 changes: 14 additions & 14 deletions apis/v1/spec/original-openapi.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions apis/v1/zz_types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func Example_applicationAPI() {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down Expand Up @@ -122,8 +122,8 @@ func Example_versionAPI() {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down Expand Up @@ -204,8 +204,8 @@ func Example_trafficAPI() {
Name: "component1",
MaxCpu: "0.1",
MaxMemory: "256Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-test.sakuracr.jp/apprun/test1:latest",
},
},
Expand Down
24 changes: 12 additions & 12 deletions fake/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func (engine *Engine) CreateApplication(reqBody *v1.PostApplicationBody) (*v1.Ap

var components []v1.HandlerApplicationComponent
for _, reqComponent := range reqBody.Components {
var cr v1.HandlerApplicationComponentDataSourceContainerRegistry
if reqComponent.Datasource.ContainerRegistry != nil {
cr.Image = reqComponent.Datasource.ContainerRegistry.Image
cr.Server = reqComponent.Datasource.ContainerRegistry.Server
cr.Username = reqComponent.Datasource.ContainerRegistry.Username
var cr v1.HandlerApplicationComponentDeploySourceContainerRegistry
if reqComponent.DeploySource.ContainerRegistry != nil {
cr.Image = reqComponent.DeploySource.ContainerRegistry.Image
cr.Server = reqComponent.DeploySource.ContainerRegistry.Server
cr.Username = reqComponent.DeploySource.ContainerRegistry.Username
}

var env []v1.HandlerApplicationComponentEnv
Expand Down Expand Up @@ -138,7 +138,7 @@ func (engine *Engine) CreateApplication(reqBody *v1.PostApplicationBody) (*v1.Ap
component.Name = reqComponent.Name
component.MaxCpu = string(reqComponent.MaxCpu)
component.MaxMemory = string(reqComponent.MaxMemory)
component.Datasource.ContainerRegistry = &cr
component.DeploySource.ContainerRegistry = &cr
component.Env = &env
component.Probe = &probe
components = append(components, component)
Expand Down Expand Up @@ -214,11 +214,11 @@ func (engine *Engine) UpdateApplication(id string, reqBody *v1.PatchApplicationB
if reqBody.Components != nil && len(*reqBody.Components) > 0 {
var components []v1.HandlerApplicationComponent
for _, reqComponent := range *reqBody.Components {
var cr v1.HandlerApplicationComponentDataSourceContainerRegistry
if reqComponent.Datasource.ContainerRegistry != nil {
cr.Image = reqComponent.Datasource.ContainerRegistry.Image
cr.Server = reqComponent.Datasource.ContainerRegistry.Server
cr.Username = reqComponent.Datasource.ContainerRegistry.Username
var cr v1.HandlerApplicationComponentDeploySourceContainerRegistry
if reqComponent.DeploySource.ContainerRegistry != nil {
cr.Image = reqComponent.DeploySource.ContainerRegistry.Image
cr.Server = reqComponent.DeploySource.ContainerRegistry.Server
cr.Username = reqComponent.DeploySource.ContainerRegistry.Username
}

var env []v1.HandlerApplicationComponentEnv
Expand Down Expand Up @@ -250,7 +250,7 @@ func (engine *Engine) UpdateApplication(id string, reqBody *v1.PatchApplicationB
component.Name = reqComponent.Name
component.MaxCpu = string(reqComponent.MaxCpu)
component.MaxMemory = string(reqComponent.MaxMemory)
component.Datasource.ContainerRegistry = &cr
component.DeploySource.ContainerRegistry = &cr
component.Env = &env
component.Probe = &probe
components = append(components, component)
Expand Down
8 changes: 4 additions & 4 deletions fake/applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestEngine_Application(t *testing.T) {
"name": "component1",
"max_cpu": "0.2",
"max_memory": "512Mi",
"datasource": {
"deploy_source": {
"container_registry": {
"image": "apprun-example.sakuracr.jp/helloworld:latest",
"server": "apprun-example.sakuracr.jp",
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestEngine_Application(t *testing.T) {
"name": "component1",
"max_cpu": "0.2",
"max_memory": "512Mi",
"datasource": {
"deploy_source": {
"container_registry": {
"image": "apprun-example.sakuracr.jp/helloworld:latest",
"server": "apprun-example.sakuracr.jp",
Expand Down Expand Up @@ -253,8 +253,8 @@ func postApplicationBody() *v1.PostApplicationBody {
Name: "component1",
MaxCpu: "0.2",
MaxMemory: "512Mi",
Datasource: v1.PostApplicationBodyComponentDataSource{
ContainerRegistry: &v1.PostApplicationBodyComponentDataSourceContainerRegistry{
DeploySource: v1.PostApplicationBodyComponentDeploySource{
ContainerRegistry: &v1.PostApplicationBodyComponentDeploySourceContainerRegistry{
Image: "apprun-example.sakuracr.jp/helloworld:latest",
Server: &server,
Username: &userName,
Expand Down
2 changes: 1 addition & 1 deletion fake/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestEngine_Version(t *testing.T) {
"name": "component1",
"max_cpu": "0.2",
"max_memory": "512Mi",
"datasource": {
"deploy_source": {
"container_registry": {
"image": "apprun-example.sakuracr.jp/helloworld:latest",
"server": "apprun-example.sakuracr.jp",
Expand Down

0 comments on commit eafc651

Please sign in to comment.