From f5719e0afe41529504e5bfdf91839ba696d7b657 Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Wed, 6 Dec 2023 16:47:37 -0500 Subject: [PATCH] feat: sdl Signed-off-by: Artur Troian --- docs/proto/node.md | 1529 +++++++++++++++++ go.mod | 27 +- go.sum | 55 +- go/sdl/sdl.go | 162 ++ go/sdl/sdl_test.go | 59 + go/sdl/v2/accept.go | 24 + go/sdl/v2/accept.pb.go | 322 ++++ go/sdl/v2/coin.go | 41 + go/sdl/v2/coin.pb.go | 323 ++++ go/sdl/v2/coin_test.go | 34 + go/sdl/v2/compute_resources.go | 52 + go/sdl/v2/compute_resources.pb.go | 522 ++++++ go/sdl/v2/cpu.go | 42 + go/sdl/v2/cpu.pb.go | 372 ++++ go/sdl/v2/dependency.go | 21 + go/sdl/v2/dependency.pb.go | 318 ++++ go/sdl/v2/deployments.go | 144 ++ go/sdl/v2/endpoint.pb.go | 318 ++++ go/sdl/v2/expose.go | 93 + go/sdl/v2/expose.pb.go | 570 ++++++ go/sdl/v2/expose_test.go | 24 + go/sdl/v2/expose_to.go | 3 + go/sdl/v2/expose_to.pb.go | 472 +++++ go/sdl/v2/gpu.go | 106 ++ go/sdl/v2/gpu.pb.go | 372 ++++ go/sdl/v2/gpu_test.go | 155 ++ go/sdl/v2/group_builder.go | 141 ++ go/sdl/v2/http_options.go | 99 ++ go/sdl/v2/http_options.pb.go | 509 ++++++ go/sdl/v2/memory.go | 35 + go/sdl/v2/memory.pb.go | 372 ++++ go/sdl/v2/profiles.go | 115 ++ go/sdl/v2/profiles.pb.go | 1223 +++++++++++++ go/sdl/v2/sdl.go | 379 ++++ go/sdl/v2/sdl.pb.go | 781 +++++++++ go/sdl/v2/service.pb.go | 684 ++++++++ go/sdl/v2/service_params.pb.go | 665 +++++++ go/sdl/v2/service_placement.pb.go | 386 +++++ go/sdl/v2/storage.go | 234 +++ go/sdl/v2/storage.pb.go | 425 +++++ go/sdl/v2/storage_test.go | 198 +++ go/sdl/v2/units.go | 154 ++ go/sdl/v2/units_test.go | 99 ++ go/sdl/v2/utils.go | 21 + go/sdl/v2_1/accept.go | 24 + go/sdl/v2_1/accept.pb.go | 322 ++++ go/sdl/v2_1/coin.go | 41 + go/sdl/v2_1/coin.pb.go | 324 ++++ go/sdl/v2_1/compute_resources.go | 52 + go/sdl/v2_1/compute_resources.pb.go | 522 ++++++ go/sdl/v2_1/cpu.go | 42 + go/sdl/v2_1/cpu.pb.go | 372 ++++ go/sdl/v2_1/dependency.go | 21 + go/sdl/v2_1/dependency.pb.go | 318 ++++ go/sdl/v2_1/deployments.go | 144 ++ go/sdl/v2_1/endpoint.pb.go | 318 ++++ go/sdl/v2_1/expose.go | 93 + go/sdl/v2_1/expose.pb.go | 571 ++++++ go/sdl/v2_1/expose_test.go | 24 + go/sdl/v2_1/expose_to.go | 3 + go/sdl/v2_1/expose_to.pb.go | 473 +++++ go/sdl/v2_1/gpu.go | 106 ++ go/sdl/v2_1/gpu.pb.go | 372 ++++ go/sdl/v2_1/gpu_test.go | 155 ++ go/sdl/v2_1/group_builder.go | 150 ++ go/sdl/v2_1/http_options.go | 99 ++ go/sdl/v2_1/http_options.pb.go | 509 ++++++ go/sdl/v2_1/memory.go | 35 + go/sdl/v2_1/memory.pb.go | 372 ++++ go/sdl/v2_1/profiles.go | 116 ++ go/sdl/v2_1/profiles.pb.go | 1231 +++++++++++++ go/sdl/v2_1/sdl.go | 348 ++++ go/sdl/v2_1/sdl.pb.go | 829 +++++++++ go/sdl/v2_1/service.pb.go | 684 ++++++++ go/sdl/v2_1/service_params.pb.go | 668 +++++++ go/sdl/v2_1/service_placement.pb.go | 386 +++++ go/sdl/v2_1/storage.go | 234 +++ go/sdl/v2_1/storage.pb.go | 425 +++++ go/sdl/v2_1/units.go | 154 ++ go/sdl/v2_1/units_test.go | 99 ++ go/sdl/v2_1/utils.go | 21 + go/sdl/v2_1_ip_test.go | 279 +++ go/sdl/v2_1_test.go | 728 ++++++++ go/sdl/v2_ip_test.go | 297 ++++ go/sdl/v2_test.go | 925 ++++++++++ proto/node/akash/sdl/v2.1/accept.proto | 15 + proto/node/akash/sdl/v2.1/coin.proto | 17 + .../akash/sdl/v2.1/compute_resources.proto | 40 + proto/node/akash/sdl/v2.1/cpu.proto | 25 + proto/node/akash/sdl/v2.1/dependency.proto | 15 + proto/node/akash/sdl/v2.1/endpoint.proto | 15 + proto/node/akash/sdl/v2.1/expose.proto | 48 + proto/node/akash/sdl/v2.1/expose_to.proto | 32 + proto/node/akash/sdl/v2.1/gpu.proto | 25 + proto/node/akash/sdl/v2.1/http_options.proto | 40 + proto/node/akash/sdl/v2.1/memory.proto | 25 + proto/node/akash/sdl/v2.1/profiles.proto | 54 + proto/node/akash/sdl/v2.1/sdl.proto | 42 + proto/node/akash/sdl/v2.1/service.proto | 53 + .../node/akash/sdl/v2.1/service_params.proto | 28 + .../akash/sdl/v2.1/service_placement.proto | 21 + proto/node/akash/sdl/v2.1/storage.proto | 30 + proto/node/akash/sdl/v2/accept.proto | 15 + proto/node/akash/sdl/v2/coin.proto | 17 + .../node/akash/sdl/v2/compute_resources.proto | 40 + proto/node/akash/sdl/v2/cpu.proto | 25 + proto/node/akash/sdl/v2/dependency.proto | 15 + proto/node/akash/sdl/v2/endpoint.proto | 15 + proto/node/akash/sdl/v2/expose.proto | 48 + proto/node/akash/sdl/v2/expose_to.proto | 32 + proto/node/akash/sdl/v2/gpu.proto | 25 + proto/node/akash/sdl/v2/http_options.proto | 40 + proto/node/akash/sdl/v2/memory.proto | 25 + proto/node/akash/sdl/v2/profiles.proto | 54 + proto/node/akash/sdl/v2/sdl.proto | 41 + proto/node/akash/sdl/v2/service.proto | 53 + proto/node/akash/sdl/v2/service_params.proto | 28 + .../node/akash/sdl/v2/service_placement.proto | 21 + proto/node/akash/sdl/v2/storage.proto | 30 + testdata/v2.1/deployment.yaml | 36 + testdata/v2.1/ip-endpoint.yaml | 41 + testdata/v2.1/multi-groups-ip-endpoint.yaml | 69 + testdata/v2.1/multi-ip-endpoint.yaml | 56 + testdata/v2.1/private_service.yaml | 64 + testdata/v2.1/profile-svc-name-mismatch.yaml | 38 + testdata/v2.1/service-mix.yaml | 80 + testdata/v2.1/service-mix2.yaml | 69 + testdata/v2.1/shared-ip-endpoint.yaml | 55 + testdata/v2.1/simple-gpu.yaml | 52 + testdata/v2.1/simple-with-ip.yaml | 50 + testdata/v2.1/simple.yaml | 45 + testdata/v2.1/simple2.yaml | 64 + testdata/v2.1/simple3.yaml | 45 + testdata/v2.1/simple4.yaml | 90 + testdata/v2.1/svc-mismatch.yaml | 45 + testdata/v2/deployment-svc-mismatch.yaml | 45 + testdata/v2/deployment-v2-c2c.yaml | 58 + testdata/v2/deployment-v2-escrow.yaml | 58 + testdata/v2/deployment-v2-ip-endpoint.yaml | 41 + testdata/v2/deployment-v2-migrate.yaml | 37 + ...eployment-v2-multi-groups-ip-endpoint.yaml | 69 + .../v2/deployment-v2-multi-ip-endpoint.yaml | 56 + testdata/v2/deployment-v2-newcontainer.yaml | 36 + testdata/v2/deployment-v2-nodeport.yaml | 39 + testdata/v2/deployment-v2-nohost.yaml | 34 + .../v2/deployment-v2-shared-ip-endpoint.yaml | 55 + testdata/v2/deployment-v2-storage-beta2.yaml | 42 + .../v2/deployment-v2-storage-default.yaml | 40 + .../v2/deployment-v2-storage-updateC.yaml | 43 + testdata/v2/deployment-v2-updateA.yaml | 36 + testdata/v2/deployment-v2-updateB.yaml | 37 + testdata/v2/deployment-v2.yaml | 36 + testdata/v2/deployment.yaml | 36 + testdata/v2/private_service.yaml | 64 + testdata/v2/profile-svc-name-mismatch.yaml | 38 + testdata/v2/service-mix.yaml | 80 + testdata/v2/service-mix2.yaml | 69 + testdata/v2/simple-double-ram.yaml | 45 + testdata/v2/simple-gpu.yaml | 52 + testdata/v2/simple-with-ip.yaml | 50 + testdata/v2/simple.yaml | 45 + testdata/v2/simple2.yaml | 64 + testdata/v2/simple3.yaml | 45 + testdata/v2/simple4.yaml | 90 + testdata/v2/storageClass1.yaml | 52 + testdata/v2/storageClass2.yaml | 53 + testdata/v2/storageClass3.yaml | 52 + testdata/v2/storageClass4.yaml | 59 + testdata/v2/storageClass5.yaml | 51 + testdata/v2/storageClass6.yaml | 53 + 170 files changed, 29232 insertions(+), 42 deletions(-) create mode 100644 go/sdl/sdl.go create mode 100644 go/sdl/sdl_test.go create mode 100644 go/sdl/v2/accept.go create mode 100644 go/sdl/v2/accept.pb.go create mode 100644 go/sdl/v2/coin.go create mode 100644 go/sdl/v2/coin.pb.go create mode 100644 go/sdl/v2/coin_test.go create mode 100644 go/sdl/v2/compute_resources.go create mode 100644 go/sdl/v2/compute_resources.pb.go create mode 100644 go/sdl/v2/cpu.go create mode 100644 go/sdl/v2/cpu.pb.go create mode 100644 go/sdl/v2/dependency.go create mode 100644 go/sdl/v2/dependency.pb.go create mode 100644 go/sdl/v2/deployments.go create mode 100644 go/sdl/v2/endpoint.pb.go create mode 100644 go/sdl/v2/expose.go create mode 100644 go/sdl/v2/expose.pb.go create mode 100644 go/sdl/v2/expose_test.go create mode 100644 go/sdl/v2/expose_to.go create mode 100644 go/sdl/v2/expose_to.pb.go create mode 100644 go/sdl/v2/gpu.go create mode 100644 go/sdl/v2/gpu.pb.go create mode 100644 go/sdl/v2/gpu_test.go create mode 100644 go/sdl/v2/group_builder.go create mode 100644 go/sdl/v2/http_options.go create mode 100644 go/sdl/v2/http_options.pb.go create mode 100644 go/sdl/v2/memory.go create mode 100644 go/sdl/v2/memory.pb.go create mode 100644 go/sdl/v2/profiles.go create mode 100644 go/sdl/v2/profiles.pb.go create mode 100644 go/sdl/v2/sdl.go create mode 100644 go/sdl/v2/sdl.pb.go create mode 100644 go/sdl/v2/service.pb.go create mode 100644 go/sdl/v2/service_params.pb.go create mode 100644 go/sdl/v2/service_placement.pb.go create mode 100644 go/sdl/v2/storage.go create mode 100644 go/sdl/v2/storage.pb.go create mode 100644 go/sdl/v2/storage_test.go create mode 100644 go/sdl/v2/units.go create mode 100644 go/sdl/v2/units_test.go create mode 100644 go/sdl/v2/utils.go create mode 100644 go/sdl/v2_1/accept.go create mode 100644 go/sdl/v2_1/accept.pb.go create mode 100644 go/sdl/v2_1/coin.go create mode 100644 go/sdl/v2_1/coin.pb.go create mode 100644 go/sdl/v2_1/compute_resources.go create mode 100644 go/sdl/v2_1/compute_resources.pb.go create mode 100644 go/sdl/v2_1/cpu.go create mode 100644 go/sdl/v2_1/cpu.pb.go create mode 100644 go/sdl/v2_1/dependency.go create mode 100644 go/sdl/v2_1/dependency.pb.go create mode 100644 go/sdl/v2_1/deployments.go create mode 100644 go/sdl/v2_1/endpoint.pb.go create mode 100644 go/sdl/v2_1/expose.go create mode 100644 go/sdl/v2_1/expose.pb.go create mode 100644 go/sdl/v2_1/expose_test.go create mode 100644 go/sdl/v2_1/expose_to.go create mode 100644 go/sdl/v2_1/expose_to.pb.go create mode 100644 go/sdl/v2_1/gpu.go create mode 100644 go/sdl/v2_1/gpu.pb.go create mode 100644 go/sdl/v2_1/gpu_test.go create mode 100644 go/sdl/v2_1/group_builder.go create mode 100644 go/sdl/v2_1/http_options.go create mode 100644 go/sdl/v2_1/http_options.pb.go create mode 100644 go/sdl/v2_1/memory.go create mode 100644 go/sdl/v2_1/memory.pb.go create mode 100644 go/sdl/v2_1/profiles.go create mode 100644 go/sdl/v2_1/profiles.pb.go create mode 100644 go/sdl/v2_1/sdl.go create mode 100644 go/sdl/v2_1/sdl.pb.go create mode 100644 go/sdl/v2_1/service.pb.go create mode 100644 go/sdl/v2_1/service_params.pb.go create mode 100644 go/sdl/v2_1/service_placement.pb.go create mode 100644 go/sdl/v2_1/storage.go create mode 100644 go/sdl/v2_1/storage.pb.go create mode 100644 go/sdl/v2_1/units.go create mode 100644 go/sdl/v2_1/units_test.go create mode 100644 go/sdl/v2_1/utils.go create mode 100644 go/sdl/v2_1_ip_test.go create mode 100644 go/sdl/v2_1_test.go create mode 100644 go/sdl/v2_ip_test.go create mode 100644 go/sdl/v2_test.go create mode 100644 proto/node/akash/sdl/v2.1/accept.proto create mode 100644 proto/node/akash/sdl/v2.1/coin.proto create mode 100644 proto/node/akash/sdl/v2.1/compute_resources.proto create mode 100644 proto/node/akash/sdl/v2.1/cpu.proto create mode 100644 proto/node/akash/sdl/v2.1/dependency.proto create mode 100644 proto/node/akash/sdl/v2.1/endpoint.proto create mode 100644 proto/node/akash/sdl/v2.1/expose.proto create mode 100644 proto/node/akash/sdl/v2.1/expose_to.proto create mode 100644 proto/node/akash/sdl/v2.1/gpu.proto create mode 100644 proto/node/akash/sdl/v2.1/http_options.proto create mode 100644 proto/node/akash/sdl/v2.1/memory.proto create mode 100644 proto/node/akash/sdl/v2.1/profiles.proto create mode 100644 proto/node/akash/sdl/v2.1/sdl.proto create mode 100644 proto/node/akash/sdl/v2.1/service.proto create mode 100644 proto/node/akash/sdl/v2.1/service_params.proto create mode 100644 proto/node/akash/sdl/v2.1/service_placement.proto create mode 100644 proto/node/akash/sdl/v2.1/storage.proto create mode 100644 proto/node/akash/sdl/v2/accept.proto create mode 100644 proto/node/akash/sdl/v2/coin.proto create mode 100644 proto/node/akash/sdl/v2/compute_resources.proto create mode 100644 proto/node/akash/sdl/v2/cpu.proto create mode 100644 proto/node/akash/sdl/v2/dependency.proto create mode 100644 proto/node/akash/sdl/v2/endpoint.proto create mode 100644 proto/node/akash/sdl/v2/expose.proto create mode 100644 proto/node/akash/sdl/v2/expose_to.proto create mode 100644 proto/node/akash/sdl/v2/gpu.proto create mode 100644 proto/node/akash/sdl/v2/http_options.proto create mode 100644 proto/node/akash/sdl/v2/memory.proto create mode 100644 proto/node/akash/sdl/v2/profiles.proto create mode 100644 proto/node/akash/sdl/v2/sdl.proto create mode 100644 proto/node/akash/sdl/v2/service.proto create mode 100644 proto/node/akash/sdl/v2/service_params.proto create mode 100644 proto/node/akash/sdl/v2/service_placement.proto create mode 100644 proto/node/akash/sdl/v2/storage.proto create mode 100644 testdata/v2.1/deployment.yaml create mode 100644 testdata/v2.1/ip-endpoint.yaml create mode 100644 testdata/v2.1/multi-groups-ip-endpoint.yaml create mode 100644 testdata/v2.1/multi-ip-endpoint.yaml create mode 100644 testdata/v2.1/private_service.yaml create mode 100644 testdata/v2.1/profile-svc-name-mismatch.yaml create mode 100644 testdata/v2.1/service-mix.yaml create mode 100644 testdata/v2.1/service-mix2.yaml create mode 100644 testdata/v2.1/shared-ip-endpoint.yaml create mode 100644 testdata/v2.1/simple-gpu.yaml create mode 100644 testdata/v2.1/simple-with-ip.yaml create mode 100644 testdata/v2.1/simple.yaml create mode 100644 testdata/v2.1/simple2.yaml create mode 100644 testdata/v2.1/simple3.yaml create mode 100644 testdata/v2.1/simple4.yaml create mode 100644 testdata/v2.1/svc-mismatch.yaml create mode 100644 testdata/v2/deployment-svc-mismatch.yaml create mode 100644 testdata/v2/deployment-v2-c2c.yaml create mode 100644 testdata/v2/deployment-v2-escrow.yaml create mode 100644 testdata/v2/deployment-v2-ip-endpoint.yaml create mode 100644 testdata/v2/deployment-v2-migrate.yaml create mode 100644 testdata/v2/deployment-v2-multi-groups-ip-endpoint.yaml create mode 100644 testdata/v2/deployment-v2-multi-ip-endpoint.yaml create mode 100644 testdata/v2/deployment-v2-newcontainer.yaml create mode 100644 testdata/v2/deployment-v2-nodeport.yaml create mode 100644 testdata/v2/deployment-v2-nohost.yaml create mode 100644 testdata/v2/deployment-v2-shared-ip-endpoint.yaml create mode 100644 testdata/v2/deployment-v2-storage-beta2.yaml create mode 100644 testdata/v2/deployment-v2-storage-default.yaml create mode 100644 testdata/v2/deployment-v2-storage-updateC.yaml create mode 100644 testdata/v2/deployment-v2-updateA.yaml create mode 100644 testdata/v2/deployment-v2-updateB.yaml create mode 100644 testdata/v2/deployment-v2.yaml create mode 100644 testdata/v2/deployment.yaml create mode 100644 testdata/v2/private_service.yaml create mode 100644 testdata/v2/profile-svc-name-mismatch.yaml create mode 100644 testdata/v2/service-mix.yaml create mode 100644 testdata/v2/service-mix2.yaml create mode 100644 testdata/v2/simple-double-ram.yaml create mode 100644 testdata/v2/simple-gpu.yaml create mode 100644 testdata/v2/simple-with-ip.yaml create mode 100644 testdata/v2/simple.yaml create mode 100644 testdata/v2/simple2.yaml create mode 100644 testdata/v2/simple3.yaml create mode 100644 testdata/v2/simple4.yaml create mode 100644 testdata/v2/storageClass1.yaml create mode 100644 testdata/v2/storageClass2.yaml create mode 100644 testdata/v2/storageClass3.yaml create mode 100644 testdata/v2/storageClass4.yaml create mode 100644 testdata/v2/storageClass5.yaml create mode 100644 testdata/v2/storageClass6.yaml diff --git a/docs/proto/node.md b/docs/proto/node.md index 5614aea7..12a11c3f 100644 --- a/docs/proto/node.md +++ b/docs/proto/node.md @@ -140,6 +140,126 @@ - [DenomTakeRate](#akash.take.v1beta3.DenomTakeRate) - [Params](#akash.take.v1beta3.Params) + - [akash/sdl/v2.1/http_options.proto](#akash/sdl/v2.1/http_options.proto) + - [HTTPOptions](#akash.sdl.v2_1.HTTPOptions) + + - [akash/sdl/v2.1/coin.proto](#akash/sdl/v2.1/coin.proto) + - [Coin](#akash.sdl.v2_1.Coin) + + - [akash/sdl/v2.1/memory.proto](#akash/sdl/v2.1/memory.proto) + - [ResourceMemory](#akash.sdl.v2_1.ResourceMemory) + + - [akash/sdl/v2.1/dependency.proto](#akash/sdl/v2.1/dependency.proto) + - [Dependency](#akash.sdl.v2_1.Dependency) + + - [akash/sdl/v2.1/service_params.proto](#akash/sdl/v2.1/service_params.proto) + - [ServiceParams](#akash.sdl.v2_1.ServiceParams) + - [ServiceParams.StorageEntry](#akash.sdl.v2_1.ServiceParams.StorageEntry) + - [ServiceStorageParams](#akash.sdl.v2_1.ServiceStorageParams) + + - [akash/sdl/v2.1/cpu.proto](#akash/sdl/v2.1/cpu.proto) + - [ResourceCPU](#akash.sdl.v2_1.ResourceCPU) + + - [akash/sdl/v2.1/profiles.proto](#akash/sdl/v2.1/profiles.proto) + - [ProfileCompute](#akash.sdl.v2_1.ProfileCompute) + - [ProfilePlacement](#akash.sdl.v2_1.ProfilePlacement) + - [ProfilePlacement.PricingEntry](#akash.sdl.v2_1.ProfilePlacement.PricingEntry) + - [Profiles](#akash.sdl.v2_1.Profiles) + - [Profiles.ComputeEntry](#akash.sdl.v2_1.Profiles.ComputeEntry) + - [Profiles.PlacementEntry](#akash.sdl.v2_1.Profiles.PlacementEntry) + + - [akash/sdl/v2.1/endpoint.proto](#akash/sdl/v2.1/endpoint.proto) + - [Endpoint](#akash.sdl.v2_1.Endpoint) + + - [akash/sdl/v2.1/service_placement.proto](#akash/sdl/v2.1/service_placement.proto) + - [ServicePlacement](#akash.sdl.v2_1.ServicePlacement) + + - [akash/sdl/v2.1/gpu.proto](#akash/sdl/v2.1/gpu.proto) + - [ResourceGPU](#akash.sdl.v2_1.ResourceGPU) + + - [akash/sdl/v2.1/storage.proto](#akash/sdl/v2.1/storage.proto) + - [ResourceStorage](#akash.sdl.v2_1.ResourceStorage) + + - [akash/sdl/v2.1/accept.proto](#akash/sdl/v2.1/accept.proto) + - [Accept](#akash.sdl.v2_1.Accept) + + - [akash/sdl/v2.1/expose.proto](#akash/sdl/v2.1/expose.proto) + - [Expose](#akash.sdl.v2_1.Expose) + + - [akash/sdl/v2.1/service.proto](#akash/sdl/v2.1/service.proto) + - [Service](#akash.sdl.v2_1.Service) + + - [akash/sdl/v2.1/sdl.proto](#akash/sdl/v2.1/sdl.proto) + - [content](#akash.sdl.v2_1.content) + - [content.EndpointsEntry](#akash.sdl.v2_1.content.EndpointsEntry) + - [content.ServicesEntry](#akash.sdl.v2_1.content.ServicesEntry) + + - [akash/sdl/v2.1/expose_to.proto](#akash/sdl/v2.1/expose_to.proto) + - [ExposeTo](#akash.sdl.v2_1.ExposeTo) + + - [akash/sdl/v2.1/compute_resources.proto](#akash/sdl/v2.1/compute_resources.proto) + - [ComputeResources](#akash.sdl.v2_1.ComputeResources) + + - [akash/sdl/v2/http_options.proto](#akash/sdl/v2/http_options.proto) + - [HTTPOptions](#akash.sdl.v2.HTTPOptions) + + - [akash/sdl/v2/coin.proto](#akash/sdl/v2/coin.proto) + - [Coin](#akash.sdl.v2.Coin) + + - [akash/sdl/v2/memory.proto](#akash/sdl/v2/memory.proto) + - [ResourceMemory](#akash.sdl.v2.ResourceMemory) + + - [akash/sdl/v2/dependency.proto](#akash/sdl/v2/dependency.proto) + - [Dependency](#akash.sdl.v2.Dependency) + + - [akash/sdl/v2/service_params.proto](#akash/sdl/v2/service_params.proto) + - [ServiceParams](#akash.sdl.v2.ServiceParams) + - [ServiceParams.StorageEntry](#akash.sdl.v2.ServiceParams.StorageEntry) + - [ServiceStorageParams](#akash.sdl.v2.ServiceStorageParams) + + - [akash/sdl/v2/cpu.proto](#akash/sdl/v2/cpu.proto) + - [ResourceCPU](#akash.sdl.v2.ResourceCPU) + + - [akash/sdl/v2/profiles.proto](#akash/sdl/v2/profiles.proto) + - [ProfileCompute](#akash.sdl.v2.ProfileCompute) + - [ProfilePlacement](#akash.sdl.v2.ProfilePlacement) + - [ProfilePlacement.PricingEntry](#akash.sdl.v2.ProfilePlacement.PricingEntry) + - [Profiles](#akash.sdl.v2.Profiles) + - [Profiles.ComputeEntry](#akash.sdl.v2.Profiles.ComputeEntry) + - [Profiles.PlacementEntry](#akash.sdl.v2.Profiles.PlacementEntry) + + - [akash/sdl/v2/endpoint.proto](#akash/sdl/v2/endpoint.proto) + - [Endpoint](#akash.sdl.v2.Endpoint) + + - [akash/sdl/v2/service_placement.proto](#akash/sdl/v2/service_placement.proto) + - [ServicePlacement](#akash.sdl.v2.ServicePlacement) + + - [akash/sdl/v2/gpu.proto](#akash/sdl/v2/gpu.proto) + - [ResourceGPU](#akash.sdl.v2.ResourceGPU) + + - [akash/sdl/v2/storage.proto](#akash/sdl/v2/storage.proto) + - [ResourceStorage](#akash.sdl.v2.ResourceStorage) + + - [akash/sdl/v2/accept.proto](#akash/sdl/v2/accept.proto) + - [Accept](#akash.sdl.v2.Accept) + + - [akash/sdl/v2/expose.proto](#akash/sdl/v2/expose.proto) + - [Expose](#akash.sdl.v2.Expose) + + - [akash/sdl/v2/service.proto](#akash/sdl/v2/service.proto) + - [Service](#akash.sdl.v2.Service) + + - [akash/sdl/v2/sdl.proto](#akash/sdl/v2/sdl.proto) + - [content](#akash.sdl.v2.content) + - [content.EndpointsEntry](#akash.sdl.v2.content.EndpointsEntry) + - [content.ServicesEntry](#akash.sdl.v2.content.ServicesEntry) + + - [akash/sdl/v2/expose_to.proto](#akash/sdl/v2/expose_to.proto) + - [ExposeTo](#akash.sdl.v2.ExposeTo) + + - [akash/sdl/v2/compute_resources.proto](#akash/sdl/v2/compute_resources.proto) + - [ComputeResources](#akash.sdl.v2.ComputeResources) + - [akash/deployment/v1beta3/groupmsg.proto](#akash/deployment/v1beta3/groupmsg.proto) - [MsgCloseGroup](#akash.deployment.v1beta3.MsgCloseGroup) - [MsgCloseGroupResponse](#akash.deployment.v1beta3.MsgCloseGroupResponse) @@ -2256,6 +2376,1415 @@ + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/http_options.proto + + + + + + ### HTTPOptions + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `max_body_size` | [uint32](#uint32) | | | + | `read_timeout` | [uint32](#uint32) | | | + | `send_timeout` | [uint32](#uint32) | | | + | `next_tries` | [uint32](#uint32) | | | + | `next_timeout` | [uint32](#uint32) | | | + | `next_cases` | [string](#string) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/coin.proto + + + + + + ### Coin + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `value` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/memory.proto + + + + + + ### ResourceMemory + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `quantity` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/dependency.proto + + + + + + ### Dependency + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `service` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/service_params.proto + + + + + + ### ServiceParams + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `Storage` | [ServiceParams.StorageEntry](#akash.sdl.v2_1.ServiceParams.StorageEntry) | repeated | | + + + + + + + + + ### ServiceParams.StorageEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ServiceStorageParams](#akash.sdl.v2_1.ServiceStorageParams) | | | + + + + + + + + + ### ServiceStorageParams + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `mount` | [string](#string) | | | + | `read_only` | [bool](#bool) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/cpu.proto + + + + + + ### ResourceCPU + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `units` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/profiles.proto + + + + + + ### ProfileCompute + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `resources` | [ComputeResources](#akash.sdl.v2_1.ComputeResources) | | | + + + + + + + + + ### ProfilePlacement + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + | `signed_by` | [akash.base.v1beta3.SignedBy](#akash.base.v1beta3.SignedBy) | | | + | `pricing` | [ProfilePlacement.PricingEntry](#akash.sdl.v2_1.ProfilePlacement.PricingEntry) | repeated | | + + + + + + + + + ### ProfilePlacement.PricingEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Coin](#akash.sdl.v2_1.Coin) | | | + + + + + + + + + ### Profiles + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `compute` | [Profiles.ComputeEntry](#akash.sdl.v2_1.Profiles.ComputeEntry) | repeated | | + | `placement` | [Profiles.PlacementEntry](#akash.sdl.v2_1.Profiles.PlacementEntry) | repeated | | + + + + + + + + + ### Profiles.ComputeEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ProfileCompute](#akash.sdl.v2_1.ProfileCompute) | | | + + + + + + + + + ### Profiles.PlacementEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ProfilePlacement](#akash.sdl.v2_1.ProfilePlacement) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/endpoint.proto + + + + + + ### Endpoint + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `kind` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/service_placement.proto + + + + + + ### ServicePlacement + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `profile` | [string](#string) | | | + | `count` | [uint32](#uint32) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/gpu.proto + + + + + + ### ResourceGPU + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `units` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/storage.proto + + + + + + ### ResourceStorage + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `name` | [string](#string) | | | + | `quantity` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/accept.proto + + + + + + ### Accept + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `items` | [string](#string) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/expose.proto + + + + + + ### Expose + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `port` | [uint32](#uint32) | | | + | `as` | [uint32](#uint32) | | | + | `proto` | [string](#string) | | | + | `to` | [ExposeTo](#akash.sdl.v2_1.ExposeTo) | repeated | | + | `accept` | [Accept](#akash.sdl.v2_1.Accept) | | | + | `http_options` | [HTTPOptions](#akash.sdl.v2_1.HTTPOptions) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/service.proto + + + + + + ### Service + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `image` | [string](#string) | | | + | `command` | [string](#string) | repeated | | + | `args` | [string](#string) | repeated | | + | `env` | [string](#string) | repeated | | + | `expose` | [Expose](#akash.sdl.v2_1.Expose) | repeated | | + | `dependencies` | [Dependency](#akash.sdl.v2_1.Dependency) | repeated | | + | `params` | [ServiceParams](#akash.sdl.v2_1.ServiceParams) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/sdl.proto + + + + + + ### content + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `include` | [string](#string) | | | + | `version` | [string](#string) | | | + | `services` | [content.ServicesEntry](#akash.sdl.v2_1.content.ServicesEntry) | repeated | | + | `profiles` | [Profiles](#akash.sdl.v2_1.Profiles) | | | + | `deployments` | [google.protobuf.Struct](#google.protobuf.Struct) | | | + | `endpoints` | [content.EndpointsEntry](#akash.sdl.v2_1.content.EndpointsEntry) | repeated | | + + + + + + + + + ### content.EndpointsEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Endpoint](#akash.sdl.v2_1.Endpoint) | | | + + + + + + + + + ### content.ServicesEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Service](#akash.sdl.v2_1.Service) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/expose_to.proto + + + + + + ### ExposeTo + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `service` | [string](#string) | | | + | `Global` | [bool](#bool) | | | + | `http_options` | [HTTPOptions](#akash.sdl.v2_1.HTTPOptions) | | | + | `ip` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2.1/compute_resources.proto + + + + + + ### ComputeResources + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `cpu` | [ResourceCPU](#akash.sdl.v2_1.ResourceCPU) | | | + | `gpu` | [ResourceGPU](#akash.sdl.v2_1.ResourceGPU) | | | + | `memory` | [ResourceMemory](#akash.sdl.v2_1.ResourceMemory) | | | + | `storage` | [ResourceStorage](#akash.sdl.v2_1.ResourceStorage) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/http_options.proto + + + + + + ### HTTPOptions + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `max_body_size` | [uint32](#uint32) | | | + | `read_timeout` | [uint32](#uint32) | | | + | `send_timeout` | [uint32](#uint32) | | | + | `next_tries` | [uint32](#uint32) | | | + | `next_timeout` | [uint32](#uint32) | | | + | `next_cases` | [string](#string) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/coin.proto + + + + + + ### Coin + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `value` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/memory.proto + + + + + + ### ResourceMemory + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `quantity` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/dependency.proto + + + + + + ### Dependency + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `service` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/service_params.proto + + + + + + ### ServiceParams + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `Storage` | [ServiceParams.StorageEntry](#akash.sdl.v2.ServiceParams.StorageEntry) | repeated | | + + + + + + + + + ### ServiceParams.StorageEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ServiceStorageParams](#akash.sdl.v2.ServiceStorageParams) | | | + + + + + + + + + ### ServiceStorageParams + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `mount` | [string](#string) | | | + | `read_only` | [bool](#bool) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/cpu.proto + + + + + + ### ResourceCPU + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `units` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/profiles.proto + + + + + + ### ProfileCompute + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `resources` | [ComputeResources](#akash.sdl.v2.ComputeResources) | | | + + + + + + + + + ### ProfilePlacement + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + | `signed_by` | [akash.base.v1beta3.SignedBy](#akash.base.v1beta3.SignedBy) | | | + | `pricing` | [ProfilePlacement.PricingEntry](#akash.sdl.v2.ProfilePlacement.PricingEntry) | repeated | | + + + + + + + + + ### ProfilePlacement.PricingEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Coin](#akash.sdl.v2.Coin) | | | + + + + + + + + + ### Profiles + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `compute` | [Profiles.ComputeEntry](#akash.sdl.v2.Profiles.ComputeEntry) | repeated | | + | `placement` | [Profiles.PlacementEntry](#akash.sdl.v2.Profiles.PlacementEntry) | repeated | | + + + + + + + + + ### Profiles.ComputeEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ProfileCompute](#akash.sdl.v2.ProfileCompute) | | | + + + + + + + + + ### Profiles.PlacementEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [ProfilePlacement](#akash.sdl.v2.ProfilePlacement) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/endpoint.proto + + + + + + ### Endpoint + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `kind` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/service_placement.proto + + + + + + ### ServicePlacement + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `profile` | [string](#string) | | | + | `count` | [uint32](#uint32) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/gpu.proto + + + + + + ### ResourceGPU + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `units` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/storage.proto + + + + + + ### ResourceStorage + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `name` | [string](#string) | | | + | `quantity` | [uint32](#uint32) | | | + | `attributes` | [akash.base.v1beta3.Attribute](#akash.base.v1beta3.Attribute) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/accept.proto + + + + + + ### Accept + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `items` | [string](#string) | repeated | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/expose.proto + + + + + + ### Expose + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `port` | [uint32](#uint32) | | | + | `as` | [uint32](#uint32) | | | + | `proto` | [string](#string) | | | + | `to` | [ExposeTo](#akash.sdl.v2.ExposeTo) | repeated | | + | `accept` | [Accept](#akash.sdl.v2.Accept) | | | + | `http_options` | [HTTPOptions](#akash.sdl.v2.HTTPOptions) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/service.proto + + + + + + ### Service + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `image` | [string](#string) | | | + | `command` | [string](#string) | repeated | | + | `args` | [string](#string) | repeated | | + | `env` | [string](#string) | repeated | | + | `expose` | [Expose](#akash.sdl.v2.Expose) | repeated | | + | `dependencies` | [Dependency](#akash.sdl.v2.Dependency) | repeated | | + | `params` | [ServiceParams](#akash.sdl.v2.ServiceParams) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/sdl.proto + + + + + + ### content + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `include` | [string](#string) | repeated | | + | `services` | [content.ServicesEntry](#akash.sdl.v2.content.ServicesEntry) | repeated | | + | `profiles` | [Profiles](#akash.sdl.v2.Profiles) | | | + | `deployments` | [google.protobuf.Struct](#google.protobuf.Struct) | | | + | `endpoints` | [content.EndpointsEntry](#akash.sdl.v2.content.EndpointsEntry) | repeated | | + + + + + + + + + ### content.EndpointsEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Endpoint](#akash.sdl.v2.Endpoint) | | | + + + + + + + + + ### content.ServicesEntry + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `key` | [string](#string) | | | + | `value` | [Service](#akash.sdl.v2.Service) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/expose_to.proto + + + + + + ### ExposeTo + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `service` | [string](#string) | | | + | `Global` | [bool](#bool) | | | + | `http_options` | [HTTPOptions](#akash.sdl.v2.HTTPOptions) | | | + | `ip` | [string](#string) | | | + + + + + + + + + + + + + + + + +

Top

+ + ## akash/sdl/v2/compute_resources.proto + + + + + + ### ComputeResources + + + + | Field | Type | Label | Description | + | ----- | ---- | ----- | ----------- | + | `cpu` | [ResourceCPU](#akash.sdl.v2.ResourceCPU) | | | + | `gpu` | [ResourceGPU](#akash.sdl.v2.ResourceGPU) | | | + | `memory` | [ResourceMemory](#akash.sdl.v2.ResourceMemory) | | | + | `storage` | [ResourceStorage](#akash.sdl.v2.ResourceStorage) | repeated | | + + + + + diff --git a/go.mod b/go.mod index 22fc277c..f3c48333 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.21 require ( github.com/99designs/keyring v1.2.1 + github.com/blang/semver/v4 v4.0.0 github.com/boz/go-lifecycle v0.1.1 github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 github.com/cosmos/cosmos-sdk v0.45.16 @@ -63,7 +64,7 @@ require ( github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash v1.1.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 // indirect @@ -73,18 +74,16 @@ require ( github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.5 // indirect github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -94,8 +93,8 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -103,14 +102,13 @@ require ( github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect - github.com/hashicorp/hcl v1.0.1-0.20191016231534-914dc3f8dd7c // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/huandu/xstrings v1.0.0 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/jmhodges/levigo v1.0.1-0.20191019112844-b572e7f4cdac // indirect + github.com/jmhodges/levigo v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.11 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -128,7 +126,7 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect @@ -145,20 +143,21 @@ require ( github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tendermint/tm-db v0.6.7 // indirect + github.com/tendermint/tm-db v0.6.6 // indirect github.com/tidwall/btree v1.5.0 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.15.0 // indirect golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect - golang.org/x/net v0.18.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.14.0 // indirect golang.org/x/term v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 3a3f74c3..b87daf9e 100644 --- a/go.sum +++ b/go.sum @@ -55,6 +55,7 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3 github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -98,6 +99,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boz/go-lifecycle v0.1.1 h1:tG/wff7Zxbkf19g4D4I0G8Y4sq83iT5QjD4rzEf/zrI= github.com/boz/go-lifecycle v0.1.1/go.mod h1:zdagAUMcC2C0OmQkBlJZFV77uF4GCVaGphAexGi7oho= github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= @@ -119,9 +122,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -167,8 +169,6 @@ github.com/cosmos/cosmos-sdk v0.45.16/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= -github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= @@ -188,9 +188,8 @@ github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuA github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= @@ -198,6 +197,7 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= @@ -224,8 +224,8 @@ github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpm github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= -github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= +github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= @@ -320,6 +320,7 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -343,8 +344,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -362,8 +363,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -392,18 +393,16 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl v1.0.1-0.20191016231534-914dc3f8dd7c h1:PdZEHcpa3117kJ1Wa5EYupzCzn9QlBby8Fx2YpZPYvo= -github.com/hashicorp/hcl v1.0.1-0.20191016231534-914dc3f8dd7c/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -428,8 +427,8 @@ github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7Ua github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmhodges/levigo v1.0.1-0.20191019112844-b572e7f4cdac h1:GcJkaxD5Wy/Ucn+L0USlpbGJy9O6+7r0nBI7ftJ7Uu0= -github.com/jmhodges/levigo v1.0.1-0.20191019112844-b572e7f4cdac/go.mod h1:dM7ihgFM8Do6WGIfOXWPgpJ+4bKGR/4ZkYh8HKDdFy4= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= +github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -576,9 +575,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -685,14 +683,15 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= -github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= +github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM= +github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= github.com/tidwall/btree v1.5.0 h1:iV0yVY/frd7r6qGBXfEYs7DH0gTDgrKTrDjS7xt/IyQ= github.com/tidwall/btree v1.5.0/go.mod h1:LGm8L/DZjPLmeWGjv5kFrY8dL4uVhMmzmmLYmsObdKE= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -839,8 +838,8 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1083,12 +1082,12 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= +google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 h1:I6WNifs6pF9tNdSob2W24JtyxIYjzFB9qDlpUC76q+U= +google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405/go.mod h1:3WDQMjmJk36UQhjQ89emUzb1mdaHcPeeAh4SCBKznB4= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= diff --git a/go/sdl/sdl.go b/go/sdl/sdl.go new file mode 100644 index 00000000..6383085c --- /dev/null +++ b/go/sdl/sdl.go @@ -0,0 +1,162 @@ +package sdl + +import ( + "errors" + "fmt" + "os" + + "github.com/blang/semver/v4" + "gopkg.in/yaml.v3" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + "github.com/akash-network/akash-api/go/sdl/v2" + "github.com/akash-network/akash-api/go/sdl/v2_1" +) + +const ( + sdlVersionField = "version" +) + +var ( + errSDLInvalid = errors.New("sdl: invalid") + errUninitializedConfig = errors.New("sdl: uninitialized") + errSDLInvalidNoVersion = fmt.Errorf("no version found: %w", errSDLInvalid) +) + +// SDL is the interface which wraps Validate, Deployment and Manifest methods +type SDL interface { + DeploymentGroups() (dtypes.GroupSpecs, error) + Manifest() (manifest.Manifest, error) + Version() ([]byte, error) + Validate() error +} + +var _ SDL = (*sdl)(nil) + +type sdl struct { + Ver semver.Version `yaml:"version,-"` + data SDL `yaml:"-"` +} + +func (s *sdl) UnmarshalYAML(node *yaml.Node) error { + var result sdl + + foundVersion := false + for idx := range node.Content { + if node.Content[idx].Value == sdlVersionField { + var err error + if result.Ver, err = semver.ParseTolerant(node.Content[idx+1].Value); err != nil { + return err + } + foundVersion = true + break + } + } + + if !foundVersion { + return errSDLInvalidNoVersion + } + + // nolint: gocritic + if result.Ver.EQ(semver.MustParse("2.0.0")) { + var decoded v2.SDL + if err := node.Decode(&decoded); err != nil { + return err + } + + result.data = &decoded + } else if result.Ver.GE(semver.MustParse("2.1.0")) { + var decoded v2_1.SDL + if err := node.Decode(&decoded); err != nil { + return err + } + + result.data = &decoded + } else { + return fmt.Errorf("%w: config: unsupported version %q", errSDLInvalid, result.Ver) + } + + *s = result + + return nil +} + +// ReadFile read from given path and returns SDL instance +func ReadFile(path string) (SDL, error) { + buf, err := os.ReadFile(path) + if err != nil { + return nil, err + } + return Read(buf) +} + +// Read reads buffer data and returns SDL instance +func Read(buf []byte) (SDL, error) { + obj := &sdl{} + if err := yaml.Unmarshal(buf, obj); err != nil { + return nil, err + } + + if err := obj.Validate(); err != nil { + return nil, err + } + + // dgroups, err := obj.DeploymentGroups() + // if err != nil { + // return nil, err + // } + // + // vgroups := make([]dtypes.GroupSpec, 0, len(dgroups)) + // for _, dgroup := range dgroups { + // vgroups = append(vgroups, *dgroup) + // } + // + // if err := dtypes.ValidateDeploymentGroups(vgroups); err != nil { + // return nil, err + // } + // + // m, err := obj.Manifest() + // if err != nil { + // return nil, err + // } + // + // if err := m.Validate(); err != nil { + // return nil, err + // } + + return obj, nil +} + +// Version creates the deterministic Deployment Version hash from the SDL. +func (s *sdl) Version() ([]byte, error) { + if s.data == nil { + return nil, errUninitializedConfig + } + + return s.data.Version() +} + +func (s *sdl) DeploymentGroups() (dtypes.GroupSpecs, error) { + if s.data == nil { + return dtypes.GroupSpecs{}, errUninitializedConfig + } + + return s.data.DeploymentGroups() +} + +func (s *sdl) Manifest() (manifest.Manifest, error) { + if s.data == nil { + return manifest.Manifest{}, errUninitializedConfig + } + + return s.data.Manifest() +} + +func (s *sdl) Validate() error { + if s.data == nil { + return errUninitializedConfig + } + + return s.data.Validate() +} diff --git a/go/sdl/sdl_test.go b/go/sdl/sdl_test.go new file mode 100644 index 00000000..24652cb3 --- /dev/null +++ b/go/sdl/sdl_test.go @@ -0,0 +1,59 @@ +package sdl + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestSDLManifestVersion(t *testing.T) { + obj, err := ReadFile("../../testdata/v2/simple.yaml") + require.NoError(t, err) + + m, err := obj.Manifest() + require.NoError(t, err) + + version, err := m.Version() + require.NoError(t, err) + // Should return a value + require.NotEmpty(t, version) + + obj, err = ReadFile("../../testdata/v2/private_service.yaml") + require.NoError(t, err) + + m, err = obj.Manifest() + require.NoError(t, err) + + secondVersion, err := m.Version() + require.NoError(t, err) + // Should return a value + require.NotEmpty(t, secondVersion) + // Should be different from the first + require.NotEqual(t, secondVersion, version) +} + +func TestSDLManifestVersionChangesWithVersion(t *testing.T) { + obj, err := ReadFile("../../testdata/v2/simple.yaml") + require.NoError(t, err) + + m, err := obj.Manifest() + require.NoError(t, err) + + version, err := m.Version() + require.NoError(t, err) + // Should return a value + require.NotEmpty(t, version) + + obj, err = ReadFile("../../testdata/v2/simple-double-ram.yaml") + require.NoError(t, err) + + m, err = obj.Manifest() + require.NoError(t, err) + + secondVersion, err := m.Version() + require.NoError(t, err) + // Should return a value + require.NotEmpty(t, secondVersion) + // Should be different from the first + require.NotEqual(t, secondVersion, version) +} diff --git a/go/sdl/v2/accept.go b/go/sdl/v2/accept.go new file mode 100644 index 00000000..e5f53dfe --- /dev/null +++ b/go/sdl/v2/accept.go @@ -0,0 +1,24 @@ +package v2 + +import ( + "net/url" + + "gopkg.in/yaml.v3" +) + +func (p *Accept) UnmarshalYAML(node *yaml.Node) error { + var accept []string + if err := node.Decode(&accept); err != nil { + return err + } + + for _, item := range accept { + if _, err := url.ParseRequestURI("http://" + item); err != nil { + return err + } + } + + p.Items = accept + + return nil +} diff --git a/go/sdl/v2/accept.pb.go b/go/sdl/v2/accept.pb.go new file mode 100644 index 00000000..980cf26e --- /dev/null +++ b/go/sdl/v2/accept.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/accept.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Accept struct { + Items []string `protobuf:"bytes,1,rep,name=items,proto3" json:"items" yaml:"items"` +} + +func (m *Accept) Reset() { *m = Accept{} } +func (m *Accept) String() string { return proto.CompactTextString(m) } +func (*Accept) ProtoMessage() {} +func (*Accept) Descriptor() ([]byte, []int) { + return fileDescriptor_5df2b9576cd847d5, []int{0} +} +func (m *Accept) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Accept) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Accept.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Accept) XXX_Merge(src proto.Message) { + xxx_messageInfo_Accept.Merge(m, src) +} +func (m *Accept) XXX_Size() int { + return m.Size() +} +func (m *Accept) XXX_DiscardUnknown() { + xxx_messageInfo_Accept.DiscardUnknown(m) +} + +var xxx_messageInfo_Accept proto.InternalMessageInfo + +func (m *Accept) GetItems() []string { + if m != nil { + return m.Items + } + return nil +} + +func init() { + proto.RegisterType((*Accept)(nil), "akash.sdl.v2.Accept") +} + +func init() { proto.RegisterFile("akash/sdl/v2/accept.proto", fileDescriptor_5df2b9576cd847d5) } + +var fileDescriptor_5df2b9576cd847d5 = []byte{ + // 193 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, 0x28, 0xd1, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x4b, 0xe9, 0x15, 0xa7, 0xe4, 0xe8, 0x95, 0x19, + 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x25, 0x27, 0x2e, + 0x36, 0x47, 0xb0, 0x1e, 0x21, 0x0b, 0x2e, 0xd6, 0xcc, 0x92, 0xd4, 0xdc, 0x62, 0x09, 0x46, 0x05, + 0x66, 0x0d, 0x4e, 0x27, 0xa5, 0x47, 0xf7, 0xe4, 0x59, 0x3d, 0x41, 0x02, 0xaf, 0xee, 0xc9, 0x43, + 0x64, 0x3e, 0xdd, 0x93, 0xe7, 0xa9, 0x4c, 0xcc, 0xcd, 0xb1, 0x52, 0x02, 0x73, 0x95, 0x82, 0x20, + 0xc2, 0x4e, 0x6e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, + 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x93, 0x9e, + 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x76, 0x8c, 0x6e, 0x5e, 0x6a, 0x49, + 0x79, 0x7e, 0x51, 0x36, 0x94, 0x97, 0x58, 0x90, 0xa9, 0x9f, 0x9e, 0x0f, 0x75, 0x7c, 0x12, 0x1b, + 0xd8, 0x49, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x13, 0xbd, 0x83, 0xd3, 0x00, 0x00, + 0x00, +} + +func (m *Accept) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Accept) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Accept) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Items[iNdEx]) + copy(dAtA[i:], m.Items[iNdEx]) + i = encodeVarintAccept(dAtA, i, uint64(len(m.Items[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintAccept(dAtA []byte, offset int, v uint64) int { + offset -= sovAccept(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Accept) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Items) > 0 { + for _, s := range m.Items { + l = len(s) + n += 1 + l + sovAccept(uint64(l)) + } + } + return n +} + +func sovAccept(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAccept(x uint64) (n int) { + return sovAccept(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Accept) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccept + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Accept: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Accept: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccept + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAccept + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAccept + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAccept(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAccept + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAccept(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAccept + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAccept + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAccept + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAccept = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAccept = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAccept = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/coin.go b/go/sdl/v2/coin.go new file mode 100644 index 00000000..7731c3fb --- /dev/null +++ b/go/sdl/v2/coin.go @@ -0,0 +1,41 @@ +package v2 + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v3" +) + +func (sdl *Coin) UnmarshalYAML(node *yaml.Node) error { + parsedCoin := struct { + Amount string `yaml:"amount"` + Denom string `yaml:"denom"` + }{} + + if err := node.Decode(&parsedCoin); err != nil { + return err + } + + amount, err := sdk.NewDecFromStr(parsedCoin.Amount) + if err != nil { + return err + } + + if amount.IsZero() { + return fmt.Errorf("%w: amount is zero", errInvalidCoinAmount) + } + + // Never pass negative amounts to cosmos SDK DecCoin + if amount.IsNegative() { + return fmt.Errorf("%w: amount %q is negative", errNegativeValue, amount.String()) + } + + coin := sdk.NewDecCoinFromDec(parsedCoin.Denom, amount) + + *sdl = Coin{ + Value: coin, + } + + return nil +} diff --git a/go/sdl/v2/coin.pb.go b/go/sdl/v2/coin.pb.go new file mode 100644 index 00000000..723bbca3 --- /dev/null +++ b/go/sdl/v2/coin.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/coin.proto + +package v2 + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Coin struct { + Value types.DecCoin `protobuf:"bytes,1,opt,name=value,proto3" json:"value" yaml:"value"` +} + +func (m *Coin) Reset() { *m = Coin{} } +func (m *Coin) String() string { return proto.CompactTextString(m) } +func (*Coin) ProtoMessage() {} +func (*Coin) Descriptor() ([]byte, []int) { + return fileDescriptor_536f3f7d1ce6d812, []int{0} +} +func (m *Coin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Coin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Coin.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Coin) XXX_Merge(src proto.Message) { + xxx_messageInfo_Coin.Merge(m, src) +} +func (m *Coin) XXX_Size() int { + return m.Size() +} +func (m *Coin) XXX_DiscardUnknown() { + xxx_messageInfo_Coin.DiscardUnknown(m) +} + +var xxx_messageInfo_Coin proto.InternalMessageInfo + +func (m *Coin) GetValue() types.DecCoin { + if m != nil { + return m.Value + } + return types.DecCoin{} +} + +func init() { + proto.RegisterType((*Coin)(nil), "akash.sdl.v2.Coin") +} + +func init() { proto.RegisterFile("akash/sdl/v2/coin.proto", fileDescriptor_536f3f7d1ce6d812) } + +var fileDescriptor_536f3f7d1ce6d812 = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x4f, 0xce, 0xcf, 0xcc, 0xd3, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x4b, 0xe8, 0x15, 0xa7, 0xe4, 0xe8, 0x95, 0x19, 0x49, 0x89, + 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0xb9, 0xe4, 0xfc, 0xe2, + 0xdc, 0xfc, 0x62, 0xfd, 0xa4, 0xc4, 0xe2, 0x54, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x43, + 0x24, 0x33, 0x94, 0x92, 0xb8, 0x58, 0x9c, 0xf3, 0x33, 0xf3, 0x84, 0xa2, 0xb8, 0x58, 0xcb, 0x12, + 0x73, 0x4a, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, 0xf4, 0x20, 0xfa, 0xf4, 0x40, + 0xfa, 0xf4, 0xa0, 0xfa, 0xf4, 0x5c, 0x52, 0x93, 0x41, 0x8a, 0x9d, 0xd4, 0x4e, 0xdc, 0x93, 0x67, + 0x78, 0x74, 0x4f, 0x9e, 0x35, 0x0c, 0xa4, 0xe5, 0xd5, 0x3d, 0x79, 0x88, 0xde, 0x4f, 0xf7, 0xe4, + 0x79, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0xc0, 0x5c, 0xa5, 0x20, 0x88, 0xb0, 0x93, 0xdb, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x3d, 0xa3, 0x9b, 0x97, 0x5a, 0x52, 0x9e, 0x5f, 0x94, 0x0d, + 0xe5, 0x25, 0x16, 0x64, 0xea, 0xa7, 0xe7, 0x43, 0xbd, 0x9e, 0xc4, 0x06, 0x76, 0xb2, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x2f, 0xc1, 0x21, 0xed, 0x11, 0x01, 0x00, 0x00, +} + +func (m *Coin) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Coin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Coin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCoin(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintCoin(dAtA []byte, offset int, v uint64) int { + offset -= sovCoin(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Coin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Value.Size() + n += 1 + l + sovCoin(uint64(l)) + return n +} + +func sovCoin(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCoin(x uint64) (n int) { + return sovCoin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Coin) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Coin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Coin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCoin + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCoin(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCoin + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCoin + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCoin + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCoin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCoin = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCoin = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/coin_test.go b/go/sdl/v2/coin_test.go new file mode 100644 index 00000000..4c917a96 --- /dev/null +++ b/go/sdl/v2/coin_test.go @@ -0,0 +1,34 @@ +package v2 + +// func TestPricing(t *testing.T) { +// lessThanOne, err := sdk.NewDecFromStr("0.7") +// require.NoError(t, err) +// tests := []struct { +// text string +// value sdk.DecCoin +// err bool +// }{ +// {"amount: 1\ndenom: uakt", sdk.NewDecCoin("uakt", sdk.NewInt(1)), false}, +// {"amount: -1\ndenom: uakt", sdk.NewDecCoin("uakt", sdk.NewInt(1)), true}, +// {"amount: 0.7\ndenom: uakt", sdk.NewDecCoinFromDec("uakt", lessThanOne), false}, +// {"amount: -0.7\ndenom: uakt", sdk.NewDecCoin("uakt", sdk.NewInt(0)), true}, +// } +// +// for idx, test := range tests { +// buf := []byte(test.text) +// obj := &Coin{} +// +// err := yaml.Unmarshal(buf, obj) +// +// if test.err { +// assert.Error(t, err, "idx:%v text:`%v`", idx, test.text) +// continue +// } +// +// if !assert.NoError(t, err, "idx:%v text:`%v`", idx, test.text) { +// continue +// } +// +// assert.Equal(t, test.value, obj.Value, "idx:%v text:`%v`", idx, test.text) +// } +// } diff --git a/go/sdl/v2/compute_resources.go b/go/sdl/v2/compute_resources.go new file mode 100644 index 00000000..ed4a7ce8 --- /dev/null +++ b/go/sdl/v2/compute_resources.go @@ -0,0 +1,52 @@ +package v2 + +import ( + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func (sdl *ComputeResources) toResources() types.Resources { + if sdl == nil { + return types.Resources{} + } + + units := types.Resources{ + Endpoints: types.Endpoints{}, + } + + if sdl.CPU != nil { + units.CPU = &types.CPU{ + Units: types.NewResourceValue(uint64(sdl.CPU.Units)), + Attributes: types.Attributes(sdl.CPU.Attributes), + } + } + + if sdl.GPU != nil { + units.GPU = &types.GPU{ + Units: types.NewResourceValue(uint64(sdl.GPU.Units)), + Attributes: types.Attributes(sdl.GPU.Attributes), + } + } else { + units.GPU = &types.GPU{ + Units: types.NewResourceValue(0), + } + } + + if sdl.Memory != nil { + units.Memory = &types.Memory{ + Quantity: types.NewResourceValue(uint64(sdl.Memory.Quantity)), + Attributes: types.Attributes(sdl.Memory.Attributes), + } + } + + for _, storage := range sdl.Storage { + storageEntry := types.Storage{ + Name: storage.Name, + Quantity: types.NewResourceValue(uint64(storage.Quantity)), + Attributes: types.Attributes(storage.Attributes), + } + + units.Storage = append(units.Storage, storageEntry) + } + + return units +} diff --git a/go/sdl/v2/compute_resources.pb.go b/go/sdl/v2/compute_resources.pb.go new file mode 100644 index 00000000..540004cf --- /dev/null +++ b/go/sdl/v2/compute_resources.pb.go @@ -0,0 +1,522 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/compute_resources.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ComputeResources struct { + CPU *ResourceCPU `protobuf:"bytes,1,opt,name=cpu,proto3" json:"cpu" yaml:"cpu"` + GPU *ResourceGPU `protobuf:"bytes,2,opt,name=gpu,proto3" json:"gpu" yaml:"gpu"` + Memory *ResourceMemory `protobuf:"bytes,3,opt,name=memory,proto3" json:"memory" yaml:"memory"` + Storage StorageArray `protobuf:"bytes,4,rep,name=storage,proto3,castrepeated=StorageArray" json:"storage" yaml:"storage"` +} + +func (m *ComputeResources) Reset() { *m = ComputeResources{} } +func (m *ComputeResources) String() string { return proto.CompactTextString(m) } +func (*ComputeResources) ProtoMessage() {} +func (*ComputeResources) Descriptor() ([]byte, []int) { + return fileDescriptor_311f2013b307f858, []int{0} +} +func (m *ComputeResources) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ComputeResources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ComputeResources.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ComputeResources) XXX_Merge(src proto.Message) { + xxx_messageInfo_ComputeResources.Merge(m, src) +} +func (m *ComputeResources) XXX_Size() int { + return m.Size() +} +func (m *ComputeResources) XXX_DiscardUnknown() { + xxx_messageInfo_ComputeResources.DiscardUnknown(m) +} + +var xxx_messageInfo_ComputeResources proto.InternalMessageInfo + +func (m *ComputeResources) GetCPU() *ResourceCPU { + if m != nil { + return m.CPU + } + return nil +} + +func (m *ComputeResources) GetGPU() *ResourceGPU { + if m != nil { + return m.GPU + } + return nil +} + +func (m *ComputeResources) GetMemory() *ResourceMemory { + if m != nil { + return m.Memory + } + return nil +} + +func (m *ComputeResources) GetStorage() StorageArray { + if m != nil { + return m.Storage + } + return nil +} + +func init() { + proto.RegisterType((*ComputeResources)(nil), "akash.sdl.v2.ComputeResources") +} + +func init() { + proto.RegisterFile("akash/sdl/v2/compute_resources.proto", fileDescriptor_311f2013b307f858) +} + +var fileDescriptor_311f2013b307f858 = []byte{ + // 379 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x6a, 0xea, 0x40, + 0x18, 0x85, 0x93, 0x9b, 0x8b, 0x42, 0xf4, 0x5e, 0x2e, 0xe1, 0x52, 0xa2, 0xb4, 0x19, 0x09, 0x5d, + 0x58, 0x68, 0x13, 0x48, 0x77, 0xa5, 0x9b, 0x46, 0xa8, 0x2b, 0x41, 0x52, 0xdc, 0x74, 0x23, 0x31, + 0x86, 0x51, 0x34, 0x9d, 0x61, 0x92, 0xb1, 0xf8, 0x06, 0x5d, 0xf6, 0x39, 0xfa, 0x24, 0x2e, 0x5d, + 0x76, 0x35, 0x2d, 0x71, 0xe7, 0xd2, 0x27, 0x28, 0x99, 0x99, 0x14, 0x05, 0xe9, 0x2e, 0xff, 0x39, + 0x67, 0xbe, 0x39, 0x99, 0x5f, 0x3f, 0x0f, 0x67, 0x61, 0x3a, 0x71, 0xd3, 0xf1, 0xdc, 0x5d, 0x78, + 0x6e, 0x84, 0x12, 0x4c, 0xb3, 0x78, 0x48, 0xe2, 0x14, 0x51, 0x12, 0xc5, 0xa9, 0x83, 0x09, 0xca, + 0x90, 0x51, 0xe7, 0x29, 0x27, 0x1d, 0xcf, 0x9d, 0x85, 0xd7, 0xfc, 0x0f, 0x11, 0x44, 0xdc, 0x70, + 0x8b, 0x2f, 0x91, 0x69, 0x9e, 0x1c, 0x92, 0x30, 0x3d, 0xaa, 0xc3, 0x6f, 0xbd, 0x71, 0xa0, 0x27, + 0x71, 0x82, 0xc8, 0x52, 0x5a, 0xcd, 0x03, 0x2b, 0xcd, 0x10, 0x09, 0x61, 0x2c, 0x3c, 0xfb, 0x45, + 0xd3, 0xff, 0x75, 0x44, 0xcd, 0xa0, 0x6c, 0x69, 0xf4, 0x74, 0x2d, 0xc2, 0xd4, 0x54, 0x5b, 0x6a, + 0xbb, 0xe6, 0x35, 0x9c, 0xfd, 0xb6, 0x4e, 0x99, 0xea, 0xf4, 0x07, 0x7e, 0x6b, 0xc5, 0x80, 0x9a, + 0x33, 0xa0, 0x75, 0xfa, 0x83, 0x2d, 0x03, 0xc5, 0xa1, 0x1d, 0x03, 0xfa, 0x32, 0x4c, 0xe6, 0x37, + 0x76, 0x84, 0xa9, 0x1d, 0x14, 0x52, 0x81, 0x83, 0x98, 0x9a, 0xbf, 0x7e, 0xc2, 0x75, 0xf7, 0x71, + 0x5d, 0x81, 0x83, 0xfb, 0x38, 0xc8, 0x71, 0x10, 0x53, 0x63, 0xa8, 0x57, 0xc4, 0xef, 0x99, 0x1a, + 0x27, 0x9e, 0x1e, 0x27, 0xf6, 0x78, 0xc6, 0xbf, 0x90, 0xd0, 0x8a, 0x98, 0xb7, 0x0c, 0xc8, 0xd3, + 0x3b, 0x06, 0xfe, 0x08, 0xb4, 0x98, 0xed, 0x40, 0x1a, 0x06, 0xd5, 0xab, 0xf2, 0x91, 0xcc, 0xdf, + 0x2d, 0xad, 0x5d, 0xf3, 0xce, 0x8e, 0xdf, 0xf0, 0x20, 0x42, 0xfe, 0xed, 0x8a, 0x01, 0x25, 0x67, + 0xa0, 0x2a, 0x85, 0x2d, 0x03, 0x25, 0x60, 0xc7, 0xc0, 0x5f, 0x71, 0x89, 0x14, 0xec, 0xb7, 0x0f, + 0x50, 0x97, 0xb9, 0x3b, 0x42, 0xc2, 0x65, 0x50, 0x46, 0xfd, 0xfb, 0x55, 0x6e, 0xa9, 0xeb, 0xdc, + 0x52, 0x3f, 0x73, 0x4b, 0x7d, 0xdd, 0x58, 0xca, 0x7a, 0x63, 0x29, 0xef, 0x1b, 0x4b, 0x79, 0xbc, + 0x84, 0xd3, 0x6c, 0x42, 0x47, 0x4e, 0x84, 0x12, 0x97, 0x37, 0xb9, 0x7a, 0x8a, 0xb3, 0x67, 0x44, + 0x66, 0x72, 0x0a, 0xf1, 0xd4, 0x85, 0x48, 0x2e, 0x78, 0x54, 0xe1, 0x9b, 0xbd, 0xfe, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0xa3, 0xa7, 0x32, 0x31, 0x8c, 0x02, 0x00, 0x00, +} + +func (m *ComputeResources) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ComputeResources) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ComputeResources) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Storage) > 0 { + for iNdEx := len(m.Storage) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Storage[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.Memory != nil { + { + size, err := m.Memory.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.GPU != nil { + { + size, err := m.GPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CPU != nil { + { + size, err := m.CPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintComputeResources(dAtA []byte, offset int, v uint64) int { + offset -= sovComputeResources(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ComputeResources) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CPU != nil { + l = m.CPU.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if m.GPU != nil { + l = m.GPU.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if m.Memory != nil { + l = m.Memory.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if len(m.Storage) > 0 { + for _, e := range m.Storage { + l = e.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + } + return n +} + +func sovComputeResources(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozComputeResources(x uint64) (n int) { + return sovComputeResources(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ComputeResources) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ComputeResources: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ComputeResources: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CPU == nil { + m.CPU = &ResourceCPU{} + } + if err := m.CPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.GPU == nil { + m.GPU = &ResourceGPU{} + } + if err := m.GPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Memory", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Memory == nil { + m.Memory = &ResourceMemory{} + } + if err := m.Memory.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Storage = append(m.Storage, ResourceStorage{}) + if err := m.Storage[len(m.Storage)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipComputeResources(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthComputeResources + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipComputeResources(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthComputeResources + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupComputeResources + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthComputeResources + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthComputeResources = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowComputeResources = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupComputeResources = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/cpu.go b/go/sdl/v2/cpu.go new file mode 100644 index 00000000..2074ba2e --- /dev/null +++ b/go/sdl/v2/cpu.go @@ -0,0 +1,42 @@ +package v2 + +import ( + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type cpuAttributes types.Attributes + +func (sdl *cpuAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr cpuAttributes + + for i := 0; i+1 < len(node.Content); i += 2 { + var value string + switch node.Content[i].Value { + case "arch": + if err := node.Content[i+1].Decode(&value); err != nil { + return err + } + default: + return fmt.Errorf("unsupported cpu attribute \"%s\"", node.Content[i].Value) + } + + attr = append(attr, types.Attribute{ + Key: node.Content[i].Value, + Value: value, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Slice(attr, func(i, j int) bool { + return attr[i].Key < attr[j].Key + }) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2/cpu.pb.go b/go/sdl/v2/cpu.pb.go new file mode 100644 index 00000000..a8f7b224 --- /dev/null +++ b/go/sdl/v2/cpu.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/cpu.proto + +package v2 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceCPU struct { + Units cpuQuantity `protobuf:"varint,1,opt,name=units,proto3,casttype=cpuQuantity" json:"units" yaml:"units"` + Attributes cpuAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=cpuAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceCPU) Reset() { *m = ResourceCPU{} } +func (m *ResourceCPU) String() string { return proto.CompactTextString(m) } +func (*ResourceCPU) ProtoMessage() {} +func (*ResourceCPU) Descriptor() ([]byte, []int) { + return fileDescriptor_4d87070d7e47d2ed, []int{0} +} +func (m *ResourceCPU) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceCPU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceCPU.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceCPU) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceCPU.Merge(m, src) +} +func (m *ResourceCPU) XXX_Size() int { + return m.Size() +} +func (m *ResourceCPU) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceCPU.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceCPU proto.InternalMessageInfo + +func (m *ResourceCPU) GetUnits() cpuQuantity { + if m != nil { + return m.Units + } + return 0 +} + +func (m *ResourceCPU) GetAttributes() cpuAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceCPU)(nil), "akash.sdl.v2.ResourceCPU") +} + +func init() { proto.RegisterFile("akash/sdl/v2/cpu.proto", fileDescriptor_4d87070d7e47d2ed) } + +var fileDescriptor_4d87070d7e47d2ed = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x6e, 0xf2, 0x30, + 0x14, 0x85, 0xe3, 0xff, 0x17, 0x1d, 0x0c, 0x0c, 0x45, 0x55, 0x85, 0x90, 0x6a, 0xa3, 0x4c, 0x0c, + 0xad, 0x2d, 0x60, 0xeb, 0x56, 0x2a, 0xd1, 0xb5, 0x45, 0x62, 0xe9, 0xe6, 0x04, 0x2b, 0x44, 0x84, + 0x38, 0x8a, 0xed, 0x54, 0x3c, 0x40, 0xf7, 0x3e, 0x47, 0x9f, 0x84, 0x91, 0xb1, 0x93, 0x5b, 0x25, + 0x5b, 0x47, 0xc6, 0x4e, 0x55, 0xe2, 0x14, 0xd8, 0x7c, 0xcf, 0x3d, 0xc7, 0xe7, 0xd3, 0x85, 0x97, + 0x6c, 0xc5, 0xe4, 0x92, 0xca, 0x45, 0x44, 0xb3, 0x11, 0xf5, 0x13, 0x4d, 0x92, 0x54, 0x28, 0xd1, + 0x69, 0x55, 0x3a, 0x91, 0x8b, 0x88, 0x64, 0xa3, 0xde, 0x45, 0x20, 0x02, 0x51, 0x2d, 0x68, 0xf9, + 0xb2, 0x9e, 0x9e, 0x6b, 0xb3, 0x1e, 0x93, 0x9c, 0x66, 0x43, 0x8f, 0x2b, 0x36, 0xa6, 0x4c, 0xa9, + 0x34, 0xf4, 0xb4, 0xe2, 0xd6, 0xe3, 0x1a, 0x00, 0x9b, 0x33, 0x2e, 0x85, 0x4e, 0x7d, 0x7e, 0xff, + 0x38, 0xef, 0x3c, 0xc0, 0x86, 0x8e, 0x43, 0x25, 0xbb, 0xa0, 0x0f, 0x06, 0xed, 0xc9, 0x30, 0x37, + 0xb8, 0x31, 0x2f, 0x85, 0x6f, 0x83, 0xed, 0x66, 0x6f, 0x70, 0x6b, 0xc3, 0xd6, 0xd1, 0xad, 0x5b, + 0x8d, 0xee, 0x8f, 0xc1, 0x4d, 0x3f, 0xd1, 0x4f, 0x9a, 0xc5, 0x2a, 0x54, 0x9b, 0x99, 0x75, 0x75, + 0x5e, 0x01, 0x84, 0x87, 0x32, 0xd9, 0xfd, 0xd7, 0xff, 0x3f, 0x68, 0x8e, 0xae, 0x88, 0xc5, 0x2e, + 0x91, 0x48, 0x8d, 0x44, 0xee, 0xfe, 0x5c, 0x93, 0xe9, 0xd6, 0x60, 0x27, 0x37, 0x18, 0x1e, 0xa4, + 0xb2, 0xf6, 0xe4, 0x9b, 0xbd, 0xc1, 0xe7, 0xb6, 0xfb, 0xa8, 0xb9, 0xef, 0x9f, 0xb8, 0xed, 0x27, + 0xfa, 0x98, 0x99, 0x9d, 0x24, 0x26, 0xd3, 0x6d, 0x8e, 0xc0, 0x2e, 0x47, 0xe0, 0x2b, 0x47, 0xe0, + 0xad, 0x40, 0xce, 0xae, 0x40, 0xce, 0x47, 0x81, 0x9c, 0xe7, 0xeb, 0x20, 0x54, 0x4b, 0xed, 0x11, + 0x5f, 0xac, 0x69, 0x85, 0x75, 0x13, 0x73, 0xf5, 0x22, 0xd2, 0x55, 0x3d, 0xb1, 0x24, 0xa4, 0x81, + 0xa8, 0x4f, 0xef, 0x9d, 0x55, 0xf7, 0x1a, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x30, 0x0b, 0xe4, + 0x9e, 0x91, 0x01, 0x00, 0x00, +} + +func (m *ResourceCPU) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceCPU) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceCPU) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCpu(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Units != 0 { + i = encodeVarintCpu(dAtA, i, uint64(m.Units)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCpu(dAtA []byte, offset int, v uint64) int { + offset -= sovCpu(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceCPU) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Units != 0 { + n += 1 + sovCpu(uint64(m.Units)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovCpu(uint64(l)) + } + } + return n +} + +func sovCpu(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCpu(x uint64) (n int) { + return sovCpu(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceCPU) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceCPU: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceCPU: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + m.Units = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Units |= cpuQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCpu + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCpu + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCpu(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCpu + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCpu(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCpu + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCpu + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCpu + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCpu = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCpu = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCpu = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/dependency.go b/go/sdl/v2/dependency.go new file mode 100644 index 00000000..1c8eae4b --- /dev/null +++ b/go/sdl/v2/dependency.go @@ -0,0 +1,21 @@ +package v2 + +import ( + "sort" +) + +type Dependencies []Dependency + +var _ sort.Interface = (*Dependencies)(nil) + +func (s Dependencies) Len() int { + return len(s) +} + +func (s Dependencies) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s Dependencies) Less(i, j int) bool { + return s[i].Service < s[j].Service +} diff --git a/go/sdl/v2/dependency.pb.go b/go/sdl/v2/dependency.pb.go new file mode 100644 index 00000000..f8846f5e --- /dev/null +++ b/go/sdl/v2/dependency.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/dependency.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Dependency struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service" yaml:"service"` +} + +func (m *Dependency) Reset() { *m = Dependency{} } +func (m *Dependency) String() string { return proto.CompactTextString(m) } +func (*Dependency) ProtoMessage() {} +func (*Dependency) Descriptor() ([]byte, []int) { + return fileDescriptor_e0274038b6eeb9ed, []int{0} +} +func (m *Dependency) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Dependency) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Dependency.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Dependency) XXX_Merge(src proto.Message) { + xxx_messageInfo_Dependency.Merge(m, src) +} +func (m *Dependency) XXX_Size() int { + return m.Size() +} +func (m *Dependency) XXX_DiscardUnknown() { + xxx_messageInfo_Dependency.DiscardUnknown(m) +} + +var xxx_messageInfo_Dependency proto.InternalMessageInfo + +func (m *Dependency) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func init() { + proto.RegisterType((*Dependency)(nil), "akash.sdl.v2.Dependency") +} + +func init() { proto.RegisterFile("akash/sdl/v2/dependency.proto", fileDescriptor_e0274038b6eeb9ed) } + +var fileDescriptor_e0274038b6eeb9ed = []byte{ + // 199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x4f, 0x49, 0x2d, 0x48, 0xcd, 0x4b, 0x49, + 0xcd, 0x4b, 0xae, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x4b, 0xeb, 0x15, 0xa7, + 0xe4, 0xe8, 0x95, 0x19, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, + 0x1a, 0xa5, 0x00, 0x2e, 0x2e, 0x17, 0xb8, 0x3e, 0x21, 0x27, 0x2e, 0xf6, 0xe2, 0xd4, 0xa2, 0xb2, + 0xcc, 0xe4, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0x8d, 0x47, 0xf7, 0xe4, 0xd9, 0x83, + 0x21, 0x42, 0xaf, 0xee, 0xc9, 0xc3, 0x64, 0x3f, 0xdd, 0x93, 0xe7, 0xab, 0x4c, 0xcc, 0xcd, 0xb1, + 0x52, 0x82, 0x0a, 0x28, 0x05, 0xc1, 0xa4, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, + 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, + 0x58, 0x8e, 0x21, 0x4a, 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, + 0xec, 0x34, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x28, 0x2f, 0xb1, 0x20, 0x53, 0x3f, + 0x3d, 0x1f, 0xea, 0x9d, 0x24, 0x36, 0xb0, 0x03, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6e, + 0xb7, 0x1e, 0x14, 0xe5, 0x00, 0x00, 0x00, +} + +func (m *Dependency) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Dependency) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Dependency) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Service) > 0 { + i -= len(m.Service) + copy(dAtA[i:], m.Service) + i = encodeVarintDependency(dAtA, i, uint64(len(m.Service))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDependency(dAtA []byte, offset int, v uint64) int { + offset -= sovDependency(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Dependency) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Service) + if l > 0 { + n += 1 + l + sovDependency(uint64(l)) + } + return n +} + +func sovDependency(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDependency(x uint64) (n int) { + return sovDependency(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Dependency) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDependency + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Dependency: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Dependency: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDependency + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDependency + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDependency + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Service = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDependency(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDependency + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDependency(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDependency + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDependency + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDependency + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDependency = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDependency = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDependency = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/deployments.go b/go/sdl/v2/deployments.go new file mode 100644 index 00000000..1b27d41e --- /dev/null +++ b/go/sdl/v2/deployments.go @@ -0,0 +1,144 @@ +package v2 + +import ( + "sort" + + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +type Placements map[string]ServicePlacement +type Deployments map[string]Placements + +func (t *Deployments) Marshal() ([]byte, error) { + return t.MarshalJSON() +} + +func (t *Deployments) MarshalTo(data []byte) (n int, err error) { + val, err := structpb.NewValue(t) + if err != nil { + return 0, err + } + + res, err := protojson.Marshal(val) + if err != nil { + return 0, err + } + + return copy(data, res), nil +} + +func (t *Deployments) Unmarshal(data []byte) error { + return t.UnmarshalJSON(data) +} + +func (t *Deployments) Size() int { + data, _ := t.MarshalJSON() + + return len(data) +} + +func (t *Deployments) MarshalJSON() ([]byte, error) { + val, err := structpb.NewValue(t) + if err != nil { + return nil, err + } + + return protojson.Marshal(val) +} + +func (t *Deployments) UnmarshalJSON(data []byte) error { + val, err := structpb.NewValue(t) + if err != nil { + return err + } + + return protojson.Unmarshal(data, val) +} + +// var _ sort.Interface = (*Placements)(nil) +// +// func (pl Placements) Len() int { +// return len(pl) +// } +// +// func (pl Placements) Swap(i, j int) { +// pl[i], pl[j] = pl[j], pl[i] +// } +// +// func (pl Placements) Less(i, j int) bool { +// return pl[i].Placement < pl[j].Placement +// } +// +// type deploymentServices map[string]DeploymentPlacements +func (t Deployments) svcNames() []string { + names := make([]string, 0, len(t)) + for name := range t { + names = append(names, name) + } + + sort.Strings(names) + + return names +} + +func (t Placements) placements() []string { + names := make([]string, 0, len(t)) + for placement := range t { + names = append(names, placement) + } + sort.Strings(names) + + return names +} + +// // placementNames stable ordered placement names +// func (sdl deploymentServices) placementNames() []string { +// names := make([]string, 0, len(sdl)) +// for name := range sdl { +// names = append(names, name) +// } +// sort.Strings(names) +// +// return names +// } +// +// func v2DeploymentPlacementNames(m DeploymentPlacements) []string { +// names := make([]string, 0, len(m.Placements)) +// for _, placement := range m.Placements { +// names = append(names, placement.Placement) +// } +// sort.Strings(names) +// +// return names +// } + +// func (sdl *DeploymentPlacements) UnmarshalYAML(node *yaml.Node) error { +// var placements DeploymentPlacements +// +// for i := 0; i+1 < len(node.Content); i += 2 { +// var value string +// switch node.Content[i].Value { +// case "arch": +// if err := node.Content[i+1].Decode(&value); err != nil { +// return err +// } +// default: +// return fmt.Errorf("unsupported cpu attribute \"%s\"", node.Content[i].Value) +// } +// +// placements = append(placements, types.Attribute{ +// Key: node.Content[i].Value, +// Value: value, +// }) +// } +// +// // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable +// sort.Slice(placements, func(i, j int) bool { +// return placements[i].Key < placements[j].Key +// }) +// +// *sdl = placements +// +// return nil +// } diff --git a/go/sdl/v2/endpoint.pb.go b/go/sdl/v2/endpoint.pb.go new file mode 100644 index 00000000..12c8189c --- /dev/null +++ b/go/sdl/v2/endpoint.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/endpoint.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Endpoint struct { + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind" yaml:"kind"` +} + +func (m *Endpoint) Reset() { *m = Endpoint{} } +func (m *Endpoint) String() string { return proto.CompactTextString(m) } +func (*Endpoint) ProtoMessage() {} +func (*Endpoint) Descriptor() ([]byte, []int) { + return fileDescriptor_1aa0bd9c2e31e15e, []int{0} +} +func (m *Endpoint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Endpoint) XXX_Merge(src proto.Message) { + xxx_messageInfo_Endpoint.Merge(m, src) +} +func (m *Endpoint) XXX_Size() int { + return m.Size() +} +func (m *Endpoint) XXX_DiscardUnknown() { + xxx_messageInfo_Endpoint.DiscardUnknown(m) +} + +var xxx_messageInfo_Endpoint proto.InternalMessageInfo + +func (m *Endpoint) GetKind() string { + if m != nil { + return m.Kind + } + return "" +} + +func init() { + proto.RegisterType((*Endpoint)(nil), "akash.sdl.v2.Endpoint") +} + +func init() { proto.RegisterFile("akash/sdl/v2/endpoint.proto", fileDescriptor_1aa0bd9c2e31e15e) } + +var fileDescriptor_1aa0bd9c2e31e15e = []byte{ + // 195 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x4f, 0xcd, 0x4b, 0x29, 0xc8, 0xcf, 0xcc, + 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x4b, 0xea, 0x15, 0xa7, 0xe4, 0xe8, + 0x95, 0x19, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x25, + 0x7b, 0x2e, 0x0e, 0x57, 0xa8, 0x2e, 0x21, 0x63, 0x2e, 0x96, 0xec, 0xcc, 0xbc, 0x14, 0x09, 0x46, + 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xf9, 0x47, 0xf7, 0xe4, 0x59, 0xbc, 0x33, 0xf3, 0x52, 0x5e, 0xdd, + 0x93, 0x07, 0x8b, 0x7f, 0xba, 0x27, 0xcf, 0x5d, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x04, 0xe2, 0x29, + 0x05, 0x81, 0x05, 0x9d, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, + 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xec, 0x12, 0xdd, 0xbc, + 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x28, 0x2f, 0xb1, 0x20, 0x53, 0x3f, 0x3d, 0x1f, 0xea, 0xf6, + 0x24, 0x36, 0xb0, 0x7b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xb5, 0xb2, 0x3d, 0xd2, + 0x00, 0x00, 0x00, +} + +func (m *Endpoint) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Kind) > 0 { + i -= len(m.Kind) + copy(dAtA[i:], m.Kind) + i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Kind))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEndpoint(dAtA []byte, offset int, v uint64) int { + offset -= sovEndpoint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Endpoint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Kind) + if l > 0 { + n += 1 + l + sovEndpoint(uint64(l)) + } + return n +} + +func sovEndpoint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEndpoint(x uint64) (n int) { + return sovEndpoint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Endpoint) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEndpoint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEndpoint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEndpoint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEndpoint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Kind = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEndpoint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEndpoint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEndpoint(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEndpoint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEndpoint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEndpoint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEndpoint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEndpoint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEndpoint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/expose.go b/go/sdl/v2/expose.go new file mode 100644 index 00000000..3084cb71 --- /dev/null +++ b/go/sdl/v2/expose.go @@ -0,0 +1,93 @@ +package v2 + +import ( + "sort" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" +) + +type Exposes []Expose + +func (sdl Exposes) toManifestExpose(endpointNames map[string]uint32) (manifest.ServiceExposes, error) { + exposeCount := 0 + for _, expose := range sdl { + if len(expose.To) > 0 { + exposeCount += len(expose.To) + } else { + exposeCount++ + } + } + + res := make(manifest.ServiceExposes, 0, exposeCount) + + for _, expose := range sdl { + exp, err := expose.toManifestExposes(endpointNames) + if err != nil { + return nil, err + } + + res = append(res, exp...) + } + + sort.Sort(res) + + return res, nil +} + +func (sdl Expose) toManifestExposes(endpointNames map[string]uint32) (manifest.ServiceExposes, error) { + exposeCount := len(sdl.To) + if exposeCount == 0 { + exposeCount = 1 + } + + res := make(manifest.ServiceExposes, 0, exposeCount) + + proto, err := manifest.ParseServiceProtocol(sdl.Proto) + if err != nil { + return nil, err + } + + httpOptions, err := sdl.HTTPOptions.asManifest() + if err != nil { + return nil, err + } + + if len(sdl.To) > 0 { + for _, to := range sdl.To { + // This value is created just so it can be passed to the utility function + expose := manifest.ServiceExpose{ + Service: to.Service, + Port: sdl.Port, + ExternalPort: sdl.As, + Proto: proto, + Global: to.Global, + Hosts: sdl.Accept.Items, + HTTPOptions: httpOptions, + IP: to.IP, + } + + // Check to see if an IP endpoint is also specified + if expose.Global && len(expose.IP) != 0 { + seqNo := endpointNames[expose.IP] + expose.EndpointSequenceNumber = seqNo + } + + res = append(res, expose) + } + } else { + expose := manifest.ServiceExpose{ + Service: "", + Port: sdl.Port, + ExternalPort: sdl.As, + Proto: proto, + Global: false, + Hosts: sdl.Accept.Items, + HTTPOptions: httpOptions, + IP: "", + } + + res = append(res, expose) + } + + return res, nil +} diff --git a/go/sdl/v2/expose.pb.go b/go/sdl/v2/expose.pb.go new file mode 100644 index 00000000..c339e6af --- /dev/null +++ b/go/sdl/v2/expose.pb.go @@ -0,0 +1,570 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/expose.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Expose struct { + Port uint32 `protobuf:"varint,1,opt,name=port,proto3" json:"port" yaml:"port"` + As uint32 `protobuf:"varint,2,opt,name=as,proto3" json:"as" yaml:"as"` + Proto string `protobuf:"bytes,3,opt,name=proto,proto3" json:"proto" yaml:"proto"` + To ExposeToSlice `protobuf:"bytes,4,rep,name=to,proto3,castrepeated=ExposeToSlice" json:"to" yaml:"to"` + Accept Accept `protobuf:"bytes,5,opt,name=accept,proto3" json:"accept" yaml:"accept"` + HTTPOptions HTTPOptions `protobuf:"bytes,6,opt,name=http_options,json=httpOptions,proto3" json:"http_options" yaml:"http_options"` +} + +func (m *Expose) Reset() { *m = Expose{} } +func (m *Expose) String() string { return proto.CompactTextString(m) } +func (*Expose) ProtoMessage() {} +func (*Expose) Descriptor() ([]byte, []int) { + return fileDescriptor_39b1bcc922222916, []int{0} +} +func (m *Expose) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Expose) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Expose.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Expose) XXX_Merge(src proto.Message) { + xxx_messageInfo_Expose.Merge(m, src) +} +func (m *Expose) XXX_Size() int { + return m.Size() +} +func (m *Expose) XXX_DiscardUnknown() { + xxx_messageInfo_Expose.DiscardUnknown(m) +} + +var xxx_messageInfo_Expose proto.InternalMessageInfo + +func (m *Expose) GetPort() uint32 { + if m != nil { + return m.Port + } + return 0 +} + +func (m *Expose) GetAs() uint32 { + if m != nil { + return m.As + } + return 0 +} + +func (m *Expose) GetProto() string { + if m != nil { + return m.Proto + } + return "" +} + +func (m *Expose) GetTo() ExposeToSlice { + if m != nil { + return m.To + } + return nil +} + +func (m *Expose) GetAccept() Accept { + if m != nil { + return m.Accept + } + return Accept{} +} + +func (m *Expose) GetHTTPOptions() HTTPOptions { + if m != nil { + return m.HTTPOptions + } + return HTTPOptions{} +} + +func init() { + proto.RegisterType((*Expose)(nil), "akash.sdl.v2.Expose") +} + +func init() { proto.RegisterFile("akash/sdl/v2/expose.proto", fileDescriptor_39b1bcc922222916) } + +var fileDescriptor_39b1bcc922222916 = []byte{ + // 430 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x3f, 0x6b, 0xdb, 0x40, + 0x14, 0xb7, 0xce, 0xb6, 0x20, 0x27, 0x7b, 0x51, 0x43, 0x91, 0x43, 0xd1, 0x33, 0x37, 0x39, 0xd0, + 0x4a, 0xe0, 0x2c, 0x25, 0x5b, 0x04, 0x2d, 0xdd, 0x6a, 0x54, 0xd3, 0x42, 0x97, 0x70, 0x71, 0x84, + 0x6d, 0xe2, 0xe4, 0x09, 0xdd, 0x35, 0x4d, 0xbf, 0x45, 0x3f, 0x47, 0x3f, 0x49, 0x96, 0x42, 0xc6, + 0x4e, 0xd7, 0x22, 0x6f, 0x1a, 0xf5, 0x09, 0x8a, 0xee, 0xce, 0x20, 0x41, 0x36, 0xbd, 0xdf, 0xbf, + 0xf7, 0xd3, 0xe3, 0xe8, 0x84, 0xdf, 0x70, 0xb1, 0x89, 0xc5, 0xf5, 0x2e, 0xbe, 0x9f, 0xc7, 0xd9, + 0x43, 0x8e, 0x22, 0x8b, 0xf2, 0x02, 0x25, 0xfa, 0x23, 0x4d, 0x45, 0xe2, 0x7a, 0x17, 0xdd, 0xcf, + 0x4f, 0x8e, 0xd7, 0xb8, 0x46, 0x4d, 0xc4, 0xcd, 0x97, 0xd1, 0x9c, 0x74, 0xed, 0x7c, 0xb5, 0xca, + 0x72, 0x69, 0xa9, 0x57, 0xcf, 0x24, 0x5f, 0xca, 0x83, 0x11, 0x3a, 0xec, 0x46, 0xca, 0xfc, 0x12, + 0x73, 0xb9, 0xc5, 0x3b, 0x61, 0x04, 0xec, 0x77, 0x9f, 0xba, 0xef, 0xb4, 0xc9, 0x3f, 0xa3, 0x83, + 0x1c, 0x0b, 0x19, 0x38, 0x53, 0x67, 0x36, 0x4e, 0xa0, 0x54, 0x30, 0x58, 0x60, 0x21, 0x2b, 0x05, + 0x1a, 0xaf, 0x15, 0x78, 0x3f, 0xf8, 0xed, 0xee, 0x9c, 0x35, 0x13, 0x4b, 0x35, 0xe8, 0x9f, 0x52, + 0xc2, 0x45, 0x40, 0xb4, 0x65, 0x52, 0x2a, 0x20, 0x17, 0xa2, 0x52, 0x40, 0xb8, 0xa8, 0x15, 0x1c, + 0x19, 0x39, 0x17, 0x2c, 0x25, 0x5c, 0xf8, 0x6f, 0xe9, 0x50, 0xef, 0x0c, 0xfa, 0x53, 0x67, 0x76, + 0x94, 0xb0, 0x52, 0xc1, 0x70, 0xd1, 0x00, 0x95, 0x02, 0xc3, 0xd4, 0x0a, 0x46, 0x76, 0x85, 0x2e, + 0x97, 0x1a, 0xd8, 0xff, 0x4c, 0x89, 0xc4, 0x60, 0x30, 0xed, 0xcf, 0xbc, 0xf9, 0xcb, 0xa8, 0x7d, + 0xaf, 0xc8, 0x74, 0x5f, 0x62, 0x12, 0x3d, 0x2a, 0xe8, 0x35, 0x05, 0x96, 0x4d, 0x1e, 0xd1, 0x61, + 0xb6, 0x80, 0x44, 0xf6, 0xeb, 0x2f, 0x8c, 0x0f, 0xd2, 0x4f, 0xbb, 0xed, 0x2a, 0x4b, 0x89, 0x44, + 0xff, 0x0b, 0x75, 0xcd, 0x2d, 0x83, 0xe1, 0xd4, 0x99, 0x79, 0xf3, 0xe3, 0x6e, 0xf6, 0x85, 0xe6, + 0x92, 0x53, 0x9b, 0xec, 0x9a, 0xb9, 0x52, 0x60, 0x5d, 0xb5, 0x82, 0xb1, 0xfd, 0x45, 0x3d, 0xb3, + 0xd4, 0x12, 0xfe, 0x03, 0x1d, 0xb5, 0x6f, 0x1d, 0xb8, 0x3a, 0x7e, 0xd2, 0x8d, 0xff, 0xb0, 0x5c, + 0x2e, 0x3e, 0x1a, 0x41, 0x72, 0x6e, 0x77, 0x78, 0x2d, 0xb0, 0x52, 0xd0, 0x49, 0xa9, 0x15, 0xbc, + 0x30, 0xeb, 0xda, 0x28, 0x4b, 0xbd, 0x66, 0x3c, 0x04, 0xbd, 0x7f, 0x2c, 0x43, 0xe7, 0xa9, 0x0c, + 0x9d, 0x7f, 0x65, 0xe8, 0xfc, 0xdc, 0x87, 0xbd, 0xa7, 0x7d, 0xd8, 0xfb, 0xb3, 0x0f, 0x7b, 0x5f, + 0x5f, 0xaf, 0xb7, 0x72, 0xf3, 0xed, 0x2a, 0x5a, 0xe1, 0x6d, 0xac, 0x7b, 0xbc, 0xb9, 0xcb, 0xe4, + 0x77, 0x2c, 0x6e, 0xec, 0xc4, 0xf3, 0x6d, 0xbc, 0x46, 0xfb, 0x54, 0xae, 0x5c, 0x7d, 0xf9, 0xb3, + 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x1f, 0x41, 0x77, 0xb9, 0x02, 0x00, 0x00, +} + +func (m *Expose) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Expose) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Expose) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.HTTPOptions.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size, err := m.Accept.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.To) > 0 { + for iNdEx := len(m.To) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.To[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Proto) > 0 { + i -= len(m.Proto) + copy(dAtA[i:], m.Proto) + i = encodeVarintExpose(dAtA, i, uint64(len(m.Proto))) + i-- + dAtA[i] = 0x1a + } + if m.As != 0 { + i = encodeVarintExpose(dAtA, i, uint64(m.As)) + i-- + dAtA[i] = 0x10 + } + if m.Port != 0 { + i = encodeVarintExpose(dAtA, i, uint64(m.Port)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintExpose(dAtA []byte, offset int, v uint64) int { + offset -= sovExpose(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Expose) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Port != 0 { + n += 1 + sovExpose(uint64(m.Port)) + } + if m.As != 0 { + n += 1 + sovExpose(uint64(m.As)) + } + l = len(m.Proto) + if l > 0 { + n += 1 + l + sovExpose(uint64(l)) + } + if len(m.To) > 0 { + for _, e := range m.To { + l = e.Size() + n += 1 + l + sovExpose(uint64(l)) + } + } + l = m.Accept.Size() + n += 1 + l + sovExpose(uint64(l)) + l = m.HTTPOptions.Size() + n += 1 + l + sovExpose(uint64(l)) + return n +} + +func sovExpose(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExpose(x uint64) (n int) { + return sovExpose(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Expose) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Expose: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Expose: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) + } + m.Port = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Port |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field As", wireType) + } + m.As = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.As |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proto", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proto = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.To = append(m.To, ExposeTo{}) + if err := m.To[len(m.To)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accept", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Accept.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HTTPOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.HTTPOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipExpose(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExpose + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExpose(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthExpose + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExpose + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExpose + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExpose = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExpose = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExpose = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/expose_test.go b/go/sdl/v2/expose_test.go new file mode 100644 index 00000000..5cfda139 --- /dev/null +++ b/go/sdl/v2/expose_test.go @@ -0,0 +1,24 @@ +package v2 + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +func TestV2Expose(t *testing.T) { + var stream = ` +- port: 80 + as: 80 + accept: + - hello.localhost + to: + - global: true +` + + var p Exposes + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) +} diff --git a/go/sdl/v2/expose_to.go b/go/sdl/v2/expose_to.go new file mode 100644 index 00000000..b49f6c27 --- /dev/null +++ b/go/sdl/v2/expose_to.go @@ -0,0 +1,3 @@ +package v2 + +type ExposeToSlice []ExposeTo diff --git a/go/sdl/v2/expose_to.pb.go b/go/sdl/v2/expose_to.pb.go new file mode 100644 index 00000000..7f19d61f --- /dev/null +++ b/go/sdl/v2/expose_to.pb.go @@ -0,0 +1,472 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/expose_to.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ExposeTo struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service" yaml:"service"` + Global bool `protobuf:"varint,2,opt,name=Global,proto3" json:"global" yaml:"global"` + HTTPOptions HTTPOptions `protobuf:"bytes,3,opt,name=http_options,json=httpOptions,proto3" json:"http_options" yaml:"http_options"` + IP string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip" yaml:"ip"` +} + +func (m *ExposeTo) Reset() { *m = ExposeTo{} } +func (m *ExposeTo) String() string { return proto.CompactTextString(m) } +func (*ExposeTo) ProtoMessage() {} +func (*ExposeTo) Descriptor() ([]byte, []int) { + return fileDescriptor_f4d15619ab49a1b7, []int{0} +} +func (m *ExposeTo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExposeTo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExposeTo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExposeTo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExposeTo.Merge(m, src) +} +func (m *ExposeTo) XXX_Size() int { + return m.Size() +} +func (m *ExposeTo) XXX_DiscardUnknown() { + xxx_messageInfo_ExposeTo.DiscardUnknown(m) +} + +var xxx_messageInfo_ExposeTo proto.InternalMessageInfo + +func (m *ExposeTo) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func (m *ExposeTo) GetGlobal() bool { + if m != nil { + return m.Global + } + return false +} + +func (m *ExposeTo) GetHTTPOptions() HTTPOptions { + if m != nil { + return m.HTTPOptions + } + return HTTPOptions{} +} + +func (m *ExposeTo) GetIP() string { + if m != nil { + return m.IP + } + return "" +} + +func init() { + proto.RegisterType((*ExposeTo)(nil), "akash.sdl.v2.ExposeTo") +} + +func init() { proto.RegisterFile("akash/sdl/v2/expose_to.proto", fileDescriptor_f4d15619ab49a1b7) } + +var fileDescriptor_f4d15619ab49a1b7 = []byte{ + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x51, 0xcd, 0x6a, 0xfa, 0x40, + 0x10, 0x4f, 0xf2, 0xff, 0xe3, 0x47, 0xb4, 0x3d, 0xa4, 0x3d, 0x44, 0x29, 0x19, 0x09, 0x14, 0x52, + 0x68, 0x13, 0xb0, 0x37, 0xa1, 0x97, 0x40, 0xbf, 0x4e, 0x95, 0xd4, 0x53, 0x2f, 0x12, 0x35, 0xc4, + 0xc5, 0xe8, 0x2e, 0x66, 0x6b, 0xed, 0x5b, 0xf4, 0x59, 0xfa, 0x14, 0x1e, 0x3d, 0xf6, 0xb4, 0x94, + 0xf5, 0x96, 0x63, 0x9e, 0xa0, 0xb8, 0x1b, 0x21, 0xde, 0xe6, 0xf7, 0x31, 0xbf, 0x99, 0x61, 0xf4, + 0x8b, 0x70, 0x16, 0xa6, 0x53, 0x2f, 0x9d, 0x24, 0xde, 0xaa, 0xeb, 0x45, 0x6b, 0x82, 0xd3, 0x68, + 0x48, 0xb1, 0x4b, 0x96, 0x98, 0x62, 0xa3, 0x29, 0x54, 0x37, 0x9d, 0x24, 0xee, 0xaa, 0xdb, 0x3e, + 0x8f, 0x71, 0x8c, 0x85, 0xe0, 0xed, 0x2b, 0xe9, 0x69, 0xc3, 0x51, 0xc2, 0x94, 0x52, 0x32, 0xc4, + 0x84, 0x22, 0xbc, 0x48, 0xa5, 0xc1, 0xfe, 0xd6, 0xf4, 0xda, 0xbd, 0x08, 0x1e, 0x60, 0xc3, 0xd7, + 0xab, 0x69, 0xb4, 0x5c, 0xa1, 0x71, 0x64, 0xaa, 0x1d, 0xd5, 0xa9, 0xfb, 0x0e, 0x67, 0x50, 0x7d, + 0x95, 0x54, 0xc6, 0xe0, 0xa0, 0xe6, 0x0c, 0x4e, 0x3f, 0xc3, 0x79, 0xd2, 0xb3, 0x0b, 0xc2, 0x0e, + 0x0e, 0x92, 0x71, 0xa7, 0x57, 0x1e, 0x13, 0x3c, 0x0a, 0x13, 0x53, 0xeb, 0xa8, 0x4e, 0xcd, 0xbf, + 0xe4, 0x0c, 0x0a, 0x26, 0x63, 0x50, 0x89, 0x45, 0x95, 0x33, 0x38, 0x91, 0x01, 0x12, 0xdb, 0x41, + 0x61, 0x31, 0xd6, 0x7a, 0xb3, 0xbc, 0xa5, 0xf9, 0xaf, 0xa3, 0x3a, 0x8d, 0x6e, 0xcb, 0x2d, 0xdf, + 0xea, 0x3e, 0x0d, 0x06, 0xfd, 0x17, 0x69, 0xf0, 0x7b, 0x1b, 0x06, 0x0a, 0x67, 0xd0, 0x28, 0x91, + 0x19, 0x83, 0xa3, 0x94, 0x9c, 0xc1, 0x99, 0x1c, 0x57, 0x66, 0xed, 0xa0, 0xb1, 0x87, 0x45, 0x8f, + 0x71, 0xa5, 0x6b, 0x88, 0x98, 0xff, 0xc5, 0xdd, 0x2d, 0xce, 0x40, 0x7b, 0xee, 0x67, 0x0c, 0x34, + 0x44, 0x72, 0x06, 0x75, 0xd9, 0x8d, 0x88, 0x1d, 0x68, 0x88, 0xf8, 0x0f, 0x1b, 0x6e, 0xa9, 0x5b, + 0x6e, 0xa9, 0xbf, 0xdc, 0x52, 0xbf, 0x76, 0x96, 0xb2, 0xdd, 0x59, 0xca, 0xcf, 0xce, 0x52, 0xde, + 0xae, 0x63, 0x44, 0xa7, 0xef, 0x23, 0x77, 0x8c, 0xe7, 0x9e, 0x58, 0xf9, 0x66, 0x11, 0xd1, 0x0f, + 0xbc, 0x9c, 0x15, 0x28, 0x24, 0xc8, 0x8b, 0x71, 0xf1, 0x8f, 0x51, 0x45, 0xfc, 0xe0, 0xf6, 0x2f, + 0x00, 0x00, 0xff, 0xff, 0x4d, 0x15, 0x59, 0x58, 0xe8, 0x01, 0x00, 0x00, +} + +func (m *ExposeTo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExposeTo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExposeTo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IP) > 0 { + i -= len(m.IP) + copy(dAtA[i:], m.IP) + i = encodeVarintExposeTo(dAtA, i, uint64(len(m.IP))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.HTTPOptions.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExposeTo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Global { + i-- + if m.Global { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Service) > 0 { + i -= len(m.Service) + copy(dAtA[i:], m.Service) + i = encodeVarintExposeTo(dAtA, i, uint64(len(m.Service))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintExposeTo(dAtA []byte, offset int, v uint64) int { + offset -= sovExposeTo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExposeTo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Service) + if l > 0 { + n += 1 + l + sovExposeTo(uint64(l)) + } + if m.Global { + n += 2 + } + l = m.HTTPOptions.Size() + n += 1 + l + sovExposeTo(uint64(l)) + l = len(m.IP) + if l > 0 { + n += 1 + l + sovExposeTo(uint64(l)) + } + return n +} + +func sovExposeTo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExposeTo(x uint64) (n int) { + return sovExposeTo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExposeTo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ExposeTo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExposeTo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Service = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Global", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Global = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HTTPOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.HTTPOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IP = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipExposeTo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExposeTo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExposeTo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthExposeTo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExposeTo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExposeTo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExposeTo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExposeTo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExposeTo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/gpu.go b/go/sdl/v2/gpu.go new file mode 100644 index 00000000..eed8f3df --- /dev/null +++ b/go/sdl/v2/gpu.go @@ -0,0 +1,106 @@ +package v2 + +import ( + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type v2GPUNvidia struct { + Model string `yaml:"model"` + RAM *memoryQuantity `yaml:"ram,omitempty"` +} + +func (sdl *v2GPUNvidia) String() string { + key := sdl.Model + if sdl.RAM != nil { + key += "/" + sdl.RAM.StringWithSuffix("Gi") + } + + return key +} + +type v2GPUsNvidia []v2GPUNvidia + +type gpuVendor struct { + Nvidia v2GPUsNvidia `yaml:"nvidia,omitempty"` +} + +type gpuAttributes types.Attributes + +func (sdl *ResourceGPU) UnmarshalYAML(node *yaml.Node) error { + res := ResourceGPU{} + + for i := 0; i < len(node.Content); i += 2 { + switch node.Content[i].Value { + case "units": + if err := node.Content[i+1].Decode(&res.Units); err != nil { + return err + } + case "attributes": + if err := node.Content[i+1].Decode(&res.Attributes); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unsupported field (%s) for GPU resource", node.Content[i].Value) + } + } + + if res.Units > 0 && len(res.Attributes) == 0 { + return fmt.Errorf("sdl: GPU attributes must be present if units > 0") + } + + *sdl = res + + return nil +} + +func (sdl *gpuAttributes) UnmarshalYAML(node *yaml.Node) error { + var res types.Attributes + + var vendor *gpuVendor + + for i := 0; i < len(node.Content); i += 2 { + switch node.Content[i].Value { + case "vendor": + if err := node.Content[i+1].Decode(&vendor); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unsupported attribute (%s) for GPU resource", node.Content[i].Value) + } + } + + if vendor == nil { + return fmt.Errorf("sdl: invalid GPU attributes. at least one vendor must be set") + } + + res = make(types.Attributes, 0, len(vendor.Nvidia)) + + for _, model := range vendor.Nvidia { + res = append(res, types.Attribute{ + Key: fmt.Sprintf("vendor/nvidia/model/%s", model.String()), + Value: "true", + }) + } + + if len(res) == 0 { + res = append(res, types.Attribute{ + Key: "vendor/nvidia/model/*", + Value: "true", + }) + } + + sort.Sort(res) + + if err := res.Validate(); err != nil { + return fmt.Errorf("sdl: invalid GPU attributes: %w", err) + } + + *sdl = gpuAttributes(res) + + return nil +} diff --git a/go/sdl/v2/gpu.pb.go b/go/sdl/v2/gpu.pb.go new file mode 100644 index 00000000..9ec77f1c --- /dev/null +++ b/go/sdl/v2/gpu.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/gpu.proto + +package v2 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceGPU struct { + Units gpuQuantity `protobuf:"varint,1,opt,name=units,proto3,casttype=gpuQuantity" json:"units" yaml:"units"` + Attributes gpuAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=gpuAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceGPU) Reset() { *m = ResourceGPU{} } +func (m *ResourceGPU) String() string { return proto.CompactTextString(m) } +func (*ResourceGPU) ProtoMessage() {} +func (*ResourceGPU) Descriptor() ([]byte, []int) { + return fileDescriptor_3f7ec069ab2f18d2, []int{0} +} +func (m *ResourceGPU) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceGPU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceGPU.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceGPU) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceGPU.Merge(m, src) +} +func (m *ResourceGPU) XXX_Size() int { + return m.Size() +} +func (m *ResourceGPU) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceGPU.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceGPU proto.InternalMessageInfo + +func (m *ResourceGPU) GetUnits() gpuQuantity { + if m != nil { + return m.Units + } + return 0 +} + +func (m *ResourceGPU) GetAttributes() gpuAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceGPU)(nil), "akash.sdl.v2.ResourceGPU") +} + +func init() { proto.RegisterFile("akash/sdl/v2/gpu.proto", fileDescriptor_3f7ec069ab2f18d2) } + +var fileDescriptor_3f7ec069ab2f18d2 = []byte{ + // 308 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x6e, 0xf2, 0x30, + 0x14, 0x85, 0xe3, 0xff, 0x17, 0x1d, 0x0c, 0x0c, 0x45, 0x55, 0x85, 0x90, 0x6a, 0xa3, 0x4c, 0x0c, + 0xad, 0x2d, 0x60, 0xeb, 0x56, 0x06, 0x58, 0x5b, 0x24, 0x96, 0x6e, 0x0e, 0x58, 0x26, 0x02, 0xe2, + 0x28, 0xb6, 0x53, 0xf1, 0x00, 0xdd, 0xfb, 0x1c, 0x7d, 0x12, 0x46, 0xc6, 0x4e, 0x6e, 0x95, 0x6c, + 0x1d, 0x19, 0x3b, 0x55, 0x89, 0x53, 0x60, 0xf3, 0x3d, 0xf7, 0x1c, 0x9f, 0x4f, 0x17, 0x5e, 0xb3, + 0x15, 0x53, 0x4b, 0xaa, 0x16, 0x6b, 0x9a, 0x0e, 0xa8, 0x88, 0x0d, 0x89, 0x13, 0xa9, 0x65, 0xab, + 0x51, 0xea, 0x44, 0x2d, 0xd6, 0x24, 0x1d, 0x74, 0xae, 0x84, 0x14, 0xb2, 0x5c, 0xd0, 0xe2, 0xe5, + 0x3c, 0x1d, 0xdf, 0x65, 0x03, 0xa6, 0x38, 0x4d, 0xfb, 0x01, 0xd7, 0x6c, 0x48, 0x99, 0xd6, 0x49, + 0x18, 0x18, 0xcd, 0x9d, 0xc7, 0xb7, 0x00, 0xd6, 0xa7, 0x5c, 0x49, 0x93, 0xcc, 0xf9, 0xe4, 0x71, + 0xd6, 0x9a, 0xc0, 0x9a, 0x89, 0x42, 0xad, 0xda, 0xa0, 0x0b, 0x7a, 0xcd, 0x51, 0x3f, 0xb3, 0xb8, + 0x36, 0x2b, 0x84, 0x6f, 0x8b, 0xdd, 0xe6, 0x60, 0x71, 0x63, 0xcb, 0x36, 0xeb, 0x7b, 0xbf, 0x1c, + 0xfd, 0x1f, 0x8b, 0xeb, 0x22, 0x36, 0x4f, 0x86, 0x45, 0x3a, 0xd4, 0xdb, 0xa9, 0x73, 0xb5, 0x5e, + 0x01, 0x84, 0xc7, 0x32, 0xd5, 0xfe, 0xd7, 0xfd, 0xdf, 0xab, 0x0f, 0x6e, 0x88, 0xc3, 0x2e, 0x90, + 0x48, 0x85, 0x44, 0x1e, 0xfe, 0x5c, 0xa3, 0xf1, 0xce, 0x62, 0x2f, 0xb3, 0x18, 0x1e, 0xa5, 0xa2, + 0xf6, 0xec, 0x9b, 0x83, 0xc5, 0x97, 0xae, 0xfb, 0xa4, 0xf9, 0xef, 0x9f, 0xb8, 0x29, 0x62, 0x73, + 0xca, 0x4c, 0xcf, 0x12, 0xa3, 0xf1, 0x2e, 0x43, 0x60, 0x9f, 0x21, 0xf0, 0x95, 0x21, 0xf0, 0x96, + 0x23, 0x6f, 0x9f, 0x23, 0xef, 0x23, 0x47, 0xde, 0xf3, 0xad, 0x08, 0xf5, 0xd2, 0x04, 0x64, 0x2e, + 0x37, 0xb4, 0xc4, 0xba, 0x8b, 0xb8, 0x7e, 0x91, 0xc9, 0xaa, 0x9a, 0x58, 0x1c, 0x52, 0x21, 0xab, + 0xd3, 0x07, 0x17, 0xe5, 0xbd, 0x86, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x5f, 0xc4, 0x00, + 0x91, 0x01, 0x00, 0x00, +} + +func (m *ResourceGPU) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceGPU) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceGPU) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGpu(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Units != 0 { + i = encodeVarintGpu(dAtA, i, uint64(m.Units)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGpu(dAtA []byte, offset int, v uint64) int { + offset -= sovGpu(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceGPU) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Units != 0 { + n += 1 + sovGpu(uint64(m.Units)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovGpu(uint64(l)) + } + } + return n +} + +func sovGpu(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGpu(x uint64) (n int) { + return sovGpu(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceGPU) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceGPU: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceGPU: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + m.Units = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Units |= gpuQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGpu + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGpu + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGpu(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGpu + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGpu(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGpu + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGpu + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGpu + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGpu = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGpu = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGpu = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/gpu_test.go b/go/sdl/v2/gpu_test.go new file mode 100644 index 00000000..59991359 --- /dev/null +++ b/go/sdl/v2/gpu_test.go @@ -0,0 +1,155 @@ +package v2 + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +func TestV2ResourceGPU_EmptyVendor(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.Error(t, err) +} + +func TestV2ResourceGPU_Wildcard(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/*", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_SingleModel(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_SingleModelWithRAM(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_InvalidRAMUnit(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80G +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.Error(t, err) +} + +func TestV2ResourceGPU_MultipleModels(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi + - model: a100 + ram: 40Gi +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100/40Gi", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} + +func TestV2ResourceGPU_MultipleModels2(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi + - model: a100 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} + +func TestV2ResourceGPU_MultipleModels3(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a6000 + - model: a40 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a40", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a6000", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} diff --git a/go/sdl/v2/group_builder.go b/go/sdl/v2/group_builder.go new file mode 100644 index 00000000..41a96831 --- /dev/null +++ b/go/sdl/v2/group_builder.go @@ -0,0 +1,141 @@ +package v2 + +import ( + "sort" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type groupsBuilder struct { + dgroup *dtypes.GroupSpec + mgroup *manifest.Group + boundComputes map[string]map[string]int +} + +// buildGroups +func (sdl *SDL) buildGroups() error { + endpointsNames := sdl.computeEndpointSequenceNumbers() + + groups := make(map[string]*groupsBuilder) + + for _, svcName := range sdl.Deployments.svcNames() { + depl := sdl.Deployments[svcName] + + for _, placementName := range depl.placements() { + // objects below have been ensured to exist + svcdepl := depl[placementName] + compute := sdl.Profiles.Compute[svcdepl.Profile] + svc := sdl.Services[svcName] + infra := sdl.Profiles.Placement[placementName] + price := infra.Pricing[svcdepl.Profile] + + group := groups[placementName] + + if group == nil { + group = &groupsBuilder{ + dgroup: &dtypes.GroupSpec{ + Name: placementName, + }, + mgroup: &manifest.Group{ + Name: placementName, + }, + boundComputes: make(map[string]map[string]int), + } + + group.dgroup.Requirements.Attributes = types.Attributes(infra.Attributes) + group.dgroup.Requirements.SignedBy = infra.SignedBy + + // keep ordering stable + sort.Sort(group.dgroup.Requirements.Attributes) + + groups[placementName] = group + } + + if _, exists := group.boundComputes[placementName]; !exists { + group.boundComputes[placementName] = make(map[string]int) + } + + expose, err := sdl.Services[svcName].Expose.toManifestExpose(endpointsNames) + if err != nil { + return err + } + + resources := compute.Resources.toResources() + resources.Endpoints = expose.GetEndpoints() + + res := compute.Resources.toResources() + res.Endpoints = expose.GetEndpoints() + + var resID int + if ln := len(group.dgroup.Resources); ln > 0 { + resID = ln + 1 + } else { + resID = 1 + } + + res.ID = uint32(resID) + resources.ID = res.ID + + group.dgroup.Resources = append(group.dgroup.Resources, dtypes.ResourceUnit{ + Resources: res, + Price: price.Value, + Count: svcdepl.Count, + }) + + group.boundComputes[placementName][svcdepl.Profile] = len(group.dgroup.Resources) - 1 + + msvc := manifest.Service{ + Name: svcName, + Image: svc.Image, + Args: svc.Args, + Env: svc.Env, + Resources: resources, + Count: svcdepl.Count, + Command: svc.Command, + Expose: expose, + } + + if svc.Params != nil { + params := &manifest.ServiceParams{} + + if len(svc.Params.Storage) > 0 { + params.Storage = make([]manifest.StorageParams, 0, len(svc.Params.Storage)) + for volName, volParams := range svc.Params.Storage { + params.Storage = append(params.Storage, manifest.StorageParams{ + Name: volName, + Mount: volParams.Mount, + ReadOnly: volParams.ReadOnly, + }) + } + } + + msvc.Params = params + } + + group.mgroup.Services = append(group.mgroup.Services, msvc) + } + } + + // keep ordering stable + names := make([]string, 0, len(groups)) + for name := range groups { + names = append(names, name) + } + sort.Strings(names) + + sdl.result.dgroups = make(dtypes.GroupSpecs, 0, len(names)) + sdl.result.mgroups = make(manifest.Groups, 0, len(names)) + + for _, name := range names { + mgroup := *groups[name].mgroup + // stable ordering services by name + sort.Sort(mgroup.Services) + + sdl.result.dgroups = append(sdl.result.dgroups, groups[name].dgroup) + sdl.result.mgroups = append(sdl.result.mgroups, mgroup) + } + + return nil +} diff --git a/go/sdl/v2/http_options.go b/go/sdl/v2/http_options.go new file mode 100644 index 00000000..5b5619b9 --- /dev/null +++ b/go/sdl/v2/http_options.go @@ -0,0 +1,99 @@ +package v2 + +import ( + "errors" + "fmt" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" +) + +const ( + nextCaseError = "error" + nextCaseTimeout = "timeout" + nextCase500 = "500" + nextCase502 = "502" + nextCase503 = "503" + nextCase504 = "504" + nextCase403 = "403" + nextCase404 = "404" + nextCase400 = "429" + nextCaseOff = "off" + DefaultMaxBodySize = uint32(1048576) + upperLimitBodySize = uint32(104857600) + DefaultReadTimeout = uint32(60000) + upperLimitReadTimeout = DefaultReadTimeout + DefaultSendTimeout = uint32(60000) + upperLimitSendTimeout = DefaultSendTimeout + DefaultNextTries = uint32(3) + endpointKindIP = "ip" +) + +var ( + defaultNextCases = []string{nextCaseError, nextCaseTimeout} + errCannotSpecifyOffAndOtherCases = errors.New("if 'off' is specified, no other cases may be specified") + errUnknownNextCase = errors.New("next case is unknown") + errHTTPOptionNotAllowed = errors.New("http option not allowed") +) + +func (ho HTTPOptions) asManifest() (manifest.ServiceExposeHTTPOptions, error) { + maxBodySize := ho.MaxBodySize + + if maxBodySize == 0 { + maxBodySize = DefaultMaxBodySize + } else if maxBodySize > upperLimitBodySize { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: body size cannot be greater than %d bytes", errHTTPOptionNotAllowed, upperLimitBodySize) + } + + readTimeout := ho.ReadTimeout + if readTimeout == 0 { + readTimeout = DefaultReadTimeout + } else if readTimeout > upperLimitReadTimeout { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: read timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitReadTimeout) + } + + sendTimeout := ho.SendTimeout + if sendTimeout == 0 { + sendTimeout = DefaultSendTimeout + } else if sendTimeout > upperLimitSendTimeout { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: send timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitSendTimeout) + } + + nextTries := ho.NextTries + if nextTries == 0 { + nextTries = DefaultNextTries + } + + nextCases := ho.NextCases + if len(nextCases) == 0 { + nextCases = defaultNextCases + } else { + for _, nextCase := range nextCases { + switch nextCase { + case nextCaseOff: + if len(nextCases) != 1 { + return manifest.ServiceExposeHTTPOptions{}, errCannotSpecifyOffAndOtherCases + } + case nextCaseError: + case nextCaseTimeout: + case nextCase500: + case nextCase502: + case nextCase503: + case nextCase504: + case nextCase403: + case nextCase404: + case nextCase400: + default: + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: %q", errUnknownNextCase, nextCase) + } + } + } + + return manifest.ServiceExposeHTTPOptions{ + MaxBodySize: maxBodySize, + ReadTimeout: readTimeout, + SendTimeout: sendTimeout, + NextTries: nextTries, + NextTimeout: ho.NextTimeout, + NextCases: nextCases, + }, nil +} diff --git a/go/sdl/v2/http_options.pb.go b/go/sdl/v2/http_options.pb.go new file mode 100644 index 00000000..d8a070d0 --- /dev/null +++ b/go/sdl/v2/http_options.pb.go @@ -0,0 +1,509 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/http_options.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type HTTPOptions struct { + MaxBodySize uint32 `protobuf:"varint,1,opt,name=max_body_size,json=maxBodySize,proto3" json:"max_body_size" yaml:"max_body_size"` + ReadTimeout uint32 `protobuf:"varint,2,opt,name=read_timeout,json=readTimeout,proto3" json:"read_timeout" yaml:"read_timeout"` + SendTimeout uint32 `protobuf:"varint,3,opt,name=send_timeout,json=sendTimeout,proto3" json:"send_timeout" yaml:"send_timeout"` + NextTries uint32 `protobuf:"varint,4,opt,name=next_tries,json=nextTries,proto3" json:"next_tries" yaml:"next_tries"` + NextTimeout uint32 `protobuf:"varint,5,opt,name=next_timeout,json=nextTimeout,proto3" json:"next_timeout" yaml:"next_timeout"` + NextCases []string `protobuf:"bytes,6,rep,name=next_cases,json=nextCases,proto3" json:"next_cases" yaml:"next_cases"` +} + +func (m *HTTPOptions) Reset() { *m = HTTPOptions{} } +func (m *HTTPOptions) String() string { return proto.CompactTextString(m) } +func (*HTTPOptions) ProtoMessage() {} +func (*HTTPOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_6265af1b64db036a, []int{0} +} +func (m *HTTPOptions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HTTPOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HTTPOptions.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HTTPOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_HTTPOptions.Merge(m, src) +} +func (m *HTTPOptions) XXX_Size() int { + return m.Size() +} +func (m *HTTPOptions) XXX_DiscardUnknown() { + xxx_messageInfo_HTTPOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_HTTPOptions proto.InternalMessageInfo + +func (m *HTTPOptions) GetMaxBodySize() uint32 { + if m != nil { + return m.MaxBodySize + } + return 0 +} + +func (m *HTTPOptions) GetReadTimeout() uint32 { + if m != nil { + return m.ReadTimeout + } + return 0 +} + +func (m *HTTPOptions) GetSendTimeout() uint32 { + if m != nil { + return m.SendTimeout + } + return 0 +} + +func (m *HTTPOptions) GetNextTries() uint32 { + if m != nil { + return m.NextTries + } + return 0 +} + +func (m *HTTPOptions) GetNextTimeout() uint32 { + if m != nil { + return m.NextTimeout + } + return 0 +} + +func (m *HTTPOptions) GetNextCases() []string { + if m != nil { + return m.NextCases + } + return nil +} + +func init() { + proto.RegisterType((*HTTPOptions)(nil), "akash.sdl.v2.HTTPOptions") +} + +func init() { proto.RegisterFile("akash/sdl/v2/http_options.proto", fileDescriptor_6265af1b64db036a) } + +var fileDescriptor_6265af1b64db036a = []byte{ + // 394 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xc1, 0x6e, 0xa2, 0x40, + 0x1c, 0xc6, 0x65, 0x75, 0x4d, 0x04, 0x3d, 0x2c, 0xeb, 0x81, 0xec, 0x81, 0x31, 0x9c, 0x3c, 0xec, + 0xc2, 0xc6, 0x26, 0x4d, 0xd3, 0xa3, 0x4d, 0x9a, 0x5e, 0x5a, 0x1b, 0xe4, 0xd2, 0xa6, 0x09, 0x19, + 0x65, 0x82, 0x44, 0x61, 0x08, 0x33, 0x5a, 0xf4, 0x29, 0xfa, 0x04, 0x7d, 0x9e, 0x1e, 0x3d, 0xf6, + 0x34, 0x69, 0xf0, 0xe6, 0xd1, 0x27, 0x68, 0x18, 0xa8, 0x83, 0xbd, 0xc1, 0x37, 0xdf, 0xf7, 0xcb, + 0xef, 0xf0, 0x97, 0x01, 0x9c, 0x43, 0x32, 0xb3, 0x88, 0xb7, 0xb0, 0x56, 0x03, 0x6b, 0x46, 0x69, + 0xec, 0xe2, 0x98, 0x06, 0x38, 0x22, 0x66, 0x9c, 0x60, 0x8a, 0xd5, 0x36, 0x2f, 0x98, 0xc4, 0x5b, + 0x98, 0xab, 0xc1, 0x9f, 0xae, 0x8f, 0x7d, 0xcc, 0x1f, 0xac, 0xfc, 0xab, 0xe8, 0x18, 0xaf, 0x0d, + 0x59, 0xb9, 0x71, 0x9c, 0xfb, 0x51, 0xb1, 0x54, 0x9f, 0xe4, 0x4e, 0x08, 0x53, 0x77, 0x82, 0xbd, + 0xb5, 0x4b, 0x82, 0x0d, 0xd2, 0xa4, 0x9e, 0xd4, 0xef, 0x0c, 0x2f, 0x32, 0x06, 0x94, 0x5b, 0x98, + 0x0e, 0xb1, 0xb7, 0x1e, 0x07, 0x1b, 0xb4, 0x67, 0xe0, 0xb4, 0x77, 0x60, 0xa0, 0xbb, 0x86, 0xe1, + 0xe2, 0xd2, 0x38, 0x89, 0x0d, 0x5b, 0x09, 0xc5, 0x4a, 0x7d, 0x90, 0xdb, 0x09, 0x82, 0x9e, 0x4b, + 0x83, 0x10, 0xe1, 0x25, 0xd5, 0x7e, 0x70, 0xf8, 0x79, 0x0e, 0xb7, 0x11, 0xf4, 0x9c, 0x22, 0xde, + 0x33, 0x70, 0x52, 0x3b, 0x30, 0xf0, 0xbb, 0x60, 0x57, 0x53, 0xc3, 0x56, 0x12, 0xb1, 0xc9, 0xd1, + 0x04, 0x45, 0x02, 0x5d, 0x17, 0xe8, 0x31, 0x8a, 0xaa, 0xe8, 0x6a, 0x4d, 0xa0, 0xab, 0xa9, 0x61, + 0x2b, 0x44, 0x6c, 0xd4, 0x91, 0x2c, 0x47, 0x28, 0xa5, 0x2e, 0x4d, 0x02, 0x44, 0xb4, 0x06, 0x07, + 0xff, 0xcf, 0x18, 0x68, 0xdd, 0xa1, 0x94, 0x3a, 0x79, 0xb8, 0x67, 0xa0, 0x52, 0x39, 0x30, 0xf0, + 0xab, 0x80, 0x8a, 0xcc, 0xb0, 0x5b, 0xd1, 0x57, 0x3b, 0x77, 0x2d, 0x5e, 0x4a, 0xd7, 0x9f, 0xc2, + 0x95, 0x23, 0x85, 0x6b, 0xb5, 0x26, 0x5c, 0xab, 0xa9, 0x61, 0x2b, 0x91, 0xd8, 0x1c, 0x5d, 0xa7, + 0x90, 0x20, 0xa2, 0x35, 0x7b, 0xf5, 0x7e, 0x4b, 0xb8, 0x5e, 0xe5, 0xe1, 0xd1, 0x95, 0x57, 0xbe, + 0xb9, 0xf2, 0xac, 0x74, 0xe5, 0xed, 0xe1, 0xf5, 0x5b, 0xa6, 0x4b, 0xdb, 0x4c, 0x97, 0x3e, 0x32, + 0x5d, 0x7a, 0xd9, 0xe9, 0xb5, 0xed, 0x4e, 0xaf, 0xbd, 0xef, 0xf4, 0xda, 0xe3, 0x5f, 0x3f, 0xa0, + 0xb3, 0xe5, 0xc4, 0x9c, 0xe2, 0xd0, 0xe2, 0x97, 0xf6, 0x2f, 0x42, 0xf4, 0x19, 0x27, 0xf3, 0xf2, + 0x0f, 0xc6, 0x81, 0xe5, 0xe3, 0xf2, 0x3e, 0x27, 0x4d, 0x7e, 0x6f, 0x67, 0x9f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0xbf, 0xe9, 0x90, 0x45, 0xb6, 0x02, 0x00, 0x00, +} + +func (m *HTTPOptions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPOptions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HTTPOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NextCases) > 0 { + for iNdEx := len(m.NextCases) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.NextCases[iNdEx]) + copy(dAtA[i:], m.NextCases[iNdEx]) + i = encodeVarintHttpOptions(dAtA, i, uint64(len(m.NextCases[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if m.NextTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.NextTimeout)) + i-- + dAtA[i] = 0x28 + } + if m.NextTries != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.NextTries)) + i-- + dAtA[i] = 0x20 + } + if m.SendTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.SendTimeout)) + i-- + dAtA[i] = 0x18 + } + if m.ReadTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.ReadTimeout)) + i-- + dAtA[i] = 0x10 + } + if m.MaxBodySize != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.MaxBodySize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintHttpOptions(dAtA []byte, offset int, v uint64) int { + offset -= sovHttpOptions(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *HTTPOptions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxBodySize != 0 { + n += 1 + sovHttpOptions(uint64(m.MaxBodySize)) + } + if m.ReadTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.ReadTimeout)) + } + if m.SendTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.SendTimeout)) + } + if m.NextTries != 0 { + n += 1 + sovHttpOptions(uint64(m.NextTries)) + } + if m.NextTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.NextTimeout)) + } + if len(m.NextCases) > 0 { + for _, s := range m.NextCases { + l = len(s) + n += 1 + l + sovHttpOptions(uint64(l)) + } + } + return n +} + +func sovHttpOptions(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozHttpOptions(x uint64) (n int) { + return sovHttpOptions(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *HTTPOptions) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPOptions: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPOptions: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBodySize", wireType) + } + m.MaxBodySize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxBodySize |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadTimeout", wireType) + } + m.ReadTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReadTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SendTimeout", wireType) + } + m.SendTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SendTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextTries", wireType) + } + m.NextTries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextTries |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextTimeout", wireType) + } + m.NextTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextCases", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthHttpOptions + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthHttpOptions + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextCases = append(m.NextCases, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipHttpOptions(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHttpOptions + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipHttpOptions(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthHttpOptions + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupHttpOptions + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthHttpOptions + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthHttpOptions = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowHttpOptions = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupHttpOptions = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/memory.go b/go/sdl/v2/memory.go new file mode 100644 index 00000000..0dba9cdd --- /dev/null +++ b/go/sdl/v2/memory.go @@ -0,0 +1,35 @@ +package v2 + +import ( + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type memoryAttributes types.Attributes + +func (sdl *memoryAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr memoryAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + for k, v := range res { + attr = append(attr, types.Attribute{ + Key: k, + Value: v, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2/memory.pb.go b/go/sdl/v2/memory.pb.go new file mode 100644 index 00000000..517535ee --- /dev/null +++ b/go/sdl/v2/memory.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/memory.proto + +package v2 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceMemory struct { + Quantity memoryQuantity `protobuf:"varint,1,opt,name=quantity,proto3,casttype=memoryQuantity" json:"size" yaml:"size"` + Attributes memoryAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=memoryAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceMemory) Reset() { *m = ResourceMemory{} } +func (m *ResourceMemory) String() string { return proto.CompactTextString(m) } +func (*ResourceMemory) ProtoMessage() {} +func (*ResourceMemory) Descriptor() ([]byte, []int) { + return fileDescriptor_3507184ff5877dd1, []int{0} +} +func (m *ResourceMemory) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceMemory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceMemory.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceMemory) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceMemory.Merge(m, src) +} +func (m *ResourceMemory) XXX_Size() int { + return m.Size() +} +func (m *ResourceMemory) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceMemory.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceMemory proto.InternalMessageInfo + +func (m *ResourceMemory) GetQuantity() memoryQuantity { + if m != nil { + return m.Quantity + } + return 0 +} + +func (m *ResourceMemory) GetAttributes() memoryAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceMemory)(nil), "akash.sdl.v2.ResourceMemory") +} + +func init() { proto.RegisterFile("akash/sdl/v2/memory.proto", fileDescriptor_3507184ff5877dd1) } + +var fileDescriptor_3507184ff5877dd1 = []byte{ + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0xcf, 0x4d, 0xcd, 0xcd, 0x2f, 0xaa, 0xd4, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x01, 0x4b, 0xe9, 0x15, 0xa7, 0xe4, 0xe8, 0x95, 0x19, + 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0x25, 0x88, + 0xf6, 0xa4, 0xc4, 0xe2, 0x54, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x63, 0xfd, 0xc4, 0x92, + 0x92, 0xa2, 0xcc, 0xa4, 0xd2, 0x92, 0x54, 0x88, 0x1a, 0xa5, 0x77, 0x8c, 0x5c, 0x7c, 0x41, 0xa9, + 0xc5, 0xf9, 0xa5, 0x45, 0xc9, 0xa9, 0xbe, 0x60, 0x0b, 0x84, 0x02, 0xb9, 0x38, 0x0a, 0x4b, 0x13, + 0xf3, 0x4a, 0x32, 0x4b, 0x2a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x9d, 0x4c, 0x1f, 0xdd, 0x93, + 0xe7, 0x08, 0x84, 0x8a, 0xbd, 0xba, 0x27, 0xcf, 0x52, 0x9c, 0x59, 0x95, 0xfa, 0xe9, 0x9e, 0x3c, + 0x77, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x88, 0xa7, 0xf4, 0xeb, 0x9e, 0x3c, 0x1f, 0xc4, 0x85, + 0x30, 0x85, 0x41, 0x70, 0x63, 0x84, 0x3a, 0x18, 0xb9, 0xb8, 0xe0, 0x36, 0x17, 0x4b, 0x30, 0x29, + 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xea, 0x41, 0xfc, 0x00, 0x72, 0x9f, 0x1e, 0xd4, 0x7d, 0x7a, 0x8e, + 0x30, 0x55, 0x4e, 0x9e, 0x27, 0xee, 0xc9, 0x33, 0x3c, 0xba, 0x27, 0xcf, 0x05, 0x17, 0x2a, 0x7e, + 0x75, 0x4f, 0x1e, 0xc9, 0x98, 0x4f, 0xf7, 0xe4, 0x05, 0x21, 0x0e, 0x40, 0x88, 0x29, 0xad, 0xba, + 0x2f, 0x2f, 0x00, 0x71, 0x06, 0x42, 0x5b, 0x10, 0x92, 0x26, 0x27, 0xb7, 0x13, 0x8f, 0xe4, 0x18, + 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, + 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, + 0xcf, 0xd5, 0x07, 0xbb, 0x4c, 0x37, 0x2f, 0xb5, 0xa4, 0x3c, 0xbf, 0x28, 0x1b, 0xca, 0x4b, 0x2c, + 0xc8, 0xd4, 0x4f, 0xcf, 0x87, 0xc6, 0x46, 0x12, 0x1b, 0x38, 0xfc, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x17, 0x58, 0xa9, 0x9e, 0xa4, 0x01, 0x00, 0x00, +} + +func (m *ResourceMemory) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceMemory) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceMemory) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMemory(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Quantity != 0 { + i = encodeVarintMemory(dAtA, i, uint64(m.Quantity)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintMemory(dAtA []byte, offset int, v uint64) int { + offset -= sovMemory(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceMemory) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Quantity != 0 { + n += 1 + sovMemory(uint64(m.Quantity)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovMemory(uint64(l)) + } + } + return n +} + +func sovMemory(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMemory(x uint64) (n int) { + return sovMemory(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceMemory) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceMemory: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceMemory: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantity", wireType) + } + m.Quantity = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Quantity |= memoryQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMemory + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMemory + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMemory(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMemory + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMemory(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMemory + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMemory + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMemory + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMemory = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMemory = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMemory = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/profiles.go b/go/sdl/v2/profiles.go new file mode 100644 index 00000000..f75ae9b0 --- /dev/null +++ b/go/sdl/v2/profiles.go @@ -0,0 +1,115 @@ +package v2 + +import ( + "errors" + "fmt" + "sort" + + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +var errInvalidCoinAmount = errors.New("invalid coin amount") + +type placementPricing map[string]sdk.DecCoin + +type placementAttributes types.Attributes + +type coinNode struct { + Amount string `yaml:"amount"` + Denom string `yaml:"denom"` +} + +func (sdl *placementAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr placementAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + for k, v := range res { + attr = append(attr, types.Attribute{ + Key: k, + Value: v, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} + +func (sdl *placementPricing) UnmarshalYAML(node *yaml.Node) error { + result := make(placementPricing) + + for i := 0; i < len(node.Content); i += 2 { + var coin sdk.DecCoin + + switch node.Content[i+1].Kind { + case yaml.MappingNode: + pcoin := coinNode{} + if err := node.Content[i+1].Decode(&pcoin); err != nil { + return err + } + + amount, err := sdk.NewDecFromStr(pcoin.Amount) + if err != nil { + return err + } + + coin = sdk.NewDecCoinFromDec(pcoin.Denom, amount) + case yaml.ScalarNode: + var err error + if coin, err = sdk.ParseDecCoin(node.Content[i+1].Value); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unexpected content type") + } + + if coin.IsZero() { + return fmt.Errorf("%w: amount is zero", errInvalidCoinAmount) + } + + if coin.IsNegative() { + return fmt.Errorf("%w: amount %q is negative", errNegativeValue, coin.Amount.String()) + } + + result[node.Content[i].Value] = coin + } + + return nil +} + +func (sdl *ProfilePlacement) UnmarshalYAML(node *yaml.Node) error { + result := ProfilePlacement{} + + for i := 0; i < len(node.Content); i += 2 { + var val interface{} + switch node.Content[i].Value { + case "attributes": + val = &result.Attributes + case "signedBy": + val = &result.SignedBy + case "pricing": + val = &result.Pricing + default: + return fmt.Errorf("sdl: unexpected field %s", node.Content[i].Value) + } + + if err := node.Content[i+1].Decode(val); err != nil { + return err + } + } + + *sdl = result + + return nil +} diff --git a/go/sdl/v2/profiles.pb.go b/go/sdl/v2/profiles.pb.go new file mode 100644 index 00000000..507110f7 --- /dev/null +++ b/go/sdl/v2/profiles.pb.go @@ -0,0 +1,1223 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/profiles.proto + +package v2 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ProfileCompute struct { + Resources ComputeResources `protobuf:"bytes,1,opt,name=resources,proto3" json:"resources" yaml:"resources"` +} + +func (m *ProfileCompute) Reset() { *m = ProfileCompute{} } +func (m *ProfileCompute) String() string { return proto.CompactTextString(m) } +func (*ProfileCompute) ProtoMessage() {} +func (*ProfileCompute) Descriptor() ([]byte, []int) { + return fileDescriptor_0d552ef2e33c3e5a, []int{0} +} +func (m *ProfileCompute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProfileCompute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProfileCompute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ProfileCompute) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProfileCompute.Merge(m, src) +} +func (m *ProfileCompute) XXX_Size() int { + return m.Size() +} +func (m *ProfileCompute) XXX_DiscardUnknown() { + xxx_messageInfo_ProfileCompute.DiscardUnknown(m) +} + +var xxx_messageInfo_ProfileCompute proto.InternalMessageInfo + +func (m *ProfileCompute) GetResources() ComputeResources { + if m != nil { + return m.Resources + } + return ComputeResources{} +} + +type ProfilePlacement struct { + Attributes placementAttributes `protobuf:"bytes,1,rep,name=attributes,proto3,castrepeated=placementAttributes" json:"attributes" yaml:"attributes"` + SignedBy v1beta3.SignedBy `protobuf:"bytes,2,opt,name=signed_by,json=signedBy,proto3" json:"signedBy" yaml:"signedBy"` + Pricing map[string]Coin `protobuf:"bytes,3,rep,name=pricing,proto3" json:"pricing" yaml:"pricing" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *ProfilePlacement) Reset() { *m = ProfilePlacement{} } +func (m *ProfilePlacement) String() string { return proto.CompactTextString(m) } +func (*ProfilePlacement) ProtoMessage() {} +func (*ProfilePlacement) Descriptor() ([]byte, []int) { + return fileDescriptor_0d552ef2e33c3e5a, []int{1} +} +func (m *ProfilePlacement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProfilePlacement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProfilePlacement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ProfilePlacement) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProfilePlacement.Merge(m, src) +} +func (m *ProfilePlacement) XXX_Size() int { + return m.Size() +} +func (m *ProfilePlacement) XXX_DiscardUnknown() { + xxx_messageInfo_ProfilePlacement.DiscardUnknown(m) +} + +var xxx_messageInfo_ProfilePlacement proto.InternalMessageInfo + +func (m *ProfilePlacement) GetAttributes() placementAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func (m *ProfilePlacement) GetSignedBy() v1beta3.SignedBy { + if m != nil { + return m.SignedBy + } + return v1beta3.SignedBy{} +} + +func (m *ProfilePlacement) GetPricing() map[string]Coin { + if m != nil { + return m.Pricing + } + return nil +} + +type Profiles struct { + Compute map[string]*ProfileCompute `protobuf:"bytes,1,rep,name=compute,proto3" json:"compute" yaml:"compute" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Placement map[string]*ProfilePlacement `protobuf:"bytes,2,rep,name=placement,proto3" json:"placement" yaml:"placement" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Profiles) Reset() { *m = Profiles{} } +func (m *Profiles) String() string { return proto.CompactTextString(m) } +func (*Profiles) ProtoMessage() {} +func (*Profiles) Descriptor() ([]byte, []int) { + return fileDescriptor_0d552ef2e33c3e5a, []int{2} +} +func (m *Profiles) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Profiles) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Profiles.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Profiles) XXX_Merge(src proto.Message) { + xxx_messageInfo_Profiles.Merge(m, src) +} +func (m *Profiles) XXX_Size() int { + return m.Size() +} +func (m *Profiles) XXX_DiscardUnknown() { + xxx_messageInfo_Profiles.DiscardUnknown(m) +} + +var xxx_messageInfo_Profiles proto.InternalMessageInfo + +func (m *Profiles) GetCompute() map[string]*ProfileCompute { + if m != nil { + return m.Compute + } + return nil +} + +func (m *Profiles) GetPlacement() map[string]*ProfilePlacement { + if m != nil { + return m.Placement + } + return nil +} + +func init() { + proto.RegisterType((*ProfileCompute)(nil), "akash.sdl.v2.ProfileCompute") + proto.RegisterType((*ProfilePlacement)(nil), "akash.sdl.v2.ProfilePlacement") + proto.RegisterMapType((map[string]Coin)(nil), "akash.sdl.v2.ProfilePlacement.PricingEntry") + proto.RegisterType((*Profiles)(nil), "akash.sdl.v2.Profiles") + proto.RegisterMapType((map[string]*ProfileCompute)(nil), "akash.sdl.v2.Profiles.ComputeEntry") + proto.RegisterMapType((map[string]*ProfilePlacement)(nil), "akash.sdl.v2.Profiles.PlacementEntry") +} + +func init() { proto.RegisterFile("akash/sdl/v2/profiles.proto", fileDescriptor_0d552ef2e33c3e5a) } + +var fileDescriptor_0d552ef2e33c3e5a = []byte{ + // 585 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x31, 0x8f, 0xd3, 0x4c, + 0x10, 0x8d, 0x13, 0x7d, 0x5f, 0x92, 0xbd, 0x28, 0x04, 0x83, 0x44, 0x64, 0x0e, 0x1b, 0x2d, 0x20, + 0x45, 0xe2, 0xb0, 0x85, 0x8f, 0x02, 0x5d, 0x87, 0x11, 0x54, 0x08, 0x45, 0xa6, 0x41, 0x08, 0xe9, + 0x64, 0x27, 0x8b, 0xcf, 0xc4, 0xb1, 0x2d, 0xaf, 0x13, 0x94, 0x96, 0x96, 0x86, 0x9f, 0x40, 0xcd, + 0x2f, 0xb9, 0xf2, 0xe8, 0xa8, 0x0c, 0x4a, 0xba, 0x94, 0xf9, 0x05, 0xc8, 0xde, 0xd9, 0xb5, 0x13, + 0x19, 0xba, 0xcd, 0x9b, 0xb7, 0x6f, 0xde, 0xbc, 0x9d, 0x18, 0xdd, 0x76, 0x66, 0x0e, 0xbd, 0x30, + 0xe8, 0x34, 0x30, 0x96, 0xa6, 0x11, 0x27, 0xd1, 0x07, 0x3f, 0x20, 0x54, 0x8f, 0x93, 0x28, 0x8d, + 0xe4, 0x5e, 0x51, 0xd4, 0xe9, 0x34, 0xd0, 0x97, 0xa6, 0x72, 0xd3, 0x8b, 0xbc, 0xa8, 0x28, 0x18, + 0xf9, 0x89, 0x71, 0x14, 0xcc, 0x04, 0x5c, 0x87, 0x12, 0x63, 0xf9, 0xd8, 0x25, 0xa9, 0x73, 0x6a, + 0x38, 0x69, 0x9a, 0xf8, 0xee, 0x22, 0x25, 0xc0, 0xb9, 0xbf, 0xd7, 0x64, 0x12, 0xcd, 0xe3, 0x45, + 0x4a, 0xce, 0x13, 0x42, 0xa3, 0x45, 0x32, 0xe1, 0xdd, 0x94, 0x5b, 0x07, 0x2c, 0x3f, 0x64, 0x05, + 0xfc, 0x59, 0x42, 0xfd, 0x31, 0x73, 0xf6, 0x9c, 0xdd, 0x95, 0x63, 0xd4, 0x15, 0xd7, 0x87, 0xd2, + 0x5d, 0x69, 0x74, 0x64, 0xaa, 0x7a, 0xd5, 0xad, 0x0e, 0x4c, 0x9b, 0xb3, 0x2c, 0xf3, 0x32, 0xd3, + 0x1a, 0xeb, 0x4c, 0xeb, 0x0a, 0x68, 0x9b, 0x69, 0xa5, 0xca, 0x2e, 0xd3, 0x06, 0x2b, 0x67, 0x1e, + 0x9c, 0x61, 0x01, 0x61, 0xbb, 0x2c, 0xe3, 0x1f, 0x2d, 0x34, 0x00, 0x13, 0xe3, 0xc0, 0x99, 0x90, + 0x39, 0x09, 0x53, 0xf9, 0x8b, 0x84, 0x90, 0x18, 0x36, 0x37, 0xd2, 0x1a, 0x1d, 0x99, 0x77, 0xc0, + 0x48, 0x1e, 0x89, 0x0e, 0x91, 0xe8, 0xcf, 0x38, 0xcb, 0x7a, 0x05, 0x3e, 0x90, 0x80, 0x72, 0x23, + 0x15, 0x99, 0x5d, 0xa6, 0x5d, 0x67, 0x4e, 0x4a, 0x0c, 0x7f, 0xff, 0xa5, 0xdd, 0x88, 0x79, 0xdf, + 0xf2, 0xa6, 0x5d, 0xb9, 0x27, 0x7f, 0x44, 0x5d, 0xea, 0x7b, 0x21, 0x99, 0x9e, 0xbb, 0xab, 0x61, + 0xb3, 0x08, 0xe5, 0xb8, 0xce, 0xcb, 0x9b, 0x82, 0x64, 0xad, 0x2c, 0x03, 0xac, 0x74, 0x38, 0xb2, + 0xcd, 0xb4, 0x0e, 0x85, 0xf3, 0x2e, 0xd3, 0xae, 0x31, 0x1b, 0x1c, 0xc1, 0xb6, 0x28, 0xca, 0x14, + 0xb5, 0xe3, 0xc4, 0x9f, 0xf8, 0xa1, 0x37, 0x6c, 0x15, 0x53, 0x3f, 0xdc, 0x8f, 0xff, 0x30, 0x2a, + 0x7d, 0xcc, 0xd8, 0x2f, 0xc2, 0x34, 0x59, 0x59, 0x27, 0xd0, 0xb8, 0x0d, 0xe8, 0x36, 0xd3, 0xb8, + 0xdc, 0x2e, 0xd3, 0xfa, 0xac, 0x2d, 0x00, 0xd8, 0xe6, 0x25, 0xe5, 0x35, 0xea, 0x55, 0x65, 0xe4, + 0x01, 0x6a, 0xcd, 0xc8, 0xaa, 0x78, 0xff, 0xae, 0x9d, 0x1f, 0xe5, 0x11, 0xfa, 0x6f, 0xe9, 0x04, + 0x0b, 0x02, 0xe3, 0xcb, 0x87, 0x3b, 0xe1, 0x87, 0x36, 0x23, 0x9c, 0x35, 0x9f, 0x4a, 0xf8, 0x5b, + 0x0b, 0x75, 0xc0, 0x28, 0x95, 0x3d, 0xd4, 0x86, 0xcd, 0x84, 0x77, 0xbc, 0x57, 0x3b, 0x11, 0xe5, + 0x9b, 0xc5, 0x26, 0x19, 0xe5, 0x53, 0x00, 0x92, 0x4f, 0x01, 0x12, 0xe5, 0x14, 0x00, 0x60, 0x9b, + 0x97, 0x64, 0x8a, 0xba, 0xe2, 0x25, 0x87, 0xcd, 0xa2, 0xd5, 0x83, 0xbf, 0xb4, 0x12, 0xf1, 0xb1, + 0x66, 0x7a, 0xbe, 0xbe, 0x02, 0xcb, 0xd7, 0x57, 0x08, 0x95, 0xeb, 0x2b, 0x20, 0x6c, 0x97, 0x65, + 0xe5, 0x2d, 0xea, 0x55, 0x7d, 0xd7, 0x44, 0x67, 0xee, 0x47, 0x77, 0x5c, 0x6b, 0x89, 0xff, 0xab, + 0xca, 0x10, 0x95, 0xf7, 0xa8, 0xbf, 0x6f, 0xb3, 0x46, 0xfb, 0xc9, 0xbe, 0xb6, 0xfa, 0xef, 0x5d, + 0xa9, 0xa8, 0x5b, 0x2f, 0x2f, 0xd7, 0xaa, 0x74, 0xb5, 0x56, 0xa5, 0xdf, 0x6b, 0x55, 0xfa, 0xba, + 0x51, 0x1b, 0x57, 0x1b, 0xb5, 0xf1, 0x73, 0xa3, 0x36, 0xde, 0x9d, 0x78, 0x7e, 0x7a, 0xb1, 0x70, + 0xf5, 0x49, 0x34, 0x37, 0x0a, 0xb9, 0x47, 0x21, 0x49, 0x3f, 0x45, 0xc9, 0x0c, 0x7e, 0x39, 0xb1, + 0x6f, 0x78, 0x11, 0x7c, 0x4e, 0xdc, 0xff, 0x8b, 0x4f, 0xc9, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xb8, 0x78, 0x79, 0x5d, 0xf0, 0x04, 0x00, 0x00, +} + +func (m *ProfileCompute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProfileCompute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProfileCompute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Resources.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *ProfilePlacement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProfilePlacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProfilePlacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Pricing) > 0 { + for k := range m.Pricing { + v := m.Pricing[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.SignedBy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Profiles) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Profiles) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Profiles) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Placement) > 0 { + for k := range m.Placement { + v := m.Placement[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Compute) > 0 { + for k := range m.Compute { + v := m.Compute[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintProfiles(dAtA []byte, offset int, v uint64) int { + offset -= sovProfiles(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ProfileCompute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Resources.Size() + n += 1 + l + sovProfiles(uint64(l)) + return n +} + +func (m *ProfilePlacement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovProfiles(uint64(l)) + } + } + l = m.SignedBy.Size() + n += 1 + l + sovProfiles(uint64(l)) + if len(m.Pricing) > 0 { + for k, v := range m.Pricing { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + 1 + l + sovProfiles(uint64(l)) + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + return n +} + +func (m *Profiles) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Compute) > 0 { + for k, v := range m.Compute { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovProfiles(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + l + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + if len(m.Placement) > 0 { + for k, v := range m.Placement { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovProfiles(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + l + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + return n +} + +func sovProfiles(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProfiles(x uint64) (n int) { + return sovProfiles(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ProfileCompute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProfileCompute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProfileCompute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Resources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProfilePlacement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProfilePlacement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProfilePlacement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignedBy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SignedBy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pricing", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pricing == nil { + m.Pricing = make(map[string]Coin) + } + var mapkey string + mapvalue := &Coin{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Coin{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Pricing[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Profiles) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Profiles: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Profiles: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Compute", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Compute == nil { + m.Compute = make(map[string]*ProfileCompute) + } + var mapkey string + var mapvalue *ProfileCompute + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ProfileCompute{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Compute[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Placement", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Placement == nil { + m.Placement = make(map[string]*ProfilePlacement) + } + var mapkey string + var mapvalue *ProfilePlacement + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ProfilePlacement{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Placement[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProfiles(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthProfiles + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProfiles + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProfiles + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProfiles = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProfiles = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProfiles = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/sdl.go b/go/sdl/v2/sdl.go new file mode 100644 index 00000000..851663d7 --- /dev/null +++ b/go/sdl/v2/sdl.go @@ -0,0 +1,379 @@ +package v2 + +import ( + "errors" + "fmt" + "path" + "regexp" + "sort" + "strconv" + + "gopkg.in/yaml.v3" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +const ( + sdlVersionField = "version" +) + +var ( + errSDLInvalid = errors.New("SDL invalid") + errUninitializedConfig = errors.New("sdl: uninitialized") + errSDLInvalidNoVersion = fmt.Errorf("%w: no version found", errSDLInvalid) + + endpointNameValidationRegex = regexp.MustCompile(`^[[:lower:]]+[[:lower:]-_\d]+$`) +) + +type SDL struct { + Content `yaml:"-"` + + result struct { + dgroups dtypes.GroupSpecs + mgroups manifest.Groups + } +} + +func (sdl *SDL) DeploymentGroups() (dtypes.GroupSpecs, error) { + return sdl.result.dgroups, nil +} + +func (sdl *SDL) Manifest() (manifest.Manifest, error) { + return manifest.Manifest(sdl.result.mgroups), nil +} + +// Version creates the deterministic Deployment Version hash from the SDL. +func (sdl *SDL) Version() ([]byte, error) { + return manifest.Manifest(sdl.result.mgroups).Version() +} + +func (sdl *SDL) UnmarshalYAML(node *yaml.Node) error { + result := SDL{} + +loop: + for i := 0; i < len(node.Content); i += 2 { + var val interface{} + switch node.Content[i].Value { + case "include": + val = &result.Include + case "services": + val = &result.Services + case "profiles": + val = &result.Profiles + case "deployment": + val = &result.Deployments + case "endpoints": + val = &result.Endpoints + case sdlVersionField: + // version is already verified + continue loop + default: + return fmt.Errorf("sdl: unexpected field %s", node.Content[i].Value) + } + + if err := node.Content[i+1].Decode(val); err != nil { + return err + } + } + + if err := result.buildGroups(); err != nil { + return err + } + + *sdl = result + + return nil +} + +func (sdl *SDL) Validate() error { + for endpointName, endpoint := range sdl.Endpoints { + if !endpointNameValidationRegex.MatchString(endpointName) { + return fmt.Errorf("%w: endpoint named %q is not a valid name", + errSDLInvalid, + endpointName, + ) + } + + if len(endpoint.Kind) == 0 { + return fmt.Errorf("%w: endpoint named %q has no kind", errSDLInvalid, endpointName) + } + + // Validate endpoint kind, there is only one allowed value for now + if endpoint.Kind != endpointKindIP { + return fmt.Errorf( + "%w: endpoint named %q, unknown kind %q", + errSDLInvalid, + endpointName, + endpoint.Kind, + ) + } + } + + endpointsUsed := make(map[string]struct{}) + portsUsed := make(map[string]string) + for _, svcName := range sdl.Deployments.svcNames() { + depl := sdl.Deployments[svcName] + + for _, placementName := range depl.placements() { + svcdepl := depl[placementName] + + compute, ok := sdl.Profiles.Compute[svcdepl.Profile] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no compute profile named %v", + errSDLInvalid, + svcName, + placementName, + svcdepl.Profile, + ) + } + + infra, ok := sdl.Profiles.Placement[placementName] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no placement profile named %v", + errSDLInvalid, + svcName, + placementName, + placementName, + ) + } + + if _, ok := infra.Pricing[svcdepl.Profile]; !ok { + return fmt.Errorf( + "%w: %v.%v: no pricing for profile %v", + errSDLInvalid, + svcName, + placementName, + svcdepl.Profile, + ) + } + + svc, ok := sdl.Services[svcName] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no service profile named %v", + errSDLInvalid, + svcName, + placementName, + svcName, + ) + } + + for _, serviceExpose := range svc.Expose { + for _, to := range serviceExpose.To { + // Check to see if an IP endpoint is also specified + if len(to.IP) != 0 { + if !to.Global { + return fmt.Errorf( + "%w: error on %q if an IP is declared the directive must be declared as global", + errSDLInvalid, + svcName, + ) + } + endpoint, endpointExists := sdl.Endpoints[to.IP] + if !endpointExists { + return fmt.Errorf( + "%w: error on service %q no endpoint named %q exists", + errSDLInvalid, + svcName, + to.IP, + ) + } + + if endpoint.Kind != endpointKindIP { + return fmt.Errorf( + "%w: error on service %q endpoint %q has type %q, should be %q", + errSDLInvalid, + svcName, + to.IP, + endpoint.Kind, + endpointKindIP, + ) + } + + endpointsUsed[to.IP] = struct{}{} + + // Endpoint exists. Now check for port collisions across a single endpoint, port, & protocol + portKey := fmt.Sprintf( + "%s-%d-%s", + to.IP, + serviceExpose.As, + serviceExpose.Proto, + ) + otherServiceName, inUse := portsUsed[portKey] + if inUse { + return fmt.Errorf( + "%w: IP endpoint %q port: %d protocol: %s specified by service %q already in use by %q", + errSDLInvalid, + to.IP, + serviceExpose.Port, + serviceExpose.Proto, + svcName, + otherServiceName, + ) + } + portsUsed[portKey] = svcName + } + } + } + + // validate storage's attributes and parameters + volumes := make(map[string]ResourceStorage) + for _, volume := range compute.Resources.Storage { + // making deepcopy here as we gonna merge compute attributes and service parameters for validation below + attr := make(storageAttributes, len(volume.Attributes)) + + copy(attr, volume.Attributes) + + volumes[volume.Name] = ResourceStorage{ + Name: volume.Name, + Quantity: volume.Quantity, + Attributes: attr, + } + } + + attr := make(map[string]string) + mounts := make(map[string]string) + + if svc.Params != nil { + for name, params := range svc.Params.Storage { + if _, exists := volumes[name]; !exists { + return fmt.Errorf( + "%w: service \"%s\" references to no-existing compute volume named \"%s\"", + errSDLInvalid, + svcName, + name, + ) + } + + if !path.IsAbs(params.Mount) { + return fmt.Errorf( + "%w: invalid value for \"service.%s.params.%s.mount\" parameter. expected absolute path", + errSDLInvalid, + svcName, + name, + ) + } + + attr[StorageAttributeMount] = params.Mount + attr[StorageAttributeReadOnly] = strconv.FormatBool(params.ReadOnly) + + mount := attr[StorageAttributeMount] + if vlname, exists := mounts[mount]; exists { + if mount == "" { + return errStorageMultipleRootEphemeral + } + + return fmt.Errorf( + "%w: mount %q already in use by volume %q", + errStorageDupMountPoint, + mount, + vlname, + ) + } + + mounts[mount] = name + } + } + + for name, volume := range volumes { + for _, nd := range types.Attributes(volume.Attributes) { + attr[nd.Key] = nd.Value + } + + persistent, _ := strconv.ParseBool(attr[StorageAttributePersistent]) + + if persistent && attr[StorageAttributeMount] == "" { + return fmt.Errorf( + "%w: compute.storage.%s has persistent=true which requires service.%s.params.storage.%s to have mount", + errSDLInvalid, + name, + svcName, + name, + ) + } + } + } + } + + for endpointName := range sdl.Endpoints { + _, inUse := endpointsUsed[endpointName] + if !inUse { + return fmt.Errorf( + "%w: endpoint %q declared but never used", + errSDLInvalid, + endpointName, + ) + } + } + + return nil +} + +func (sdl *SDL) computeEndpointSequenceNumbers() map[string]uint32 { + var endpointNames []string + res := make(map[string]uint32) + + for _, serviceName := range sdl.Deployments.svcNames() { + for _, expose := range sdl.Services[serviceName].Expose { + for _, to := range expose.To { + if to.Global && len(to.IP) == 0 { + continue + } + + endpointNames = append(endpointNames, to.IP) + } + } + } + + if len(endpointNames) == 0 { + return res + } + + // Make the assignment stable + sort.Strings(endpointNames) + + // Start at zero, so the first assigned one is 1 + endpointSeqNumber := uint32(0) + for _, name := range endpointNames { + endpointSeqNumber++ + seqNo := endpointSeqNumber + res[name] = seqNo + } + + return res +} + +// func (sdl deployments) svcNames() []string { +// names := make([]string, 0, len(sdl)) +// for name := range sdl { +// names = append(names, name) +// } +// sort.Strings(names) +// +// return names +// } +// +// // placementNames stable ordered placement names +// func (sdl deployment) placementNames() []string { +// names := make([]string, 0, len(sdl)) +// for name := range sdl { +// names = append(names, name) +// } +// sort.Strings(names) +// +// return names +// } +// +// func v2DeploymentPlacementNames(m deployment) []string { +// names := make([]string, 0, len(m)) +// for name := range m { +// names = append(names, name) +// } +// sort.Strings(names) +// +// return names +// } diff --git a/go/sdl/v2/sdl.pb.go b/go/sdl/v2/sdl.pb.go new file mode 100644 index 00000000..c51a9a4f --- /dev/null +++ b/go/sdl/v2/sdl.pb.go @@ -0,0 +1,781 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/sdl.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/structpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Content struct { + Include []string `protobuf:"bytes,1,rep,name=include,proto3" json:"include,omitempty"` + Services map[string]Service `protobuf:"bytes,2,rep,name=services,proto3" json:"services" yaml:"services" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Profiles Profiles `protobuf:"bytes,3,opt,name=profiles,proto3" json:"profiles" yaml:"profiles"` + Deployments Deployments `protobuf:"bytes,4,opt,name=deployments,proto3,customtype=Deployments" json:"deployments" yaml:"deployments"` + Endpoints map[string]Endpoint `protobuf:"bytes,5,rep,name=endpoints,proto3" json:"endpoints" yaml:"endpoints" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Content) Reset() { *m = Content{} } +func (m *Content) String() string { return proto.CompactTextString(m) } +func (*Content) ProtoMessage() {} +func (*Content) Descriptor() ([]byte, []int) { + return fileDescriptor_801d1e6c19755a66, []int{0} +} +func (m *Content) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Content.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_Content.Merge(m, src) +} +func (m *Content) XXX_Size() int { + return m.Size() +} +func (m *Content) XXX_DiscardUnknown() { + xxx_messageInfo_Content.DiscardUnknown(m) +} + +var xxx_messageInfo_Content proto.InternalMessageInfo + +func (m *Content) GetInclude() []string { + if m != nil { + return m.Include + } + return nil +} + +func (m *Content) GetServices() map[string]Service { + if m != nil { + return m.Services + } + return nil +} + +func (m *Content) GetProfiles() Profiles { + if m != nil { + return m.Profiles + } + return Profiles{} +} + +func (m *Content) GetEndpoints() map[string]Endpoint { + if m != nil { + return m.Endpoints + } + return nil +} + +func init() { + proto.RegisterType((*Content)(nil), "akash.sdl.v2.content") + proto.RegisterMapType((map[string]Endpoint)(nil), "akash.sdl.v2.content.EndpointsEntry") + proto.RegisterMapType((map[string]Service)(nil), "akash.sdl.v2.content.ServicesEntry") +} + +func init() { proto.RegisterFile("akash/sdl/v2/sdl.proto", fileDescriptor_801d1e6c19755a66) } + +var fileDescriptor_801d1e6c19755a66 = []byte{ + // 476 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xcb, 0x8e, 0xd3, 0x30, + 0x14, 0x6d, 0xa6, 0x94, 0x69, 0x5d, 0x1e, 0x23, 0x0b, 0x86, 0x28, 0xa0, 0xb8, 0x0a, 0x2c, 0x2a, + 0x31, 0x38, 0x52, 0xd8, 0xa0, 0x59, 0x56, 0x0c, 0x6c, 0x51, 0x86, 0x15, 0xbb, 0x34, 0xf5, 0x64, + 0xa2, 0xa6, 0x71, 0x94, 0x38, 0x41, 0xdd, 0xf2, 0x05, 0xfc, 0x02, 0x7f, 0x33, 0xcb, 0x59, 0x22, + 0x16, 0x16, 0x4a, 0x77, 0x5d, 0xf6, 0x0b, 0x50, 0x1c, 0x3b, 0x0f, 0xd4, 0x55, 0x7c, 0xcf, 0xb9, + 0xf7, 0x1c, 0xfb, 0x9e, 0x80, 0x73, 0x6f, 0xed, 0x65, 0xb7, 0x76, 0xb6, 0x8a, 0xec, 0xc2, 0xa9, + 0x3e, 0x38, 0x49, 0x29, 0xa3, 0xf0, 0x91, 0xc0, 0x71, 0x05, 0x14, 0x8e, 0xf1, 0x2c, 0xa0, 0x01, + 0x15, 0x84, 0x5d, 0x9d, 0xea, 0x1e, 0xe3, 0x55, 0x40, 0x69, 0x10, 0x11, 0x5b, 0x54, 0xcb, 0xfc, + 0xc6, 0xce, 0x58, 0x9a, 0xfb, 0x4c, 0xb2, 0x46, 0x5f, 0x99, 0xa4, 0x45, 0xe8, 0x13, 0xc9, 0xbd, + 0xec, 0x71, 0x49, 0x4a, 0x6f, 0xc2, 0x88, 0x64, 0x47, 0x49, 0x12, 0xaf, 0x12, 0x1a, 0xc6, 0x52, + 0xd5, 0xfa, 0x35, 0x02, 0xa7, 0x3e, 0x8d, 0x19, 0x89, 0x19, 0xd4, 0xc1, 0x69, 0x18, 0xfb, 0x51, + 0xbe, 0x22, 0xba, 0x36, 0x1b, 0xce, 0x27, 0xae, 0x2a, 0x61, 0x02, 0xc6, 0xd2, 0x30, 0xd3, 0x4f, + 0x66, 0xc3, 0xf9, 0xd4, 0x79, 0x8d, 0xbb, 0x0f, 0xc2, 0x52, 0x02, 0x5f, 0xcb, 0xae, 0xab, 0x98, + 0xa5, 0xdb, 0x85, 0x7d, 0xc7, 0xd1, 0xa0, 0xe4, 0x68, 0xac, 0xe0, 0x3d, 0x47, 0x8d, 0xd0, 0x81, + 0xa3, 0xa7, 0x5b, 0x6f, 0x13, 0x5d, 0x5a, 0x0a, 0xb1, 0xdc, 0x86, 0x84, 0x3e, 0x18, 0xab, 0x67, + 0xe8, 0xc3, 0x99, 0x36, 0x9f, 0x3a, 0xe7, 0x7d, 0xc7, 0x2f, 0x92, 0x6d, 0x4d, 0x14, 0x52, 0x99, + 0xa8, 0xd9, 0xd6, 0x44, 0x21, 0x96, 0xdb, 0x90, 0xf0, 0x87, 0x06, 0xa6, 0x2b, 0x92, 0x44, 0x74, + 0xbb, 0x21, 0x31, 0xcb, 0xf4, 0x07, 0xc2, 0xe8, 0x05, 0xae, 0x73, 0xc0, 0x2a, 0x07, 0x7c, 0x2d, + 0x72, 0x58, 0x7c, 0xae, 0x9c, 0xfe, 0x70, 0x34, 0xfd, 0xd8, 0xce, 0x94, 0xfd, 0x72, 0xcf, 0x51, + 0x57, 0xf1, 0xc0, 0x11, 0xac, 0xed, 0x3b, 0xa0, 0xe5, 0x76, 0x5b, 0x60, 0x01, 0x26, 0x2a, 0x93, + 0x4c, 0x1f, 0x89, 0xe5, 0xbe, 0x39, 0xbe, 0xdc, 0x2b, 0xd5, 0x56, 0x6f, 0xd7, 0x91, 0x0f, 0x9f, + 0x34, 0xf8, 0x9e, 0xa3, 0x56, 0xeb, 0xc0, 0xd1, 0x59, 0xed, 0xdd, 0x40, 0x96, 0xdb, 0xd2, 0x86, + 0x0b, 0x1e, 0xf7, 0xd2, 0x82, 0x67, 0x60, 0xb8, 0x26, 0x5b, 0x5d, 0x9b, 0x69, 0xf3, 0x89, 0x5b, + 0x1d, 0xe1, 0x5b, 0x30, 0x2a, 0xbc, 0x28, 0x27, 0xfa, 0x89, 0x58, 0xcc, 0xf3, 0xfe, 0xb5, 0xe4, + 0xb4, 0x5b, 0xf7, 0x5c, 0x9e, 0x7c, 0xd0, 0x8c, 0xaf, 0xe0, 0x49, 0xff, 0x92, 0x47, 0x44, 0x2f, + 0xfa, 0xa2, 0xff, 0xc5, 0xaa, 0xc6, 0x3b, 0xaa, 0x8b, 0x4f, 0x77, 0xa5, 0xa9, 0xdd, 0x97, 0xa6, + 0xf6, 0xb7, 0x34, 0xb5, 0x9f, 0x3b, 0x73, 0x70, 0xbf, 0x33, 0x07, 0xbf, 0x77, 0xe6, 0xe0, 0xdb, + 0x45, 0x10, 0xb2, 0xdb, 0x7c, 0x89, 0x7d, 0xba, 0xb1, 0x85, 0xcc, 0xbb, 0x98, 0xb0, 0xef, 0x34, + 0x5d, 0xcb, 0xca, 0x4b, 0x42, 0x3b, 0xa0, 0xf2, 0xd7, 0x5f, 0x3e, 0x14, 0x81, 0xbe, 0xff, 0x17, + 0x00, 0x00, 0xff, 0xff, 0xcd, 0x22, 0x0c, 0xed, 0xa4, 0x03, 0x00, 0x00, +} + +func (m *Content) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Content) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Endpoints) > 0 { + for k := range m.Endpoints { + v := m.Endpoints[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSdl(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSdl(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } + } + { + size := m.Deployments.Size() + i -= size + if _, err := m.Deployments.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.Profiles.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Services) > 0 { + for k := range m.Services { + v := m.Services[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSdl(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSdl(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Include) > 0 { + for iNdEx := len(m.Include) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Include[iNdEx]) + copy(dAtA[i:], m.Include[iNdEx]) + i = encodeVarintSdl(dAtA, i, uint64(len(m.Include[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintSdl(dAtA []byte, offset int, v uint64) int { + offset -= sovSdl(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Content) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Include) > 0 { + for _, s := range m.Include { + l = len(s) + n += 1 + l + sovSdl(uint64(l)) + } + } + if len(m.Services) > 0 { + for k, v := range m.Services { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSdl(uint64(len(k))) + 1 + l + sovSdl(uint64(l)) + n += mapEntrySize + 1 + sovSdl(uint64(mapEntrySize)) + } + } + l = m.Profiles.Size() + n += 1 + l + sovSdl(uint64(l)) + l = m.Deployments.Size() + n += 1 + l + sovSdl(uint64(l)) + if len(m.Endpoints) > 0 { + for k, v := range m.Endpoints { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSdl(uint64(len(k))) + 1 + l + sovSdl(uint64(l)) + n += mapEntrySize + 1 + sovSdl(uint64(mapEntrySize)) + } + } + return n +} + +func sovSdl(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSdl(x uint64) (n int) { + return sovSdl(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Content) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: content: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: content: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Include", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Include = append(m.Include, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Services == nil { + m.Services = make(map[string]Service) + } + var mapkey string + mapvalue := &Service{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthSdl + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSdl + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSdl + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSdl + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Service{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Services[mapkey] = *mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profiles", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Profiles.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deployments", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Deployments.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Endpoints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Endpoints == nil { + m.Endpoints = make(map[string]Endpoint) + } + var mapkey string + mapvalue := &Endpoint{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthSdl + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSdl + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSdl + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSdl + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Endpoint{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Endpoints[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSdl(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSdl + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSdl + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSdl + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSdl = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSdl = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSdl = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/service.pb.go b/go/sdl/v2/service.pb.go new file mode 100644 index 00000000..fa60de2d --- /dev/null +++ b/go/sdl/v2/service.pb.go @@ -0,0 +1,684 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/service.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Service struct { + Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image" yaml:"image"` + Command []string `protobuf:"bytes,2,rep,name=command,proto3" json:"command" yaml:"command"` + Args []string `protobuf:"bytes,3,rep,name=args,proto3" json:"args" yaml:"args"` + Env []string `protobuf:"bytes,4,rep,name=env,proto3" json:"env" yaml:"env"` + Expose Exposes `protobuf:"bytes,5,rep,name=expose,proto3,castrepeated=Exposes" json:"expose" yaml:"expose"` + Dependencies Dependencies `protobuf:"bytes,6,rep,name=dependencies,proto3,castrepeated=Dependencies" json:"dependencies" yaml:"dependencies"` + Params *ServiceParams `protobuf:"bytes,7,opt,name=params,proto3" json:"params" yaml:"params"` +} + +func (m *Service) Reset() { *m = Service{} } +func (m *Service) String() string { return proto.CompactTextString(m) } +func (*Service) ProtoMessage() {} +func (*Service) Descriptor() ([]byte, []int) { + return fileDescriptor_f1746d0a871f7bbe, []int{0} +} +func (m *Service) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Service.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Service) XXX_Merge(src proto.Message) { + xxx_messageInfo_Service.Merge(m, src) +} +func (m *Service) XXX_Size() int { + return m.Size() +} +func (m *Service) XXX_DiscardUnknown() { + xxx_messageInfo_Service.DiscardUnknown(m) +} + +var xxx_messageInfo_Service proto.InternalMessageInfo + +func (m *Service) GetImage() string { + if m != nil { + return m.Image + } + return "" +} + +func (m *Service) GetCommand() []string { + if m != nil { + return m.Command + } + return nil +} + +func (m *Service) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +func (m *Service) GetEnv() []string { + if m != nil { + return m.Env + } + return nil +} + +func (m *Service) GetExpose() Exposes { + if m != nil { + return m.Expose + } + return nil +} + +func (m *Service) GetDependencies() Dependencies { + if m != nil { + return m.Dependencies + } + return nil +} + +func (m *Service) GetParams() *ServiceParams { + if m != nil { + return m.Params + } + return nil +} + +func init() { + proto.RegisterType((*Service)(nil), "akash.sdl.v2.Service") +} + +func init() { proto.RegisterFile("akash/sdl/v2/service.proto", fileDescriptor_f1746d0a871f7bbe) } + +var fileDescriptor_f1746d0a871f7bbe = []byte{ + // 473 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xb1, 0x8e, 0xd3, 0x40, + 0x10, 0x8d, 0x71, 0x62, 0xeb, 0x36, 0x81, 0xc2, 0x5c, 0x61, 0x02, 0x78, 0x82, 0x25, 0x24, 0x17, + 0x60, 0x4b, 0x39, 0x0a, 0x44, 0x87, 0xb9, 0x43, 0x42, 0x34, 0xc8, 0x74, 0xd7, 0x20, 0x27, 0x5e, + 0xf9, 0xac, 0x8b, 0xbd, 0x96, 0x37, 0x18, 0xee, 0x13, 0xe8, 0xf8, 0x0e, 0xbe, 0x80, 0x4f, 0xb8, + 0xf2, 0x4a, 0xaa, 0x01, 0x39, 0x9d, 0x4b, 0x7f, 0x01, 0xf2, 0xee, 0x5e, 0x88, 0x25, 0xba, 0x7d, + 0xef, 0xcd, 0x9b, 0xb7, 0xb3, 0xb3, 0x64, 0x1e, 0x5f, 0xc6, 0xfc, 0x22, 0xe0, 0xc9, 0x26, 0xa8, + 0x97, 0x01, 0xa7, 0x55, 0x9d, 0xad, 0xa9, 0x5f, 0x56, 0x6c, 0xcb, 0xac, 0x99, 0xd0, 0x7c, 0x9e, + 0x6c, 0xfc, 0x7a, 0x39, 0x3f, 0x4e, 0x59, 0xca, 0x84, 0x10, 0xf4, 0x27, 0x59, 0x33, 0x7f, 0x3c, + 0xf0, 0x27, 0xb4, 0xa4, 0x45, 0x42, 0x8b, 0xf5, 0x95, 0x92, 0x1f, 0x0c, 0x64, 0xfa, 0xb5, 0x64, + 0x5c, 0x75, 0x9f, 0x3f, 0xf9, 0x5f, 0xf2, 0xa7, 0x32, 0xae, 0xe2, 0x9c, 0xcb, 0x12, 0xf7, 0xe7, + 0x98, 0x98, 0x1f, 0xa5, 0x60, 0xbd, 0x24, 0x93, 0x2c, 0x8f, 0x53, 0x6a, 0x6b, 0x0b, 0xcd, 0x3b, + 0x0a, 0xdd, 0x06, 0x61, 0xf2, 0xae, 0x27, 0x5a, 0x04, 0xa9, 0x74, 0x08, 0xb3, 0xab, 0x38, 0xdf, + 0xbc, 0x72, 0x05, 0x74, 0x23, 0x49, 0x5b, 0x21, 0x31, 0xd7, 0x2c, 0xcf, 0xe3, 0x22, 0xb1, 0xef, + 0x2c, 0x74, 0xef, 0x28, 0xf4, 0x1a, 0x04, 0xf3, 0x8d, 0xa4, 0x5a, 0x84, 0x5b, 0xb5, 0x43, 0xb8, + 0x27, 0xfd, 0x8a, 0x70, 0xa3, 0x5b, 0xc9, 0x3a, 0x21, 0xe3, 0xb8, 0x4a, 0xb9, 0xad, 0x8b, 0x06, + 0xd0, 0x20, 0x8c, 0x5f, 0x57, 0x29, 0x6f, 0x11, 0x04, 0xdf, 0x21, 0x4c, 0xa5, 0xb5, 0x47, 0x6e, + 0x24, 0x48, 0xcb, 0x27, 0x3a, 0x2d, 0x6a, 0x7b, 0x2c, 0x3c, 0x8f, 0x1a, 0x04, 0xfd, 0xac, 0xa8, + 0x5b, 0x84, 0x9e, 0xed, 0x10, 0x88, 0x74, 0xd0, 0xa2, 0x76, 0xa3, 0x9e, 0xb2, 0x56, 0xc4, 0x90, + 0x2f, 0x64, 0x4f, 0x16, 0xba, 0x37, 0x5d, 0x1e, 0xfb, 0x87, 0x0b, 0xf0, 0xcf, 0x84, 0x16, 0xbe, + 0xb8, 0x46, 0x18, 0x35, 0x08, 0x86, 0xc4, 0x2d, 0x82, 0x72, 0x75, 0x08, 0x77, 0x55, 0x4b, 0x81, + 0xdd, 0x1f, 0xbf, 0xc1, 0x94, 0x45, 0x3c, 0x52, 0x35, 0xd6, 0x37, 0x8d, 0xcc, 0xf6, 0x5b, 0xca, + 0x28, 0xb7, 0x0d, 0x11, 0x65, 0x0f, 0xa3, 0x4e, 0xf7, 0x7b, 0x0c, 0xdf, 0xab, 0xb8, 0xd9, 0xe9, + 0x81, 0xab, 0x45, 0x18, 0x74, 0xe9, 0x10, 0xee, 0xcb, 0xe8, 0x43, 0xb6, 0xbf, 0xc0, 0xc0, 0x16, + 0x0d, 0x4c, 0xd6, 0x39, 0x31, 0xe4, 0xba, 0x6d, 0x73, 0xa1, 0x79, 0xd3, 0xe5, 0xc3, 0xe1, 0x25, + 0xd4, 0xe6, 0x3f, 0x88, 0x92, 0xf0, 0x69, 0x3f, 0xb2, 0x3c, 0xf7, 0x23, 0x4b, 0xe3, 0xbf, 0x91, + 0x25, 0x76, 0x23, 0x25, 0x84, 0x6f, 0xaf, 0x1b, 0x47, 0xbb, 0x69, 0x1c, 0xed, 0x4f, 0xe3, 0x68, + 0xdf, 0x77, 0xce, 0xe8, 0x66, 0xe7, 0x8c, 0x7e, 0xed, 0x9c, 0xd1, 0xf9, 0xb3, 0x34, 0xdb, 0x5e, + 0x7c, 0x5e, 0xf9, 0x6b, 0x96, 0x07, 0x22, 0xef, 0x79, 0x41, 0xb7, 0x5f, 0x58, 0x75, 0xa9, 0x50, + 0x5c, 0x66, 0x41, 0xca, 0xd4, 0xbf, 0x5c, 0x19, 0xe2, 0x27, 0x9e, 0xfc, 0x0d, 0x00, 0x00, 0xff, + 0xff, 0xcc, 0x62, 0x19, 0xb6, 0x28, 0x03, 0x00, 0x00, +} + +func (m *Service) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Service) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.Dependencies) > 0 { + for iNdEx := len(m.Dependencies) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Dependencies[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Expose) > 0 { + for iNdEx := len(m.Expose) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Expose[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Env) > 0 { + for iNdEx := len(m.Env) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Env[iNdEx]) + copy(dAtA[i:], m.Env[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Env[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Args) > 0 { + for iNdEx := len(m.Args) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Args[iNdEx]) + copy(dAtA[i:], m.Args[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Args[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Command) > 0 { + for iNdEx := len(m.Command) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Command[iNdEx]) + copy(dAtA[i:], m.Command[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Command[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Image) > 0 { + i -= len(m.Image) + copy(dAtA[i:], m.Image) + i = encodeVarintService(dAtA, i, uint64(len(m.Image))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintService(dAtA []byte, offset int, v uint64) int { + offset -= sovService(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Service) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Image) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + if len(m.Command) > 0 { + for _, s := range m.Command { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Args) > 0 { + for _, s := range m.Args { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Env) > 0 { + for _, s := range m.Env { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Expose) > 0 { + for _, e := range m.Expose { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Dependencies) > 0 { + for _, e := range m.Dependencies { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovService(uint64(l)) + } + return n +} + +func sovService(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozService(x uint64) (n int) { + return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Service) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Service: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Service: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Image = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Command", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Command = append(m.Command, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Args = append(m.Args, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Env", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Env = append(m.Env, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expose", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Expose = append(m.Expose, Expose{}) + if err := m.Expose[len(m.Expose)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dependencies", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Dependencies = append(m.Dependencies, Dependency{}) + if err := m.Dependencies[len(m.Dependencies)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &ServiceParams{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipService(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthService + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupService + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthService + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowService = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/service_params.pb.go b/go/sdl/v2/service_params.pb.go new file mode 100644 index 00000000..8c478ebc --- /dev/null +++ b/go/sdl/v2/service_params.pb.go @@ -0,0 +1,665 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/service_params.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ServiceStorageParams struct { + Mount string `protobuf:"bytes,1,opt,name=mount,proto3" json:"mount" yaml:"mount"` + ReadOnly bool `protobuf:"varint,2,opt,name=read_only,json=readOnly,proto3" json:"readOnly" yaml:"readOnly"` +} + +func (m *ServiceStorageParams) Reset() { *m = ServiceStorageParams{} } +func (m *ServiceStorageParams) String() string { return proto.CompactTextString(m) } +func (*ServiceStorageParams) ProtoMessage() {} +func (*ServiceStorageParams) Descriptor() ([]byte, []int) { + return fileDescriptor_25037b2bfca6b25d, []int{0} +} +func (m *ServiceStorageParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServiceStorageParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServiceStorageParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServiceStorageParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceStorageParams.Merge(m, src) +} +func (m *ServiceStorageParams) XXX_Size() int { + return m.Size() +} +func (m *ServiceStorageParams) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceStorageParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceStorageParams proto.InternalMessageInfo + +func (m *ServiceStorageParams) GetMount() string { + if m != nil { + return m.Mount + } + return "" +} + +func (m *ServiceStorageParams) GetReadOnly() bool { + if m != nil { + return m.ReadOnly + } + return false +} + +type ServiceParams struct { + Storage map[string]*ServiceStorageParams `protobuf:"bytes,1,rep,name=Storage,proto3" json:"storage" yaml:"storage" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *ServiceParams) Reset() { *m = ServiceParams{} } +func (m *ServiceParams) String() string { return proto.CompactTextString(m) } +func (*ServiceParams) ProtoMessage() {} +func (*ServiceParams) Descriptor() ([]byte, []int) { + return fileDescriptor_25037b2bfca6b25d, []int{1} +} +func (m *ServiceParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServiceParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServiceParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServiceParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceParams.Merge(m, src) +} +func (m *ServiceParams) XXX_Size() int { + return m.Size() +} +func (m *ServiceParams) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceParams proto.InternalMessageInfo + +func (m *ServiceParams) GetStorage() map[string]*ServiceStorageParams { + if m != nil { + return m.Storage + } + return nil +} + +func init() { + proto.RegisterType((*ServiceStorageParams)(nil), "akash.sdl.v2.ServiceStorageParams") + proto.RegisterType((*ServiceParams)(nil), "akash.sdl.v2.ServiceParams") + proto.RegisterMapType((map[string]*ServiceStorageParams)(nil), "akash.sdl.v2.ServiceParams.StorageEntry") +} + +func init() { proto.RegisterFile("akash/sdl/v2/service_params.proto", fileDescriptor_25037b2bfca6b25d) } + +var fileDescriptor_25037b2bfca6b25d = []byte{ + // 364 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0xc1, 0x6a, 0xea, 0x40, + 0x14, 0x75, 0x14, 0x9f, 0x3a, 0xfa, 0xde, 0x2b, 0xc1, 0x85, 0xb8, 0xc8, 0xd8, 0x59, 0x05, 0xda, + 0x26, 0x90, 0x6e, 0xc4, 0x65, 0xa0, 0xa5, 0x9b, 0xd2, 0x12, 0x77, 0x5d, 0x54, 0x46, 0x33, 0x44, + 0x31, 0xc9, 0xc8, 0x24, 0xa6, 0xe4, 0x2f, 0xba, 0xee, 0x17, 0x75, 0xe9, 0xb2, 0x9b, 0x0e, 0x25, + 0xee, 0x5c, 0xfa, 0x05, 0x25, 0x99, 0xb1, 0x28, 0x74, 0x77, 0xee, 0xb9, 0xe7, 0x1e, 0xce, 0xbd, + 0x17, 0x9e, 0x93, 0x25, 0x89, 0xe7, 0x56, 0xec, 0x05, 0x56, 0x6a, 0x5b, 0x31, 0xe5, 0xe9, 0x62, + 0x46, 0x27, 0x2b, 0xc2, 0x49, 0x18, 0x9b, 0x2b, 0xce, 0x12, 0xa6, 0x75, 0x4a, 0x89, 0x19, 0x7b, + 0x81, 0x99, 0xda, 0xfd, 0xae, 0xcf, 0x7c, 0x56, 0x36, 0xac, 0x02, 0x49, 0x0d, 0x7e, 0x03, 0xb0, + 0x3b, 0x96, 0xc3, 0xe3, 0x84, 0x71, 0xe2, 0xd3, 0xc7, 0xd2, 0x42, 0x1b, 0xc2, 0x7a, 0xc8, 0xd6, + 0x51, 0xd2, 0x03, 0x03, 0x60, 0xb4, 0x1c, 0x9c, 0x0b, 0x54, 0xbf, 0x2f, 0x88, 0x9d, 0x40, 0xb2, + 0xb3, 0x17, 0xa8, 0x93, 0x91, 0x30, 0x18, 0xe1, 0xb2, 0xc4, 0xae, 0xa4, 0xb5, 0x3b, 0xd8, 0xe2, + 0x94, 0x78, 0x13, 0x16, 0x05, 0x59, 0xaf, 0x3a, 0x00, 0x46, 0xd3, 0xb9, 0xc8, 0x05, 0x6a, 0xba, + 0x94, 0x78, 0x0f, 0x51, 0x90, 0xed, 0x04, 0x6a, 0x72, 0x85, 0xf7, 0x02, 0xfd, 0x97, 0x1e, 0x07, + 0x06, 0xbb, 0x3f, 0x4d, 0xfc, 0x09, 0xe0, 0x5f, 0x15, 0x4e, 0xa5, 0x0a, 0x60, 0x43, 0xc5, 0xec, + 0x81, 0x41, 0xcd, 0x68, 0xdb, 0x86, 0x79, 0xbc, 0xa4, 0x79, 0xa2, 0x36, 0x95, 0xf4, 0x26, 0x4a, + 0x78, 0xe6, 0x18, 0xb9, 0x40, 0x87, 0xe1, 0x9d, 0x40, 0x8d, 0x58, 0xc2, 0xbd, 0x40, 0xff, 0x64, + 0x02, 0x45, 0x60, 0xf7, 0xa0, 0xea, 0x3f, 0xc3, 0xce, 0xb1, 0x85, 0x76, 0x06, 0x6b, 0x4b, 0x9a, + 0xc9, 0x8b, 0xb8, 0x05, 0x2c, 0xae, 0x94, 0x92, 0x60, 0x4d, 0xcb, 0x3d, 0xdb, 0x36, 0xfe, 0x35, + 0xcd, 0xc9, 0x61, 0x5d, 0x39, 0x30, 0xaa, 0x0e, 0x81, 0x73, 0xfb, 0x9e, 0xeb, 0x60, 0x93, 0xeb, + 0xe0, 0x2b, 0xd7, 0xc1, 0xeb, 0x56, 0xaf, 0x6c, 0xb6, 0x7a, 0xe5, 0x63, 0xab, 0x57, 0x9e, 0x2e, + 0xfd, 0x45, 0x32, 0x5f, 0x4f, 0xcd, 0x19, 0x0b, 0xad, 0xd2, 0xf2, 0x2a, 0xa2, 0xc9, 0x0b, 0xe3, + 0x4b, 0x55, 0x91, 0xd5, 0xc2, 0xf2, 0x99, 0xfa, 0xfe, 0xf4, 0x4f, 0xf9, 0xcb, 0xeb, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x7f, 0x3d, 0xe1, 0xce, 0x14, 0x02, 0x00, 0x00, +} + +func (m *ServiceStorageParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServiceStorageParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServiceStorageParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReadOnly { + i-- + if m.ReadOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Mount) > 0 { + i -= len(m.Mount) + copy(dAtA[i:], m.Mount) + i = encodeVarintServiceParams(dAtA, i, uint64(len(m.Mount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ServiceParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServiceParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServiceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Storage) > 0 { + for k := range m.Storage { + v := m.Storage[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintServiceParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintServiceParams(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintServiceParams(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintServiceParams(dAtA []byte, offset int, v uint64) int { + offset -= sovServiceParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ServiceStorageParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Mount) + if l > 0 { + n += 1 + l + sovServiceParams(uint64(l)) + } + if m.ReadOnly { + n += 2 + } + return n +} + +func (m *ServiceParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Storage) > 0 { + for k, v := range m.Storage { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovServiceParams(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovServiceParams(uint64(len(k))) + l + n += mapEntrySize + 1 + sovServiceParams(uint64(mapEntrySize)) + } + } + return n +} + +func sovServiceParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozServiceParams(x uint64) (n int) { + return sovServiceParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ServiceStorageParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServiceStorageParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServiceStorageParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthServiceParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Mount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadOnly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ServiceParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServiceParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServiceParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthServiceParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Storage == nil { + m.Storage = make(map[string]*ServiceStorageParams) + } + var mapkey string + var mapvalue *ServiceStorageParams + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthServiceParams + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthServiceParams + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthServiceParams + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ServiceStorageParams{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Storage[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipServiceParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthServiceParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupServiceParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthServiceParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthServiceParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowServiceParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupServiceParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/service_placement.pb.go b/go/sdl/v2/service_placement.pb.go new file mode 100644 index 00000000..224c13f9 --- /dev/null +++ b/go/sdl/v2/service_placement.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/service_placement.proto + +package v2 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ServicePlacement struct { + Profile string `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile" yaml:"profile"` + Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count" yaml:"count"` +} + +func (m *ServicePlacement) Reset() { *m = ServicePlacement{} } +func (m *ServicePlacement) String() string { return proto.CompactTextString(m) } +func (*ServicePlacement) ProtoMessage() {} +func (*ServicePlacement) Descriptor() ([]byte, []int) { + return fileDescriptor_b7c2b83cdfe6ca6f, []int{0} +} +func (m *ServicePlacement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServicePlacement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServicePlacement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServicePlacement) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServicePlacement.Merge(m, src) +} +func (m *ServicePlacement) XXX_Size() int { + return m.Size() +} +func (m *ServicePlacement) XXX_DiscardUnknown() { + xxx_messageInfo_ServicePlacement.DiscardUnknown(m) +} + +var xxx_messageInfo_ServicePlacement proto.InternalMessageInfo + +func (m *ServicePlacement) GetProfile() string { + if m != nil { + return m.Profile + } + return "" +} + +func (m *ServicePlacement) GetCount() uint32 { + if m != nil { + return m.Count + } + return 0 +} + +func init() { + proto.RegisterType((*ServicePlacement)(nil), "akash.sdl.v2.ServicePlacement") +} + +func init() { + proto.RegisterFile("akash/sdl/v2/service_placement.proto", fileDescriptor_b7c2b83cdfe6ca6f) +} + +var fileDescriptor_b7c2b83cdfe6ca6f = []byte{ + // 258 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, + 0x8d, 0x2f, 0xc8, 0x49, 0x4c, 0x4e, 0xcd, 0x4d, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0xe2, 0x01, 0xab, 0xd2, 0x2b, 0x4e, 0xc9, 0xd1, 0x2b, 0x33, 0x92, 0x12, 0x49, 0xcf, 0x4f, + 0xcf, 0x07, 0x4b, 0xe8, 0x83, 0x58, 0x10, 0x35, 0x4a, 0xd3, 0x18, 0xb9, 0x04, 0x82, 0x21, 0xfa, + 0x03, 0x60, 0xda, 0x85, 0x9c, 0xb8, 0xd8, 0x0b, 0x8a, 0xf2, 0xd3, 0x32, 0x73, 0x52, 0x25, 0x18, + 0x15, 0x18, 0x35, 0x38, 0x9d, 0x34, 0x1e, 0xdd, 0x93, 0x67, 0x0f, 0x80, 0x08, 0xbd, 0xba, 0x27, + 0x0f, 0x93, 0xfd, 0x74, 0x4f, 0x9e, 0xaf, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x2a, 0xa0, 0x14, + 0x04, 0x93, 0x12, 0xb2, 0xe0, 0x62, 0x4d, 0xce, 0x2f, 0xcd, 0x2b, 0x91, 0x60, 0x52, 0x60, 0xd4, + 0xe0, 0x75, 0x52, 0x7a, 0x74, 0x4f, 0x9e, 0xd5, 0x19, 0x24, 0xf0, 0xea, 0x9e, 0x3c, 0x44, 0xe6, + 0xd3, 0x3d, 0x79, 0x1e, 0x88, 0x6e, 0x30, 0x57, 0x29, 0x08, 0x22, 0x6c, 0xc5, 0xf2, 0x62, 0x81, + 0x3c, 0xa3, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, + 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, + 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x7d, 0xa8, 0x9b, 0x97, 0x5a, + 0x52, 0x9e, 0x5f, 0x94, 0x0d, 0xe5, 0x25, 0x16, 0x64, 0xea, 0xa7, 0xe7, 0x43, 0x03, 0x27, 0x89, + 0x0d, 0xec, 0x4f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xb7, 0x3a, 0x72, 0x33, 0x01, + 0x00, 0x00, +} + +func (this *ServicePlacement) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ServicePlacement) + if !ok { + that2, ok := that.(ServicePlacement) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Profile != that1.Profile { + return false + } + if this.Count != that1.Count { + return false + } + return true +} +func (m *ServicePlacement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServicePlacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServicePlacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Count != 0 { + i = encodeVarintServicePlacement(dAtA, i, uint64(m.Count)) + i-- + dAtA[i] = 0x10 + } + if len(m.Profile) > 0 { + i -= len(m.Profile) + copy(dAtA[i:], m.Profile) + i = encodeVarintServicePlacement(dAtA, i, uint64(len(m.Profile))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintServicePlacement(dAtA []byte, offset int, v uint64) int { + offset -= sovServicePlacement(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ServicePlacement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Profile) + if l > 0 { + n += 1 + l + sovServicePlacement(uint64(l)) + } + if m.Count != 0 { + n += 1 + sovServicePlacement(uint64(m.Count)) + } + return n +} + +func sovServicePlacement(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozServicePlacement(x uint64) (n int) { + return sovServicePlacement(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ServicePlacement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServicePlacement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServicePlacement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profile", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthServicePlacement + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthServicePlacement + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Profile = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipServicePlacement(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServicePlacement + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipServicePlacement(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthServicePlacement + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupServicePlacement + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthServicePlacement + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthServicePlacement = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowServicePlacement = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupServicePlacement = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/storage.go b/go/sdl/v2/storage.go new file mode 100644 index 00000000..024a4b6a --- /dev/null +++ b/go/sdl/v2/storage.go @@ -0,0 +1,234 @@ +package v2 + +import ( + "errors" + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +const ( + StorageEphemeral = "ephemeral" + StorageAttributePersistent = "persistent" + StorageAttributeClass = "class" + StorageAttributeMount = "mount" + StorageAttributeReadOnly = "readOnly" // we might not need it at this point of time + StorageClassDefault = "default" +) + +var ( + errUnsupportedStorageAttribute = errors.New("sdl: unsupported storage attribute") + errStorageDupMountPoint = errors.New("sdl: duplicated mount point") + errStorageMultipleRootEphemeral = errors.New("sdl: multiple root ephemeral storages are not allowed") + errStorageDuplicatedVolumeName = errors.New("sdl: duplicated volume name") + errStorageEphemeralClass = errors.New("sdl: ephemeral storage should not set attribute class") +) + +type storageAttributes types.Attributes + +type StorageArray []ResourceStorage + +var _ sort.Interface = (*StorageArray)(nil) + +func (sdl StorageArray) Len() int { + return len(sdl) +} + +func (sdl StorageArray) Swap(i, j int) { + sdl[i], sdl[j] = sdl[j], sdl[i] +} + +// Less storage slice in the following order +// 1. smaller size +// 2. if sizes are equal then one without class goes up +// 3. when both class present use lexicographic order +// 4. if no class in both cases check persistent attribute. one persistent = false goes up +// 5. volume name +func (sdl StorageArray) Less(i, j int) bool { + if sdl[i].Quantity < sdl[j].Quantity { + return true + } + + if sdl[i].Quantity > sdl[j].Quantity { + return false + } + + iAttr := types.Attributes(sdl[i].Attributes) + jAttr := types.Attributes(sdl[j].Attributes) + + iClass, iExists := iAttr.Find(StorageAttributePersistent).AsString() + jClass, jExists := jAttr.Find(StorageAttributePersistent).AsString() + + if (!iExists && jExists) || + (jExists && iExists && iClass < jClass) { + return true + } else if iExists && !jExists { + return false + } + + iPersistent, _ := iAttr.Find(StorageAttributePersistent).AsBool() + jPersistent, _ := jAttr.Find(StorageAttributePersistent).AsBool() + + if !iPersistent { + return true + } else if !jPersistent { + return false + } + + return sdl[i].Name < sdl[j].Name +} + +type validateAttrFn func(string, *string) error + +var allowedStorageClasses = map[string]bool{ + "default": true, + "beta1": true, + "beta2": true, + "beta3": true, +} + +var validateStorageAttributes = map[string]validateAttrFn{ + StorageAttributePersistent: validateAttributeBool, + StorageAttributeClass: validateAttributeStorageClass, +} + +func validateAttributeBool(key string, val *string) error { + if res, valid := unifyStringAsBool(*val); valid { + *val = res + + return nil + } + + return fmt.Errorf("sdl: invalid value for attribute \"%s\". expected bool", key) +} + +func validateAttributeStorageClass(_ string, val *string) error { + if _, valid := allowedStorageClasses[*val]; valid { + return nil + } + + return fmt.Errorf("sdl: invalid value for attribute class") +} + +// UnmarshalYAML unmarshal storage config +// data can be present either as single entry mapping or an array of them +// nolint: gofmt +// e.g +// single entity +// ```yaml +// storage: +// +// size: 1Gi +// attributes: +// class: ssd +// +// ``` +// +// ```yaml +// storage: +// - size: 512Mi # ephemeral storage +// - size: 1Gi +// name: cache +// attributes: +// class: ssd +// - size: 100Gi +// name: data +// attributes: +// persistent: true # this volumes survives pod restart +// class: gp # aka general purpose +// +// ``` +func (sdl *StorageArray) UnmarshalYAML(node *yaml.Node) error { + var nodes StorageArray + + switch node.Kind { + case yaml.SequenceNode: + for _, content := range node.Content { + var nd ResourceStorage + if err := content.Decode(&nd); err != nil { + return err + } + + // set default name to ephemeral. later in validation error thrown if multiple + if nd.Name == "" { + nd.Name = "default" + } + nodes = append(nodes, nd) + } + case yaml.MappingNode: + var nd ResourceStorage + if err := node.Decode(&nd); err != nil { + return err + } + + nd.Name = "default" + nodes = append(nodes, nd) + } + + // check for duplicated volume names + names := make(map[string]string) + for _, nd := range nodes { + if _, exists := names[nd.Name]; exists { + return errStorageDuplicatedVolumeName + } + + names[nd.Name] = nd.Name + } + + sort.Stable(nodes) + + *sdl = nodes + + return nil +} + +func (sdl *storageAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr storageAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + // set default + if _, set := res[StorageAttributePersistent]; !set { + res[StorageAttributePersistent] = valueFalse + } + + persistent := res[StorageAttributePersistent] + class := res[StorageAttributeClass] + if persistent == valueFalse && class != "" { + return errStorageEphemeralClass + } + if persistent == valueTrue && class == "" { + res[StorageAttributeClass] = StorageClassDefault + } + + for k, v := range res { + validateFn, supportedAttr := validateStorageAttributes[k] + if !supportedAttr { + return fmt.Errorf("%w: %s", errUnsupportedStorageAttribute, k) + } + + val := v + if err := validateFn(k, &val); err != nil { + return err + } + + attr = append(attr, types.Attribute{ + Key: k, + Value: val, + }) + } + + // at this point keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2/storage.pb.go b/go/sdl/v2/storage.pb.go new file mode 100644 index 00000000..8aef9e56 --- /dev/null +++ b/go/sdl/v2/storage.pb.go @@ -0,0 +1,425 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2/storage.proto + +package v2 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceStorage struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name" yaml:"name"` + Quantity byteQuantity `protobuf:"varint,2,opt,name=quantity,proto3,casttype=byteQuantity" json:"size" yaml:"size"` + Attributes storageAttributes `protobuf:"bytes,3,rep,name=attributes,proto3,castrepeated=storageAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceStorage) Reset() { *m = ResourceStorage{} } +func (m *ResourceStorage) String() string { return proto.CompactTextString(m) } +func (*ResourceStorage) ProtoMessage() {} +func (*ResourceStorage) Descriptor() ([]byte, []int) { + return fileDescriptor_a3b8e3335e767863, []int{0} +} +func (m *ResourceStorage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceStorage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceStorage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceStorage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceStorage.Merge(m, src) +} +func (m *ResourceStorage) XXX_Size() int { + return m.Size() +} +func (m *ResourceStorage) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceStorage.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceStorage proto.InternalMessageInfo + +func (m *ResourceStorage) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ResourceStorage) GetQuantity() byteQuantity { + if m != nil { + return m.Quantity + } + return 0 +} + +func (m *ResourceStorage) GetAttributes() storageAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceStorage)(nil), "akash.sdl.v2.ResourceStorage") +} + +func init() { proto.RegisterFile("akash/sdl/v2/storage.proto", fileDescriptor_a3b8e3335e767863) } + +var fileDescriptor_a3b8e3335e767863 = []byte{ + // 343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0x31, 0x4f, 0xc2, 0x40, + 0x14, 0xee, 0x01, 0x31, 0x78, 0x60, 0x0c, 0x8d, 0x03, 0x21, 0xb1, 0x47, 0x3a, 0x31, 0xe8, 0x5d, + 0xa4, 0x9b, 0x9b, 0x1d, 0x1c, 0x1c, 0x34, 0xd6, 0xcd, 0xed, 0x0a, 0x97, 0xd2, 0x40, 0x39, 0xec, + 0x5d, 0x31, 0xf8, 0x0f, 0xdc, 0xfc, 0x0f, 0x6e, 0xfe, 0x12, 0x46, 0x46, 0xa7, 0xd3, 0x94, 0x8d, + 0x91, 0xd1, 0xc9, 0xb4, 0x3d, 0xa0, 0xdb, 0xbd, 0xef, 0x7d, 0xdf, 0xf7, 0xde, 0xf7, 0x0e, 0x76, + 0xe8, 0x98, 0x8a, 0x11, 0x11, 0xc3, 0x09, 0x99, 0xf7, 0x89, 0x90, 0x3c, 0xa6, 0x01, 0xc3, 0xb3, + 0x98, 0x4b, 0x6e, 0x36, 0xf3, 0x1e, 0x16, 0xc3, 0x09, 0x9e, 0xf7, 0x3b, 0x67, 0x01, 0x0f, 0x78, + 0xde, 0x20, 0xd9, 0xab, 0xe0, 0x74, 0xec, 0x42, 0xef, 0x53, 0xc1, 0xc8, 0xfc, 0xca, 0x67, 0x92, + 0x3a, 0x84, 0x4a, 0x19, 0x87, 0x7e, 0x22, 0xb5, 0x8f, 0xfd, 0x59, 0x81, 0xa7, 0x1e, 0x13, 0x3c, + 0x89, 0x07, 0xec, 0xa9, 0x98, 0x60, 0x3a, 0xb0, 0x36, 0xa5, 0x11, 0x6b, 0x83, 0x2e, 0xe8, 0x1d, + 0xbb, 0x28, 0x55, 0xa8, 0x76, 0x4f, 0x23, 0xb6, 0x51, 0x28, 0xc7, 0xb7, 0x0a, 0x35, 0x16, 0x34, + 0x9a, 0x5c, 0xdb, 0x59, 0x65, 0x7b, 0x39, 0x68, 0x3e, 0xc0, 0xfa, 0x4b, 0x42, 0xa7, 0x32, 0x94, + 0x8b, 0x76, 0xa5, 0x0b, 0x7a, 0x27, 0xae, 0x93, 0x2a, 0x54, 0x7f, 0xd4, 0x58, 0x26, 0x16, 0xe1, + 0x5b, 0x49, 0x9c, 0x55, 0xf6, 0x9f, 0x42, 0x4d, 0x7f, 0x21, 0xd9, 0x8e, 0xe6, 0xed, 0x4d, 0xcc, + 0x77, 0x00, 0xe1, 0x7e, 0x5b, 0xd1, 0xae, 0x76, 0xab, 0xbd, 0x46, 0xff, 0x1c, 0x17, 0xb9, 0xb3, + 0x4c, 0x58, 0x67, 0xc2, 0x37, 0x3b, 0x96, 0x7b, 0xb7, 0x54, 0xc8, 0x48, 0x15, 0x82, 0x7b, 0x48, + 0x6c, 0x14, 0x2a, 0xd9, 0x6c, 0x15, 0x6a, 0x15, 0xe3, 0x0f, 0x98, 0xfd, 0xf5, 0x83, 0x5a, 0xfa, + 0xba, 0x07, 0x9d, 0x57, 0x52, 0xb9, 0xb7, 0xcb, 0xd4, 0x02, 0xab, 0xd4, 0x02, 0xbf, 0xa9, 0x05, + 0x3e, 0xd6, 0x96, 0xb1, 0x5a, 0x5b, 0xc6, 0xf7, 0xda, 0x32, 0x9e, 0x2f, 0x82, 0x50, 0x8e, 0x12, + 0x1f, 0x0f, 0x78, 0x44, 0xf2, 0xd5, 0x2e, 0xa7, 0x4c, 0xbe, 0xf2, 0x78, 0xac, 0x2b, 0x3a, 0x0b, + 0x49, 0xc0, 0xf5, 0x1f, 0xfa, 0x47, 0xf9, 0xd1, 0x9d, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb4, + 0x12, 0x26, 0xe3, 0xda, 0x01, 0x00, 0x00, +} + +func (m *ResourceStorage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceStorage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceStorage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStorage(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Quantity != 0 { + i = encodeVarintStorage(dAtA, i, uint64(m.Quantity)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintStorage(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintStorage(dAtA []byte, offset int, v uint64) int { + offset -= sovStorage(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceStorage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovStorage(uint64(l)) + } + if m.Quantity != 0 { + n += 1 + sovStorage(uint64(m.Quantity)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovStorage(uint64(l)) + } + } + return n +} + +func sovStorage(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStorage(x uint64) (n int) { + return sovStorage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceStorage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceStorage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceStorage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantity", wireType) + } + m.Quantity = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Quantity |= byteQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStorage(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStorage(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthStorage + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStorage + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStorage + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStorage = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStorage = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStorage = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2/storage_test.go b/go/sdl/v2/storage_test.go new file mode 100644 index 00000000..ba24a8a8 --- /dev/null +++ b/go/sdl/v2/storage_test.go @@ -0,0 +1,198 @@ +package v2 + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func TestStorage_LegacyValid(t *testing.T) { + var stream = ` +size: 1Gi +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + + require.Len(t, p, 1) + require.Equal(t, byteQuantity(1*unit.Gi), p[0].Quantity) + require.Len(t, p[0].Attributes, 0) +} + +func TestStorage_ArraySingleElemValid(t *testing.T) { + var stream = ` +- size: 1Gi +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + + require.Len(t, p, 1) + require.Equal(t, byteQuantity(1*unit.Gi), p[0].Quantity) + require.Len(t, p[0].Attributes, 0) +} + +func TestStorage_AttributesPersistentValidClass(t *testing.T) { + var stream = ` +- size: 1Gi + attributes: + persistent: true + class: default +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + + require.Len(t, p, 1) + require.Equal(t, byteQuantity(1*unit.Gi), p[0].Quantity) + require.Len(t, p[0].Attributes, 2) + + attr := types.Attributes(p[0].Attributes) + require.Equal(t, attr[0].Key, "class") + require.Equal(t, attr[0].Value, "default") +} + +func TestStorage_AttributesUnknown(t *testing.T) { + var stream = ` +- size: 1Gi + attributes: + somefield: foo +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.ErrorIs(t, err, errUnsupportedStorageAttribute) +} + +func TestStorage_MultipleUnnamedEphemeral(t *testing.T) { + var stream = ` +- size: 1Gi +- size: 2Gi +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.EqualError(t, err, errStorageDuplicatedVolumeName.Error()) +} + +func TestStorage_EphemeralNoClass(t *testing.T) { + var stream = ` +- size: 1Gi +` + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) +} + +func TestStorage_EphemeralClass(t *testing.T) { + var stream = ` +- size: 1Gi + attributes: + class: foo +` + + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.EqualError(t, err, errStorageEphemeralClass.Error()) +} + +func TestStorage_PersistentDefaultClass(t *testing.T) { + var stream = ` +- size: 1Gi + attributes: + persistent: true +` + + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Len(t, p[0].Attributes, 2) + + require.Equal(t, p[0].Attributes[0].Key, "class") + require.Equal(t, p[0].Attributes[0].Value, "default") +} + +func TestStorage_PersistentClass(t *testing.T) { + var stream = ` +- size: 1Gi + attributes: + persistent: true + class: beta1 +` + + var p StorageArray + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Len(t, p[0].Attributes, 2) + + require.Equal(t, p[0].Attributes[0].Key, "class") + require.Equal(t, p[0].Attributes[0].Value, "beta1") +} + +func TestStorage_StableSort(t *testing.T) { + storage := StorageArray{ + { + Quantity: 2 * unit.Gi, + Attributes: storageAttributes{ + types.Attribute{ + Key: "persistent", + Value: "true", + }, + }, + }, + { + Quantity: 1 * unit.Gi, + }, + { + Quantity: 10 * unit.Gi, + }, + } + + sort.Stable(storage) + + require.Equal(t, byteQuantity(1*unit.Gi), storage[0].Quantity) + require.Equal(t, byteQuantity(2*unit.Gi), storage[1].Quantity) + require.Equal(t, byteQuantity(10*unit.Gi), storage[2].Quantity) +} + +// func TestStorage_Invalid_InvalidMount(t *testing.T) { +// _, err := ReadFile("./_testdata/storageClass1.yaml") +// require.Error(t, err) +// require.Contains(t, err.Error(), "expected absolute path") +// } +// +// func TestStorage_Invalid_MountNotAbsolute(t *testing.T) { +// _, err := ReadFile("./_testdata/storageClass2.yaml") +// require.Error(t, err) +// require.Contains(t, err.Error(), "expected absolute path") +// } +// +// func TestStorage_Invalid_VolumeReference(t *testing.T) { +// _, err := ReadFile("./_testdata/storageClass3.yaml") +// require.Error(t, err) +// require.Contains(t, err.Error(), "references to no-existing compute volume") +// } +// +// func TestStorage_Invalid_DuplicatedMount(t *testing.T) { +// _, err := ReadFile("./_testdata/storageClass4.yaml") +// require.Error(t, err) +// require.Contains(t, err.Error(), "already in use by volume") +// } +// +// func TestStorage_Invalid_NoMount(t *testing.T) { +// _, err := ReadFile("./_testdata/storageClass5.yaml") +// require.Error(t, err) +// require.Contains(t, err.Error(), "to have mount") +// } diff --git a/go/sdl/v2/units.go b/go/sdl/v2/units.go new file mode 100644 index 00000000..b55f0fee --- /dev/null +++ b/go/sdl/v2/units.go @@ -0,0 +1,154 @@ +package v2 + +import ( + "fmt" + "strconv" + "strings" + + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +var ( + errNegativeValue = fmt.Errorf("invalid: negative value not allowed") +) + +var unitSuffixes = map[string]uint64{ + "k": unit.K, + "Ki": unit.Ki, + "M": unit.M, + "Mi": unit.Mi, + "G": unit.G, + "Gi": unit.Gi, + "T": unit.T, + "Ti": unit.Ti, + "P": unit.P, + "Pi": unit.Pi, + "E": unit.E, + "Ei": unit.Ei, +} + +var memorySuffixes = map[string]uint64{ + "Ki": unit.Ki, + "Mi": unit.Mi, + "Gi": unit.Gi, + "Ti": unit.Ti, + "Pi": unit.Pi, + "Ei": unit.Ei, +} + +// CPU shares. One CPUQuantity = 1/1000 of a CPU +type cpuQuantity uint32 + +type gpuQuantity uint64 + +func (u *cpuQuantity) UnmarshalYAML(node *yaml.Node) error { + sval := node.Value + if strings.HasSuffix(sval, "m") { + sval = strings.TrimSuffix(sval, "m") + val, err := strconv.ParseUint(sval, 10, 32) + if err != nil { + return err + } + *u = cpuQuantity(val) + return nil + } + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return err + } + + val *= 1000 + + if val < 0 { + return errNegativeValue + } + + *u = cpuQuantity(val) + + return nil +} + +func (u *gpuQuantity) UnmarshalYAML(node *yaml.Node) error { + sval := node.Value + + val, err := strconv.ParseUint(sval, 10, 64) + if err != nil { + return err + } + + *u = gpuQuantity(val) + + return nil +} + +// Memory,Storage size in bytes. +type byteQuantity uint64 +type memoryQuantity uint64 + +func (u *byteQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := parseWithSuffix(node.Value, unitSuffixes) + if err != nil { + return err + } + *u = byteQuantity(val) + return nil +} + +func (u *memoryQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := parseWithSuffix(node.Value, memorySuffixes) + if err != nil { + return err + } + *u = memoryQuantity(val) + return nil +} + +func (u *memoryQuantity) StringWithSuffix(suffix string) string { + unit, exists := memorySuffixes[suffix] + + val := uint64(*u) / unit + + res := fmt.Sprintf("%d", val) + if exists { + res += suffix + } + + return res +} + +func parseWithSuffix(sval string, units map[string]uint64) (uint64, error) { + for suffix, unit := range units { + if !strings.HasSuffix(sval, suffix) { + continue + } + + sval := strings.TrimSuffix(sval, suffix) + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return 0, err + } + + val *= float64(unit) + + if val < 0 { + return 0, errNegativeValue + } + + return uint64(val), nil + } + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return 0, err + } + + if val < 0 { + return 0, errNegativeValue + } + + return uint64(val), nil +} diff --git a/go/sdl/v2/units_test.go b/go/sdl/v2/units_test.go new file mode 100644 index 00000000..85d4e422 --- /dev/null +++ b/go/sdl/v2/units_test.go @@ -0,0 +1,99 @@ +package v2 + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +func TestCPUQuantity(t *testing.T) { + + type vtype struct { + Val cpuQuantity `yaml:"val"` + } + + tests := []struct { + text string + value uint32 + err bool + }{ + {`val: 1`, 1000, false}, + {`val: -1`, 1000, true}, + + {`val: 0.5`, 500, false}, + {`val: -0.5`, 500, true}, + + {`val: "100m"`, 100, false}, + {`val: "-100m"`, 100, true}, + + {`val: ""`, 0, true}, + } + + for idx, test := range tests { + buf := []byte(test.text) + obj := &vtype{} + + err := yaml.Unmarshal(buf, obj) + + if test.err { + assert.Error(t, err, "idx:%v text:`%v`", idx, test.text) + continue + } + + if !assert.NoError(t, err, "idx:%v text:`%v`", idx, test.text) { + continue + } + + assert.Equal(t, cpuQuantity(test.value), obj.Val, "idx:%v text:`%v`", idx, test.text) + } +} + +func TestByteQuantity(t *testing.T) { + type vtype struct { + Val byteQuantity `yaml:"val"` + } + + tests := []struct { + text string + value uint64 + err bool + }{ + {`val: 1`, 1, false}, + {`val: -1`, 1, true}, + + {`val: "1M"`, unit.M, false}, + {`val: "-1M"`, 0, true}, + + {`val: "0.5M"`, unit.M / 2, false}, + {`val: "-0.5M"`, 0, true}, + + {`val: "3M"`, 3 * unit.M, false}, + {`val: "3G"`, 3 * unit.G, false}, + {`val: "3T"`, 3 * unit.T, false}, + {`val: "3P"`, 3 * unit.P, false}, + {`val: "3E"`, 3 * unit.E, false}, + + {`val: ""`, 0, true}, + } + + for idx, test := range tests { + buf := []byte(test.text) + obj := &vtype{} + + err := yaml.Unmarshal(buf, obj) + + if test.err { + assert.Error(t, err, "idx:%v text:`%v`", idx, test.text) + continue + } + + if !assert.NoError(t, err, "idx:%v text:`%v`", idx, test.text) { + continue + } + + assert.Equal(t, byteQuantity(test.value), obj.Val, "idx:%v text:`%v`", idx, test.text) + } +} diff --git a/go/sdl/v2/utils.go b/go/sdl/v2/utils.go new file mode 100644 index 00000000..b0761a7a --- /dev/null +++ b/go/sdl/v2/utils.go @@ -0,0 +1,21 @@ +package v2 + +const ( + valueFalse = "false" + valueTrue = "true" + valueOn = "on" + valueOff = "off" + valueYes = "yes" + valueNo = "no" +) + +// as per yaml following allowed as bool values +func unifyStringAsBool(val string) (string, bool) { + if val == valueTrue || val == valueOn || val == valueYes { + return valueTrue, true + } else if val == valueFalse || val == valueOff || val == valueNo { + return valueFalse, true + } + + return "", false +} diff --git a/go/sdl/v2_1/accept.go b/go/sdl/v2_1/accept.go new file mode 100644 index 00000000..665762eb --- /dev/null +++ b/go/sdl/v2_1/accept.go @@ -0,0 +1,24 @@ +package v2_1 + +import ( + "net/url" + + "gopkg.in/yaml.v3" +) + +func (p *Accept) UnmarshalYAML(node *yaml.Node) error { + var accept []string + if err := node.Decode(&accept); err != nil { + return err + } + + for _, item := range accept { + if _, err := url.ParseRequestURI("http://" + item); err != nil { + return err + } + } + + p.Items = accept + + return nil +} diff --git a/go/sdl/v2_1/accept.pb.go b/go/sdl/v2_1/accept.pb.go new file mode 100644 index 00000000..a98cbfe9 --- /dev/null +++ b/go/sdl/v2_1/accept.pb.go @@ -0,0 +1,322 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/accept.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Accept struct { + Items []string `protobuf:"bytes,1,rep,name=items,proto3" json:"items" yaml:"items"` +} + +func (m *Accept) Reset() { *m = Accept{} } +func (m *Accept) String() string { return proto.CompactTextString(m) } +func (*Accept) ProtoMessage() {} +func (*Accept) Descriptor() ([]byte, []int) { + return fileDescriptor_40ce6cb9b3fe4f19, []int{0} +} +func (m *Accept) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Accept) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Accept.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Accept) XXX_Merge(src proto.Message) { + xxx_messageInfo_Accept.Merge(m, src) +} +func (m *Accept) XXX_Size() int { + return m.Size() +} +func (m *Accept) XXX_DiscardUnknown() { + xxx_messageInfo_Accept.DiscardUnknown(m) +} + +var xxx_messageInfo_Accept proto.InternalMessageInfo + +func (m *Accept) GetItems() []string { + if m != nil { + return m.Items + } + return nil +} + +func init() { + proto.RegisterType((*Accept)(nil), "akash.sdl.v2_1.Accept") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/accept.proto", fileDescriptor_40ce6cb9b3fe4f19) } + +var fileDescriptor_40ce6cb9b3fe4f19 = []byte{ + // 199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, + 0x28, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x4b, 0xea, 0x15, 0xa7, 0xe4, 0xe8, + 0x95, 0x19, 0xc5, 0x1b, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, + 0x2a, 0x25, 0x27, 0x2e, 0x36, 0x47, 0xb0, 0x2e, 0x21, 0x0b, 0x2e, 0xd6, 0xcc, 0x92, 0xd4, 0xdc, + 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x4e, 0x27, 0xa5, 0x47, 0xf7, 0xe4, 0x59, 0x3d, 0x41, 0x02, + 0xaf, 0xee, 0xc9, 0x43, 0x64, 0x3e, 0xdd, 0x93, 0xe7, 0xa9, 0x4c, 0xcc, 0xcd, 0xb1, 0x52, 0x02, + 0x73, 0x95, 0x82, 0x20, 0xc2, 0x4e, 0x1e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, + 0x10, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x76, 0x8e, + 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0x94, 0x97, 0x58, 0x90, 0xa9, 0x9f, 0x9e, 0x0f, + 0xf5, 0x40, 0xbc, 0x61, 0x12, 0x1b, 0xd8, 0x51, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x97, + 0xe7, 0x5d, 0x5d, 0xd9, 0x00, 0x00, 0x00, +} + +func (m *Accept) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Accept) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Accept) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Items[iNdEx]) + copy(dAtA[i:], m.Items[iNdEx]) + i = encodeVarintAccept(dAtA, i, uint64(len(m.Items[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintAccept(dAtA []byte, offset int, v uint64) int { + offset -= sovAccept(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Accept) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Items) > 0 { + for _, s := range m.Items { + l = len(s) + n += 1 + l + sovAccept(uint64(l)) + } + } + return n +} + +func sovAccept(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAccept(x uint64) (n int) { + return sovAccept(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Accept) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccept + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Accept: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Accept: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAccept + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAccept + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAccept + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAccept(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAccept + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAccept(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAccept + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAccept + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAccept + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAccept + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAccept = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAccept = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAccept = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/coin.go b/go/sdl/v2_1/coin.go new file mode 100644 index 00000000..c9711c1e --- /dev/null +++ b/go/sdl/v2_1/coin.go @@ -0,0 +1,41 @@ +package v2_1 + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "gopkg.in/yaml.v3" +) + +func (sdl *Coin) UnmarshalYAML(node *yaml.Node) error { + parsedCoin := struct { + Amount string `yaml:"amount"` + Denom string `yaml:"denom"` + }{} + + if err := node.Decode(&parsedCoin); err != nil { + return err + } + + amount, err := sdk.NewDecFromStr(parsedCoin.Amount) + if err != nil { + return err + } + + if amount.IsZero() { + return fmt.Errorf("%w: amount is zero", errInvalidCoinAmount) + } + + // Never pass negative amounts to cosmos SDK DecCoin + if amount.IsNegative() { + return fmt.Errorf("%w: amount %q is negative", errNegativeValue, amount.String()) + } + + coin := sdk.NewDecCoinFromDec(parsedCoin.Denom, amount) + + *sdl = Coin{ + Value: coin, + } + + return nil +} diff --git a/go/sdl/v2_1/coin.pb.go b/go/sdl/v2_1/coin.pb.go new file mode 100644 index 00000000..2ba286d7 --- /dev/null +++ b/go/sdl/v2_1/coin.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/coin.proto + +package v2_1 + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Coin struct { + Value types.DecCoin `protobuf:"bytes,1,opt,name=value,proto3" json:"value" yaml:"value"` +} + +func (m *Coin) Reset() { *m = Coin{} } +func (m *Coin) String() string { return proto.CompactTextString(m) } +func (*Coin) ProtoMessage() {} +func (*Coin) Descriptor() ([]byte, []int) { + return fileDescriptor_4d218c06fdd86aff, []int{0} +} +func (m *Coin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Coin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Coin.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Coin) XXX_Merge(src proto.Message) { + xxx_messageInfo_Coin.Merge(m, src) +} +func (m *Coin) XXX_Size() int { + return m.Size() +} +func (m *Coin) XXX_DiscardUnknown() { + xxx_messageInfo_Coin.DiscardUnknown(m) +} + +var xxx_messageInfo_Coin proto.InternalMessageInfo + +func (m *Coin) GetValue() types.DecCoin { + if m != nil { + return m.Value + } + return types.DecCoin{} +} + +func init() { + proto.RegisterType((*Coin)(nil), "akash.sdl.v2_1.Coin") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/coin.proto", fileDescriptor_4d218c06fdd86aff) } + +var fileDescriptor_4d218c06fdd86aff = []byte{ + // 241 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x33, 0xd4, 0x4f, 0xce, 0xcf, 0xcc, 0xd3, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x4b, 0xe9, 0x15, 0xa7, 0xe4, 0xe8, 0x95, 0x19, + 0xc5, 0x1b, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x29, + 0xb9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xa4, 0xc4, 0xe2, 0x54, 0xfd, 0x32, 0xc3, 0xa4, + 0xd4, 0x92, 0x44, 0x64, 0x53, 0x94, 0x92, 0xb8, 0x58, 0x9c, 0xf3, 0x33, 0xf3, 0x84, 0xa2, 0xb8, + 0x58, 0xcb, 0x12, 0x73, 0x4a, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, 0xf4, 0x20, + 0xfa, 0xf4, 0x40, 0xfa, 0xf4, 0xa0, 0xfa, 0xf4, 0x5c, 0x52, 0x93, 0x41, 0x8a, 0x9d, 0xd4, 0x4e, + 0xdc, 0x93, 0x67, 0x78, 0x74, 0x4f, 0x9e, 0x35, 0x0c, 0xa4, 0xe5, 0xd5, 0x3d, 0x79, 0x88, 0xde, + 0x4f, 0xf7, 0xe4, 0x79, 0x2a, 0x13, 0x73, 0x73, 0xac, 0x94, 0xc0, 0x5c, 0xa5, 0x20, 0x88, 0xb0, + 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, + 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, + 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0xbd, 0xa3, 0x9b, 0x97, 0x5a, 0x52, 0x9e, + 0x5f, 0x94, 0x0d, 0xe5, 0x25, 0x16, 0x64, 0xea, 0xa7, 0xe7, 0x43, 0xbd, 0x1f, 0x6f, 0x98, 0xc4, + 0x06, 0x76, 0xb4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x42, 0x62, 0x85, 0x24, 0x17, 0x01, 0x00, + 0x00, +} + +func (m *Coin) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Coin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Coin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCoin(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintCoin(dAtA []byte, offset int, v uint64) int { + offset -= sovCoin(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Coin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Value.Size() + n += 1 + l + sovCoin(uint64(l)) + return n +} + +func sovCoin(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCoin(x uint64) (n int) { + return sovCoin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Coin) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Coin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Coin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCoin + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCoin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCoin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCoin(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCoin + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCoin + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCoin + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCoin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCoin = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCoin = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/compute_resources.go b/go/sdl/v2_1/compute_resources.go new file mode 100644 index 00000000..05912e31 --- /dev/null +++ b/go/sdl/v2_1/compute_resources.go @@ -0,0 +1,52 @@ +package v2_1 + +import ( + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func (sdl *ComputeResources) toResources() types.Resources { + if sdl == nil { + return types.Resources{} + } + + units := types.Resources{ + Endpoints: types.Endpoints{}, + } + + if sdl.CPU != nil { + units.CPU = &types.CPU{ + Units: types.NewResourceValue(uint64(sdl.CPU.Units)), + Attributes: types.Attributes(sdl.CPU.Attributes), + } + } + + if sdl.GPU != nil { + units.GPU = &types.GPU{ + Units: types.NewResourceValue(uint64(sdl.GPU.Units)), + Attributes: types.Attributes(sdl.GPU.Attributes), + } + } else { + units.GPU = &types.GPU{ + Units: types.NewResourceValue(0), + } + } + + if sdl.Memory != nil { + units.Memory = &types.Memory{ + Quantity: types.NewResourceValue(uint64(sdl.Memory.Quantity)), + Attributes: types.Attributes(sdl.Memory.Attributes), + } + } + + for _, storage := range sdl.Storage { + storageEntry := types.Storage{ + Name: storage.Name, + Quantity: types.NewResourceValue(uint64(storage.Quantity)), + Attributes: types.Attributes(storage.Attributes), + } + + units.Storage = append(units.Storage, storageEntry) + } + + return units +} diff --git a/go/sdl/v2_1/compute_resources.pb.go b/go/sdl/v2_1/compute_resources.pb.go new file mode 100644 index 00000000..dee47688 --- /dev/null +++ b/go/sdl/v2_1/compute_resources.pb.go @@ -0,0 +1,522 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/compute_resources.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ComputeResources struct { + CPU *ResourceCPU `protobuf:"bytes,1,opt,name=cpu,proto3" json:"cpu" yaml:"cpu"` + GPU *ResourceGPU `protobuf:"bytes,2,opt,name=gpu,proto3" json:"gpu" yaml:"gpu"` + Memory *ResourceMemory `protobuf:"bytes,3,opt,name=memory,proto3" json:"memory" yaml:"memory"` + Storage StorageArray `protobuf:"bytes,4,rep,name=storage,proto3,castrepeated=StorageArray" json:"storage" yaml:"storage"` +} + +func (m *ComputeResources) Reset() { *m = ComputeResources{} } +func (m *ComputeResources) String() string { return proto.CompactTextString(m) } +func (*ComputeResources) ProtoMessage() {} +func (*ComputeResources) Descriptor() ([]byte, []int) { + return fileDescriptor_d2800b6974327e57, []int{0} +} +func (m *ComputeResources) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ComputeResources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ComputeResources.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ComputeResources) XXX_Merge(src proto.Message) { + xxx_messageInfo_ComputeResources.Merge(m, src) +} +func (m *ComputeResources) XXX_Size() int { + return m.Size() +} +func (m *ComputeResources) XXX_DiscardUnknown() { + xxx_messageInfo_ComputeResources.DiscardUnknown(m) +} + +var xxx_messageInfo_ComputeResources proto.InternalMessageInfo + +func (m *ComputeResources) GetCPU() *ResourceCPU { + if m != nil { + return m.CPU + } + return nil +} + +func (m *ComputeResources) GetGPU() *ResourceGPU { + if m != nil { + return m.GPU + } + return nil +} + +func (m *ComputeResources) GetMemory() *ResourceMemory { + if m != nil { + return m.Memory + } + return nil +} + +func (m *ComputeResources) GetStorage() StorageArray { + if m != nil { + return m.Storage + } + return nil +} + +func init() { + proto.RegisterType((*ComputeResources)(nil), "akash.sdl.v2_1.ComputeResources") +} + +func init() { + proto.RegisterFile("akash/sdl/v2.1/compute_resources.proto", fileDescriptor_d2800b6974327e57) +} + +var fileDescriptor_d2800b6974327e57 = []byte{ + // 383 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xb1, 0x6e, 0xe2, 0x30, + 0x18, 0xc7, 0x93, 0xcb, 0x09, 0xa4, 0x70, 0x87, 0x4e, 0xd1, 0x0d, 0x11, 0x9c, 0x62, 0x94, 0xe1, + 0x44, 0x87, 0x3a, 0x22, 0xdd, 0xaa, 0x2e, 0x0d, 0x03, 0x5d, 0xaa, 0xa2, 0x54, 0x2c, 0x5d, 0x50, + 0x08, 0x91, 0x41, 0x90, 0xda, 0x72, 0x62, 0x10, 0x6f, 0xc1, 0x73, 0xf4, 0x49, 0x18, 0x19, 0x3b, + 0xb9, 0x55, 0xd8, 0x18, 0x79, 0x82, 0x2a, 0xb1, 0x53, 0x51, 0x24, 0xba, 0xe5, 0xfb, 0x7e, 0x7f, + 0xff, 0xfc, 0xc5, 0x9f, 0xfe, 0x3f, 0x98, 0x05, 0xc9, 0xc4, 0x49, 0xc6, 0x73, 0x67, 0xe1, 0xc2, + 0x8e, 0x13, 0xe2, 0x98, 0xb0, 0x34, 0x1a, 0xd2, 0x28, 0xc1, 0x8c, 0x86, 0x51, 0x02, 0x09, 0xc5, + 0x29, 0x36, 0xea, 0x45, 0x0e, 0x26, 0xe3, 0x39, 0x5c, 0xb8, 0xc3, 0x4e, 0xe3, 0x2f, 0xc2, 0x08, + 0x17, 0xc8, 0xc9, 0xbf, 0x44, 0xaa, 0x61, 0x9e, 0xda, 0x08, 0x3b, 0x43, 0xd0, 0x27, 0x69, 0x9e, + 0x90, 0x38, 0x8a, 0x31, 0x5d, 0x49, 0xf8, 0xef, 0x04, 0x26, 0x29, 0xa6, 0x01, 0x8a, 0x04, 0xb5, + 0xd7, 0x9a, 0xfe, 0xa7, 0x2b, 0x06, 0xf6, 0xcb, 0x79, 0x8d, 0x07, 0x5d, 0x0b, 0x09, 0x33, 0xd5, + 0x96, 0xda, 0xae, 0xb9, 0x4d, 0xf8, 0x75, 0x6e, 0x58, 0xe6, 0xba, 0xfd, 0x81, 0xd7, 0xda, 0x70, + 0xa0, 0x66, 0x1c, 0x68, 0xdd, 0xfe, 0x60, 0xcf, 0x41, 0x7e, 0xec, 0xc0, 0x81, 0xbe, 0x0a, 0xe2, + 0xf9, 0xb5, 0x1d, 0x12, 0x66, 0xfb, 0x79, 0x2b, 0x17, 0x22, 0xc2, 0xcc, 0x1f, 0xdf, 0x0b, 0x7b, + 0xc7, 0xc2, 0x9e, 0x10, 0xa2, 0x63, 0x21, 0x2a, 0x84, 0x88, 0x30, 0x23, 0xd0, 0x2b, 0xe2, 0x27, + 0x4d, 0xad, 0x70, 0x5a, 0xe7, 0x9c, 0xf7, 0x45, 0xca, 0xbb, 0x90, 0xda, 0x8a, 0xa8, 0xf7, 0x1c, + 0xc8, 0xf3, 0x07, 0x0e, 0x7e, 0x0b, 0xb9, 0xa8, 0x6d, 0x5f, 0x02, 0x63, 0xa9, 0x57, 0xe5, 0x53, + 0x99, 0x3f, 0x5b, 0x5a, 0xbb, 0xe6, 0x82, 0x73, 0x77, 0x3c, 0x8a, 0x98, 0x77, 0xb3, 0xe1, 0x40, + 0xc9, 0x38, 0xa8, 0xca, 0xc6, 0x9e, 0x83, 0x52, 0x71, 0xe0, 0xa0, 0x2e, 0xae, 0x91, 0x0d, 0xfb, + 0xe5, 0x0d, 0xfc, 0x92, 0xb9, 0x5b, 0x4a, 0x83, 0x95, 0x5f, 0x46, 0xbd, 0xbb, 0x4d, 0x66, 0xa9, + 0xdb, 0xcc, 0x52, 0xdf, 0x33, 0x4b, 0x5d, 0xef, 0x2c, 0x65, 0xbb, 0xb3, 0x94, 0xd7, 0x9d, 0xa5, + 0x3c, 0x41, 0x34, 0x4d, 0x27, 0x6c, 0x04, 0x43, 0x1c, 0x3b, 0xc5, 0x2c, 0x97, 0xcf, 0x51, 0xba, + 0xc4, 0x74, 0x26, 0xab, 0x80, 0x4c, 0x1d, 0x84, 0xe5, 0xaa, 0x87, 0x9d, 0x51, 0xa5, 0xd8, 0xf1, + 0xd5, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x78, 0xcd, 0xa9, 0xa2, 0x02, 0x00, 0x00, +} + +func (m *ComputeResources) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ComputeResources) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ComputeResources) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Storage) > 0 { + for iNdEx := len(m.Storage) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Storage[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.Memory != nil { + { + size, err := m.Memory.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.GPU != nil { + { + size, err := m.GPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.CPU != nil { + { + size, err := m.CPU.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintComputeResources(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintComputeResources(dAtA []byte, offset int, v uint64) int { + offset -= sovComputeResources(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ComputeResources) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CPU != nil { + l = m.CPU.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if m.GPU != nil { + l = m.GPU.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if m.Memory != nil { + l = m.Memory.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + if len(m.Storage) > 0 { + for _, e := range m.Storage { + l = e.Size() + n += 1 + l + sovComputeResources(uint64(l)) + } + } + return n +} + +func sovComputeResources(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozComputeResources(x uint64) (n int) { + return sovComputeResources(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ComputeResources) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ComputeResources: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ComputeResources: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CPU == nil { + m.CPU = &ResourceCPU{} + } + if err := m.CPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GPU", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.GPU == nil { + m.GPU = &ResourceGPU{} + } + if err := m.GPU.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Memory", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Memory == nil { + m.Memory = &ResourceMemory{} + } + if err := m.Memory.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeResources + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthComputeResources + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthComputeResources + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Storage = append(m.Storage, ResourceStorage{}) + if err := m.Storage[len(m.Storage)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipComputeResources(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthComputeResources + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipComputeResources(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowComputeResources + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthComputeResources + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupComputeResources + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthComputeResources + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthComputeResources = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowComputeResources = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupComputeResources = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/cpu.go b/go/sdl/v2_1/cpu.go new file mode 100644 index 00000000..745de731 --- /dev/null +++ b/go/sdl/v2_1/cpu.go @@ -0,0 +1,42 @@ +package v2_1 + +import ( + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type cpuAttributes types.Attributes + +func (sdl *cpuAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr cpuAttributes + + for i := 0; i+1 < len(node.Content); i += 2 { + var value string + switch node.Content[i].Value { + case "arch": + if err := node.Content[i+1].Decode(&value); err != nil { + return err + } + default: + return fmt.Errorf("unsupported cpu attribute \"%s\"", node.Content[i].Value) + } + + attr = append(attr, types.Attribute{ + Key: node.Content[i].Value, + Value: value, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Slice(attr, func(i, j int) bool { + return attr[i].Key < attr[j].Key + }) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2_1/cpu.pb.go b/go/sdl/v2_1/cpu.pb.go new file mode 100644 index 00000000..c698058c --- /dev/null +++ b/go/sdl/v2_1/cpu.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/cpu.proto + +package v2_1 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceCPU struct { + Units cpuQuantity `protobuf:"varint,1,opt,name=units,proto3,casttype=cpuQuantity" json:"units" yaml:"units"` + Attributes cpuAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=cpuAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceCPU) Reset() { *m = ResourceCPU{} } +func (m *ResourceCPU) String() string { return proto.CompactTextString(m) } +func (*ResourceCPU) ProtoMessage() {} +func (*ResourceCPU) Descriptor() ([]byte, []int) { + return fileDescriptor_bd4b195fc07dd6d6, []int{0} +} +func (m *ResourceCPU) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceCPU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceCPU.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceCPU) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceCPU.Merge(m, src) +} +func (m *ResourceCPU) XXX_Size() int { + return m.Size() +} +func (m *ResourceCPU) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceCPU.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceCPU proto.InternalMessageInfo + +func (m *ResourceCPU) GetUnits() cpuQuantity { + if m != nil { + return m.Units + } + return 0 +} + +func (m *ResourceCPU) GetAttributes() cpuAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceCPU)(nil), "akash.sdl.v2_1.ResourceCPU") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/cpu.proto", fileDescriptor_bd4b195fc07dd6d6) } + +var fileDescriptor_bd4b195fc07dd6d6 = []byte{ + // 313 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x50, 0xbf, 0x4e, 0xf3, 0x30, + 0x1c, 0x8c, 0xbf, 0x4f, 0x65, 0x70, 0x29, 0x12, 0x15, 0x43, 0x55, 0x09, 0xbb, 0xca, 0xd4, 0x05, + 0x5b, 0x69, 0x37, 0x36, 0x8a, 0x04, 0x8c, 0x50, 0xa9, 0x0b, 0x4b, 0xe5, 0xa4, 0x56, 0x1a, 0xb5, + 0x8d, 0xa3, 0xd8, 0x0e, 0xea, 0x03, 0xb0, 0xf3, 0x1c, 0x3c, 0x49, 0xc7, 0x8e, 0x4c, 0x06, 0x25, + 0x1b, 0x63, 0x47, 0x26, 0x94, 0x38, 0xb4, 0xdd, 0xfc, 0xbb, 0x3f, 0xbe, 0xd3, 0xc1, 0x0e, 0x5b, + 0x30, 0x39, 0xa7, 0x72, 0xb6, 0xa4, 0xd9, 0x80, 0x78, 0x34, 0x48, 0x34, 0x49, 0x52, 0xa1, 0x44, + 0xfb, 0xac, 0x62, 0x88, 0x9c, 0x2d, 0x49, 0x36, 0x98, 0x7a, 0xdd, 0x8b, 0x50, 0x84, 0xa2, 0xa2, + 0x68, 0xf9, 0xb2, 0xaa, 0xae, 0x6b, 0xfd, 0x3e, 0x93, 0x9c, 0x66, 0x9e, 0xcf, 0x15, 0x1b, 0x52, + 0xa6, 0x54, 0x1a, 0xf9, 0x5a, 0x71, 0xab, 0x71, 0x0d, 0x80, 0xcd, 0x31, 0x97, 0x42, 0xa7, 0x01, + 0xbf, 0x7d, 0x9c, 0xb4, 0xef, 0x61, 0x43, 0xc7, 0x91, 0x92, 0x1d, 0xd0, 0x03, 0xfd, 0xd6, 0xc8, + 0xcb, 0x0d, 0x6e, 0x4c, 0x4a, 0xe0, 0xdb, 0x60, 0xcb, 0xec, 0x0c, 0x3e, 0x5d, 0xb3, 0xd5, 0xf2, + 0xda, 0xad, 0x4e, 0xf7, 0xc7, 0xe0, 0x66, 0x90, 0xe8, 0x27, 0xcd, 0x62, 0x15, 0xa9, 0xf5, 0xd8, + 0xaa, 0xda, 0xaf, 0x00, 0xc2, 0x7d, 0x98, 0xec, 0xfc, 0xeb, 0xfd, 0xef, 0x37, 0x07, 0x97, 0xc4, + 0x16, 0x2f, 0x2b, 0x91, 0xba, 0x12, 0xb9, 0xf9, 0x53, 0x8d, 0xee, 0x36, 0x06, 0x3b, 0xb9, 0xc1, + 0x70, 0x0f, 0x95, 0xb1, 0x47, 0xdf, 0xec, 0x0c, 0x3e, 0xb7, 0xd9, 0x07, 0xcc, 0x7d, 0xff, 0xc4, + 0xad, 0x20, 0xd1, 0x07, 0xcf, 0xf8, 0xc8, 0x31, 0x7a, 0xd8, 0xe4, 0x08, 0x6c, 0x73, 0x04, 0xbe, + 0x72, 0x04, 0xde, 0x0a, 0xe4, 0x6c, 0x0b, 0xe4, 0x7c, 0x14, 0xc8, 0x79, 0x26, 0x61, 0xa4, 0xe6, + 0xda, 0x27, 0x81, 0x58, 0xd1, 0xaa, 0xd6, 0x55, 0xcc, 0xd5, 0x8b, 0x48, 0x17, 0xf5, 0xc5, 0x92, + 0x88, 0x86, 0xa2, 0x9e, 0x7f, 0xea, 0xf9, 0x27, 0xd5, 0x62, 0xc3, 0xdf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x75, 0xfb, 0x26, 0xa5, 0x97, 0x01, 0x00, 0x00, +} + +func (m *ResourceCPU) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceCPU) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceCPU) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCpu(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Units != 0 { + i = encodeVarintCpu(dAtA, i, uint64(m.Units)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintCpu(dAtA []byte, offset int, v uint64) int { + offset -= sovCpu(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceCPU) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Units != 0 { + n += 1 + sovCpu(uint64(m.Units)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovCpu(uint64(l)) + } + } + return n +} + +func sovCpu(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCpu(x uint64) (n int) { + return sovCpu(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceCPU) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceCPU: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceCPU: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + m.Units = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Units |= cpuQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCpu + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCpu + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCpu(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCpu + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCpu(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCpu + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCpu + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCpu + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCpu = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCpu = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCpu = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/dependency.go b/go/sdl/v2_1/dependency.go new file mode 100644 index 00000000..7de3f9d3 --- /dev/null +++ b/go/sdl/v2_1/dependency.go @@ -0,0 +1,21 @@ +package v2_1 + +import ( + "sort" +) + +type Dependencies []Dependency + +var _ sort.Interface = (*Dependencies)(nil) + +func (s Dependencies) Len() int { + return len(s) +} + +func (s Dependencies) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s Dependencies) Less(i, j int) bool { + return s[i].Service < s[j].Service +} diff --git a/go/sdl/v2_1/dependency.pb.go b/go/sdl/v2_1/dependency.pb.go new file mode 100644 index 00000000..a9d70dd2 --- /dev/null +++ b/go/sdl/v2_1/dependency.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/dependency.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Dependency struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service" yaml:"service"` +} + +func (m *Dependency) Reset() { *m = Dependency{} } +func (m *Dependency) String() string { return proto.CompactTextString(m) } +func (*Dependency) ProtoMessage() {} +func (*Dependency) Descriptor() ([]byte, []int) { + return fileDescriptor_dc2225ae5c0007e1, []int{0} +} +func (m *Dependency) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Dependency) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Dependency.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Dependency) XXX_Merge(src proto.Message) { + xxx_messageInfo_Dependency.Merge(m, src) +} +func (m *Dependency) XXX_Size() int { + return m.Size() +} +func (m *Dependency) XXX_DiscardUnknown() { + xxx_messageInfo_Dependency.DiscardUnknown(m) +} + +var xxx_messageInfo_Dependency proto.InternalMessageInfo + +func (m *Dependency) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func init() { + proto.RegisterType((*Dependency)(nil), "akash.sdl.v2_1.Dependency") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/dependency.proto", fileDescriptor_dc2225ae5c0007e1) } + +var fileDescriptor_dc2225ae5c0007e1 = []byte{ + // 205 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x33, 0xd4, 0x4f, 0x49, 0x2d, 0x48, 0xcd, + 0x4b, 0x49, 0xcd, 0x4b, 0xae, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x2b, 0xd0, + 0x2b, 0x4e, 0xc9, 0xd1, 0x2b, 0x33, 0x8a, 0x37, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, + 0xe9, 0x83, 0x58, 0x10, 0x55, 0x4a, 0x01, 0x5c, 0x5c, 0x2e, 0x70, 0x9d, 0x42, 0x4e, 0x5c, 0xec, + 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x1a, 0x8f, + 0xee, 0xc9, 0xb3, 0x07, 0x43, 0x84, 0x5e, 0xdd, 0x93, 0x87, 0xc9, 0x7e, 0xba, 0x27, 0xcf, 0x57, + 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x04, 0x15, 0x50, 0x0a, 0x82, 0x49, 0x39, 0x79, 0x9c, 0x78, 0x24, + 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, + 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x5e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, + 0x72, 0x7e, 0xae, 0x3e, 0xd8, 0x71, 0xba, 0x79, 0xa9, 0x25, 0xe5, 0xf9, 0x45, 0xd9, 0x50, 0x5e, + 0x62, 0x41, 0xa6, 0x7e, 0x7a, 0x3e, 0xd4, 0x4b, 0xf1, 0x86, 0x49, 0x6c, 0x60, 0x27, 0x1a, 0x03, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x97, 0xff, 0xb9, 0xeb, 0x00, 0x00, 0x00, +} + +func (m *Dependency) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Dependency) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Dependency) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Service) > 0 { + i -= len(m.Service) + copy(dAtA[i:], m.Service) + i = encodeVarintDependency(dAtA, i, uint64(len(m.Service))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDependency(dAtA []byte, offset int, v uint64) int { + offset -= sovDependency(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Dependency) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Service) + if l > 0 { + n += 1 + l + sovDependency(uint64(l)) + } + return n +} + +func sovDependency(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDependency(x uint64) (n int) { + return sovDependency(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Dependency) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDependency + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Dependency: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Dependency: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDependency + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDependency + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDependency + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Service = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDependency(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDependency + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDependency(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDependency + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDependency + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDependency + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDependency + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDependency = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDependency = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDependency = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/deployments.go b/go/sdl/v2_1/deployments.go new file mode 100644 index 00000000..6bf55851 --- /dev/null +++ b/go/sdl/v2_1/deployments.go @@ -0,0 +1,144 @@ +package v2_1 + +import ( + "sort" + + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" +) + +type Placements map[string]ServicePlacement +type Deployments map[string]Placements + +func (t *Deployments) Marshal() ([]byte, error) { + return t.MarshalJSON() +} + +func (t *Deployments) MarshalTo(data []byte) (n int, err error) { + val, err := structpb.NewValue(t) + if err != nil { + return 0, err + } + + res, err := protojson.Marshal(val) + if err != nil { + return 0, err + } + + return copy(data, res), nil +} + +func (t *Deployments) Unmarshal(data []byte) error { + return t.UnmarshalJSON(data) +} + +func (t *Deployments) Size() int { + data, _ := t.MarshalJSON() + + return len(data) +} + +func (t *Deployments) MarshalJSON() ([]byte, error) { + val, err := structpb.NewValue(t) + if err != nil { + return nil, err + } + + return protojson.Marshal(val) +} + +func (t *Deployments) UnmarshalJSON(data []byte) error { + val, err := structpb.NewValue(t) + if err != nil { + return err + } + + return protojson.Unmarshal(data, val) +} + +// var _ sort.Interface = (*Placements)(nil) +// +// func (pl Placements) Len() int { +// return len(pl) +// } +// +// func (pl Placements) Swap(i, j int) { +// pl[i], pl[j] = pl[j], pl[i] +// } +// +// func (pl Placements) Less(i, j int) bool { +// return pl[i].Placement < pl[j].Placement +// } +// +// type deploymentServices map[string]DeploymentPlacements +func (t Deployments) svcNames() []string { + names := make([]string, 0, len(t)) + for name := range t { + names = append(names, name) + } + + sort.Strings(names) + + return names +} + +func (t Placements) placements() []string { + names := make([]string, 0, len(t)) + for placement := range t { + names = append(names, placement) + } + sort.Strings(names) + + return names +} + +// // placementNames stable ordered placement names +// func (sdl deploymentServices) placementNames() []string { +// names := make([]string, 0, len(sdl)) +// for name := range sdl { +// names = append(names, name) +// } +// sort.Strings(names) +// +// return names +// } +// +// func v2DeploymentPlacementNames(m DeploymentPlacements) []string { +// names := make([]string, 0, len(m.Placements)) +// for _, placement := range m.Placements { +// names = append(names, placement.Placement) +// } +// sort.Strings(names) +// +// return names +// } + +// func (sdl *DeploymentPlacements) UnmarshalYAML(node *yaml.Node) error { +// var placements DeploymentPlacements +// +// for i := 0; i+1 < len(node.Content); i += 2 { +// var value string +// switch node.Content[i].Value { +// case "arch": +// if err := node.Content[i+1].Decode(&value); err != nil { +// return err +// } +// default: +// return fmt.Errorf("unsupported cpu attribute \"%s\"", node.Content[i].Value) +// } +// +// placements = append(placements, types.Attribute{ +// Key: node.Content[i].Value, +// Value: value, +// }) +// } +// +// // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable +// sort.Slice(placements, func(i, j int) bool { +// return placements[i].Key < placements[j].Key +// }) +// +// *sdl = placements +// +// return nil +// } diff --git a/go/sdl/v2_1/endpoint.pb.go b/go/sdl/v2_1/endpoint.pb.go new file mode 100644 index 00000000..e441127c --- /dev/null +++ b/go/sdl/v2_1/endpoint.pb.go @@ -0,0 +1,318 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/endpoint.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Endpoint struct { + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind" yaml:"kind"` +} + +func (m *Endpoint) Reset() { *m = Endpoint{} } +func (m *Endpoint) String() string { return proto.CompactTextString(m) } +func (*Endpoint) ProtoMessage() {} +func (*Endpoint) Descriptor() ([]byte, []int) { + return fileDescriptor_cece567f66b451bd, []int{0} +} +func (m *Endpoint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Endpoint.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Endpoint) XXX_Merge(src proto.Message) { + xxx_messageInfo_Endpoint.Merge(m, src) +} +func (m *Endpoint) XXX_Size() int { + return m.Size() +} +func (m *Endpoint) XXX_DiscardUnknown() { + xxx_messageInfo_Endpoint.DiscardUnknown(m) +} + +var xxx_messageInfo_Endpoint proto.InternalMessageInfo + +func (m *Endpoint) GetKind() string { + if m != nil { + return m.Kind + } + return "" +} + +func init() { + proto.RegisterType((*Endpoint)(nil), "akash.sdl.v2_1.Endpoint") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/endpoint.proto", fileDescriptor_cece567f66b451bd) } + +var fileDescriptor_cece567f66b451bd = []byte{ + // 201 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x33, 0xd4, 0x4f, 0xcd, 0x4b, 0x29, 0xc8, + 0xcf, 0xcc, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x4b, 0xeb, 0x15, 0xa7, + 0xe4, 0xe8, 0x95, 0x19, 0xc5, 0x1b, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, + 0x2c, 0x88, 0x2a, 0x25, 0x7b, 0x2e, 0x0e, 0x57, 0xa8, 0x3e, 0x21, 0x63, 0x2e, 0x96, 0xec, 0xcc, + 0xbc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x4e, 0x27, 0xf9, 0x47, 0xf7, 0xe4, 0x59, 0xbc, 0x33, + 0xf3, 0x52, 0x5e, 0xdd, 0x93, 0x07, 0x8b, 0x7f, 0xba, 0x27, 0xcf, 0x5d, 0x99, 0x98, 0x9b, 0x63, + 0xa5, 0x04, 0xe2, 0x29, 0x05, 0x81, 0x05, 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, + 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, + 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, + 0xec, 0x16, 0xdd, 0xbc, 0xd4, 0x92, 0xf2, 0xfc, 0xa2, 0x6c, 0x28, 0x2f, 0xb1, 0x20, 0x53, 0x3f, + 0x3d, 0x1f, 0xea, 0xfe, 0x78, 0xc3, 0x24, 0x36, 0xb0, 0x8b, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xf1, 0xc2, 0xdc, 0x63, 0xd8, 0x00, 0x00, 0x00, +} + +func (m *Endpoint) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Endpoint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Kind) > 0 { + i -= len(m.Kind) + copy(dAtA[i:], m.Kind) + i = encodeVarintEndpoint(dAtA, i, uint64(len(m.Kind))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEndpoint(dAtA []byte, offset int, v uint64) int { + offset -= sovEndpoint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Endpoint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Kind) + if l > 0 { + n += 1 + l + sovEndpoint(uint64(l)) + } + return n +} + +func sovEndpoint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEndpoint(x uint64) (n int) { + return sovEndpoint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Endpoint) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEndpoint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Endpoint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Endpoint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEndpoint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEndpoint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEndpoint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Kind = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEndpoint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEndpoint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEndpoint(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEndpoint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEndpoint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEndpoint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEndpoint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEndpoint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEndpoint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEndpoint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/expose.go b/go/sdl/v2_1/expose.go new file mode 100644 index 00000000..2bee46cc --- /dev/null +++ b/go/sdl/v2_1/expose.go @@ -0,0 +1,93 @@ +package v2_1 + +import ( + "sort" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" +) + +type Exposes []Expose + +func (sdl Exposes) toManifestExpose(endpointNames map[string]uint32) (manifest.ServiceExposes, error) { + exposeCount := 0 + for _, expose := range sdl { + if len(expose.To) > 0 { + exposeCount += len(expose.To) + } else { + exposeCount++ + } + } + + res := make(manifest.ServiceExposes, 0, exposeCount) + + for _, expose := range sdl { + exp, err := expose.toManifestExposes(endpointNames) + if err != nil { + return nil, err + } + + res = append(res, exp...) + } + + sort.Sort(res) + + return res, nil +} + +func (sdl Expose) toManifestExposes(endpointNames map[string]uint32) (manifest.ServiceExposes, error) { + exposeCount := len(sdl.To) + if exposeCount == 0 { + exposeCount = 1 + } + + res := make(manifest.ServiceExposes, 0, exposeCount) + + proto, err := manifest.ParseServiceProtocol(sdl.Proto) + if err != nil { + return nil, err + } + + httpOptions, err := sdl.HTTPOptions.asManifest() + if err != nil { + return nil, err + } + + if len(sdl.To) > 0 { + for _, to := range sdl.To { + // This value is created just so it can be passed to the utility function + expose := manifest.ServiceExpose{ + Service: to.Service, + Port: sdl.Port, + ExternalPort: sdl.As, + Proto: proto, + Global: to.Global, + Hosts: sdl.Accept.Items, + HTTPOptions: httpOptions, + IP: to.IP, + } + + // Check to see if an IP endpoint is also specified + if expose.Global && len(expose.IP) != 0 { + seqNo := endpointNames[expose.IP] + expose.EndpointSequenceNumber = seqNo + } + + res = append(res, expose) + } + } else { + expose := manifest.ServiceExpose{ + Service: "", + Port: sdl.Port, + ExternalPort: sdl.As, + Proto: proto, + Global: false, + Hosts: sdl.Accept.Items, + HTTPOptions: httpOptions, + IP: "", + } + + res = append(res, expose) + } + + return res, nil +} diff --git a/go/sdl/v2_1/expose.pb.go b/go/sdl/v2_1/expose.pb.go new file mode 100644 index 00000000..f200d341 --- /dev/null +++ b/go/sdl/v2_1/expose.pb.go @@ -0,0 +1,571 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/expose.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Expose struct { + Port uint32 `protobuf:"varint,1,opt,name=port,proto3" json:"port" yaml:"port"` + As uint32 `protobuf:"varint,2,opt,name=as,proto3" json:"as" yaml:"as"` + Proto string `protobuf:"bytes,3,opt,name=proto,proto3" json:"proto" yaml:"proto"` + To ExposeToSlice `protobuf:"bytes,4,rep,name=to,proto3,castrepeated=ExposeToSlice" json:"to" yaml:"to"` + Accept Accept `protobuf:"bytes,5,opt,name=accept,proto3" json:"accept" yaml:"accept"` + HTTPOptions HTTPOptions `protobuf:"bytes,6,opt,name=http_options,json=httpOptions,proto3" json:"http_options" yaml:"http_options"` +} + +func (m *Expose) Reset() { *m = Expose{} } +func (m *Expose) String() string { return proto.CompactTextString(m) } +func (*Expose) ProtoMessage() {} +func (*Expose) Descriptor() ([]byte, []int) { + return fileDescriptor_9b85661b555590aa, []int{0} +} +func (m *Expose) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Expose) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Expose.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Expose) XXX_Merge(src proto.Message) { + xxx_messageInfo_Expose.Merge(m, src) +} +func (m *Expose) XXX_Size() int { + return m.Size() +} +func (m *Expose) XXX_DiscardUnknown() { + xxx_messageInfo_Expose.DiscardUnknown(m) +} + +var xxx_messageInfo_Expose proto.InternalMessageInfo + +func (m *Expose) GetPort() uint32 { + if m != nil { + return m.Port + } + return 0 +} + +func (m *Expose) GetAs() uint32 { + if m != nil { + return m.As + } + return 0 +} + +func (m *Expose) GetProto() string { + if m != nil { + return m.Proto + } + return "" +} + +func (m *Expose) GetTo() ExposeToSlice { + if m != nil { + return m.To + } + return nil +} + +func (m *Expose) GetAccept() Accept { + if m != nil { + return m.Accept + } + return Accept{} +} + +func (m *Expose) GetHTTPOptions() HTTPOptions { + if m != nil { + return m.HTTPOptions + } + return HTTPOptions{} +} + +func init() { + proto.RegisterType((*Expose)(nil), "akash.sdl.v2_1.Expose") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/expose.proto", fileDescriptor_9b85661b555590aa) } + +var fileDescriptor_9b85661b555590aa = []byte{ + // 439 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x3d, 0x6f, 0xdb, 0x30, + 0x14, 0xb4, 0x68, 0x5b, 0x40, 0xa8, 0xb8, 0x83, 0x5a, 0x14, 0x6a, 0x02, 0xe8, 0xb9, 0x9c, 0x9c, + 0xa1, 0x14, 0xec, 0x2c, 0x45, 0xb6, 0x08, 0x28, 0x90, 0xad, 0x86, 0xea, 0xa1, 0xed, 0x62, 0x30, + 0x8e, 0x60, 0x1b, 0x71, 0xf2, 0x04, 0x93, 0x4d, 0x3f, 0x7e, 0x45, 0x7f, 0x47, 0x7f, 0x49, 0xc6, + 0x00, 0x5d, 0x3a, 0xb1, 0x85, 0xbc, 0x69, 0xd4, 0x2f, 0x28, 0x44, 0xd2, 0x80, 0x63, 0x64, 0xd3, + 0xbb, 0xbb, 0x77, 0x77, 0x7a, 0x12, 0x3d, 0x16, 0xd7, 0x42, 0x2e, 0x12, 0x79, 0xb5, 0x4a, 0xee, + 0x46, 0x7c, 0x98, 0xe4, 0xdf, 0x0a, 0x94, 0x39, 0x2f, 0xd6, 0xa8, 0x30, 0x7c, 0x66, 0x48, 0x2e, + 0xaf, 0x56, 0xfc, 0x6e, 0x34, 0x1d, 0x1e, 0xbd, 0x98, 0xe3, 0x1c, 0x0d, 0x95, 0x34, 0x4f, 0x56, + 0x75, 0xb4, 0x6f, 0x21, 0x66, 0xb3, 0xbc, 0x50, 0x8e, 0x8c, 0x9f, 0xf4, 0x9f, 0xaa, 0xed, 0xf2, + 0xeb, 0x3d, 0x7e, 0xa1, 0x54, 0x31, 0xc5, 0x42, 0x2d, 0xf1, 0x56, 0x5a, 0x09, 0xfb, 0xdd, 0xa6, + 0xfe, 0x3b, 0xb3, 0x16, 0x9e, 0xd2, 0x4e, 0x81, 0x6b, 0x15, 0x79, 0x7d, 0x6f, 0xd0, 0x4b, 0xa1, + 0xd4, 0xd0, 0x19, 0xe3, 0x5a, 0x55, 0x1a, 0x0c, 0x5e, 0x6b, 0x08, 0xbe, 0x8b, 0x9b, 0xd5, 0x19, + 0x6b, 0x26, 0x96, 0x19, 0x30, 0x3c, 0xa1, 0x44, 0xc8, 0x88, 0x98, 0x95, 0x57, 0xa5, 0x06, 0x72, + 0x2e, 0x2b, 0x0d, 0x44, 0xc8, 0x5a, 0xc3, 0x81, 0x95, 0x0b, 0xc9, 0x32, 0x22, 0x64, 0xf8, 0x96, + 0x76, 0x4d, 0x66, 0xd4, 0xee, 0x7b, 0x83, 0x83, 0x94, 0x95, 0x1a, 0xba, 0xe3, 0x06, 0xa8, 0x34, + 0x58, 0xa6, 0xd6, 0x70, 0xe8, 0x22, 0x4c, 0xb9, 0xcc, 0xc2, 0xe1, 0x47, 0x4a, 0x14, 0x46, 0x9d, + 0x7e, 0x7b, 0x10, 0x8c, 0x22, 0xfe, 0xf8, 0x6e, 0xdc, 0xb6, 0x9f, 0x60, 0xca, 0xef, 0x35, 0xb4, + 0x9a, 0x0a, 0x93, 0xc6, 0x91, 0x18, 0x3b, 0x57, 0x41, 0x21, 0xfb, 0xf5, 0x17, 0x7a, 0x5b, 0xe9, + 0x87, 0xd5, 0x72, 0x96, 0x67, 0x44, 0x61, 0xf8, 0x89, 0xfa, 0xf6, 0xa2, 0x51, 0xb7, 0xef, 0x0d, + 0x82, 0xd1, 0xcb, 0x7d, 0xf7, 0x73, 0xc3, 0xa6, 0x27, 0xce, 0xdb, 0xb7, 0x73, 0xa5, 0xc1, 0xed, + 0xd5, 0x1a, 0x7a, 0xee, 0x35, 0xcd, 0xcc, 0x32, 0x47, 0x84, 0x3f, 0xe8, 0xe1, 0xee, 0xbd, 0x23, + 0xdf, 0x04, 0x1c, 0xef, 0x07, 0x5c, 0x4c, 0x26, 0xe3, 0xf7, 0x56, 0x92, 0x9e, 0xb9, 0x94, 0x60, + 0x07, 0xac, 0x34, 0x3c, 0xf2, 0xa9, 0x35, 0x3c, 0xb7, 0x81, 0xbb, 0x28, 0xcb, 0x82, 0x66, 0xdc, + 0x1a, 0x5d, 0xdc, 0x97, 0xb1, 0xf7, 0x50, 0xc6, 0xde, 0xbf, 0x32, 0xf6, 0x7e, 0x6e, 0xe2, 0xd6, + 0xc3, 0x26, 0x6e, 0xfd, 0xd9, 0xc4, 0xad, 0xcf, 0x7c, 0xbe, 0x54, 0x8b, 0x2f, 0x97, 0x7c, 0x86, + 0x37, 0x89, 0x69, 0xf2, 0xe6, 0x36, 0x57, 0x5f, 0x71, 0x7d, 0xed, 0x26, 0x51, 0x2c, 0x93, 0x39, + 0xba, 0x5f, 0x66, 0x3a, 0xbc, 0xf4, 0xcd, 0x17, 0x38, 0xfd, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x7d, + 0x73, 0xd8, 0xdb, 0xcb, 0x02, 0x00, 0x00, +} + +func (m *Expose) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Expose) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Expose) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.HTTPOptions.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size, err := m.Accept.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.To) > 0 { + for iNdEx := len(m.To) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.To[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExpose(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Proto) > 0 { + i -= len(m.Proto) + copy(dAtA[i:], m.Proto) + i = encodeVarintExpose(dAtA, i, uint64(len(m.Proto))) + i-- + dAtA[i] = 0x1a + } + if m.As != 0 { + i = encodeVarintExpose(dAtA, i, uint64(m.As)) + i-- + dAtA[i] = 0x10 + } + if m.Port != 0 { + i = encodeVarintExpose(dAtA, i, uint64(m.Port)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintExpose(dAtA []byte, offset int, v uint64) int { + offset -= sovExpose(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Expose) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Port != 0 { + n += 1 + sovExpose(uint64(m.Port)) + } + if m.As != 0 { + n += 1 + sovExpose(uint64(m.As)) + } + l = len(m.Proto) + if l > 0 { + n += 1 + l + sovExpose(uint64(l)) + } + if len(m.To) > 0 { + for _, e := range m.To { + l = e.Size() + n += 1 + l + sovExpose(uint64(l)) + } + } + l = m.Accept.Size() + n += 1 + l + sovExpose(uint64(l)) + l = m.HTTPOptions.Size() + n += 1 + l + sovExpose(uint64(l)) + return n +} + +func sovExpose(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExpose(x uint64) (n int) { + return sovExpose(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Expose) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Expose: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Expose: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) + } + m.Port = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Port |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field As", wireType) + } + m.As = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.As |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proto", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proto = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.To = append(m.To, ExposeTo{}) + if err := m.To[len(m.To)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Accept", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Accept.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HTTPOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExpose + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExpose + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExpose + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.HTTPOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipExpose(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExpose + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExpose(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExpose + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthExpose + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExpose + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExpose + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExpose = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExpose = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExpose = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/expose_test.go b/go/sdl/v2_1/expose_test.go new file mode 100644 index 00000000..4cce1ba3 --- /dev/null +++ b/go/sdl/v2_1/expose_test.go @@ -0,0 +1,24 @@ +package v2_1 + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +func TestExpose(t *testing.T) { + var stream = ` +- port: 80 + as: 80 + accept: + - hello.localhost + to: + - global: true +` + + var p Exposes + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) +} diff --git a/go/sdl/v2_1/expose_to.go b/go/sdl/v2_1/expose_to.go new file mode 100644 index 00000000..964ff2db --- /dev/null +++ b/go/sdl/v2_1/expose_to.go @@ -0,0 +1,3 @@ +package v2_1 + +type ExposeToSlice []ExposeTo diff --git a/go/sdl/v2_1/expose_to.pb.go b/go/sdl/v2_1/expose_to.pb.go new file mode 100644 index 00000000..a7bab99c --- /dev/null +++ b/go/sdl/v2_1/expose_to.pb.go @@ -0,0 +1,473 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/expose_to.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ExposeTo struct { + Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service" yaml:"service"` + Global bool `protobuf:"varint,2,opt,name=Global,proto3" json:"global" yaml:"global"` + HTTPOptions HTTPOptions `protobuf:"bytes,3,opt,name=http_options,json=httpOptions,proto3" json:"http_options" yaml:"http_options"` + IP string `protobuf:"bytes,4,opt,name=ip,proto3" json:"ip" yaml:"ip"` +} + +func (m *ExposeTo) Reset() { *m = ExposeTo{} } +func (m *ExposeTo) String() string { return proto.CompactTextString(m) } +func (*ExposeTo) ProtoMessage() {} +func (*ExposeTo) Descriptor() ([]byte, []int) { + return fileDescriptor_42360c3d4d968c85, []int{0} +} +func (m *ExposeTo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExposeTo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExposeTo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ExposeTo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExposeTo.Merge(m, src) +} +func (m *ExposeTo) XXX_Size() int { + return m.Size() +} +func (m *ExposeTo) XXX_DiscardUnknown() { + xxx_messageInfo_ExposeTo.DiscardUnknown(m) +} + +var xxx_messageInfo_ExposeTo proto.InternalMessageInfo + +func (m *ExposeTo) GetService() string { + if m != nil { + return m.Service + } + return "" +} + +func (m *ExposeTo) GetGlobal() bool { + if m != nil { + return m.Global + } + return false +} + +func (m *ExposeTo) GetHTTPOptions() HTTPOptions { + if m != nil { + return m.HTTPOptions + } + return HTTPOptions{} +} + +func (m *ExposeTo) GetIP() string { + if m != nil { + return m.IP + } + return "" +} + +func init() { + proto.RegisterType((*ExposeTo)(nil), "akash.sdl.v2_1.ExposeTo") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/expose_to.proto", fileDescriptor_42360c3d4d968c85) } + +var fileDescriptor_42360c3d4d968c85 = []byte{ + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x51, 0xbd, 0x6e, 0xe2, 0x40, + 0x10, 0xb6, 0x7d, 0x27, 0x7e, 0xcc, 0x1d, 0x85, 0xef, 0x0a, 0x87, 0x48, 0xbb, 0xc4, 0x52, 0x24, + 0xa7, 0xc8, 0x5a, 0x90, 0x0e, 0x29, 0x8d, 0xa5, 0x28, 0xa4, 0x0a, 0x72, 0xa8, 0xd2, 0x58, 0x06, + 0x2c, 0xb3, 0xc2, 0xb0, 0x2b, 0xbc, 0x21, 0x3f, 0x4f, 0x91, 0x87, 0xc9, 0x43, 0x50, 0x52, 0xa6, + 0x5a, 0x45, 0x4b, 0xe7, 0xd2, 0x4f, 0x10, 0xb1, 0x6b, 0x24, 0x48, 0x37, 0xdf, 0xcf, 0x7c, 0x33, + 0xa3, 0x31, 0x41, 0x34, 0x8b, 0xb2, 0xa9, 0x97, 0x4d, 0x52, 0x6f, 0xd5, 0x45, 0x1d, 0x2f, 0x7e, + 0xa1, 0x24, 0x8b, 0x43, 0x46, 0x10, 0x5d, 0x12, 0x46, 0xac, 0xa6, 0xd4, 0x51, 0x36, 0x49, 0xd1, + 0xaa, 0x1b, 0x76, 0x5a, 0xff, 0x13, 0x92, 0x10, 0x29, 0x79, 0xbb, 0x4a, 0xb9, 0x5a, 0x67, 0x3f, + 0x52, 0xa6, 0x8c, 0xd1, 0x90, 0x50, 0x86, 0xc9, 0x22, 0x53, 0x16, 0xe7, 0xc3, 0x30, 0x6b, 0x37, + 0x32, 0x7c, 0x48, 0x2c, 0xdf, 0xac, 0x66, 0xf1, 0x72, 0x85, 0xc7, 0xb1, 0xad, 0xb7, 0x75, 0xb7, + 0xee, 0xbb, 0x82, 0xc3, 0xea, 0x83, 0xa2, 0x72, 0x0e, 0xf7, 0x6a, 0xc1, 0x61, 0xf3, 0x35, 0x9a, + 0xa7, 0x3d, 0xa7, 0x24, 0x9c, 0x60, 0x2f, 0x59, 0xd7, 0x66, 0xe5, 0x36, 0x25, 0xa3, 0x28, 0xb5, + 0x8d, 0xb6, 0xee, 0xd6, 0xfc, 0x73, 0xc1, 0x61, 0xc9, 0xe4, 0x1c, 0x56, 0x12, 0x59, 0x15, 0x1c, + 0xfe, 0x55, 0x01, 0x0a, 0x3b, 0x41, 0x69, 0xb1, 0xde, 0xcc, 0x3f, 0x87, 0x5b, 0xda, 0xbf, 0xda, + 0xba, 0xdb, 0xe8, 0x9e, 0xa2, 0xe3, 0x7b, 0x51, 0x7f, 0x38, 0x1c, 0xdc, 0x2b, 0x8b, 0xdf, 0x5b, + 0x73, 0xa8, 0x09, 0x0e, 0x1b, 0x07, 0x64, 0xce, 0xe1, 0x51, 0x4e, 0xc1, 0xe1, 0x3f, 0x35, 0xf0, + 0x90, 0x75, 0x82, 0xc6, 0x0e, 0x96, 0x3d, 0xd6, 0x85, 0x69, 0x60, 0x6a, 0xff, 0x96, 0x97, 0x9f, + 0x08, 0x0e, 0x8d, 0xbb, 0x41, 0xce, 0xa1, 0x81, 0x69, 0xc1, 0x61, 0x5d, 0x75, 0x63, 0xea, 0x04, + 0x06, 0xa6, 0x7e, 0x7f, 0x2d, 0x80, 0xbe, 0x11, 0x40, 0xff, 0x12, 0x40, 0x7f, 0xdf, 0x02, 0x6d, + 0xb3, 0x05, 0xda, 0xe7, 0x16, 0x68, 0x8f, 0x28, 0xc1, 0x6c, 0xfa, 0x34, 0x42, 0x63, 0x32, 0xf7, + 0xe4, 0xd2, 0x97, 0x8b, 0x98, 0x3d, 0x93, 0xe5, 0xac, 0x44, 0x11, 0xc5, 0x5e, 0x42, 0xca, 0x9f, + 0x84, 0x9d, 0x51, 0x45, 0xfe, 0xe1, 0xea, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x89, 0x73, 0xd3, + 0xf2, 0x01, 0x00, 0x00, +} + +func (m *ExposeTo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExposeTo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExposeTo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IP) > 0 { + i -= len(m.IP) + copy(dAtA[i:], m.IP) + i = encodeVarintExposeTo(dAtA, i, uint64(len(m.IP))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.HTTPOptions.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExposeTo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Global { + i-- + if m.Global { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Service) > 0 { + i -= len(m.Service) + copy(dAtA[i:], m.Service) + i = encodeVarintExposeTo(dAtA, i, uint64(len(m.Service))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintExposeTo(dAtA []byte, offset int, v uint64) int { + offset -= sovExposeTo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ExposeTo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Service) + if l > 0 { + n += 1 + l + sovExposeTo(uint64(l)) + } + if m.Global { + n += 2 + } + l = m.HTTPOptions.Size() + n += 1 + l + sovExposeTo(uint64(l)) + l = len(m.IP) + if l > 0 { + n += 1 + l + sovExposeTo(uint64(l)) + } + return n +} + +func sovExposeTo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozExposeTo(x uint64) (n int) { + return sovExposeTo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ExposeTo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ExposeTo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExposeTo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Service = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Global", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Global = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HTTPOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.HTTPOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExposeTo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthExposeTo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExposeTo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IP = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipExposeTo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthExposeTo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipExposeTo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowExposeTo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthExposeTo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExposeTo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthExposeTo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthExposeTo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExposeTo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExposeTo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/gpu.go b/go/sdl/v2_1/gpu.go new file mode 100644 index 00000000..77c862f0 --- /dev/null +++ b/go/sdl/v2_1/gpu.go @@ -0,0 +1,106 @@ +package v2_1 + +import ( + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type v2GPUNvidia struct { + Model string `yaml:"model"` + RAM *memoryQuantity `yaml:"ram,omitempty"` +} + +func (sdl *v2GPUNvidia) String() string { + key := sdl.Model + if sdl.RAM != nil { + key += "/" + sdl.RAM.StringWithSuffix("Gi") + } + + return key +} + +type v2GPUsNvidia []v2GPUNvidia + +type gpuVendor struct { + Nvidia v2GPUsNvidia `yaml:"nvidia,omitempty"` +} + +type gpuAttributes types.Attributes + +func (sdl *ResourceGPU) UnmarshalYAML(node *yaml.Node) error { + res := ResourceGPU{} + + for i := 0; i < len(node.Content); i += 2 { + switch node.Content[i].Value { + case "units": + if err := node.Content[i+1].Decode(&res.Units); err != nil { + return err + } + case "attributes": + if err := node.Content[i+1].Decode(&res.Attributes); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unsupported field (%s) for GPU resource", node.Content[i].Value) + } + } + + if res.Units > 0 && len(res.Attributes) == 0 { + return fmt.Errorf("sdl: GPU attributes must be present if units > 0") + } + + *sdl = res + + return nil +} + +func (sdl *gpuAttributes) UnmarshalYAML(node *yaml.Node) error { + var res types.Attributes + + var vendor *gpuVendor + + for i := 0; i < len(node.Content); i += 2 { + switch node.Content[i].Value { + case "vendor": + if err := node.Content[i+1].Decode(&vendor); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unsupported attribute (%s) for GPU resource", node.Content[i].Value) + } + } + + if vendor == nil { + return fmt.Errorf("sdl: invalid GPU attributes. at least one vendor must be set") + } + + res = make(types.Attributes, 0, len(vendor.Nvidia)) + + for _, model := range vendor.Nvidia { + res = append(res, types.Attribute{ + Key: fmt.Sprintf("vendor/nvidia/model/%s", model.String()), + Value: "true", + }) + } + + if len(res) == 0 { + res = append(res, types.Attribute{ + Key: "vendor/nvidia/model/*", + Value: "true", + }) + } + + sort.Sort(res) + + if err := res.Validate(); err != nil { + return fmt.Errorf("sdl: invalid GPU attributes: %w", err) + } + + *sdl = gpuAttributes(res) + + return nil +} diff --git a/go/sdl/v2_1/gpu.pb.go b/go/sdl/v2_1/gpu.pb.go new file mode 100644 index 00000000..d2bbd28f --- /dev/null +++ b/go/sdl/v2_1/gpu.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/gpu.proto + +package v2_1 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceGPU struct { + Units gpuQuantity `protobuf:"varint,1,opt,name=units,proto3,casttype=gpuQuantity" json:"units" yaml:"units"` + Attributes gpuAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=gpuAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceGPU) Reset() { *m = ResourceGPU{} } +func (m *ResourceGPU) String() string { return proto.CompactTextString(m) } +func (*ResourceGPU) ProtoMessage() {} +func (*ResourceGPU) Descriptor() ([]byte, []int) { + return fileDescriptor_c3d4331f8a99b7ef, []int{0} +} +func (m *ResourceGPU) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceGPU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceGPU.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceGPU) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceGPU.Merge(m, src) +} +func (m *ResourceGPU) XXX_Size() int { + return m.Size() +} +func (m *ResourceGPU) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceGPU.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceGPU proto.InternalMessageInfo + +func (m *ResourceGPU) GetUnits() gpuQuantity { + if m != nil { + return m.Units + } + return 0 +} + +func (m *ResourceGPU) GetAttributes() gpuAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceGPU)(nil), "akash.sdl.v2_1.ResourceGPU") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/gpu.proto", fileDescriptor_c3d4331f8a99b7ef) } + +var fileDescriptor_c3d4331f8a99b7ef = []byte{ + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x50, 0x3d, 0x4f, 0x3a, 0x31, + 0x1c, 0xbe, 0xfe, 0xff, 0xc1, 0xa1, 0x88, 0x89, 0xc4, 0x81, 0x90, 0xd8, 0x92, 0x9b, 0x58, 0x6c, + 0x73, 0xb0, 0xb9, 0xc9, 0x20, 0x8e, 0x4a, 0xc2, 0xe2, 0x42, 0x7a, 0xd0, 0x94, 0x0b, 0x2f, 0xbd, + 0x5c, 0xdb, 0x33, 0x7c, 0x00, 0x77, 0x3f, 0x87, 0x9f, 0x84, 0x91, 0xd1, 0xa9, 0x9a, 0xbb, 0xcd, + 0x91, 0xd1, 0xc9, 0xdc, 0xf5, 0x04, 0xb6, 0xfe, 0x9e, 0x97, 0x3e, 0x4f, 0x1e, 0xd8, 0x62, 0x0b, + 0xa6, 0xe6, 0x54, 0xcd, 0x96, 0x34, 0xed, 0x91, 0x80, 0x8a, 0xd8, 0x90, 0x38, 0x91, 0x5a, 0x36, + 0x2f, 0x4a, 0x86, 0xa8, 0xd9, 0x92, 0xa4, 0xbd, 0x49, 0xd0, 0xbe, 0x12, 0x52, 0xc8, 0x92, 0xa2, + 0xc5, 0xcb, 0xa9, 0xda, 0xbe, 0xf3, 0x87, 0x4c, 0x71, 0x9a, 0x06, 0x21, 0xd7, 0xac, 0x4f, 0x99, + 0xd6, 0x49, 0x14, 0x1a, 0xcd, 0x9d, 0xc6, 0xb7, 0x00, 0xd6, 0x47, 0x5c, 0x49, 0x93, 0x4c, 0xf9, + 0xf0, 0x71, 0xdc, 0x1c, 0xc2, 0x9a, 0x59, 0x47, 0x5a, 0xb5, 0x40, 0x07, 0x74, 0x1b, 0x83, 0x20, + 0xb3, 0xb8, 0x36, 0x2e, 0x80, 0x6f, 0x8b, 0x1d, 0xb3, 0xb7, 0xf8, 0x7c, 0xc3, 0x56, 0xcb, 0x5b, + 0xbf, 0x3c, 0xfd, 0x1f, 0x8b, 0xeb, 0x22, 0x36, 0x4f, 0x86, 0xad, 0x75, 0xa4, 0x37, 0x23, 0xa7, + 0x6a, 0xbe, 0x02, 0x08, 0x0f, 0x61, 0xaa, 0xf5, 0xaf, 0xf3, 0xbf, 0x5b, 0xef, 0x5d, 0x13, 0x57, + 0xbc, 0xa8, 0x44, 0xaa, 0x4a, 0xe4, 0xee, 0x4f, 0x35, 0xb8, 0xdf, 0x5a, 0xec, 0x65, 0x16, 0xc3, + 0x03, 0x54, 0xc4, 0x9e, 0x7c, 0xb3, 0xb7, 0xf8, 0xd2, 0x65, 0x1f, 0x31, 0xff, 0xfd, 0x13, 0x37, + 0x44, 0x6c, 0x8e, 0x9e, 0xd1, 0x89, 0x63, 0xf0, 0xb0, 0xcd, 0x10, 0xd8, 0x65, 0x08, 0x7c, 0x65, + 0x08, 0xbc, 0xe5, 0xc8, 0xdb, 0xe5, 0xc8, 0xfb, 0xc8, 0x91, 0xf7, 0x4c, 0x44, 0xa4, 0xe7, 0x26, + 0x24, 0x53, 0xb9, 0xa2, 0x65, 0xad, 0x9b, 0x35, 0xd7, 0x2f, 0x32, 0x59, 0x54, 0x17, 0x8b, 0x23, + 0x2a, 0x64, 0x35, 0xff, 0x24, 0x08, 0xcf, 0xca, 0xc5, 0xfa, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x48, 0x4d, 0x06, 0x62, 0x97, 0x01, 0x00, 0x00, +} + +func (m *ResourceGPU) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceGPU) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceGPU) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGpu(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Units != 0 { + i = encodeVarintGpu(dAtA, i, uint64(m.Units)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintGpu(dAtA []byte, offset int, v uint64) int { + offset -= sovGpu(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceGPU) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Units != 0 { + n += 1 + sovGpu(uint64(m.Units)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovGpu(uint64(l)) + } + } + return n +} + +func sovGpu(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGpu(x uint64) (n int) { + return sovGpu(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceGPU) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceGPU: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceGPU: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Units", wireType) + } + m.Units = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Units |= gpuQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGpu + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGpu + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGpu + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGpu(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGpu + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGpu(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGpu + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGpu + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGpu + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGpu + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGpu = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGpu = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGpu = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/gpu_test.go b/go/sdl/v2_1/gpu_test.go new file mode 100644 index 00000000..0882cb32 --- /dev/null +++ b/go/sdl/v2_1/gpu_test.go @@ -0,0 +1,155 @@ +package v2_1 + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +func TestV2ResourceGPU_EmptyVendor(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.Error(t, err) +} + +func TestV2ResourceGPU_Wildcard(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/*", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_SingleModel(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_SingleModelWithRAM(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 1, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) +} + +func TestV2ResourceGPU_InvalidRAMUnit(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80G +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.Error(t, err) +} + +func TestV2ResourceGPU_MultipleModels(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi + - model: a100 + ram: 40Gi +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100/40Gi", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} + +func TestV2ResourceGPU_MultipleModels2(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a100 + ram: 80Gi + - model: a100 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a100", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a100/80Gi", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} + +func TestV2ResourceGPU_MultipleModels3(t *testing.T) { + var stream = ` +units: 1 +attributes: + vendor: + nvidia: + - model: a6000 + - model: a40 +` + var p ResourceGPU + + err := yaml.Unmarshal([]byte(stream), &p) + require.NoError(t, err) + require.Equal(t, gpuQuantity(1), p.Units) + require.Equal(t, 2, len(p.Attributes)) + require.Equal(t, "vendor/nvidia/model/a40", p.Attributes[0].Key) + require.Equal(t, "true", p.Attributes[0].Value) + require.Equal(t, "vendor/nvidia/model/a6000", p.Attributes[1].Key) + require.Equal(t, "true", p.Attributes[1].Value) +} diff --git a/go/sdl/v2_1/group_builder.go b/go/sdl/v2_1/group_builder.go new file mode 100644 index 00000000..2479540e --- /dev/null +++ b/go/sdl/v2_1/group_builder.go @@ -0,0 +1,150 @@ +package v2_1 + +import ( + "sort" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type groupsBuilder struct { + dgroup *dtypes.GroupSpec + mgroup *manifest.Group + boundComputes map[string]map[string]int +} + +// buildGroups +func (sdl *SDL) buildGroups() error { + endpointsNames := sdl.computeEndpointSequenceNumbers() + + groups := make(map[string]*groupsBuilder) + + for _, svcName := range sdl.Deployments.svcNames() { + depl := sdl.Deployments[svcName] + + for _, pname := range depl.placements() { + // objects below have been ensured to exist + svcdepl := depl[pname] + compute := sdl.Profiles.Compute[svcdepl.Profile] + svc := sdl.Services[svcName] + infra := sdl.Profiles.Placement[pname] + price := infra.Pricing[svcdepl.Profile] + + group := groups[pname] + + if group == nil { + group = &groupsBuilder{ + dgroup: &dtypes.GroupSpec{ + Name: pname, + }, + mgroup: &manifest.Group{ + Name: pname, + }, + boundComputes: make(map[string]map[string]int), + } + + group.dgroup.Requirements.Attributes = types.Attributes(infra.Attributes) + group.dgroup.Requirements.SignedBy = infra.SignedBy + + // keep ordering stable + sort.Sort(group.dgroup.Requirements.Attributes) + + groups[pname] = group + } + + if _, exists := group.boundComputes[pname]; !exists { + group.boundComputes[pname] = make(map[string]int) + } + + expose, err := sdl.Services[svcName].Expose.toManifestExpose(endpointsNames) + if err != nil { + return err + } + + resources := compute.Resources.toResources() + resources.Endpoints = expose.GetEndpoints() + + if location, bound := group.boundComputes[pname][svcdepl.Profile]; !bound { + res := compute.Resources.toResources() + res.Endpoints = expose.GetEndpoints() + + var resID int + if ln := len(group.dgroup.Resources); ln > 0 { + resID = ln + 1 + } else { + resID = 1 + } + + res.ID = uint32(resID) + resources.ID = res.ID + + group.dgroup.Resources = append(group.dgroup.Resources, dtypes.ResourceUnit{ + Resources: res, + Price: price.Value, + Count: svcdepl.Count, + }) + + group.boundComputes[pname][svcdepl.Profile] = len(group.dgroup.Resources) - 1 + } else { + resources.ID = group.dgroup.Resources[location].ID + + group.dgroup.Resources[location].Count += svcdepl.Count + group.dgroup.Resources[location].Endpoints = append(group.dgroup.Resources[location].Endpoints, expose.GetEndpoints()...) + + sort.Sort(group.dgroup.Resources[location].Endpoints) + } + + msvc := manifest.Service{ + Name: svcName, + Image: svc.Image, + Args: svc.Args, + Env: svc.Env, + Resources: resources, + Count: svcdepl.Count, + Command: svc.Command, + Expose: expose, + } + + if svc.Params != nil { + params := &manifest.ServiceParams{} + + if len(svc.Params.Storage) > 0 { + params.Storage = make([]manifest.StorageParams, 0, len(svc.Params.Storage)) + for volName, volParams := range svc.Params.Storage { + params.Storage = append(params.Storage, manifest.StorageParams{ + Name: volName, + Mount: volParams.Mount, + ReadOnly: volParams.ReadOnly, + }) + } + } + + msvc.Params = params + } + + group.mgroup.Services = append(group.mgroup.Services, msvc) + } + } + + // keep ordering stable + names := make([]string, 0, len(groups)) + for name := range groups { + names = append(names, name) + } + sort.Strings(names) + + sdl.result.dgroups = make(dtypes.GroupSpecs, 0, len(names)) + sdl.result.mgroups = make(manifest.Groups, 0, len(names)) + + for _, name := range names { + mgroup := *groups[name].mgroup + // stable ordering services by name + sort.Sort(mgroup.Services) + + sdl.result.dgroups = append(sdl.result.dgroups, groups[name].dgroup) + sdl.result.mgroups = append(sdl.result.mgroups, mgroup) + } + + return nil +} diff --git a/go/sdl/v2_1/http_options.go b/go/sdl/v2_1/http_options.go new file mode 100644 index 00000000..456d0504 --- /dev/null +++ b/go/sdl/v2_1/http_options.go @@ -0,0 +1,99 @@ +package v2_1 + +import ( + "errors" + "fmt" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" +) + +const ( + nextCaseError = "error" + nextCaseTimeout = "timeout" + nextCase500 = "500" + nextCase502 = "502" + nextCase503 = "503" + nextCase504 = "504" + nextCase403 = "403" + nextCase404 = "404" + nextCase400 = "429" + nextCaseOff = "off" + defaultMaxBodySize = uint32(1048576) + upperLimitBodySize = uint32(104857600) + defaultReadTimeout = uint32(60000) + upperLimitReadTimeout = defaultReadTimeout + defaultSendTimeout = uint32(60000) + upperLimitSendTimeout = defaultSendTimeout + defaultNextTries = uint32(3) + endpointKindIP = "ip" +) + +var ( + defaultNextCases = []string{nextCaseError, nextCaseTimeout} + errCannotSpecifyOffAndOtherCases = errors.New("if 'off' is specified, no other cases may be specified") + errUnknownNextCase = errors.New("next case is unknown") + errHTTPOptionNotAllowed = errors.New("http option not allowed") +) + +func (ho HTTPOptions) asManifest() (manifest.ServiceExposeHTTPOptions, error) { + maxBodySize := ho.MaxBodySize + + if maxBodySize == 0 { + maxBodySize = defaultMaxBodySize + } else if maxBodySize > upperLimitBodySize { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: body size cannot be greater than %d bytes", errHTTPOptionNotAllowed, upperLimitBodySize) + } + + readTimeout := ho.ReadTimeout + if readTimeout == 0 { + readTimeout = defaultReadTimeout + } else if readTimeout > upperLimitReadTimeout { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: read timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitReadTimeout) + } + + sendTimeout := ho.SendTimeout + if sendTimeout == 0 { + sendTimeout = defaultSendTimeout + } else if sendTimeout > upperLimitSendTimeout { + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: send timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitSendTimeout) + } + + nextTries := ho.NextTries + if nextTries == 0 { + nextTries = defaultNextTries + } + + nextCases := ho.NextCases + if len(nextCases) == 0 { + nextCases = defaultNextCases + } else { + for _, nextCase := range nextCases { + switch nextCase { + case nextCaseOff: + if len(nextCases) != 1 { + return manifest.ServiceExposeHTTPOptions{}, errCannotSpecifyOffAndOtherCases + } + case nextCaseError: + case nextCaseTimeout: + case nextCase500: + case nextCase502: + case nextCase503: + case nextCase504: + case nextCase403: + case nextCase404: + case nextCase400: + default: + return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: %q", errUnknownNextCase, nextCase) + } + } + } + + return manifest.ServiceExposeHTTPOptions{ + MaxBodySize: maxBodySize, + ReadTimeout: readTimeout, + SendTimeout: sendTimeout, + NextTries: nextTries, + NextTimeout: ho.NextTimeout, + NextCases: nextCases, + }, nil +} diff --git a/go/sdl/v2_1/http_options.pb.go b/go/sdl/v2_1/http_options.pb.go new file mode 100644 index 00000000..a63bfc89 --- /dev/null +++ b/go/sdl/v2_1/http_options.pb.go @@ -0,0 +1,509 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/http_options.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type HTTPOptions struct { + MaxBodySize uint32 `protobuf:"varint,1,opt,name=max_body_size,json=maxBodySize,proto3" json:"max_body_size" yaml:"max_body_size"` + ReadTimeout uint32 `protobuf:"varint,2,opt,name=read_timeout,json=readTimeout,proto3" json:"read_timeout" yaml:"read_timeout"` + SendTimeout uint32 `protobuf:"varint,3,opt,name=send_timeout,json=sendTimeout,proto3" json:"send_timeout" yaml:"send_timeout"` + NextTries uint32 `protobuf:"varint,4,opt,name=next_tries,json=nextTries,proto3" json:"next_tries" yaml:"next_tries"` + NextTimeout uint32 `protobuf:"varint,5,opt,name=next_timeout,json=nextTimeout,proto3" json:"next_timeout" yaml:"next_timeout"` + NextCases []string `protobuf:"bytes,6,rep,name=next_cases,json=nextCases,proto3" json:"next_cases" yaml:"next_cases"` +} + +func (m *HTTPOptions) Reset() { *m = HTTPOptions{} } +func (m *HTTPOptions) String() string { return proto.CompactTextString(m) } +func (*HTTPOptions) ProtoMessage() {} +func (*HTTPOptions) Descriptor() ([]byte, []int) { + return fileDescriptor_dc386bb5fe3bfc55, []int{0} +} +func (m *HTTPOptions) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HTTPOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HTTPOptions.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HTTPOptions) XXX_Merge(src proto.Message) { + xxx_messageInfo_HTTPOptions.Merge(m, src) +} +func (m *HTTPOptions) XXX_Size() int { + return m.Size() +} +func (m *HTTPOptions) XXX_DiscardUnknown() { + xxx_messageInfo_HTTPOptions.DiscardUnknown(m) +} + +var xxx_messageInfo_HTTPOptions proto.InternalMessageInfo + +func (m *HTTPOptions) GetMaxBodySize() uint32 { + if m != nil { + return m.MaxBodySize + } + return 0 +} + +func (m *HTTPOptions) GetReadTimeout() uint32 { + if m != nil { + return m.ReadTimeout + } + return 0 +} + +func (m *HTTPOptions) GetSendTimeout() uint32 { + if m != nil { + return m.SendTimeout + } + return 0 +} + +func (m *HTTPOptions) GetNextTries() uint32 { + if m != nil { + return m.NextTries + } + return 0 +} + +func (m *HTTPOptions) GetNextTimeout() uint32 { + if m != nil { + return m.NextTimeout + } + return 0 +} + +func (m *HTTPOptions) GetNextCases() []string { + if m != nil { + return m.NextCases + } + return nil +} + +func init() { + proto.RegisterType((*HTTPOptions)(nil), "akash.sdl.v2_1.HTTPOptions") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/http_options.proto", fileDescriptor_dc386bb5fe3bfc55) } + +var fileDescriptor_dc386bb5fe3bfc55 = []byte{ + // 399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xc1, 0x6e, 0xa2, 0x40, + 0x1c, 0xc6, 0x65, 0x75, 0x4d, 0x84, 0x75, 0x93, 0x65, 0x3d, 0x90, 0x3d, 0x30, 0x2e, 0x27, 0x2f, + 0x0b, 0xab, 0x9b, 0x6c, 0x9a, 0x1e, 0xed, 0xc5, 0x4b, 0x6b, 0x83, 0x5c, 0xda, 0x34, 0x21, 0xa3, + 0x4c, 0x90, 0x28, 0x0c, 0x61, 0x46, 0x8b, 0x3e, 0x45, 0x9f, 0xa0, 0xcf, 0xd3, 0xa3, 0xc7, 0x9e, + 0x26, 0x0d, 0xde, 0x3c, 0xfa, 0x04, 0x0d, 0x03, 0x75, 0xb0, 0x37, 0xf8, 0xe6, 0xfb, 0x7e, 0xf9, + 0x1d, 0xfe, 0xf2, 0x6f, 0xb8, 0x80, 0x64, 0x6e, 0x11, 0x6f, 0x69, 0xad, 0x07, 0x66, 0xdf, 0x9a, + 0x53, 0x1a, 0xbb, 0x38, 0xa6, 0x01, 0x8e, 0x88, 0x19, 0x27, 0x98, 0x62, 0xf5, 0x3b, 0xaf, 0x98, + 0xc4, 0x5b, 0x9a, 0xeb, 0x81, 0xdb, 0xff, 0xd5, 0xf1, 0xb1, 0x8f, 0xf9, 0x93, 0x95, 0x7f, 0x15, + 0x2d, 0xe3, 0xb9, 0x21, 0x2b, 0x23, 0xc7, 0xb9, 0x1d, 0x17, 0x5b, 0xf5, 0x41, 0x6e, 0x87, 0x30, + 0x75, 0xa7, 0xd8, 0xdb, 0xb8, 0x24, 0xd8, 0x22, 0x4d, 0xea, 0x4a, 0xbd, 0xf6, 0xf0, 0x22, 0x63, + 0x40, 0xb9, 0x86, 0xe9, 0x10, 0x7b, 0x9b, 0x49, 0xb0, 0x45, 0x07, 0x06, 0xce, 0x7b, 0x47, 0x06, + 0x3a, 0x1b, 0x18, 0x2e, 0x2f, 0x8d, 0xb3, 0xd8, 0xb0, 0x95, 0x50, 0xac, 0xd4, 0x3b, 0xf9, 0x5b, + 0x82, 0xa0, 0xe7, 0xd2, 0x20, 0x44, 0x78, 0x45, 0xb5, 0x2f, 0x1c, 0xfe, 0x3f, 0x87, 0xdb, 0x08, + 0x7a, 0x4e, 0x11, 0x1f, 0x18, 0x38, 0xab, 0x1d, 0x19, 0xf8, 0x59, 0xb0, 0xab, 0xa9, 0x61, 0x2b, + 0x89, 0xd8, 0xe4, 0x68, 0x82, 0x22, 0x81, 0xae, 0x0b, 0xf4, 0x04, 0x45, 0x55, 0x74, 0xb5, 0x26, + 0xd0, 0xd5, 0xd4, 0xb0, 0x15, 0x22, 0x36, 0xea, 0x58, 0x96, 0x23, 0x94, 0x52, 0x97, 0x26, 0x01, + 0x22, 0x5a, 0x83, 0x83, 0xff, 0x66, 0x0c, 0xb4, 0x6e, 0x50, 0x4a, 0x9d, 0x3c, 0x3c, 0x30, 0x50, + 0xa9, 0x1c, 0x19, 0xf8, 0x51, 0x40, 0x45, 0x66, 0xd8, 0xad, 0xe8, 0xa3, 0x9d, 0xbb, 0x16, 0x2f, + 0xa5, 0xeb, 0x57, 0xe1, 0xca, 0x91, 0xc2, 0xb5, 0x5a, 0x13, 0xae, 0xd5, 0xd4, 0xb0, 0x95, 0x48, + 0x6c, 0x4e, 0xae, 0x33, 0x48, 0x10, 0xd1, 0x9a, 0xdd, 0x7a, 0xaf, 0x25, 0x5c, 0xaf, 0xf2, 0xf0, + 0xe4, 0xca, 0x2b, 0x9f, 0x5c, 0x79, 0x56, 0xba, 0xf2, 0xf6, 0x70, 0xf4, 0x92, 0xe9, 0xd2, 0x2e, + 0xd3, 0xa5, 0xb7, 0x4c, 0x97, 0x9e, 0xf6, 0x7a, 0x6d, 0xb7, 0xd7, 0x6b, 0xaf, 0x7b, 0xbd, 0x76, + 0x6f, 0xfa, 0x01, 0x9d, 0xaf, 0xa6, 0xe6, 0x0c, 0x87, 0x16, 0xbf, 0xb5, 0x3f, 0x11, 0xa2, 0x8f, + 0x38, 0x59, 0x94, 0x7f, 0x30, 0x0e, 0x2c, 0x1f, 0x97, 0x37, 0xea, 0xf6, 0xa7, 0x4d, 0x7e, 0x71, + 0xff, 0xde, 0x03, 0x00, 0x00, 0xff, 0xff, 0x94, 0xc9, 0x7e, 0x00, 0xbc, 0x02, 0x00, 0x00, +} + +func (m *HTTPOptions) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HTTPOptions) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HTTPOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NextCases) > 0 { + for iNdEx := len(m.NextCases) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.NextCases[iNdEx]) + copy(dAtA[i:], m.NextCases[iNdEx]) + i = encodeVarintHttpOptions(dAtA, i, uint64(len(m.NextCases[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if m.NextTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.NextTimeout)) + i-- + dAtA[i] = 0x28 + } + if m.NextTries != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.NextTries)) + i-- + dAtA[i] = 0x20 + } + if m.SendTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.SendTimeout)) + i-- + dAtA[i] = 0x18 + } + if m.ReadTimeout != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.ReadTimeout)) + i-- + dAtA[i] = 0x10 + } + if m.MaxBodySize != 0 { + i = encodeVarintHttpOptions(dAtA, i, uint64(m.MaxBodySize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintHttpOptions(dAtA []byte, offset int, v uint64) int { + offset -= sovHttpOptions(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *HTTPOptions) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxBodySize != 0 { + n += 1 + sovHttpOptions(uint64(m.MaxBodySize)) + } + if m.ReadTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.ReadTimeout)) + } + if m.SendTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.SendTimeout)) + } + if m.NextTries != 0 { + n += 1 + sovHttpOptions(uint64(m.NextTries)) + } + if m.NextTimeout != 0 { + n += 1 + sovHttpOptions(uint64(m.NextTimeout)) + } + if len(m.NextCases) > 0 { + for _, s := range m.NextCases { + l = len(s) + n += 1 + l + sovHttpOptions(uint64(l)) + } + } + return n +} + +func sovHttpOptions(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozHttpOptions(x uint64) (n int) { + return sovHttpOptions(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *HTTPOptions) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HTTPOptions: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HTTPOptions: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBodySize", wireType) + } + m.MaxBodySize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxBodySize |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadTimeout", wireType) + } + m.ReadTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReadTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SendTimeout", wireType) + } + m.SendTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SendTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextTries", wireType) + } + m.NextTries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextTries |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextTimeout", wireType) + } + m.NextTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextTimeout |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NextCases", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthHttpOptions + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthHttpOptions + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NextCases = append(m.NextCases, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipHttpOptions(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthHttpOptions + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipHttpOptions(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowHttpOptions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthHttpOptions + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupHttpOptions + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthHttpOptions + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthHttpOptions = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowHttpOptions = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupHttpOptions = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/memory.go b/go/sdl/v2_1/memory.go new file mode 100644 index 00000000..6cdc3bfc --- /dev/null +++ b/go/sdl/v2_1/memory.go @@ -0,0 +1,35 @@ +package v2_1 + +import ( + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +type memoryAttributes types.Attributes + +func (sdl *memoryAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr memoryAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + for k, v := range res { + attr = append(attr, types.Attribute{ + Key: k, + Value: v, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2_1/memory.pb.go b/go/sdl/v2_1/memory.pb.go new file mode 100644 index 00000000..ddee1e09 --- /dev/null +++ b/go/sdl/v2_1/memory.pb.go @@ -0,0 +1,372 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/memory.proto + +package v2_1 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceMemory struct { + Quantity byteQuantity `protobuf:"varint,1,opt,name=quantity,proto3,casttype=byteQuantity" json:"size" yaml:"size"` + Attributes memoryAttributes `protobuf:"bytes,2,rep,name=attributes,proto3,castrepeated=memoryAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceMemory) Reset() { *m = ResourceMemory{} } +func (m *ResourceMemory) String() string { return proto.CompactTextString(m) } +func (*ResourceMemory) ProtoMessage() {} +func (*ResourceMemory) Descriptor() ([]byte, []int) { + return fileDescriptor_26ca34cce67896d0, []int{0} +} +func (m *ResourceMemory) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceMemory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceMemory.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceMemory) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceMemory.Merge(m, src) +} +func (m *ResourceMemory) XXX_Size() int { + return m.Size() +} +func (m *ResourceMemory) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceMemory.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceMemory proto.InternalMessageInfo + +func (m *ResourceMemory) GetQuantity() byteQuantity { + if m != nil { + return m.Quantity + } + return 0 +} + +func (m *ResourceMemory) GetAttributes() memoryAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceMemory)(nil), "akash.sdl.v2_1.ResourceMemory") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/memory.proto", fileDescriptor_26ca34cce67896d0) } + +var fileDescriptor_26ca34cce67896d0 = []byte{ + // 320 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0x31, 0x4f, 0x02, 0x31, + 0x14, 0xbe, 0xaa, 0x31, 0xa4, 0x28, 0x51, 0xe2, 0x40, 0x30, 0xb6, 0xe4, 0x26, 0x16, 0xdb, 0x1c, + 0x6c, 0x6e, 0x32, 0xe9, 0x60, 0x8c, 0x8c, 0x2e, 0xa4, 0x85, 0xe6, 0xb8, 0xc0, 0x51, 0xbc, 0xf6, + 0x30, 0xe7, 0x2f, 0x70, 0xf4, 0x77, 0xf8, 0x4b, 0x18, 0x19, 0x9d, 0xaa, 0x39, 0x36, 0xe2, 0xc4, + 0xe8, 0x64, 0xb8, 0x1e, 0x07, 0x5b, 0xdf, 0xf7, 0xbe, 0xf7, 0x7d, 0x5f, 0xdf, 0x83, 0x97, 0x6c, + 0xc4, 0xd4, 0x90, 0xaa, 0xc1, 0x98, 0xce, 0x5a, 0xc4, 0xa3, 0xa1, 0x08, 0x65, 0x94, 0x90, 0x69, + 0x24, 0xb5, 0xac, 0x56, 0xb2, 0x26, 0x51, 0x83, 0x31, 0x99, 0xb5, 0x7a, 0x5e, 0xfd, 0xc2, 0x97, + 0xbe, 0xcc, 0x5a, 0x74, 0xf3, 0xb2, 0xac, 0xba, 0x6b, 0x25, 0x38, 0x53, 0x82, 0xce, 0x3c, 0x2e, + 0x34, 0x6b, 0x53, 0xa6, 0x75, 0x14, 0xf0, 0x58, 0x0b, 0xcb, 0x71, 0x7f, 0x01, 0xac, 0x74, 0x85, + 0x92, 0x71, 0xd4, 0x17, 0x0f, 0x99, 0x45, 0xf5, 0x11, 0x96, 0x5e, 0x62, 0x36, 0xd1, 0x81, 0x4e, + 0x6a, 0xa0, 0x01, 0x9a, 0xa7, 0x9d, 0x76, 0x6a, 0x70, 0xe9, 0x29, 0xc7, 0x56, 0x06, 0x1f, 0xa9, + 0xe0, 0x4d, 0xac, 0x0d, 0x2e, 0x27, 0x2c, 0x1c, 0xdf, 0xb8, 0x9b, 0xca, 0xfd, 0x33, 0xf8, 0x84, + 0x27, 0x5a, 0x6c, 0x69, 0xdd, 0x42, 0xa4, 0xfa, 0x0e, 0x20, 0x2c, 0x7c, 0x55, 0xed, 0xa0, 0x71, + 0xd8, 0x2c, 0xb7, 0xae, 0x88, 0xfd, 0xc3, 0x26, 0x1d, 0xc9, 0xd3, 0x91, 0xdb, 0x2d, 0xab, 0x73, + 0x3f, 0x37, 0xd8, 0x49, 0x0d, 0x86, 0x05, 0xa4, 0x56, 0x06, 0xef, 0xc9, 0xac, 0x0d, 0x3e, 0xb7, + 0xf6, 0x3b, 0xcc, 0xfd, 0xfc, 0xc6, 0x67, 0x76, 0x51, 0xbb, 0xb1, 0xee, 0xde, 0x50, 0xe7, 0x6e, + 0x9e, 0x22, 0xb0, 0x48, 0x11, 0xf8, 0x49, 0x11, 0xf8, 0x58, 0x22, 0x67, 0xb1, 0x44, 0xce, 0xd7, + 0x12, 0x39, 0xcf, 0xc4, 0x0f, 0xf4, 0x30, 0xe6, 0xa4, 0x2f, 0x43, 0x9a, 0x25, 0xbb, 0x9e, 0x08, + 0xfd, 0x2a, 0xa3, 0x51, 0x5e, 0xb1, 0x69, 0x40, 0x7d, 0x99, 0xdf, 0xa3, 0xe7, 0xf1, 0xe3, 0x6c, + 0x7f, 0xed, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x28, 0xf0, 0x86, 0xdc, 0xa8, 0x01, 0x00, 0x00, +} + +func (m *ResourceMemory) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceMemory) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceMemory) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMemory(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Quantity != 0 { + i = encodeVarintMemory(dAtA, i, uint64(m.Quantity)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintMemory(dAtA []byte, offset int, v uint64) int { + offset -= sovMemory(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceMemory) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Quantity != 0 { + n += 1 + sovMemory(uint64(m.Quantity)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovMemory(uint64(l)) + } + } + return n +} + +func sovMemory(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMemory(x uint64) (n int) { + return sovMemory(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceMemory) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceMemory: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceMemory: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantity", wireType) + } + m.Quantity = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Quantity |= byteQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMemory + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMemory + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMemory + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMemory(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMemory + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMemory(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMemory + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMemory + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMemory + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMemory + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMemory = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMemory = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMemory = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/profiles.go b/go/sdl/v2_1/profiles.go new file mode 100644 index 00000000..b0766e14 --- /dev/null +++ b/go/sdl/v2_1/profiles.go @@ -0,0 +1,116 @@ +package v2_1 + +import ( + "errors" + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + sdk "github.com/cosmos/cosmos-sdk/types" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +var errInvalidCoinAmount = errors.New("invalid coin amount") + +type placementPricing map[string]sdk.DecCoin + +type placementAttributes types.Attributes + +type coinNode struct { + Amount string `yaml:"amount"` + Denom string `yaml:"denom"` +} + +func (sdl *placementAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr placementAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + for k, v := range res { + attr = append(attr, types.Attribute{ + Key: k, + Value: v, + }) + } + + // keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} + +func (sdl *placementPricing) UnmarshalYAML(node *yaml.Node) error { + result := make(placementPricing) + + for i := 0; i < len(node.Content); i += 2 { + var coin sdk.DecCoin + + switch node.Content[i+1].Kind { + case yaml.MappingNode: + pcoin := coinNode{} + if err := node.Content[i+1].Decode(&pcoin); err != nil { + return err + } + + amount, err := sdk.NewDecFromStr(pcoin.Amount) + if err != nil { + return err + } + + coin = sdk.NewDecCoinFromDec(pcoin.Denom, amount) + case yaml.ScalarNode: + var err error + if coin, err = sdk.ParseDecCoin(node.Content[i+1].Value); err != nil { + return err + } + default: + return fmt.Errorf("sdl: unexpected content type") + } + + if coin.IsZero() { + return fmt.Errorf("%w: amount is zero", errInvalidCoinAmount) + } + + if coin.IsNegative() { + return fmt.Errorf("%w: amount %q is negative", errNegativeValue, coin.Amount.String()) + } + + result[node.Content[i].Value] = coin + } + + return nil +} + +func (sdl *ProfilePlacement) UnmarshalYAML(node *yaml.Node) error { + result := ProfilePlacement{} + + for i := 0; i < len(node.Content); i += 2 { + var val interface{} + switch node.Content[i].Value { + case "attributes": + val = &result.Attributes + case "signedBy": + val = &result.SignedBy + case "pricing": + val = &result.Pricing + default: + return fmt.Errorf("sdl: unexpected field %s", node.Content[i].Value) + } + + if err := node.Content[i+1].Decode(val); err != nil { + return err + } + } + + *sdl = result + + return nil +} diff --git a/go/sdl/v2_1/profiles.pb.go b/go/sdl/v2_1/profiles.pb.go new file mode 100644 index 00000000..4c38e898 --- /dev/null +++ b/go/sdl/v2_1/profiles.pb.go @@ -0,0 +1,1231 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/profiles.proto + +package v2_1 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ProfileCompute struct { + Resources *ComputeResources `protobuf:"bytes,1,opt,name=resources,proto3" json:"resources" yaml:"resources"` +} + +func (m *ProfileCompute) Reset() { *m = ProfileCompute{} } +func (m *ProfileCompute) String() string { return proto.CompactTextString(m) } +func (*ProfileCompute) ProtoMessage() {} +func (*ProfileCompute) Descriptor() ([]byte, []int) { + return fileDescriptor_749fab225ccea52f, []int{0} +} +func (m *ProfileCompute) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProfileCompute) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProfileCompute.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ProfileCompute) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProfileCompute.Merge(m, src) +} +func (m *ProfileCompute) XXX_Size() int { + return m.Size() +} +func (m *ProfileCompute) XXX_DiscardUnknown() { + xxx_messageInfo_ProfileCompute.DiscardUnknown(m) +} + +var xxx_messageInfo_ProfileCompute proto.InternalMessageInfo + +func (m *ProfileCompute) GetResources() *ComputeResources { + if m != nil { + return m.Resources + } + return nil +} + +type ProfilePlacement struct { + Attributes placementAttributes `protobuf:"bytes,1,rep,name=attributes,proto3,castrepeated=placementAttributes" json:"attributes" yaml:"attributes"` + SignedBy v1beta3.SignedBy `protobuf:"bytes,2,opt,name=signed_by,json=signedBy,proto3" json:"signedBy" yaml:"signedBy"` + Pricing map[string]Coin `protobuf:"bytes,3,rep,name=pricing,proto3" json:"pricing" yaml:"pricing" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *ProfilePlacement) Reset() { *m = ProfilePlacement{} } +func (m *ProfilePlacement) String() string { return proto.CompactTextString(m) } +func (*ProfilePlacement) ProtoMessage() {} +func (*ProfilePlacement) Descriptor() ([]byte, []int) { + return fileDescriptor_749fab225ccea52f, []int{1} +} +func (m *ProfilePlacement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProfilePlacement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProfilePlacement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ProfilePlacement) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProfilePlacement.Merge(m, src) +} +func (m *ProfilePlacement) XXX_Size() int { + return m.Size() +} +func (m *ProfilePlacement) XXX_DiscardUnknown() { + xxx_messageInfo_ProfilePlacement.DiscardUnknown(m) +} + +var xxx_messageInfo_ProfilePlacement proto.InternalMessageInfo + +func (m *ProfilePlacement) GetAttributes() placementAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func (m *ProfilePlacement) GetSignedBy() v1beta3.SignedBy { + if m != nil { + return m.SignedBy + } + return v1beta3.SignedBy{} +} + +func (m *ProfilePlacement) GetPricing() map[string]Coin { + if m != nil { + return m.Pricing + } + return nil +} + +type Profiles struct { + Compute map[string]*ProfileCompute `protobuf:"bytes,1,rep,name=compute,proto3" json:"compute" yaml:"compute" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Placement map[string]*ProfilePlacement `protobuf:"bytes,2,rep,name=placement,proto3" json:"placement" yaml:"placement" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Profiles) Reset() { *m = Profiles{} } +func (m *Profiles) String() string { return proto.CompactTextString(m) } +func (*Profiles) ProtoMessage() {} +func (*Profiles) Descriptor() ([]byte, []int) { + return fileDescriptor_749fab225ccea52f, []int{2} +} +func (m *Profiles) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Profiles) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Profiles.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Profiles) XXX_Merge(src proto.Message) { + xxx_messageInfo_Profiles.Merge(m, src) +} +func (m *Profiles) XXX_Size() int { + return m.Size() +} +func (m *Profiles) XXX_DiscardUnknown() { + xxx_messageInfo_Profiles.DiscardUnknown(m) +} + +var xxx_messageInfo_Profiles proto.InternalMessageInfo + +func (m *Profiles) GetCompute() map[string]*ProfileCompute { + if m != nil { + return m.Compute + } + return nil +} + +func (m *Profiles) GetPlacement() map[string]*ProfilePlacement { + if m != nil { + return m.Placement + } + return nil +} + +func init() { + proto.RegisterType((*ProfileCompute)(nil), "akash.sdl.v2_1.ProfileCompute") + proto.RegisterType((*ProfilePlacement)(nil), "akash.sdl.v2_1.ProfilePlacement") + proto.RegisterMapType((map[string]Coin)(nil), "akash.sdl.v2_1.ProfilePlacement.PricingEntry") + proto.RegisterType((*Profiles)(nil), "akash.sdl.v2_1.Profiles") + proto.RegisterMapType((map[string]*ProfileCompute)(nil), "akash.sdl.v2_1.Profiles.ComputeEntry") + proto.RegisterMapType((map[string]*ProfilePlacement)(nil), "akash.sdl.v2_1.Profiles.PlacementEntry") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/profiles.proto", fileDescriptor_749fab225ccea52f) } + +var fileDescriptor_749fab225ccea52f = []byte{ + // 594 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcf, 0x8f, 0xd2, 0x40, + 0x18, 0xa5, 0x4b, 0x74, 0x97, 0xd9, 0x0d, 0x62, 0xdd, 0x03, 0x36, 0x6e, 0x87, 0x4c, 0xa2, 0x12, + 0xe3, 0x4e, 0x03, 0x6b, 0x8c, 0xd9, 0x9b, 0x35, 0x26, 0x1e, 0x3c, 0x90, 0x7a, 0xdb, 0x83, 0xa4, + 0x85, 0xb1, 0x5b, 0x29, 0x6d, 0xd3, 0x1f, 0x18, 0xee, 0xde, 0xbc, 0xf8, 0x67, 0x18, 0xff, 0x12, + 0x8e, 0x7b, 0x31, 0xf1, 0x34, 0x1a, 0xb8, 0x71, 0xe4, 0x2f, 0x30, 0xed, 0xfc, 0x28, 0xb0, 0x10, + 0x6f, 0xc3, 0xfb, 0xde, 0xbc, 0xef, 0x7d, 0x6f, 0x3e, 0x0a, 0xce, 0xec, 0x91, 0x9d, 0x5c, 0x1b, + 0xc9, 0xd0, 0x37, 0x26, 0x5d, 0xdc, 0x31, 0xa2, 0x38, 0xfc, 0xe4, 0xf9, 0x24, 0xc1, 0x51, 0x1c, + 0xa6, 0xa1, 0x5a, 0x2f, 0xca, 0x38, 0x19, 0xfa, 0x78, 0xd2, 0xed, 0x77, 0xb4, 0x53, 0x37, 0x74, + 0xc3, 0xa2, 0x64, 0xe4, 0x27, 0xc6, 0xd2, 0x10, 0x13, 0x71, 0xec, 0x84, 0x18, 0x93, 0x8e, 0x43, + 0x52, 0xfb, 0xc2, 0xb0, 0xd3, 0x34, 0xf6, 0x9c, 0x2c, 0x25, 0x9c, 0xf3, 0x64, 0xab, 0xd1, 0x20, + 0x1c, 0x47, 0x59, 0x4a, 0xfa, 0x31, 0x49, 0xc2, 0x2c, 0x1e, 0x88, 0x8e, 0xda, 0xc3, 0x5b, 0x3c, + 0x2f, 0x60, 0x25, 0xf4, 0x55, 0x01, 0xf5, 0x1e, 0xf3, 0xf7, 0x86, 0xdd, 0x56, 0x63, 0x50, 0x93, + 0x02, 0x4d, 0xa5, 0xa5, 0xb4, 0x8f, 0xbb, 0x2d, 0xbc, 0xe9, 0x19, 0x73, 0xae, 0x25, 0x78, 0x66, + 0x77, 0x46, 0xa1, 0x32, 0xa7, 0xb0, 0x26, 0xa1, 0x25, 0x85, 0xa5, 0xce, 0x8a, 0xc2, 0xc6, 0xd4, + 0x1e, 0xfb, 0x97, 0x48, 0x42, 0xc8, 0x2a, 0xcb, 0xe8, 0x57, 0x15, 0x34, 0xb8, 0x8d, 0x9e, 0x6f, + 0x0f, 0xc8, 0x98, 0x04, 0xa9, 0xfa, 0x4d, 0x01, 0x40, 0x8e, 0x9c, 0x5b, 0xa9, 0xb6, 0x8f, 0xbb, + 0x67, 0xdc, 0x4a, 0x1e, 0x0c, 0xe6, 0xc1, 0xe0, 0xd7, 0x82, 0x65, 0xbe, 0x9f, 0x51, 0x58, 0x99, + 0x53, 0x08, 0x24, 0x94, 0x1b, 0x59, 0x93, 0x59, 0x51, 0x78, 0x9f, 0x39, 0x29, 0x31, 0xf4, 0xf3, + 0x0f, 0x7c, 0x10, 0x89, 0xbe, 0xe5, 0x4d, 0x6b, 0xed, 0x9e, 0xfa, 0x19, 0xd4, 0x12, 0xcf, 0x0d, + 0xc8, 0xb0, 0xef, 0x4c, 0x9b, 0x07, 0x45, 0x2c, 0x8f, 0x76, 0x79, 0xf9, 0x50, 0x90, 0xcc, 0xa9, + 0x69, 0x70, 0x2b, 0x47, 0x02, 0x59, 0x52, 0x78, 0x94, 0xf0, 0xf3, 0x8a, 0xc2, 0x7b, 0xcc, 0x86, + 0x40, 0x90, 0x25, 0x8b, 0x6a, 0x06, 0x0e, 0xa3, 0xd8, 0x1b, 0x78, 0x81, 0xdb, 0xac, 0x16, 0x53, + 0x9f, 0x6f, 0x3f, 0xc0, 0x76, 0x58, 0xb8, 0xc7, 0xf8, 0x6f, 0x83, 0x34, 0x9e, 0x9a, 0xcf, 0x79, + 0xeb, 0x43, 0x8e, 0x2e, 0x29, 0x14, 0x82, 0x2b, 0x0a, 0xeb, 0xac, 0x31, 0x07, 0x90, 0x25, 0x4a, + 0x5a, 0x0f, 0x9c, 0xac, 0xcb, 0xa8, 0x0d, 0x50, 0x1d, 0x91, 0x69, 0xb1, 0x03, 0x35, 0x2b, 0x3f, + 0xaa, 0xcf, 0xc0, 0x9d, 0x89, 0xed, 0x67, 0x84, 0x07, 0x70, 0x7a, 0x7b, 0x2f, 0xbc, 0xc0, 0x62, + 0x94, 0xcb, 0x83, 0x57, 0x0a, 0xfa, 0x51, 0x05, 0x47, 0xdc, 0x6a, 0xa2, 0x7a, 0xe0, 0x90, 0x6f, + 0x28, 0x7f, 0xcb, 0xc7, 0x7b, 0xa6, 0x4a, 0xc4, 0x7e, 0xb1, 0x69, 0xda, 0xf9, 0x24, 0x1c, 0xc9, + 0x27, 0xe1, 0x22, 0xe5, 0x24, 0x1c, 0x40, 0x96, 0x28, 0xa9, 0x19, 0xa8, 0xc9, 0xf7, 0x6c, 0x1e, + 0x14, 0xcd, 0x9e, 0xee, 0x6d, 0x26, 0x43, 0x64, 0xed, 0x70, 0xbe, 0xc6, 0x12, 0xcb, 0xd7, 0x58, + 0x4a, 0x95, 0x6b, 0x2c, 0x21, 0x64, 0x95, 0x65, 0xed, 0x0a, 0x9c, 0xac, 0x3b, 0xdf, 0x11, 0xe0, + 0x8b, 0xcd, 0x00, 0xf5, 0x3d, 0xa6, 0xc4, 0xff, 0xab, 0x8c, 0x52, 0xfb, 0x08, 0xea, 0x9b, 0x46, + 0x77, 0xa8, 0xbf, 0xdc, 0x54, 0x6f, 0xfd, 0x6f, 0x6b, 0xd6, 0xf4, 0xcd, 0x77, 0xb3, 0xb9, 0xae, + 0xdc, 0xcc, 0x75, 0xe5, 0xef, 0x5c, 0x57, 0xbe, 0x2f, 0xf4, 0xca, 0xcd, 0x42, 0xaf, 0xfc, 0x5e, + 0xe8, 0x95, 0x2b, 0xec, 0x7a, 0xe9, 0x75, 0xe6, 0xe0, 0x41, 0x38, 0x36, 0x0a, 0xc1, 0xf3, 0x80, + 0xa4, 0x5f, 0xc2, 0x78, 0xc4, 0x7f, 0xd9, 0x91, 0x67, 0xb8, 0x21, 0xff, 0xbc, 0xf4, 0x3b, 0xce, + 0xdd, 0xe2, 0xd3, 0x72, 0xf1, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xc8, 0xc9, 0xe7, 0x49, 0x08, 0x05, + 0x00, 0x00, +} + +func (m *ProfileCompute) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProfileCompute) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProfileCompute) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Resources != nil { + { + size, err := m.Resources.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ProfilePlacement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProfilePlacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProfilePlacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Pricing) > 0 { + for k := range m.Pricing { + v := m.Pricing[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + { + size, err := m.SignedBy.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Profiles) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Profiles) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Profiles) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Placement) > 0 { + for k := range m.Placement { + v := m.Placement[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Compute) > 0 { + for k := range m.Compute { + v := m.Compute[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProfiles(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintProfiles(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintProfiles(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintProfiles(dAtA []byte, offset int, v uint64) int { + offset -= sovProfiles(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ProfileCompute) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Resources != nil { + l = m.Resources.Size() + n += 1 + l + sovProfiles(uint64(l)) + } + return n +} + +func (m *ProfilePlacement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovProfiles(uint64(l)) + } + } + l = m.SignedBy.Size() + n += 1 + l + sovProfiles(uint64(l)) + if len(m.Pricing) > 0 { + for k, v := range m.Pricing { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + 1 + l + sovProfiles(uint64(l)) + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + return n +} + +func (m *Profiles) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Compute) > 0 { + for k, v := range m.Compute { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovProfiles(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + l + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + if len(m.Placement) > 0 { + for k, v := range m.Placement { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovProfiles(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovProfiles(uint64(len(k))) + l + n += mapEntrySize + 1 + sovProfiles(uint64(mapEntrySize)) + } + } + return n +} + +func sovProfiles(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProfiles(x uint64) (n int) { + return sovProfiles(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ProfileCompute) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProfileCompute: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProfileCompute: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Resources == nil { + m.Resources = &ComputeResources{} + } + if err := m.Resources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProfilePlacement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProfilePlacement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProfilePlacement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SignedBy", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SignedBy.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pricing", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pricing == nil { + m.Pricing = make(map[string]Coin) + } + var mapkey string + mapvalue := &Coin{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Coin{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Pricing[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Profiles) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Profiles: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Profiles: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Compute", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Compute == nil { + m.Compute = make(map[string]*ProfileCompute) + } + var mapkey string + var mapvalue *ProfileCompute + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ProfileCompute{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Compute[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Placement", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProfiles + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProfiles + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Placement == nil { + m.Placement = make(map[string]*ProfilePlacement) + } + var mapkey string + var mapvalue *ProfilePlacement + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthProfiles + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthProfiles + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProfiles + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthProfiles + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthProfiles + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ProfilePlacement{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Placement[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProfiles(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProfiles + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipProfiles(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowProfiles + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthProfiles + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupProfiles + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthProfiles + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthProfiles = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProfiles = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProfiles = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/sdl.go b/go/sdl/v2_1/sdl.go new file mode 100644 index 00000000..3088e5f2 --- /dev/null +++ b/go/sdl/v2_1/sdl.go @@ -0,0 +1,348 @@ +package v2_1 + +import ( + "errors" + "fmt" + "path" + "regexp" + "sort" + "strconv" + + "gopkg.in/yaml.v3" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +const ( + sdlVersionField = "version" +) + +var ( + errSDLInvalid = errors.New("sdl: invalid") + errUninitializedConfig = errors.New("sdl: uninitialized") + errSDLInvalidNoVersion = fmt.Errorf("no version found: %w", errSDLInvalid) + + endpointNameValidationRegex = regexp.MustCompile(`^[[:lower:]]+[[:lower:]-_\d]+$`) +) + +type SDL struct { + Content `yaml:"-"` + + result struct { + dgroups dtypes.GroupSpecs + mgroups manifest.Groups + } +} + +func (sdl *SDL) DeploymentGroups() (dtypes.GroupSpecs, error) { + return sdl.result.dgroups, nil +} + +func (sdl *SDL) Manifest() (manifest.Manifest, error) { + return manifest.Manifest(sdl.result.mgroups), nil +} + +// Version creates the deterministic Deployment Version hash from the SDL. +func (sdl *SDL) Version() ([]byte, error) { + return manifest.Manifest(sdl.result.mgroups).Version() +} + +func (sdl *SDL) UnmarshalYAML(node *yaml.Node) error { + result := SDL{} + +loop: + for i := 0; i < len(node.Content); i += 2 { + var val interface{} + switch node.Content[i].Value { + case "include": + val = &result.Include + case "services": + val = &result.Services + case "profiles": + val = &result.Profiles + case "deployment": + val = &result.Deployments + case "endpoints": + val = &result.Endpoints + case sdlVersionField: + // version is already verified + continue loop + default: + return fmt.Errorf("sdl: unexpected field %s", node.Content[i].Value) + } + + if err := node.Content[i+1].Decode(val); err != nil { + return err + } + } + + if err := result.buildGroups(); err != nil { + return err + } + + *sdl = result + + return nil +} + +func (sdl *SDL) Validate() error { + for endpointName, endpoint := range sdl.Endpoints { + if !endpointNameValidationRegex.MatchString(endpointName) { + return fmt.Errorf( + "%w: endpoint named %q is not a valid name", + errSDLInvalid, + endpointName, + ) + } + + if len(endpoint.Kind) == 0 { + return fmt.Errorf("%w: endpoint named %q has no kind", errSDLInvalid, endpointName) + } + + // Validate endpoint kind, there is only one allowed value for now + if endpoint.Kind != endpointKindIP { + return fmt.Errorf( + "%w: endpoint named %q, unknown kind %q", + errSDLInvalid, + endpointName, + endpoint.Kind, + ) + } + } + + endpointsUsed := make(map[string]struct{}) + portsUsed := make(map[string]string) + for _, svcName := range sdl.Deployments.svcNames() { + depl := sdl.Deployments[svcName] + + for _, pname := range depl.placements() { + placement := depl[pname] + compute, ok := sdl.Profiles.Compute[placement.Profile] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no compute profile named %v", + errSDLInvalid, + svcName, + pname, + placement.Profile, + ) + } + + infra, ok := sdl.Profiles.Placement[pname] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no placement profile named %v", + errSDLInvalid, + svcName, + pname, + placement.Profile, + ) + } + + if _, ok := infra.Pricing[placement.Profile]; !ok { + return fmt.Errorf( + "%w: %v.%v: no pricing for profile %v", + errSDLInvalid, + svcName, + pname, + placement.Profile, + ) + } + + svc, ok := sdl.Services[svcName] + if !ok { + return fmt.Errorf( + "%w: %v.%v: no service profile named %v", + errSDLInvalid, + svcName, + pname, + svcName, + ) + } + + for _, serviceExpose := range svc.Expose { + for _, to := range serviceExpose.To { + // Check to see if an IP endpoint is also specified + if len(to.IP) != 0 { + if !to.Global { + return fmt.Errorf( + "%w: error on %q if an IP is declared the directive must be declared as global", + errSDLInvalid, + svcName, + ) + } + endpoint, endpointExists := sdl.Endpoints[to.IP] + if !endpointExists { + return fmt.Errorf( + "%w: error on service %q no endpoint named %q exists", + errSDLInvalid, + svcName, + to.IP, + ) + } + + if endpoint.Kind != endpointKindIP { + return fmt.Errorf( + "%w: error on service %q endpoint %q has type %q, should be %q", + errSDLInvalid, + svcName, + to.IP, + endpoint.Kind, + endpointKindIP, + ) + } + + endpointsUsed[to.IP] = struct{}{} + + // Endpoint exists. Now check for port collisions across a single endpoint, port, & protocol + portKey := fmt.Sprintf( + "%s-%d-%s", + to.IP, + serviceExpose.As, + serviceExpose.Proto, + ) + otherServiceName, inUse := portsUsed[portKey] + if inUse { + return fmt.Errorf( + "%w: IP endpoint %q port: %d protocol: %s specified by service %q already in use by %q", + errSDLInvalid, + to.IP, + serviceExpose.Port, + serviceExpose.Proto, + svcName, + otherServiceName, + ) + } + portsUsed[portKey] = svcName + } + } + } + + // validate storage's attributes and parameters + volumes := make(map[string]ResourceStorage) + for _, volume := range compute.Resources.Storage { + // making deepcopy here as we gonna merge compute attributes and service parameters for validation below + attr := make(storageAttributes, len(volume.Attributes)) + + copy(attr, volume.Attributes) + + volumes[volume.Name] = ResourceStorage{ + Name: volume.Name, + Quantity: volume.Quantity, + Attributes: attr, + } + } + + attr := make(map[string]string) + mounts := make(map[string]string) + + if svc.Params != nil { + for name, params := range svc.Params.Storage { + if _, exists := volumes[name]; !exists { + return fmt.Errorf( + "%w: service \"%s\" references to no-existing compute volume named \"%s\"", + errSDLInvalid, + svcName, + name, + ) + } + + if !path.IsAbs(params.Mount) { + return fmt.Errorf( + "%w: invalid value for \"service.%s.params.%s.mount\" parameter. expected absolute path", + errSDLInvalid, + svcName, + name, + ) + } + + attr[StorageAttributeMount] = params.Mount + attr[StorageAttributeReadOnly] = strconv.FormatBool(params.ReadOnly) + + mount := attr[StorageAttributeMount] + if vlname, exists := mounts[mount]; exists { + if mount == "" { + return errStorageMultipleRootEphemeral + } + + return fmt.Errorf( + "%w: mount %q already in use by volume %q", + errStorageDupMountPoint, + mount, + vlname, + ) + } + + mounts[mount] = name + } + } + + for name, volume := range volumes { + for _, nd := range types.Attributes(volume.Attributes) { + attr[nd.Key] = nd.Value + } + + persistent, _ := strconv.ParseBool(attr[StorageAttributePersistent]) + + if persistent && attr[StorageAttributeMount] == "" { + return fmt.Errorf( + "%w: compute.storage.%s has persistent=true which requires service.%s.params.storage.%s to have mount", + errSDLInvalid, + name, + svcName, + name, + ) + } + } + } + } + + for endpointName := range sdl.Endpoints { + _, inUse := endpointsUsed[endpointName] + if !inUse { + return fmt.Errorf( + "%w: endpoint %q declared but never used", + errSDLInvalid, + endpointName, + ) + } + } + + return nil +} + +func (sdl *SDL) computeEndpointSequenceNumbers() map[string]uint32 { + var endpointNames []string + res := make(map[string]uint32) + + for _, serviceName := range sdl.Deployments.svcNames() { + for _, expose := range sdl.Services[serviceName].Expose { + for _, to := range expose.To { + if to.Global && len(to.IP) == 0 { + continue + } + + endpointNames = append(endpointNames, to.IP) + } + } + } + + if len(endpointNames) == 0 { + return res + } + + // Make the assignment stable + sort.Strings(endpointNames) + + // Start at zero, so the first assigned one is 1 + endpointSeqNumber := uint32(0) + for _, name := range endpointNames { + endpointSeqNumber++ + seqNo := endpointSeqNumber + res[name] = seqNo + } + + return res +} diff --git a/go/sdl/v2_1/sdl.pb.go b/go/sdl/v2_1/sdl.pb.go new file mode 100644 index 00000000..455aefc7 --- /dev/null +++ b/go/sdl/v2_1/sdl.pb.go @@ -0,0 +1,829 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/sdl.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/protobuf/types/known/structpb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Content struct { + Include string `protobuf:"bytes,1,opt,name=include,proto3" json:"include,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + Services map[string]Service `protobuf:"bytes,3,rep,name=services,proto3" json:"services" yaml:"services" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Profiles Profiles `protobuf:"bytes,4,opt,name=profiles,proto3" json:"profiles" yaml:"profiles"` + Deployments Deployments `protobuf:"bytes,5,opt,name=deployments,proto3,customtype=Deployments" json:"deployments" yaml:"deployments"` + Endpoints map[string]Endpoint `protobuf:"bytes,6,rep,name=endpoints,proto3" json:"endpoints" yaml:"endpoints" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Content) Reset() { *m = Content{} } +func (m *Content) String() string { return proto.CompactTextString(m) } +func (*Content) ProtoMessage() {} +func (*Content) Descriptor() ([]byte, []int) { + return fileDescriptor_f76644bab840abf6, []int{0} +} +func (m *Content) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Content.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_Content.Merge(m, src) +} +func (m *Content) XXX_Size() int { + return m.Size() +} +func (m *Content) XXX_DiscardUnknown() { + xxx_messageInfo_Content.DiscardUnknown(m) +} + +var xxx_messageInfo_Content proto.InternalMessageInfo + +func (m *Content) GetInclude() string { + if m != nil { + return m.Include + } + return "" +} + +func (m *Content) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *Content) GetServices() map[string]Service { + if m != nil { + return m.Services + } + return nil +} + +func (m *Content) GetProfiles() Profiles { + if m != nil { + return m.Profiles + } + return Profiles{} +} + +func (m *Content) GetEndpoints() map[string]Endpoint { + if m != nil { + return m.Endpoints + } + return nil +} + +func init() { + proto.RegisterType((*Content)(nil), "akash.sdl.v2_1.content") + proto.RegisterMapType((map[string]Endpoint)(nil), "akash.sdl.v2_1.content.EndpointsEntry") + proto.RegisterMapType((map[string]Service)(nil), "akash.sdl.v2_1.content.ServicesEntry") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/sdl.proto", fileDescriptor_f76644bab840abf6) } + +var fileDescriptor_f76644bab840abf6 = []byte{ + // 490 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0x41, 0x6f, 0xd3, 0x30, + 0x18, 0x6d, 0x56, 0xba, 0xb5, 0xae, 0x18, 0x53, 0x84, 0x44, 0x54, 0x41, 0x5c, 0x45, 0x02, 0xf5, + 0x32, 0x47, 0x0d, 0x17, 0xb4, 0x63, 0xc5, 0x04, 0x47, 0x94, 0x21, 0x0e, 0x5c, 0xa6, 0x34, 0xf5, + 0xb2, 0xa8, 0xa9, 0x1d, 0x25, 0x4e, 0xa0, 0x57, 0x7e, 0x01, 0x7f, 0x0a, 0x69, 0xc7, 0x1d, 0x11, + 0x07, 0x0b, 0xa5, 0xb7, 0x1e, 0xfb, 0x0b, 0x50, 0x1c, 0x3b, 0x69, 0xca, 0x76, 0xf3, 0xf7, 0xde, + 0xe7, 0xf7, 0xfc, 0x7d, 0x2f, 0x01, 0x86, 0xb7, 0xf4, 0xd2, 0x5b, 0x3b, 0x5d, 0x44, 0x76, 0xee, + 0xa0, 0x69, 0x79, 0x40, 0x71, 0x42, 0x19, 0xd5, 0x4f, 0x05, 0x83, 0x4a, 0x20, 0x77, 0xae, 0xa7, + 0xa3, 0xe7, 0x01, 0x0d, 0xa8, 0xa0, 0xec, 0xf2, 0x54, 0x75, 0x8d, 0x5e, 0x06, 0x94, 0x06, 0x11, + 0xb6, 0x45, 0x35, 0xcf, 0x6e, 0xec, 0x94, 0x25, 0x99, 0xcf, 0x14, 0x7b, 0xa8, 0x8e, 0x93, 0x3c, + 0xf4, 0xb1, 0x64, 0x5f, 0x1d, 0xb0, 0x71, 0x42, 0x6f, 0xc2, 0x08, 0xa7, 0x8f, 0xd0, 0x98, 0x2c, + 0x62, 0x1a, 0x12, 0xa9, 0x6d, 0xfd, 0xea, 0x81, 0x13, 0x9f, 0x12, 0x86, 0x09, 0xd3, 0x0d, 0x70, + 0x12, 0x12, 0x3f, 0xca, 0x16, 0xd8, 0xd0, 0xc6, 0xda, 0x64, 0xe0, 0xaa, 0xb2, 0x64, 0x72, 0x9c, + 0xa4, 0x21, 0x25, 0xc6, 0x51, 0xc5, 0xc8, 0x52, 0x4f, 0x40, 0x5f, 0x3e, 0x27, 0x35, 0xba, 0xe3, + 0xee, 0x64, 0xe8, 0xbc, 0x46, 0xed, 0x91, 0x91, 0x94, 0x47, 0x57, 0xb2, 0xef, 0x92, 0xb0, 0x64, + 0x3d, 0xb3, 0xef, 0x38, 0xec, 0x14, 0x1c, 0xf6, 0x15, 0xbc, 0xe5, 0xb0, 0x96, 0xda, 0x71, 0xf8, + 0x6c, 0xed, 0xad, 0xa2, 0x0b, 0x4b, 0x21, 0x96, 0x5b, 0x93, 0x3a, 0x06, 0x7d, 0x35, 0xa4, 0xf1, + 0x64, 0xac, 0x4d, 0x86, 0x8e, 0x71, 0xe8, 0xf9, 0x49, 0xf2, 0x8d, 0x8d, 0x42, 0x4a, 0x1b, 0x75, + 0xbb, 0xb1, 0x51, 0x88, 0xe5, 0xd6, 0xa4, 0xfe, 0x43, 0x03, 0xc3, 0x05, 0x8e, 0x23, 0xba, 0x5e, + 0x61, 0xc2, 0x52, 0xa3, 0x27, 0xac, 0x5e, 0xa0, 0x2a, 0x2b, 0xa4, 0xb2, 0x42, 0x57, 0x22, 0xab, + 0xd9, 0x87, 0xd2, 0xe9, 0x0f, 0x87, 0xc3, 0xf7, 0xcd, 0x9d, 0xa2, 0x5d, 0x6e, 0x39, 0xdc, 0x57, + 0xdc, 0x71, 0xa8, 0x57, 0xf6, 0x7b, 0xa0, 0xe5, 0xee, 0xb7, 0xe8, 0xdf, 0xc1, 0x40, 0x25, 0x96, + 0x1a, 0xc7, 0x62, 0xc1, 0x6f, 0x1e, 0x5b, 0xf0, 0xa5, 0x6a, 0xac, 0x36, 0xec, 0xc8, 0xd1, 0x07, + 0x35, 0xbe, 0xe5, 0xb0, 0x51, 0xdb, 0x71, 0x78, 0x56, 0xb9, 0xd7, 0x90, 0xe5, 0x36, 0xf4, 0xe8, + 0x33, 0x78, 0xda, 0x4a, 0x4c, 0x3f, 0x03, 0xdd, 0x25, 0x5e, 0xcb, 0x4f, 0xa3, 0x3c, 0xea, 0xe7, + 0xa0, 0x97, 0x7b, 0x51, 0x86, 0xc5, 0x47, 0x51, 0xae, 0xe6, 0xe0, 0x61, 0xf2, 0xbe, 0x5b, 0x75, + 0x5d, 0x1c, 0xbd, 0xd3, 0x46, 0x5f, 0xc0, 0x69, 0xfb, 0x99, 0x0f, 0xc8, 0xa2, 0xb6, 0xec, 0x7f, + 0xe1, 0x2a, 0x81, 0x3d, 0xdd, 0xd9, 0xc7, 0xbb, 0xc2, 0xd4, 0xee, 0x0b, 0x53, 0xfb, 0x5b, 0x98, + 0xda, 0xcf, 0x8d, 0xd9, 0xb9, 0xdf, 0x98, 0x9d, 0xdf, 0x1b, 0xb3, 0xf3, 0x15, 0x05, 0x21, 0xbb, + 0xcd, 0xe6, 0xc8, 0xa7, 0x2b, 0x5b, 0x08, 0x9d, 0x13, 0xcc, 0xbe, 0xd1, 0x64, 0x29, 0x2b, 0x2f, + 0x0e, 0xed, 0x80, 0xca, 0x1f, 0xe4, 0x7a, 0x3a, 0x3f, 0x16, 0xc1, 0xbe, 0xfd, 0x17, 0x00, 0x00, + 0xff, 0xff, 0x84, 0x12, 0x98, 0x09, 0xd4, 0x03, 0x00, 0x00, +} + +func (m *Content) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Content) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Endpoints) > 0 { + for k := range m.Endpoints { + v := m.Endpoints[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSdl(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSdl(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x32 + } + } + { + size := m.Deployments.Size() + i -= size + if _, err := m.Deployments.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size, err := m.Profiles.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Services) > 0 { + for k := range m.Services { + v := m.Services[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSdl(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintSdl(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintSdl(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintSdl(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x12 + } + if len(m.Include) > 0 { + i -= len(m.Include) + copy(dAtA[i:], m.Include) + i = encodeVarintSdl(dAtA, i, uint64(len(m.Include))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSdl(dAtA []byte, offset int, v uint64) int { + offset -= sovSdl(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Content) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Include) + if l > 0 { + n += 1 + l + sovSdl(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovSdl(uint64(l)) + } + if len(m.Services) > 0 { + for k, v := range m.Services { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSdl(uint64(len(k))) + 1 + l + sovSdl(uint64(l)) + n += mapEntrySize + 1 + sovSdl(uint64(mapEntrySize)) + } + } + l = m.Profiles.Size() + n += 1 + l + sovSdl(uint64(l)) + l = m.Deployments.Size() + n += 1 + l + sovSdl(uint64(l)) + if len(m.Endpoints) > 0 { + for k, v := range m.Endpoints { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovSdl(uint64(len(k))) + 1 + l + sovSdl(uint64(l)) + n += mapEntrySize + 1 + sovSdl(uint64(mapEntrySize)) + } + } + return n +} + +func sovSdl(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSdl(x uint64) (n int) { + return sovSdl(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Content) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: content: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: content: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Include", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Include = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Services", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Services == nil { + m.Services = make(map[string]Service) + } + var mapkey string + mapvalue := &Service{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthSdl + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSdl + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSdl + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSdl + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Service{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Services[mapkey] = *mapvalue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profiles", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Profiles.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deployments", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Deployments.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Endpoints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSdl + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSdl + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Endpoints == nil { + m.Endpoints = make(map[string]Endpoint) + } + var mapkey string + mapvalue := &Endpoint{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthSdl + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthSdl + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSdl + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthSdl + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthSdl + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Endpoint{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Endpoints[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSdl(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSdl + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSdl(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowSdl + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthSdl + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSdl + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSdl + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSdl = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSdl = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSdl = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/service.pb.go b/go/sdl/v2_1/service.pb.go new file mode 100644 index 00000000..79dd666a --- /dev/null +++ b/go/sdl/v2_1/service.pb.go @@ -0,0 +1,684 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/service.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Service struct { + Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image" yaml:"image"` + Command []string `protobuf:"bytes,2,rep,name=command,proto3" json:"command" yaml:"command"` + Args []string `protobuf:"bytes,3,rep,name=args,proto3" json:"args" yaml:"args"` + Env []string `protobuf:"bytes,4,rep,name=env,proto3" json:"env" yaml:"env"` + Expose Exposes `protobuf:"bytes,5,rep,name=expose,proto3,castrepeated=Exposes" json:"expose" yaml:"expose"` + Dependencies Dependencies `protobuf:"bytes,6,rep,name=dependencies,proto3,castrepeated=Dependencies" json:"dependencies" yaml:"dependencies"` + Params *ServiceParams `protobuf:"bytes,7,opt,name=params,proto3" json:"params" yaml:"params"` +} + +func (m *Service) Reset() { *m = Service{} } +func (m *Service) String() string { return proto.CompactTextString(m) } +func (*Service) ProtoMessage() {} +func (*Service) Descriptor() ([]byte, []int) { + return fileDescriptor_24c59fd932740c9e, []int{0} +} +func (m *Service) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Service.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Service) XXX_Merge(src proto.Message) { + xxx_messageInfo_Service.Merge(m, src) +} +func (m *Service) XXX_Size() int { + return m.Size() +} +func (m *Service) XXX_DiscardUnknown() { + xxx_messageInfo_Service.DiscardUnknown(m) +} + +var xxx_messageInfo_Service proto.InternalMessageInfo + +func (m *Service) GetImage() string { + if m != nil { + return m.Image + } + return "" +} + +func (m *Service) GetCommand() []string { + if m != nil { + return m.Command + } + return nil +} + +func (m *Service) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +func (m *Service) GetEnv() []string { + if m != nil { + return m.Env + } + return nil +} + +func (m *Service) GetExpose() Exposes { + if m != nil { + return m.Expose + } + return nil +} + +func (m *Service) GetDependencies() Dependencies { + if m != nil { + return m.Dependencies + } + return nil +} + +func (m *Service) GetParams() *ServiceParams { + if m != nil { + return m.Params + } + return nil +} + +func init() { + proto.RegisterType((*Service)(nil), "akash.sdl.v2_1.Service") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/service.proto", fileDescriptor_24c59fd932740c9e) } + +var fileDescriptor_24c59fd932740c9e = []byte{ + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0x3f, 0x6f, 0xd3, 0x4c, + 0x18, 0x8f, 0x5f, 0x27, 0xb6, 0x7a, 0xc9, 0xdb, 0xc1, 0x20, 0x64, 0x85, 0xe2, 0x27, 0x32, 0x42, + 0xf2, 0x82, 0xad, 0xa4, 0x0c, 0x88, 0x0d, 0xd3, 0x4a, 0x20, 0x16, 0x64, 0x36, 0x84, 0x14, 0xb9, + 0xf1, 0xc9, 0xb5, 0x1a, 0xfb, 0x2c, 0x5f, 0x30, 0xf4, 0x33, 0xb0, 0xf0, 0x39, 0xf8, 0x10, 0xcc, + 0x1d, 0x3b, 0x32, 0x3d, 0x20, 0x67, 0xf3, 0xe8, 0x4f, 0x80, 0x7c, 0x77, 0x2d, 0x4d, 0xc4, 0xe6, + 0xdf, 0xbf, 0xe7, 0x77, 0xe7, 0xe7, 0xc8, 0x51, 0x7c, 0x11, 0xf3, 0xf3, 0x80, 0x27, 0xeb, 0xa0, + 0x5e, 0xf8, 0xf3, 0x80, 0xd3, 0xaa, 0xce, 0x56, 0xd4, 0x2f, 0x2b, 0xb6, 0x61, 0xd6, 0xa1, 0x50, + 0x7d, 0x9e, 0xac, 0xfd, 0x7a, 0xb1, 0x9c, 0x4f, 0xef, 0xa7, 0x2c, 0x65, 0x42, 0x0a, 0xfa, 0x2f, + 0xe9, 0x9a, 0xc2, 0xde, 0x8c, 0x84, 0x96, 0xb4, 0x48, 0x68, 0xb1, 0xba, 0x54, 0x86, 0x87, 0x7b, + 0x06, 0xfa, 0xa5, 0x64, 0x5c, 0x75, 0x4c, 0x1f, 0xff, 0xfb, 0x04, 0xcb, 0x32, 0xae, 0xe2, 0x9c, + 0x4b, 0x93, 0xfb, 0x63, 0x48, 0xcc, 0xf7, 0x52, 0xb0, 0x9e, 0x93, 0x51, 0x96, 0xc7, 0x29, 0xb5, + 0xb5, 0x99, 0xe6, 0x1d, 0x84, 0x6e, 0x83, 0x30, 0x7a, 0xd3, 0x13, 0x2d, 0x82, 0x54, 0x3a, 0x84, + 0xc9, 0x65, 0x9c, 0xaf, 0x5f, 0xb8, 0x02, 0xba, 0x91, 0xa4, 0xad, 0x90, 0x98, 0x2b, 0x96, 0xe7, + 0x71, 0x91, 0xd8, 0xff, 0xcd, 0x74, 0xef, 0x20, 0xf4, 0x1a, 0x04, 0xf3, 0x95, 0xa4, 0x5a, 0x84, + 0x1b, 0xb5, 0x43, 0x38, 0x94, 0x79, 0x45, 0xb8, 0xd1, 0x8d, 0x64, 0x1d, 0x93, 0x61, 0x5c, 0xa5, + 0xdc, 0xd6, 0xc5, 0x00, 0x68, 0x10, 0x86, 0x2f, 0xab, 0x94, 0xb7, 0x08, 0x82, 0xef, 0x10, 0xc6, + 0x32, 0xda, 0x23, 0x37, 0x12, 0xa4, 0xe5, 0x13, 0x9d, 0x16, 0xb5, 0x3d, 0x14, 0x99, 0xa3, 0x06, + 0x41, 0x3f, 0x2d, 0xea, 0x16, 0xa1, 0x67, 0x3b, 0x04, 0x22, 0x13, 0xb4, 0xa8, 0xdd, 0xa8, 0xa7, + 0xac, 0x84, 0x18, 0xf2, 0x1f, 0xd9, 0xa3, 0x99, 0xee, 0x8d, 0x17, 0x0f, 0xfc, 0xdd, 0x45, 0xf8, + 0xa7, 0x42, 0x0d, 0x9f, 0x5d, 0x21, 0x0c, 0x1a, 0x04, 0x43, 0xe2, 0x16, 0x41, 0xe5, 0x3a, 0x84, + 0xff, 0xd5, 0x50, 0x81, 0xdd, 0xef, 0xbf, 0xc0, 0x94, 0x26, 0x1e, 0x29, 0x8f, 0xf5, 0x55, 0x23, + 0x93, 0xdb, 0x5d, 0x65, 0x94, 0xdb, 0x86, 0x28, 0x9b, 0xee, 0x97, 0x9d, 0xdc, 0xee, 0x33, 0x7c, + 0xab, 0x0a, 0x27, 0x27, 0x77, 0x72, 0x2d, 0xc2, 0xce, 0x9c, 0x0e, 0xe1, 0x9e, 0x2c, 0xbf, 0xcb, + 0xf6, 0x47, 0xd8, 0x89, 0x45, 0x3b, 0x21, 0xeb, 0x23, 0x31, 0xe4, 0xca, 0x6d, 0x73, 0xa6, 0x79, + 0xe3, 0xc5, 0xa3, 0xfd, 0x63, 0xa8, 0xfd, 0xbf, 0x13, 0xa6, 0xf0, 0x49, 0x7f, 0x6d, 0xf9, 0xdd, + 0x5f, 0x5b, 0x46, 0xff, 0x5e, 0x5b, 0x62, 0x37, 0x52, 0x42, 0xf8, 0xfa, 0xaa, 0x71, 0xb4, 0xeb, + 0xc6, 0xd1, 0x7e, 0x37, 0x8e, 0xf6, 0x6d, 0xeb, 0x0c, 0xae, 0xb7, 0xce, 0xe0, 0xe7, 0xd6, 0x19, + 0x7c, 0xf0, 0xd3, 0x6c, 0x73, 0xfe, 0xe9, 0xcc, 0x5f, 0xb1, 0x3c, 0x10, 0x8d, 0x4f, 0x0b, 0xba, + 0xf9, 0xcc, 0xaa, 0x0b, 0x85, 0xe2, 0x32, 0x0b, 0x52, 0xa6, 0xde, 0xe7, 0x72, 0x7e, 0x66, 0x88, + 0x17, 0x79, 0xfc, 0x27, 0x00, 0x00, 0xff, 0xff, 0x75, 0x73, 0xa0, 0x03, 0x3a, 0x03, 0x00, 0x00, +} + +func (m *Service) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Service) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.Dependencies) > 0 { + for iNdEx := len(m.Dependencies) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Dependencies[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Expose) > 0 { + for iNdEx := len(m.Expose) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Expose[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Env) > 0 { + for iNdEx := len(m.Env) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Env[iNdEx]) + copy(dAtA[i:], m.Env[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Env[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Args) > 0 { + for iNdEx := len(m.Args) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Args[iNdEx]) + copy(dAtA[i:], m.Args[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Args[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Command) > 0 { + for iNdEx := len(m.Command) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Command[iNdEx]) + copy(dAtA[i:], m.Command[iNdEx]) + i = encodeVarintService(dAtA, i, uint64(len(m.Command[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Image) > 0 { + i -= len(m.Image) + copy(dAtA[i:], m.Image) + i = encodeVarintService(dAtA, i, uint64(len(m.Image))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintService(dAtA []byte, offset int, v uint64) int { + offset -= sovService(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Service) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Image) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + if len(m.Command) > 0 { + for _, s := range m.Command { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Args) > 0 { + for _, s := range m.Args { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Env) > 0 { + for _, s := range m.Env { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Expose) > 0 { + for _, e := range m.Expose { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.Dependencies) > 0 { + for _, e := range m.Dependencies { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovService(uint64(l)) + } + return n +} + +func sovService(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozService(x uint64) (n int) { + return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Service) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Service: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Service: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Image = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Command", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Command = append(m.Command, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Args = append(m.Args, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Env", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Env = append(m.Env, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expose", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Expose = append(m.Expose, Expose{}) + if err := m.Expose[len(m.Expose)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dependencies", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Dependencies = append(m.Dependencies, Dependency{}) + if err := m.Dependencies[len(m.Dependencies)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &ServiceParams{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipService(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowService + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthService + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupService + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthService + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthService = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowService = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/service_params.pb.go b/go/sdl/v2_1/service_params.pb.go new file mode 100644 index 00000000..636f6630 --- /dev/null +++ b/go/sdl/v2_1/service_params.pb.go @@ -0,0 +1,668 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/service_params.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ServiceStorageParams struct { + Mount string `protobuf:"bytes,1,opt,name=mount,proto3" json:"mount" yaml:"mount"` + ReadOnly bool `protobuf:"varint,2,opt,name=read_only,json=readOnly,proto3" json:"readOnly" yaml:"readOnly"` +} + +func (m *ServiceStorageParams) Reset() { *m = ServiceStorageParams{} } +func (m *ServiceStorageParams) String() string { return proto.CompactTextString(m) } +func (*ServiceStorageParams) ProtoMessage() {} +func (*ServiceStorageParams) Descriptor() ([]byte, []int) { + return fileDescriptor_803e2d9515f372fa, []int{0} +} +func (m *ServiceStorageParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServiceStorageParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServiceStorageParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServiceStorageParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceStorageParams.Merge(m, src) +} +func (m *ServiceStorageParams) XXX_Size() int { + return m.Size() +} +func (m *ServiceStorageParams) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceStorageParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceStorageParams proto.InternalMessageInfo + +func (m *ServiceStorageParams) GetMount() string { + if m != nil { + return m.Mount + } + return "" +} + +func (m *ServiceStorageParams) GetReadOnly() bool { + if m != nil { + return m.ReadOnly + } + return false +} + +type ServiceParams struct { + Storage map[string]*ServiceStorageParams `protobuf:"bytes,1,rep,name=Storage,proto3" json:"storage" yaml:"storage" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *ServiceParams) Reset() { *m = ServiceParams{} } +func (m *ServiceParams) String() string { return proto.CompactTextString(m) } +func (*ServiceParams) ProtoMessage() {} +func (*ServiceParams) Descriptor() ([]byte, []int) { + return fileDescriptor_803e2d9515f372fa, []int{1} +} +func (m *ServiceParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServiceParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServiceParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServiceParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceParams.Merge(m, src) +} +func (m *ServiceParams) XXX_Size() int { + return m.Size() +} +func (m *ServiceParams) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceParams proto.InternalMessageInfo + +func (m *ServiceParams) GetStorage() map[string]*ServiceStorageParams { + if m != nil { + return m.Storage + } + return nil +} + +func init() { + proto.RegisterType((*ServiceStorageParams)(nil), "akash.sdl.v2_1.ServiceStorageParams") + proto.RegisterType((*ServiceParams)(nil), "akash.sdl.v2_1.ServiceParams") + proto.RegisterMapType((map[string]*ServiceStorageParams)(nil), "akash.sdl.v2_1.ServiceParams.StorageEntry") +} + +func init() { + proto.RegisterFile("akash/sdl/v2.1/service_params.proto", fileDescriptor_803e2d9515f372fa) +} + +var fileDescriptor_803e2d9515f372fa = []byte{ + // 372 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0x31, 0x6f, 0xe2, 0x30, + 0x14, 0xc6, 0x20, 0x0e, 0x30, 0x1c, 0x77, 0x8a, 0x18, 0x10, 0x43, 0x8c, 0x72, 0x37, 0x44, 0x77, + 0x3a, 0x47, 0xe4, 0x16, 0xc4, 0x18, 0xa9, 0x12, 0x4b, 0xd5, 0x2a, 0x6c, 0x5d, 0x52, 0x43, 0xac, + 0x80, 0x48, 0x62, 0xe4, 0x84, 0x54, 0xf9, 0x17, 0x9d, 0xfb, 0x8b, 0x3a, 0x32, 0x76, 0xb2, 0xda, + 0xb0, 0x31, 0xf2, 0x0b, 0x2a, 0x62, 0x53, 0x95, 0xa1, 0xdb, 0xf7, 0xbe, 0xf7, 0xbd, 0x4f, 0xdf, + 0x7b, 0x36, 0xfc, 0x45, 0xd6, 0x24, 0x59, 0x5a, 0x89, 0x1f, 0x5a, 0x99, 0x8d, 0x47, 0x56, 0x42, + 0x79, 0xb6, 0x5a, 0x50, 0x6f, 0x43, 0x38, 0x89, 0x12, 0xbc, 0xe1, 0x2c, 0x65, 0x5a, 0xb7, 0x14, + 0xe1, 0xc4, 0x0f, 0x71, 0x66, 0x7b, 0xa3, 0x41, 0x2f, 0x60, 0x01, 0x2b, 0x5b, 0xd6, 0x09, 0x49, + 0x95, 0xf1, 0x04, 0x60, 0x6f, 0x26, 0xc7, 0x67, 0x29, 0xe3, 0x24, 0xa0, 0xb7, 0xa5, 0x89, 0x36, + 0x86, 0xf5, 0x88, 0x6d, 0xe3, 0xb4, 0x0f, 0x86, 0xc0, 0x6c, 0x39, 0x46, 0x21, 0x50, 0xfd, 0xfa, + 0x44, 0x1c, 0x04, 0x92, 0x9d, 0xa3, 0x40, 0x9d, 0x9c, 0x44, 0xe1, 0xc4, 0x28, 0x4b, 0xc3, 0x95, + 0xb4, 0x36, 0x85, 0x2d, 0x4e, 0x89, 0xef, 0xb1, 0x38, 0xcc, 0xfb, 0xd5, 0x21, 0x30, 0x9b, 0xce, + 0xdf, 0x42, 0xa0, 0xa6, 0x4b, 0x89, 0x7f, 0x13, 0x87, 0xf9, 0x41, 0xa0, 0x26, 0x57, 0xf8, 0x28, + 0xd0, 0x0f, 0xe9, 0x71, 0x66, 0x0c, 0xf7, 0xa3, 0x69, 0xbc, 0x01, 0xf8, 0x5d, 0x85, 0x53, 0xa9, + 0x62, 0xd8, 0x50, 0x31, 0xfb, 0x60, 0x58, 0x33, 0xdb, 0xf6, 0x1f, 0x7c, 0xb9, 0x26, 0xbe, 0xd0, + 0x63, 0x25, 0xbe, 0x8a, 0x53, 0x9e, 0x3b, 0x66, 0x21, 0xd0, 0x79, 0xfc, 0x20, 0x50, 0x23, 0x91, + 0xf0, 0x28, 0x50, 0x57, 0x66, 0x50, 0x84, 0xe1, 0x9e, 0x55, 0x83, 0x7b, 0xd8, 0xf9, 0x6c, 0xa1, + 0xfd, 0x84, 0xb5, 0x35, 0xcd, 0xe5, 0x4d, 0xdc, 0x13, 0xd4, 0x26, 0xb0, 0x9e, 0x91, 0x70, 0x4b, + 0xcb, 0x4d, 0xdb, 0xf6, 0xef, 0x2f, 0xf2, 0x5c, 0x1c, 0xd7, 0x95, 0x23, 0x93, 0xea, 0x18, 0x38, + 0xd3, 0xe7, 0x42, 0x07, 0xbb, 0x42, 0x07, 0xaf, 0x85, 0x0e, 0x1e, 0xf7, 0x7a, 0x65, 0xb7, 0xd7, + 0x2b, 0x2f, 0x7b, 0xbd, 0x72, 0x87, 0x83, 0x55, 0xba, 0xdc, 0xce, 0xf1, 0x82, 0x45, 0x56, 0x69, + 0xfa, 0x2f, 0xa6, 0xe9, 0x03, 0xe3, 0x6b, 0x55, 0x91, 0xcd, 0xca, 0x0a, 0x98, 0xfa, 0x05, 0xde, + 0x68, 0xfe, 0xad, 0x7c, 0xd1, 0xff, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x45, 0xf7, 0x48, + 0x1e, 0x02, 0x00, 0x00, +} + +func (m *ServiceStorageParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServiceStorageParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServiceStorageParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReadOnly { + i-- + if m.ReadOnly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Mount) > 0 { + i -= len(m.Mount) + copy(dAtA[i:], m.Mount) + i = encodeVarintServiceParams(dAtA, i, uint64(len(m.Mount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ServiceParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServiceParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServiceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Storage) > 0 { + for k := range m.Storage { + v := m.Storage[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintServiceParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintServiceParams(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintServiceParams(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintServiceParams(dAtA []byte, offset int, v uint64) int { + offset -= sovServiceParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ServiceStorageParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Mount) + if l > 0 { + n += 1 + l + sovServiceParams(uint64(l)) + } + if m.ReadOnly { + n += 2 + } + return n +} + +func (m *ServiceParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Storage) > 0 { + for k, v := range m.Storage { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovServiceParams(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovServiceParams(uint64(len(k))) + l + n += mapEntrySize + 1 + sovServiceParams(uint64(mapEntrySize)) + } + } + return n +} + +func sovServiceParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozServiceParams(x uint64) (n int) { + return sovServiceParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ServiceStorageParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServiceStorageParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServiceStorageParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Mount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthServiceParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Mount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadOnly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadOnly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ServiceParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServiceParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServiceParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Storage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthServiceParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Storage == nil { + m.Storage = make(map[string]*ServiceStorageParams) + } + var mapkey string + var mapvalue *ServiceStorageParams + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthServiceParams + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthServiceParams + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServiceParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthServiceParams + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthServiceParams + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ServiceStorageParams{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Storage[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipServiceParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServiceParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipServiceParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServiceParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthServiceParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupServiceParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthServiceParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthServiceParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowServiceParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupServiceParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/service_placement.pb.go b/go/sdl/v2_1/service_placement.pb.go new file mode 100644 index 00000000..8285c5db --- /dev/null +++ b/go/sdl/v2_1/service_placement.pb.go @@ -0,0 +1,386 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/service_placement.proto + +package v2_1 + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ServicePlacement struct { + Profile string `protobuf:"bytes,1,opt,name=profile,proto3" json:"profile" yaml:"profile"` + Count uint32 `protobuf:"varint,2,opt,name=count,proto3" json:"count" yaml:"count"` +} + +func (m *ServicePlacement) Reset() { *m = ServicePlacement{} } +func (m *ServicePlacement) String() string { return proto.CompactTextString(m) } +func (*ServicePlacement) ProtoMessage() {} +func (*ServicePlacement) Descriptor() ([]byte, []int) { + return fileDescriptor_68365a288c55f884, []int{0} +} +func (m *ServicePlacement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ServicePlacement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ServicePlacement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ServicePlacement) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServicePlacement.Merge(m, src) +} +func (m *ServicePlacement) XXX_Size() int { + return m.Size() +} +func (m *ServicePlacement) XXX_DiscardUnknown() { + xxx_messageInfo_ServicePlacement.DiscardUnknown(m) +} + +var xxx_messageInfo_ServicePlacement proto.InternalMessageInfo + +func (m *ServicePlacement) GetProfile() string { + if m != nil { + return m.Profile + } + return "" +} + +func (m *ServicePlacement) GetCount() uint32 { + if m != nil { + return m.Count + } + return 0 +} + +func init() { + proto.RegisterType((*ServicePlacement)(nil), "akash.sdl.v2_1.ServicePlacement") +} + +func init() { + proto.RegisterFile("akash/sdl/v2.1/service_placement.proto", fileDescriptor_68365a288c55f884) +} + +var fileDescriptor_68365a288c55f884 = []byte{ + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xcc, 0x4e, 0x2c, + 0xce, 0xd0, 0x2f, 0x4e, 0xc9, 0xd1, 0x2f, 0x33, 0xd2, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, + 0x4c, 0x4e, 0x8d, 0x2f, 0xc8, 0x49, 0x4c, 0x4e, 0xcd, 0x4d, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xab, 0xd3, 0x2b, 0x4e, 0xc9, 0xd1, 0x2b, 0x33, 0x8a, 0x37, 0x94, + 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xe9, 0x83, 0x58, 0x10, 0x55, 0x4a, 0xd3, 0x18, 0xb9, + 0x04, 0x82, 0x21, 0x26, 0x04, 0xc0, 0x0c, 0x10, 0x72, 0xe2, 0x62, 0x2f, 0x28, 0xca, 0x4f, 0xcb, + 0xcc, 0x49, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0xd2, 0x78, 0x74, 0x4f, 0x9e, 0x3d, 0x00, + 0x22, 0xf4, 0xea, 0x9e, 0x3c, 0x4c, 0xf6, 0xd3, 0x3d, 0x79, 0xbe, 0xca, 0xc4, 0xdc, 0x1c, 0x2b, + 0x25, 0xa8, 0x80, 0x52, 0x10, 0x4c, 0x4a, 0xc8, 0x82, 0x8b, 0x35, 0x39, 0xbf, 0x34, 0xaf, 0x44, + 0x82, 0x49, 0x81, 0x51, 0x83, 0xd7, 0x49, 0xe9, 0xd1, 0x3d, 0x79, 0x56, 0x67, 0x90, 0xc0, 0xab, + 0x7b, 0xf2, 0x10, 0x99, 0x4f, 0xf7, 0xe4, 0x79, 0x20, 0xba, 0xc1, 0x5c, 0xa5, 0x20, 0x88, 0xb0, + 0x15, 0xcb, 0x8b, 0x05, 0xf2, 0x8c, 0x4e, 0x1e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, + 0xc7, 0x10, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xf6, + 0xa3, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0x36, 0x94, 0x97, 0x58, 0x90, 0xa9, 0x9f, 0x9e, + 0x0f, 0x0d, 0xa0, 0x78, 0xc3, 0x24, 0x36, 0xb0, 0x4f, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x8f, 0x22, 0x1a, 0xc1, 0x39, 0x01, 0x00, 0x00, +} + +func (this *ServicePlacement) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ServicePlacement) + if !ok { + that2, ok := that.(ServicePlacement) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Profile != that1.Profile { + return false + } + if this.Count != that1.Count { + return false + } + return true +} +func (m *ServicePlacement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ServicePlacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ServicePlacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Count != 0 { + i = encodeVarintServicePlacement(dAtA, i, uint64(m.Count)) + i-- + dAtA[i] = 0x10 + } + if len(m.Profile) > 0 { + i -= len(m.Profile) + copy(dAtA[i:], m.Profile) + i = encodeVarintServicePlacement(dAtA, i, uint64(len(m.Profile))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintServicePlacement(dAtA []byte, offset int, v uint64) int { + offset -= sovServicePlacement(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ServicePlacement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Profile) + if l > 0 { + n += 1 + l + sovServicePlacement(uint64(l)) + } + if m.Count != 0 { + n += 1 + sovServicePlacement(uint64(m.Count)) + } + return n +} + +func sovServicePlacement(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozServicePlacement(x uint64) (n int) { + return sovServicePlacement(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ServicePlacement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ServicePlacement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ServicePlacement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Profile", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthServicePlacement + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthServicePlacement + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Profile = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipServicePlacement(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthServicePlacement + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipServicePlacement(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowServicePlacement + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthServicePlacement + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupServicePlacement + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthServicePlacement + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthServicePlacement = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowServicePlacement = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupServicePlacement = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/storage.go b/go/sdl/v2_1/storage.go new file mode 100644 index 00000000..6b6014cb --- /dev/null +++ b/go/sdl/v2_1/storage.go @@ -0,0 +1,234 @@ +package v2_1 + +import ( + "errors" + "fmt" + "sort" + + "gopkg.in/yaml.v3" + + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +const ( + StorageEphemeral = "ephemeral" + StorageAttributePersistent = "persistent" + StorageAttributeClass = "class" + StorageAttributeMount = "mount" + StorageAttributeReadOnly = "readOnly" // we might not need it at this point of time + StorageClassDefault = "default" +) + +var ( + errUnsupportedStorageAttribute = errors.New("sdl: unsupported storage attribute") + errStorageDupMountPoint = errors.New("sdl: duplicated mount point") + errStorageMultipleRootEphemeral = errors.New("sdl: multiple root ephemeral storages are not allowed") + errStorageDuplicatedVolumeName = errors.New("sdl: duplicated volume name") + errStorageEphemeralClass = errors.New("sdl: ephemeral storage should not set attribute class") +) + +type storageAttributes types.Attributes + +type StorageArray []ResourceStorage + +var _ sort.Interface = (*StorageArray)(nil) + +func (sdl StorageArray) Len() int { + return len(sdl) +} + +func (sdl StorageArray) Swap(i, j int) { + sdl[i], sdl[j] = sdl[j], sdl[i] +} + +// Less storage slice in the following order +// 1. smaller size +// 2. if sizes are equal then one without class goes up +// 3. when both class present use lexicographic order +// 4. if no class in both cases check persistent attribute. one persistent = false goes up +// 5. volume name +func (sdl StorageArray) Less(i, j int) bool { + if sdl[i].Quantity < sdl[j].Quantity { + return true + } + + if sdl[i].Quantity > sdl[j].Quantity { + return false + } + + iAttr := types.Attributes(sdl[i].Attributes) + jAttr := types.Attributes(sdl[j].Attributes) + + iClass, iExists := iAttr.Find(StorageAttributePersistent).AsString() + jClass, jExists := jAttr.Find(StorageAttributePersistent).AsString() + + if (!iExists && jExists) || + (jExists && iExists && iClass < jClass) { + return true + } else if iExists && !jExists { + return false + } + + iPersistent, _ := iAttr.Find(StorageAttributePersistent).AsBool() + jPersistent, _ := jAttr.Find(StorageAttributePersistent).AsBool() + + if !iPersistent { + return true + } else if !jPersistent { + return false + } + + return sdl[i].Name < sdl[j].Name +} + +type validateAttrFn func(string, *string) error + +var allowedStorageClasses = map[string]bool{ + "default": true, + "beta1": true, + "beta2": true, + "beta3": true, +} + +var validateStorageAttributes = map[string]validateAttrFn{ + StorageAttributePersistent: validateAttributeBool, + StorageAttributeClass: validateAttributeStorageClass, +} + +func validateAttributeBool(key string, val *string) error { + if res, valid := unifyStringAsBool(*val); valid { + *val = res + + return nil + } + + return fmt.Errorf("sdl: invalid value for attribute \"%s\". expected bool", key) +} + +func validateAttributeStorageClass(_ string, val *string) error { + if _, valid := allowedStorageClasses[*val]; valid { + return nil + } + + return fmt.Errorf("sdl: invalid value for attribute class") +} + +// UnmarshalYAML unmarshal storage config +// data can be present either as single entry mapping or an array of them +// nolint: gofmt +// e.g +// single entity +// ```yaml +// storage: +// +// size: 1Gi +// attributes: +// class: ssd +// +// ``` +// +// ```yaml +// storage: +// - size: 512Mi # ephemeral storage +// - size: 1Gi +// name: cache +// attributes: +// class: ssd +// - size: 100Gi +// name: data +// attributes: +// persistent: true # this volumes survives pod restart +// class: gp # aka general purpose +// +// ``` +func (sdl *StorageArray) UnmarshalYAML(node *yaml.Node) error { + var nodes StorageArray + + switch node.Kind { + case yaml.SequenceNode: + for _, content := range node.Content { + var nd ResourceStorage + if err := content.Decode(&nd); err != nil { + return err + } + + // set default name to ephemeral. later in validation error thrown if multiple + if nd.Name == "" { + nd.Name = "default" + } + nodes = append(nodes, nd) + } + case yaml.MappingNode: + var nd ResourceStorage + if err := node.Decode(&nd); err != nil { + return err + } + + nd.Name = "default" + nodes = append(nodes, nd) + } + + // check for duplicated volume names + names := make(map[string]string) + for _, nd := range nodes { + if _, exists := names[nd.Name]; exists { + return errStorageDuplicatedVolumeName + } + + names[nd.Name] = nd.Name + } + + sort.Stable(nodes) + + *sdl = nodes + + return nil +} + +func (sdl *storageAttributes) UnmarshalYAML(node *yaml.Node) error { + var attr storageAttributes + + var res map[string]string + + if err := node.Decode(&res); err != nil { + return err + } + + // set default + if _, set := res[StorageAttributePersistent]; !set { + res[StorageAttributePersistent] = valueFalse + } + + persistent := res[StorageAttributePersistent] + class := res[StorageAttributeClass] + if persistent == valueFalse && class != "" { + return errStorageEphemeralClass + } + if persistent == valueTrue && class == "" { + res[StorageAttributeClass] = StorageClassDefault + } + + for k, v := range res { + validateFn, supportedAttr := validateStorageAttributes[k] + if !supportedAttr { + return fmt.Errorf("%w: %s", errUnsupportedStorageAttribute, k) + } + + val := v + if err := validateFn(k, &val); err != nil { + return err + } + + attr = append(attr, types.Attribute{ + Key: k, + Value: val, + }) + } + + // at this point keys are unique in attributes parsed from sdl so don't need to use sort.SliceStable + sort.Sort(types.Attributes(attr)) + + *sdl = attr + + return nil +} diff --git a/go/sdl/v2_1/storage.pb.go b/go/sdl/v2_1/storage.pb.go new file mode 100644 index 00000000..4b8cde16 --- /dev/null +++ b/go/sdl/v2_1/storage.pb.go @@ -0,0 +1,425 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: akash/sdl/v2.1/storage.proto + +package v2_1 + +import ( + fmt "fmt" + v1beta3 "github.com/akash-network/akash-api/go/node/types/v1beta3" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ResourceStorage struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name" yaml:"name"` + Quantity byteQuantity `protobuf:"varint,2,opt,name=quantity,proto3,casttype=byteQuantity" json:"size" yaml:"size"` + Attributes storageAttributes `protobuf:"bytes,3,rep,name=attributes,proto3,castrepeated=storageAttributes" json:"attributes" yaml:"attributes"` +} + +func (m *ResourceStorage) Reset() { *m = ResourceStorage{} } +func (m *ResourceStorage) String() string { return proto.CompactTextString(m) } +func (*ResourceStorage) ProtoMessage() {} +func (*ResourceStorage) Descriptor() ([]byte, []int) { + return fileDescriptor_5f6c8670dcff3358, []int{0} +} +func (m *ResourceStorage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ResourceStorage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ResourceStorage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ResourceStorage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ResourceStorage.Merge(m, src) +} +func (m *ResourceStorage) XXX_Size() int { + return m.Size() +} +func (m *ResourceStorage) XXX_DiscardUnknown() { + xxx_messageInfo_ResourceStorage.DiscardUnknown(m) +} + +var xxx_messageInfo_ResourceStorage proto.InternalMessageInfo + +func (m *ResourceStorage) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ResourceStorage) GetQuantity() byteQuantity { + if m != nil { + return m.Quantity + } + return 0 +} + +func (m *ResourceStorage) GetAttributes() storageAttributes { + if m != nil { + return m.Attributes + } + return nil +} + +func init() { + proto.RegisterType((*ResourceStorage)(nil), "akash.sdl.v2_1.ResourceStorage") +} + +func init() { proto.RegisterFile("akash/sdl/v2.1/storage.proto", fileDescriptor_5f6c8670dcff3358) } + +var fileDescriptor_5f6c8670dcff3358 = []byte{ + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x51, 0xbd, 0x6e, 0xf2, 0x30, + 0x14, 0x8d, 0x01, 0x7d, 0xe2, 0x33, 0xfd, 0x11, 0x51, 0x07, 0x84, 0xda, 0x18, 0x65, 0x62, 0xa9, + 0xad, 0x90, 0xad, 0x5b, 0x33, 0x55, 0x1d, 0x5a, 0x35, 0xdd, 0xba, 0x20, 0x07, 0xac, 0x10, 0x41, + 0x30, 0x8d, 0x1d, 0x2a, 0xfa, 0x06, 0xdd, 0xfa, 0x0e, 0xdd, 0xfa, 0x24, 0x8c, 0x8c, 0x9d, 0xdc, + 0x2a, 0x6c, 0x8c, 0x8c, 0x9d, 0xaa, 0xfc, 0x00, 0xd9, 0x7c, 0xcf, 0x3d, 0xe7, 0xdc, 0x7b, 0xae, + 0xe1, 0x39, 0x1d, 0x53, 0x31, 0x22, 0x62, 0x38, 0x21, 0xf3, 0x1e, 0xb6, 0x88, 0x90, 0x3c, 0xa2, + 0x3e, 0xc3, 0xb3, 0x88, 0x4b, 0xae, 0x9f, 0x64, 0x5d, 0x2c, 0x86, 0x13, 0x3c, 0xef, 0xf5, 0xad, + 0xf6, 0x99, 0xcf, 0x7d, 0x9e, 0xb5, 0x48, 0xfa, 0xca, 0x59, 0x6d, 0x33, 0xf7, 0xf0, 0xa8, 0x60, + 0x64, 0x6e, 0x79, 0x4c, 0x52, 0x9b, 0x50, 0x29, 0xa3, 0xc0, 0x8b, 0x65, 0xe1, 0x64, 0x7e, 0x54, + 0xe0, 0xa9, 0xcb, 0x04, 0x8f, 0xa3, 0x01, 0x7b, 0xcc, 0x67, 0xe8, 0x36, 0xac, 0x4d, 0x69, 0xc8, + 0x5a, 0xa0, 0x03, 0xba, 0xff, 0x1d, 0x94, 0x28, 0x54, 0xbb, 0xa3, 0x21, 0xdb, 0x28, 0x94, 0xe1, + 0x5b, 0x85, 0x1a, 0x0b, 0x1a, 0x4e, 0xae, 0xcc, 0xb4, 0x32, 0xdd, 0x0c, 0xd4, 0xef, 0x61, 0xfd, + 0x39, 0xa6, 0x53, 0x19, 0xc8, 0x45, 0xab, 0xd2, 0x01, 0xdd, 0x63, 0xc7, 0x4e, 0x14, 0xaa, 0x3f, + 0x14, 0x58, 0x2a, 0x16, 0xc1, 0x6b, 0x49, 0x9c, 0x56, 0xe6, 0xaf, 0x42, 0x47, 0xde, 0x42, 0xb2, + 0x1d, 0xcd, 0xdd, 0x9b, 0xe8, 0x6f, 0x00, 0xc2, 0xfd, 0xb6, 0xa2, 0x55, 0xed, 0x54, 0xbb, 0x8d, + 0xde, 0x05, 0xce, 0x93, 0xa7, 0x99, 0x70, 0x91, 0x09, 0x5f, 0xef, 0x58, 0xce, 0xed, 0x52, 0x21, + 0x2d, 0x51, 0x08, 0xee, 0x21, 0xb1, 0x51, 0xa8, 0x64, 0xb3, 0x55, 0xa8, 0x99, 0x8f, 0x3f, 0x60, + 0xe6, 0xe7, 0x37, 0x6a, 0x16, 0xf7, 0x3d, 0xe8, 0xdc, 0x92, 0xca, 0xb9, 0x59, 0x26, 0x06, 0x58, + 0x25, 0x06, 0xf8, 0x49, 0x0c, 0xf0, 0xbe, 0x36, 0xb4, 0xd5, 0xda, 0xd0, 0xbe, 0xd6, 0x86, 0xf6, + 0x84, 0xfd, 0x40, 0x8e, 0x62, 0x0f, 0x0f, 0x78, 0x48, 0xb2, 0xd5, 0x2e, 0xa7, 0x4c, 0xbe, 0xf0, + 0x68, 0x5c, 0x54, 0x74, 0x16, 0x10, 0x9f, 0x17, 0xff, 0xd8, 0xb7, 0xbc, 0x7f, 0xd9, 0xd9, 0xed, + 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x87, 0xb6, 0xfa, 0xe0, 0x01, 0x00, 0x00, +} + +func (m *ResourceStorage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceStorage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ResourceStorage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStorage(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Quantity != 0 { + i = encodeVarintStorage(dAtA, i, uint64(m.Quantity)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintStorage(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintStorage(dAtA []byte, offset int, v uint64) int { + offset -= sovStorage(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ResourceStorage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovStorage(uint64(l)) + } + if m.Quantity != 0 { + n += 1 + sovStorage(uint64(m.Quantity)) + } + if len(m.Attributes) > 0 { + for _, e := range m.Attributes { + l = e.Size() + n += 1 + l + sovStorage(uint64(l)) + } + } + return n +} + +func sovStorage(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStorage(x uint64) (n int) { + return sovStorage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ResourceStorage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceStorage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceStorage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantity", wireType) + } + m.Quantity = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Quantity |= byteQuantity(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStorage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStorage + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStorage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes, v1beta3.Attribute{}) + if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStorage(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStorage + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStorage(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStorage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthStorage + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStorage + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStorage + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStorage = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStorage = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStorage = fmt.Errorf("proto: unexpected end of group") +) diff --git a/go/sdl/v2_1/units.go b/go/sdl/v2_1/units.go new file mode 100644 index 00000000..4f6ece93 --- /dev/null +++ b/go/sdl/v2_1/units.go @@ -0,0 +1,154 @@ +package v2_1 + +import ( + "fmt" + "strconv" + "strings" + + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +var ( + errNegativeValue = fmt.Errorf("invalid: negative value not allowed") +) + +var unitSuffixes = map[string]uint64{ + "k": unit.K, + "Ki": unit.Ki, + "M": unit.M, + "Mi": unit.Mi, + "G": unit.G, + "Gi": unit.Gi, + "T": unit.T, + "Ti": unit.Ti, + "P": unit.P, + "Pi": unit.Pi, + "E": unit.E, + "Ei": unit.Ei, +} + +var memorySuffixes = map[string]uint64{ + "Ki": unit.Ki, + "Mi": unit.Mi, + "Gi": unit.Gi, + "Ti": unit.Ti, + "Pi": unit.Pi, + "Ei": unit.Ei, +} + +// CPU shares. One CPUQuantity = 1/1000 of a CPU +type cpuQuantity uint32 + +type gpuQuantity uint64 + +func (u *cpuQuantity) UnmarshalYAML(node *yaml.Node) error { + sval := node.Value + if strings.HasSuffix(sval, "m") { + sval = strings.TrimSuffix(sval, "m") + val, err := strconv.ParseUint(sval, 10, 32) + if err != nil { + return err + } + *u = cpuQuantity(val) + return nil + } + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return err + } + + val *= 1000 + + if val < 0 { + return errNegativeValue + } + + *u = cpuQuantity(val) + + return nil +} + +func (u *gpuQuantity) UnmarshalYAML(node *yaml.Node) error { + sval := node.Value + + val, err := strconv.ParseUint(sval, 10, 64) + if err != nil { + return err + } + + *u = gpuQuantity(val) + + return nil +} + +// Memory,Storage size in bytes. +type byteQuantity uint64 +type memoryQuantity uint64 + +func (u *byteQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := parseWithSuffix(node.Value, unitSuffixes) + if err != nil { + return err + } + *u = byteQuantity(val) + return nil +} + +func (u *memoryQuantity) UnmarshalYAML(node *yaml.Node) error { + val, err := parseWithSuffix(node.Value, memorySuffixes) + if err != nil { + return err + } + *u = memoryQuantity(val) + return nil +} + +func (u *memoryQuantity) StringWithSuffix(suffix string) string { + unit, exists := memorySuffixes[suffix] + + val := uint64(*u) / unit + + res := fmt.Sprintf("%d", val) + if exists { + res += suffix + } + + return res +} + +func parseWithSuffix(sval string, units map[string]uint64) (uint64, error) { + for suffix, unit := range units { + if !strings.HasSuffix(sval, suffix) { + continue + } + + sval := strings.TrimSuffix(sval, suffix) + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return 0, err + } + + val *= float64(unit) + + if val < 0 { + return 0, errNegativeValue + } + + return uint64(val), nil + } + + val, err := strconv.ParseFloat(sval, 64) + if err != nil { + return 0, err + } + + if val < 0 { + return 0, errNegativeValue + } + + return uint64(val), nil +} diff --git a/go/sdl/v2_1/units_test.go b/go/sdl/v2_1/units_test.go new file mode 100644 index 00000000..e701a2a2 --- /dev/null +++ b/go/sdl/v2_1/units_test.go @@ -0,0 +1,99 @@ +package v2_1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v3" + + "github.com/akash-network/akash-api/go/node/types/unit" +) + +func TestCPUQuantity(t *testing.T) { + + type vtype struct { + Val cpuQuantity `yaml:"val"` + } + + tests := []struct { + text string + value uint32 + err bool + }{ + {`val: 1`, 1000, false}, + {`val: -1`, 1000, true}, + + {`val: 0.5`, 500, false}, + {`val: -0.5`, 500, true}, + + {`val: "100m"`, 100, false}, + {`val: "-100m"`, 100, true}, + + {`val: ""`, 0, true}, + } + + for idx, test := range tests { + buf := []byte(test.text) + obj := &vtype{} + + err := yaml.Unmarshal(buf, obj) + + if test.err { + assert.Error(t, err, "idx:%v text:`%v`", idx, test.text) + continue + } + + if !assert.NoError(t, err, "idx:%v text:`%v`", idx, test.text) { + continue + } + + assert.Equal(t, cpuQuantity(test.value), obj.Val, "idx:%v text:`%v`", idx, test.text) + } +} + +func TestByteQuantity(t *testing.T) { + type vtype struct { + Val byteQuantity `yaml:"val"` + } + + tests := []struct { + text string + value uint64 + err bool + }{ + {`val: 1`, 1, false}, + {`val: -1`, 1, true}, + + {`val: "1M"`, unit.M, false}, + {`val: "-1M"`, 0, true}, + + {`val: "0.5M"`, unit.M / 2, false}, + {`val: "-0.5M"`, 0, true}, + + {`val: "3M"`, 3 * unit.M, false}, + {`val: "3G"`, 3 * unit.G, false}, + {`val: "3T"`, 3 * unit.T, false}, + {`val: "3P"`, 3 * unit.P, false}, + {`val: "3E"`, 3 * unit.E, false}, + + {`val: ""`, 0, true}, + } + + for idx, test := range tests { + buf := []byte(test.text) + obj := &vtype{} + + err := yaml.Unmarshal(buf, obj) + + if test.err { + assert.Error(t, err, "idx:%v text:`%v`", idx, test.text) + continue + } + + if !assert.NoError(t, err, "idx:%v text:`%v`", idx, test.text) { + continue + } + + assert.Equal(t, byteQuantity(test.value), obj.Val, "idx:%v text:`%v`", idx, test.text) + } +} diff --git a/go/sdl/v2_1/utils.go b/go/sdl/v2_1/utils.go new file mode 100644 index 00000000..40b6ce4a --- /dev/null +++ b/go/sdl/v2_1/utils.go @@ -0,0 +1,21 @@ +package v2_1 + +const ( + valueFalse = "false" + valueTrue = "true" + valueOn = "on" + valueOff = "off" + valueYes = "yes" + valueNo = "no" +) + +// as per yaml following allowed as bool values +func unifyStringAsBool(val string) (string, bool) { + if val == valueTrue || val == valueOn || val == valueYes { + return valueTrue, true + } else if val == valueFalse || val == valueOff || val == valueNo { + return valueFalse, true + } + + return "", false +} diff --git a/go/sdl/v2_1_ip_test.go b/go/sdl/v2_1_ip_test.go new file mode 100644 index 00000000..ee104a1c --- /dev/null +++ b/go/sdl/v2_1_ip_test.go @@ -0,0 +1,279 @@ +package sdl + +import ( + "bytes" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func TestV2_1_ParseSimpleWithIP(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/simple-with-ip.yaml") + require.NoError(t, err) + require.NotNil(t, sdl) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + group := groups[0] + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + resource := resources[0] + + ipEndpoint := findIPEndpoint(t, resource.Resources.Endpoints, 1) + + require.Equal(t, ipEndpoint.Kind, types.Endpoint_LEASED_IP) + + mani, err := sdl.Manifest() + require.NoError(t, err) + var exposeIP manifest.ServiceExpose + for _, expose := range mani[0].Services[0].Expose { + if len(expose.IP) != 0 { + exposeIP = expose + break + } + } + require.NotEmpty(t, exposeIP.IP) + require.Equal(t, exposeIP.Proto, manifest.UDP) + require.Equal(t, exposeIP.Port, uint32(12345)) + require.True(t, exposeIP.Global) +} + +func TestV2_1_Parse_IP(t *testing.T) { + sdl1, err := ReadFile("../../testdata/v2.1/ip-endpoint.yaml") + require.NoError(t, err) + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + + require.Len(t, groups, 1) + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + resource := resources[0] + endpoints := resource.Resources.Endpoints + require.Len(t, endpoints, 2) + + var ipEndpoint types.Endpoint + for _, endpoint := range endpoints { + if endpoint.Kind == types.Endpoint_LEASED_IP { + ipEndpoint = endpoint + } + } + + require.Equal(t, ipEndpoint.Kind, types.Endpoint_LEASED_IP) + require.Greater(t, ipEndpoint.SequenceNumber, uint32(0)) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 1) + maniGroup := maniGroups[0] + services := maniGroup.Services + require.Len(t, services, 1) + + service := services[0] + exposes := service.Expose + require.Len(t, exposes, 1) + + expose := exposes[0] + + require.True(t, expose.Global) + require.Equal(t, expose.IP, "meow") + require.Greater(t, expose.EndpointSequenceNumber, uint32(0)) +} + +func TestV2_1_Parse_SharedIP(t *testing.T) { + // Read a file with 1 group having 1 endpoint shared amongst containers + sdl1, err := ReadFile("../../testdata/v2.1/shared-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + + resource := resources[0] + ipEndpoint1 := findIPEndpoint(t, resource.Resources.Endpoints, 1) + require.Greater(t, ipEndpoint1.SequenceNumber, uint32(0)) + + ipEndpoint2 := findIPEndpoint(t, resource.Resources.Endpoints, 2) + require.Greater(t, ipEndpoint2.SequenceNumber, uint32(0)) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 1) + maniGroup := maniGroups[0] + + services := maniGroup.Services + require.Len(t, services, 2) + serviceA := services[0] + + serviceIPEndpoint := findIPEndpoint(t, serviceA.Resources.Endpoints, 1) + require.Equal(t, serviceIPEndpoint.SequenceNumber, ipEndpoint1.SequenceNumber) + + serviceB := services[1] + serviceIPEndpoint = findIPEndpoint(t, serviceB.Resources.Endpoints, 1) + require.Equal(t, serviceIPEndpoint.SequenceNumber, ipEndpoint2.SequenceNumber) +} + +func TestV2_1_Parse_MultipleIP(t *testing.T) { + // Read a file with 1 group having two endpoints + sdl1, err := ReadFile("../../testdata/v2.1/multi-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + _ = mani +} + +func TestV2_1_Parse_MultipleGroupsIP(t *testing.T) { + // Read a file with two groups, each one having an IP endpoint that is distinct + sdl1, err := ReadFile("../../testdata/v2.1/multi-groups-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 2) + + resources := groups[0].GetResourceUnits() + require.Len(t, resources, 1) + + resource := resources[0] + require.Len(t, resource.Resources.Endpoints, 2) + ipEndpointFirstGroup := findIPEndpoint(t, resource.Resources.Endpoints, 1) + require.Greater(t, ipEndpointFirstGroup.SequenceNumber, uint32(0)) + + resources = groups[1].GetResourceUnits() + require.Len(t, resources, 1) + + resource = resources[0] + require.Len(t, resource.Resources.Endpoints, 2) + ipEndpointSecondGroup := findIPEndpoint(t, resource.Resources.Endpoints, 1) + require.Greater(t, ipEndpointSecondGroup.SequenceNumber, uint32(0)) + require.NotEqual(t, ipEndpointFirstGroup.SequenceNumber, ipEndpointSecondGroup.SequenceNumber) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 2) + + maniGroup := maniGroups[0] + mresources := maniGroup.GetResourceUnits() + require.Len(t, mresources, 1) + mresource := mresources[0] + require.Equal(t, findIPEndpoint(t, mresource.Endpoints, 1).SequenceNumber, ipEndpointFirstGroup.SequenceNumber) + + maniGroup = maniGroups[1] + mresources = maniGroup.GetResourceUnits() + require.Len(t, mresources, 1) + mresource = mresources[0] + require.Equal(t, findIPEndpoint(t, mresource.Endpoints, 1).SequenceNumber, ipEndpointSecondGroup.SequenceNumber) + +} + +func TestV2_1_Parse_IPEndpointNaming(t *testing.T) { + makeSDLWithEndpointName := func(name string) []byte { + const originalSDL = `--- +version: "2.1" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: %q + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + +endpoints: + %q: + kind: ip +` + buf := &bytes.Buffer{} + _, err := fmt.Fprintf(buf, originalSDL, name, name) + require.NoError(t, err) + return buf.Bytes() + } + + _, err := Read(makeSDLWithEndpointName("meow72-memes")) + require.NoError(t, err) + + _, err = Read(makeSDLWithEndpointName("meow72-mem_es")) + require.NoError(t, err) + + _, err = Read(makeSDLWithEndpointName("!important")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("foo^bar")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("ROAR")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("996")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("_kittens")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("-kittens")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") +} diff --git a/go/sdl/v2_1_test.go b/go/sdl/v2_1_test.go new file mode 100644 index 00000000..75217183 --- /dev/null +++ b/go/sdl/v2_1_test.go @@ -0,0 +1,728 @@ +package sdl + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + "github.com/akash-network/akash-api/go/node/types/unit" + atypes "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func TestV2_1_ParseSimpleGPU(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/simple-gpu.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, dtypes.ResourceUnit{ + Count: 2, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/a100", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, group.GetResourceUnits()[0]) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + expectedHosts := make([]string, 1) + expectedHosts[0] = "ahostname.com" // nolint: goconst + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "web", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/a100", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 2, + Expose: []manifest.ServiceExpose{ + {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + {Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func TestV2_1_Parse_Deployments(t *testing.T) { + sdl1, err := ReadFile("../../testdata/v2.1/deployment.yaml") + require.NoError(t, err) + _, err = sdl1.DeploymentGroups() + require.NoError(t, err) + + _, err = sdl1.Manifest() + require.NoError(t, err) + + sha1, err := sdl1.Version() + require.NoError(t, err) + assert.Len(t, sha1, 32) + + sdl2, err := ReadFile("../../testdata/v2.1/ip-endpoint.yaml") + require.NoError(t, err) + sha2, err := sdl2.Version() + + require.NoError(t, err) + assert.Len(t, sha2, 32) + require.NotEqual(t, sha1, sha2) +} + +func Test_V2_1_Cross_Validates(t *testing.T) { + sdl2, err := ReadFile("../../testdata/v2.1/deployment.yaml") + require.NoError(t, err) + dgroups, err := sdl2.DeploymentGroups() + require.NoError(t, err) + m, err := sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other. If this test fails at least one of the + // following is ture + // 1. Cross validation logic is wrong + // 2. The DeploymentGroups() & Manifest() code do not agree with one another + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2.1/simple.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2.1/simple3.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2.1/private_service.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + +} + +func Test_V2_1_Parse_simple(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/simple.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[0]) + + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, dtypes.ResourceUnit{ + Count: 2, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, group.GetResourceUnits()[0]) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + expectedHosts := make([]string, 1) + expectedHosts[0] = "ahostname.com" + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "web", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 2, + Expose: []manifest.ServiceExpose{ + {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + {Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func Test_v2_1_Parse_ProfileNameNotServiceName(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/profile-svc-name-mismatch.yaml") + require.NoError(t, err) + + dgroups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, dgroups, 1) + + mani, err := sdl.Manifest() + require.NoError(t, err) + assert.Len(t, mani.GetGroups(), 1) +} + +func Test_v2_1_Parse_DeploymentNameServiceNameMismatch(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/svc-mismatch.yaml") + require.Error(t, err) + require.Nil(t, sdl) + require.Contains(t, err.Error(), "no service profile named") + + sdl, err = ReadFile("../../testdata/v2.1/simple2.yaml") + require.NoError(t, err) + require.NotNil(t, sdl) + + dgroups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, dgroups, 1) + + mani, err := sdl.Manifest() + require.NoError(t, err) + assert.Len(t, mani.GetGroups(), 1) + + require.Equal(t, dgroups[0].Name, mani.GetGroups()[0].Name) + // SDL lists 2 services, but particular deployment specifies only one + require.Len(t, mani.GetGroups()[0].Services, 1) + + // make sure deployment maps to the right service + require.Len(t, mani.GetGroups()[0].Services[0].Expose, 2) + require.Len(t, mani.GetGroups()[0].Services[0].Expose[0].Hosts, 1) + require.Equal(t, mani.GetGroups()[0].Services[0].Expose[0].Hosts[0], "ahostname.com") +} + +func TestV2_1_ParseServiceMix(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/service-mix.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 2) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Equal(t, dtypes.ResourceUnits{ + { + Count: 1, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + { + Count: 1, + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + }, group.GetResourceUnits()) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "svca", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"ahostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + { + Name: "svcb", + Image: "nginx", + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"bhostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12346, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func TestV2_1_ParseServiceMix2(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2.1/service-mix2.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Equal(t, dtypes.ResourceUnits{ + { + Count: 2, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + }, group.GetResourceUnits()) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "svca", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"ahostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + { + Name: "svcb", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"bhostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12346, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + }, + }, mani.GetGroups()[0]) +} diff --git a/go/sdl/v2_ip_test.go b/go/sdl/v2_ip_test.go new file mode 100644 index 00000000..c68e2121 --- /dev/null +++ b/go/sdl/v2_ip_test.go @@ -0,0 +1,297 @@ +package sdl + +import ( + "bytes" + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + types "github.com/akash-network/akash-api/go/node/types/v1beta3" +) + +func findIPEndpoint(t *testing.T, endpoints []types.Endpoint, id int) types.Endpoint { + t.Helper() + + idx := 0 + for _, endpoint := range endpoints { + if endpoint.Kind == types.Endpoint_LEASED_IP { + idx++ + if id == idx { + return endpoint + } + } + } + + t.Fatal("did not find any IP endpoints") + return types.Endpoint{} +} + +func TestV2ParseSimpleWithIP(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/simple-with-ip.yaml") + require.NoError(t, err) + require.NotNil(t, sdl) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + group := groups[0] + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + resource := resources[0] + + ipEndpoint := findIPEndpoint(t, resource.Resources.Endpoints, 1) + + require.Equal(t, ipEndpoint.Kind, types.Endpoint_LEASED_IP) + + mani, err := sdl.Manifest() + require.NoError(t, err) + var exposeIP manifest.ServiceExpose + for _, expose := range mani[0].Services[0].Expose { + if len(expose.IP) != 0 { + exposeIP = expose + break + } + } + require.NotEmpty(t, exposeIP.IP) + require.Equal(t, exposeIP.Proto, manifest.UDP) + require.Equal(t, exposeIP.Port, uint32(12345)) + require.True(t, exposeIP.Global) +} + +func TestV2Parse_IP(t *testing.T) { + sdl1, err := ReadFile("../../testdata/v2/deployment-v2-ip-endpoint.yaml") + require.NoError(t, err) + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + + require.Len(t, groups, 1) + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 1) + resource := resources[0] + endpoints := resource.Resources.Endpoints + require.Len(t, endpoints, 2) + + var ipEndpoint types.Endpoint + for _, endpoint := range endpoints { + if endpoint.Kind == types.Endpoint_LEASED_IP { + ipEndpoint = endpoint + } + } + + require.Equal(t, ipEndpoint.Kind, types.Endpoint_LEASED_IP) + require.Greater(t, ipEndpoint.SequenceNumber, uint32(0)) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 1) + maniGroup := maniGroups[0] + services := maniGroup.Services + require.Len(t, services, 1) + + service := services[0] + exposes := service.Expose + require.Len(t, exposes, 1) + + expose := exposes[0] + + require.True(t, expose.Global) + require.Equal(t, expose.IP, "meow") + require.Greater(t, expose.EndpointSequenceNumber, uint32(0)) +} + +func TestV2Parse_SharedIP(t *testing.T) { + // Read a file with 1 group having 1 endpoint shared amongst containers + sdl1, err := ReadFile("../../testdata/v2/deployment-v2-shared-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 2) + + // resource := resources[0] + ipEndpoint1 := findIPEndpoint(t, resources[0].Resources.Endpoints, 1) + require.Greater(t, ipEndpoint1.SequenceNumber, uint32(0)) + + ipEndpoint2 := findIPEndpoint(t, resources[1].Resources.Endpoints, 1) + require.Greater(t, ipEndpoint2.SequenceNumber, uint32(0)) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 1) + maniGroup := maniGroups[0] + + services := maniGroup.Services + require.Len(t, services, 2) + serviceA := services[0] + + serviceIPEndpoint := findIPEndpoint(t, serviceA.Resources.Endpoints, 1) + require.Equal(t, serviceIPEndpoint.SequenceNumber, ipEndpoint1.SequenceNumber) + + serviceB := services[1] + serviceIPEndpoint = findIPEndpoint(t, serviceB.Resources.Endpoints, 1) + require.Equal(t, serviceIPEndpoint.SequenceNumber, ipEndpoint2.SequenceNumber) +} + +func TestV2Parse_MultipleIP(t *testing.T) { + // Read a file with 1 group having two endpoints + sdl1, err := ReadFile("../../testdata/v2/deployment-v2-multi-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 1) + + group := groups[0] + + resources := group.GetResourceUnits() + require.Len(t, resources, 2) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + _ = mani +} + +func TestV2Parse_MultipleGroupsIP(t *testing.T) { + // Read a file with two groups, each one having an IP endpoint that is distinct + sdl1, err := ReadFile("../../testdata/v2/deployment-v2-multi-groups-ip-endpoint.yaml") + require.NoError(t, err) + + groups, err := sdl1.DeploymentGroups() + require.NoError(t, err) + require.Len(t, groups, 2) + + resources := groups[0].GetResourceUnits() + require.Len(t, resources, 1) + + resource := resources[0] + require.Len(t, resource.Resources.Endpoints, 2) + ipEndpointFirstGroup := findIPEndpoint(t, resource.Resources.Endpoints, 1) + require.Greater(t, ipEndpointFirstGroup.SequenceNumber, uint32(0)) + + resources = groups[1].GetResourceUnits() + require.Len(t, resources, 1) + + resource = resources[0] + require.Len(t, resource.Resources.Endpoints, 2) + ipEndpointSecondGroup := findIPEndpoint(t, resource.Resources.Endpoints, 1) + require.Greater(t, ipEndpointSecondGroup.SequenceNumber, uint32(0)) + require.NotEqual(t, ipEndpointFirstGroup.SequenceNumber, ipEndpointSecondGroup.SequenceNumber) + + mani, err := sdl1.Manifest() + require.NoError(t, err) + maniGroups := mani.GetGroups() + require.Len(t, maniGroups, 2) + + maniGroup := maniGroups[0] + mresources := maniGroup.GetResourceUnits() + require.Len(t, mresources, 1) + mresource := mresources[0] + require.Equal(t, findIPEndpoint(t, mresource.Endpoints, 1).SequenceNumber, ipEndpointFirstGroup.SequenceNumber) + + maniGroup = maniGroups[1] + mresources = maniGroup.GetResourceUnits() + require.Len(t, mresources, 1) + mresource = mresources[0] + require.Equal(t, findIPEndpoint(t, mresource.Endpoints, 1).SequenceNumber, ipEndpointSecondGroup.SequenceNumber) + +} + +func TestV2Parse_IPEndpointNaming(t *testing.T) { + makeSDLWithEndpointName := func(name string) []byte { + const originalSDL = `--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: %q + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + +endpoints: + %q: + kind: ip +` + buf := &bytes.Buffer{} + _, err := fmt.Fprintf(buf, originalSDL, name, name) + require.NoError(t, err) + return buf.Bytes() + } + + _, err := Read(makeSDLWithEndpointName("meow72-memes")) + require.NoError(t, err) + + _, err = Read(makeSDLWithEndpointName("meow72-mem_es")) + require.NoError(t, err) + + _, err = Read(makeSDLWithEndpointName("!important")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("foo^bar")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("ROAR")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("996")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("_kittens")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + + _, err = Read(makeSDLWithEndpointName("-kittens")) + require.Error(t, err) + require.ErrorAs(t, err, &errSDLInvalid) + require.Contains(t, err.Error(), "not a valid name") + +} diff --git a/go/sdl/v2_test.go b/go/sdl/v2_test.go new file mode 100644 index 00000000..91d4ef66 --- /dev/null +++ b/go/sdl/v2_test.go @@ -0,0 +1,925 @@ +package sdl + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + manifest "github.com/akash-network/akash-api/go/manifest/v2beta2" + dtypes "github.com/akash-network/akash-api/go/node/deployment/v1beta3" + "github.com/akash-network/akash-api/go/node/types/unit" + atypes "github.com/akash-network/akash-api/go/node/types/v1beta3" + v2 "github.com/akash-network/akash-api/go/sdl/v2" +) + +func AkashDecCoin(t testing.TB, amount int64) sdk.DecCoin { + t.Helper() + amt := sdk.NewInt(amount) + return sdk.NewDecCoin("uakt", amt) +} + +const ( + randCPU uint64 = 100 + randGPU uint64 = 1 + randMemory uint64 = 128 * unit.Mi + randStorage uint64 = 1 * unit.Gi +) + +var ( + defaultHTTPOptions = manifest.ServiceExposeHTTPOptions{ + MaxBodySize: v2.DefaultMaxBodySize, + ReadTimeout: v2.DefaultReadTimeout, + SendTimeout: v2.DefaultSendTimeout, + NextTries: v2.DefaultNextTries, + NextCases: []string{"error", "timeout"}, + } +) + +func TestV2ParseSimpleGPU(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/simple-gpu.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, dtypes.ResourceUnit{ + Count: 2, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/a100", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, group.GetResourceUnits()[0]) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + expectedHosts := make([]string, 1) + expectedHosts[0] = "ahostname.com" + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "web", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/a100", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 2, + Expose: []manifest.ServiceExpose{ + {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + {Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func TestV2Parse_Deployments(t *testing.T) { + sdl1, err := ReadFile("../../testdata/v2/deployment.yaml") + require.NoError(t, err) + _, err = sdl1.DeploymentGroups() + require.NoError(t, err) + + _, err = sdl1.Manifest() + require.NoError(t, err) + + sha1, err := sdl1.Version() + require.NoError(t, err) + assert.Len(t, sha1, 32) + + sdl2, err := ReadFile("../../testdata/v2/deployment-v2.yaml") + require.NoError(t, err) + sha2, err := sdl2.Version() + + require.NoError(t, err) + assert.Len(t, sha2, 32) + require.NotEqual(t, sha1, sha2) +} + +func Test_V2_Cross_Validates(t *testing.T) { + sdl2, err := ReadFile("../../testdata/v2/deployment-v2.yaml") + require.NoError(t, err) + dgroups, err := sdl2.DeploymentGroups() + require.NoError(t, err) + m, err := sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other. If this test fails at least one of the + // following is ture + // 1. Cross validation logic is wrong + // 2. The DeploymentGroups() & Manifest() code do not agree with one another + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2/simple.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2/simple3.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + + // Repeat the same test with another file + sdl2, err = ReadFile("../../testdata/v2/private_service.yaml") + require.NoError(t, err) + dgroups, err = sdl2.DeploymentGroups() + require.NoError(t, err) + m, err = sdl2.Manifest() + require.NoError(t, err) + + // This is a single document producing both the manifest & deployment groups + // These should always agree with each other + err = m.CheckAgainstGSpecs(dgroups) + require.NoError(t, err) + +} + +func Test_V2_Parse_simple(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/simple.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[0]) + + assert.Len(t, group.GetResourceUnits(), 1) + + assert.Equal(t, dtypes.ResourceUnit{ + Count: 2, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, group.GetResourceUnits()[0]) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + expectedHosts := make([]string, 1) + expectedHosts[0] = "ahostname.com" + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "web", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 2, + Expose: []manifest.ServiceExpose{ + {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + {Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: manifest.ServiceExposeHTTPOptions{ + MaxBodySize: 1048576, + ReadTimeout: 60000, + SendTimeout: 60000, + NextTries: 3, + NextTimeout: 0, + NextCases: []string{"error", "timeout"}, + }}, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func Test_v1_Parse_ProfileNameNotServiceName(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/profile-svc-name-mismatch.yaml") + require.NoError(t, err) + + dgroups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, dgroups, 1) + + mani, err := sdl.Manifest() + require.NoError(t, err) + assert.Len(t, mani.GetGroups(), 1) +} + +func Test_v2_Parse_DeploymentNameServiceNameMismatch(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/deployment-svc-mismatch.yaml") + require.Error(t, err) + require.Nil(t, sdl) + require.Contains(t, err.Error(), "no service profile named") + + sdl, err = ReadFile("../../testdata/v2/simple2.yaml") + require.NoError(t, err) + require.NotNil(t, sdl) + + dgroups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, dgroups, 1) + + mani, err := sdl.Manifest() + require.NoError(t, err) + assert.Len(t, mani.GetGroups(), 1) + + require.Equal(t, dgroups[0].Name, mani.GetGroups()[0].Name) + // SDL lists 2 services, but particular deployment specifies only one + require.Len(t, mani.GetGroups()[0].Services, 1) + + // make sure deployment maps to the right service + require.Len(t, mani.GetGroups()[0].Services[0].Expose, 2) + require.Len(t, mani.GetGroups()[0].Services[0].Expose[0].Hosts, 1) + require.Equal(t, mani.GetGroups()[0].Services[0].Expose[0].Hosts[0], "ahostname.com") +} + +func TestV2ParseServiceMix(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/service-mix.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 2) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Equal(t, dtypes.ResourceUnits{ + { + Count: 1, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + { + Count: 1, + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + }, group.GetResourceUnits()) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "svca", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"ahostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + { + Name: "svcb", + Image: "nginx", + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"bhostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12346, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func TestV2ParseServiceMix2(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/service-mix2.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 2) + assert.Len(t, group.Requirements.Attributes, 2) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[1]) + + assert.Equal(t, dtypes.ResourceUnits{ + { + Count: 1, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + { + Count: 1, + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(randGPU), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + }, group.GetResourceUnits()) + + mani, err := sdl.Manifest() + require.NoError(t, err) + + assert.Len(t, mani.GetGroups(), 1) + + assert.Equal(t, manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "svca", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"ahostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + { + Name: "svcb", + Image: "nginx", + Resources: atypes.Resources{ + ID: 2, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(1), + Attributes: atypes.Attributes{ + { + Key: "vendor/nvidia/model/*", + Value: "true", + }, + }, + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"bhostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12346, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + }, + }, mani.GetGroups()[0]) +} + +func TestV2ParseStorageName(t *testing.T) { + sdl, err := ReadFile("../../testdata/v2/storageClass6.yaml") + require.NoError(t, err) + + groups, err := sdl.DeploymentGroups() + require.NoError(t, err) + assert.Len(t, groups, 1) + + mani, err := sdl.Manifest() + require.NoError(t, err) + assert.Len(t, mani.GetGroups(), 1) + + group := groups[0] + assert.Len(t, group.GetResourceUnits(), 1) + assert.Len(t, group.Requirements.Attributes, 1) + + assert.Equal(t, atypes.Attribute{ + Key: "region", + Value: "us-west", + }, group.Requirements.Attributes[0]) + + expRU := dtypes.ResourceUnits{ + { + Count: 1, + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(randCPU), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(randMemory), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(randStorage), + }, + { + Name: "configs", + Quantity: atypes.NewResourceValue(randStorage), + Attributes: atypes.Attributes{ + { + Key: "class", + Value: "default", + }, + { + Key: "persistent", + Value: "true", + }, + }, + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Price: AkashDecCoin(t, 50), + }, + } + + expGroup := manifest.Group{ + Name: "westcoast", + Services: []manifest.Service{ + { + Name: "web", + Image: "nginx", + Resources: atypes.Resources{ + ID: 1, + CPU: &atypes.CPU{ + Units: atypes.NewResourceValue(100), + }, + GPU: &atypes.GPU{ + Units: atypes.NewResourceValue(0), + }, + Memory: &atypes.Memory{ + Quantity: atypes.NewResourceValue(128 * unit.Mi), + }, + Storage: atypes.Volumes{ + { + Name: "default", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + }, + { + Name: "configs", + Quantity: atypes.NewResourceValue(1 * unit.Gi), + Attributes: atypes.Attributes{ + { + Key: "class", + Value: "default", + }, + { + Key: "persistent", + Value: "true", + }, + }, + }, + }, + Endpoints: []atypes.Endpoint{ + { + Kind: atypes.Endpoint_SHARED_HTTP, + }, + { + Kind: atypes.Endpoint_RANDOM_PORT, + }, + }, + }, + Params: &manifest.ServiceParams{ + Storage: []manifest.StorageParams{ + { + Name: "configs", + Mount: "/test", + ReadOnly: false, + }, + }, + }, + Count: 1, + Expose: []manifest.ServiceExpose{ + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: []string{"ahostname.com"}, + HTTPOptions: defaultHTTPOptions, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, + HTTPOptions: defaultHTTPOptions, + }, + }, + }, + }, + } + + assert.Equal(t, expRU, group.GetResourceUnits()) + assert.Equal(t, expGroup, mani.GetGroups()[0]) +} diff --git a/proto/node/akash/sdl/v2.1/accept.proto b/proto/node/akash/sdl/v2.1/accept.proto new file mode 100644 index 00000000..5ae6d0c0 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/accept.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Accept { + repeated string items = 1 [ + (gogoproto.customname) = "Items", + (gogoproto.jsontag) = "items", + (gogoproto.moretags) = "yaml:\"items\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/coin.proto b/proto/node/akash/sdl/v2.1/coin.proto new file mode 100644 index 00000000..4b6210ed --- /dev/null +++ b/proto/node/akash/sdl/v2.1/coin.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Coin { + cosmos.base.v1beta1.DecCoin value = 1 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Value", + (gogoproto.jsontag) = "value", + (gogoproto.moretags) = "yaml:\"value\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/compute_resources.proto b/proto/node/akash/sdl/v2.1/compute_resources.proto new file mode 100644 index 00000000..071fe282 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/compute_resources.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2.1/cpu.proto"; +import "akash/sdl/v2.1/gpu.proto"; +import "akash/sdl/v2.1/memory.proto"; +import "akash/sdl/v2.1/storage.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ComputeResources { + ResourceCPU cpu = 1 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "CPU", + (gogoproto.jsontag) = "cpu", + (gogoproto.moretags) = "yaml:\"cpu\"" + ]; + ResourceGPU gpu = 2 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "GPU", + (gogoproto.jsontag) = "gpu", + (gogoproto.moretags) = "yaml:\"gpu\"" + ]; + ResourceMemory memory = 3 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "Memory", + (gogoproto.jsontag) = "memory", + (gogoproto.moretags) = "yaml:\"memory\"" + ]; + repeated ResourceStorage storage = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "StorageArray", + (gogoproto.customname) = "Storage", + (gogoproto.jsontag) = "storage", + (gogoproto.moretags) = "yaml:\"storage\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/cpu.proto b/proto/node/akash/sdl/v2.1/cpu.proto new file mode 100644 index 00000000..26e32fb8 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/cpu.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ResourceCPU { + uint32 units = 1 [ + (gogoproto.casttype) = "cpuQuantity", + (gogoproto.customname) = "Units", + (gogoproto.jsontag) = "units", + (gogoproto.moretags) = "yaml:\"units\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "cpuAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/dependency.proto b/proto/node/akash/sdl/v2.1/dependency.proto new file mode 100644 index 00000000..f38bfece --- /dev/null +++ b/proto/node/akash/sdl/v2.1/dependency.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Dependency { + string service = 1 [ + (gogoproto.customname) = "Service", + (gogoproto.jsontag) = "service", + (gogoproto.moretags) = "yaml:\"service\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/endpoint.proto b/proto/node/akash/sdl/v2.1/endpoint.proto new file mode 100644 index 00000000..ae0996f2 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/endpoint.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Endpoint { + string kind = 1 [ + (gogoproto.customname) = "Kind", + (gogoproto.jsontag) = "kind", + (gogoproto.moretags) = "yaml:\"kind\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/expose.proto b/proto/node/akash/sdl/v2.1/expose.proto new file mode 100644 index 00000000..cf72b444 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/expose.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2.1/accept.proto"; +import "akash/sdl/v2.1/expose_to.proto"; +import "akash/sdl/v2.1/http_options.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Expose { + uint32 port = 1 [ + (gogoproto.customname) = "Port", + (gogoproto.jsontag) = "port", + (gogoproto.moretags) = "yaml:\"port\"" + ]; + uint32 as = 2 [ + (gogoproto.customname) = "As", + (gogoproto.jsontag) = "as", + (gogoproto.moretags) = "yaml:\"as\"" + ]; + string proto = 3 [ + (gogoproto.customname) = "Proto", + (gogoproto.jsontag) = "proto", + (gogoproto.moretags) = "yaml:\"proto\"" + ]; + repeated ExposeTo to = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "ExposeToSlice", + (gogoproto.customname) = "To", + (gogoproto.jsontag) = "to", + (gogoproto.moretags) = "yaml:\"to\"" + ]; + Accept accept = 5 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Accept", + (gogoproto.jsontag) = "accept", + (gogoproto.moretags) = "yaml:\"accept\"" + ]; + HTTPOptions http_options = 6 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "HTTPOptions", + (gogoproto.jsontag) = "http_options", + (gogoproto.moretags) = "yaml:\"http_options\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/expose_to.proto b/proto/node/akash/sdl/v2.1/expose_to.proto new file mode 100644 index 00000000..7b03dc9f --- /dev/null +++ b/proto/node/akash/sdl/v2.1/expose_to.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; +import "akash/sdl/v2.1/http_options.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ExposeTo { + string service = 1 [ + (gogoproto.customname) = "Service", + (gogoproto.jsontag) = "service", + (gogoproto.moretags) = "yaml:\"service\"" + ]; + bool Global = 2 [ + (gogoproto.customname) = "Global", + (gogoproto.jsontag) = "global", + (gogoproto.moretags) = "yaml:\"global\"" + ]; + HTTPOptions http_options = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "HTTPOptions", + (gogoproto.jsontag) = "http_options", + (gogoproto.moretags) = "yaml:\"http_options\"" + ]; + string ip = 4 [ + (gogoproto.customname) = "IP", + (gogoproto.jsontag) = "ip", + (gogoproto.moretags) = "yaml:\"ip\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/gpu.proto b/proto/node/akash/sdl/v2.1/gpu.proto new file mode 100644 index 00000000..71c2c25b --- /dev/null +++ b/proto/node/akash/sdl/v2.1/gpu.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ResourceGPU { + uint32 units = 1 [ + (gogoproto.casttype) = "gpuQuantity", + (gogoproto.customname) = "Units", + (gogoproto.jsontag) = "units", + (gogoproto.moretags) = "yaml:\"units\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "gpuAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/http_options.proto b/proto/node/akash/sdl/v2.1/http_options.proto new file mode 100644 index 00000000..6e8de6e7 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/http_options.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message HTTPOptions { + uint32 max_body_size = 1 [ + (gogoproto.customname) = "MaxBodySize", + (gogoproto.jsontag) = "max_body_size", + (gogoproto.moretags) = "yaml:\"max_body_size\"" + ]; + uint32 read_timeout = 2 [ + (gogoproto.customname) = "ReadTimeout", + (gogoproto.jsontag) = "read_timeout", + (gogoproto.moretags) = "yaml:\"read_timeout\"" + ]; + uint32 send_timeout = 3 [ + (gogoproto.customname) = "SendTimeout", + (gogoproto.jsontag) = "send_timeout", + (gogoproto.moretags) = "yaml:\"send_timeout\"" + ]; + uint32 next_tries = 4 [ + (gogoproto.customname) = "NextTries", + (gogoproto.jsontag) = "next_tries", + (gogoproto.moretags) = "yaml:\"next_tries\"" + ]; + uint32 next_timeout = 5 [ + (gogoproto.customname) = "NextTimeout", + (gogoproto.jsontag) = "next_timeout", + (gogoproto.moretags) = "yaml:\"next_timeout\"" + ]; + repeated string next_cases = 6 [ + (gogoproto.customname) = "NextCases", + (gogoproto.jsontag) = "next_cases", + (gogoproto.moretags) = "yaml:\"next_cases\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/memory.proto b/proto/node/akash/sdl/v2.1/memory.proto new file mode 100644 index 00000000..2343943b --- /dev/null +++ b/proto/node/akash/sdl/v2.1/memory.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ResourceMemory { + uint32 quantity = 1 [ + (gogoproto.casttype) = "byteQuantity", + (gogoproto.customname) = "Quantity", + (gogoproto.jsontag) = "size", + (gogoproto.moretags) = "yaml:\"size\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "memoryAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/profiles.proto b/proto/node/akash/sdl/v2.1/profiles.proto new file mode 100644 index 00000000..dc78ce79 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/profiles.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; +import "akash/base/v1beta3/attribute.proto"; +import "akash/sdl/v2.1/compute_resources.proto"; +import "akash/sdl/v2.1/coin.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ProfileCompute { + ComputeResources resources = 1 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "Resources", + (gogoproto.jsontag) = "resources", + (gogoproto.moretags) = "yaml:\"resources\"" + ]; +} + +message ProfilePlacement { + repeated akash.base.v1beta3.Attribute attributes = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "placementAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; + akash.base.v1beta3.SignedBy signed_by = 2 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "SignedBy", + (gogoproto.jsontag) = "signedBy", + (gogoproto.moretags) = "yaml:\"signedBy\"" + ]; + map pricing = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Pricing", + (gogoproto.jsontag) = "pricing", + (gogoproto.moretags) = "yaml:\"pricing\"" + ]; +} + +message Profiles { + map compute = 1 [ + (gogoproto.customname) = "Compute", + (gogoproto.jsontag) = "compute", + (gogoproto.moretags) = "yaml:\"compute\"" + ]; + map placement = 2 [ + (gogoproto.customname) = "Placement", + (gogoproto.jsontag) = "placement", + (gogoproto.moretags) = "yaml:\"placement\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/sdl.proto b/proto/node/akash/sdl/v2.1/sdl.proto new file mode 100644 index 00000000..6c278573 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/sdl.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/struct.proto"; + +import "akash/sdl/v2.1/service.proto"; +import "akash/sdl/v2.1/profiles.proto"; +import "akash/sdl/v2.1/endpoint.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message content { + string include = 1; + string version = 2; + map services = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Services", + (gogoproto.jsontag) = "services", + (gogoproto.moretags) = "yaml:\"services\"" + ]; + Profiles profiles = 4 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Profiles", + (gogoproto.jsontag) = "profiles", + (gogoproto.moretags) = "yaml:\"profiles\"" + ]; + google.protobuf.Struct deployments = 5 [ + (gogoproto.nullable) = false, + (gogoproto.customtype) = "Deployments", + (gogoproto.customname) = "Deployments", + (gogoproto.jsontag) = "deployments", + (gogoproto.moretags) = "yaml:\"deployments\"" + ]; + map endpoints = 6 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Endpoints", + (gogoproto.jsontag) = "endpoints", + (gogoproto.moretags) = "yaml:\"endpoints\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/service.proto b/proto/node/akash/sdl/v2.1/service.proto new file mode 100644 index 00000000..092db088 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/service.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2.1/dependency.proto"; +import "akash/sdl/v2.1/expose.proto"; +import "akash/sdl/v2.1/service_params.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message Service { + string image = 1 [ + (gogoproto.customname) = "Image", + (gogoproto.jsontag) = "image", + (gogoproto.moretags) = "yaml:\"image\"" + ]; + repeated string command = 2 [ + (gogoproto.customname) = "Command", + (gogoproto.jsontag) = "command", + (gogoproto.moretags) = "yaml:\"command\"" + ]; + repeated string args = 3 [ + (gogoproto.customname) = "Args", + (gogoproto.jsontag) = "args", + (gogoproto.moretags) = "yaml:\"args\"" + ]; + repeated string env = 4 [ + (gogoproto.customname) = "Env", + (gogoproto.jsontag) = "env", + (gogoproto.moretags) = "yaml:\"env\"" + ]; + repeated Expose expose = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "Exposes", + (gogoproto.customname) = "Expose", + (gogoproto.jsontag) = "expose", + (gogoproto.moretags) = "yaml:\"expose\"" + ]; + repeated Dependency dependencies = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "Dependencies", + (gogoproto.customname) = "Dependencies", + (gogoproto.jsontag) = "dependencies", + (gogoproto.moretags) = "yaml:\"dependencies\"" + ]; + ServiceParams params = 7 [ + (gogoproto.customname) = "Params", + (gogoproto.jsontag) = "params", + (gogoproto.moretags) = "yaml:\"params\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/service_params.proto b/proto/node/akash/sdl/v2.1/service_params.proto new file mode 100644 index 00000000..b2340f5c --- /dev/null +++ b/proto/node/akash/sdl/v2.1/service_params.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ServiceStorageParams { + string mount = 1 [ + (gogoproto.customname) = "Mount", + (gogoproto.jsontag) = "mount", + (gogoproto.moretags) = "yaml:\"mount\"" + ]; + bool read_only = 2 [ + (gogoproto.customname) = "ReadOnly", + (gogoproto.jsontag) = "readOnly", + (gogoproto.moretags) = "yaml:\"readOnly\"" + ]; +} + +message ServiceParams { + map Storage = 1 [ + (gogoproto.customname) = "Storage", + (gogoproto.jsontag) = "storage", + (gogoproto.moretags) = "yaml:\"storage\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/service_placement.proto b/proto/node/akash/sdl/v2.1/service_placement.proto new file mode 100644 index 00000000..5060348c --- /dev/null +++ b/proto/node/akash/sdl/v2.1/service_placement.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ServicePlacement { + option (gogoproto.equal) = true; + string profile = 1 [ + (gogoproto.customname) = "Profile", + (gogoproto.jsontag) = "profile", + (gogoproto.moretags) = "yaml:\"profile\"" + ]; + uint32 count = 2 [ + (gogoproto.customname) = "Count", + (gogoproto.jsontag) = "count", + (gogoproto.moretags) = "yaml:\"count\"" + ]; +} diff --git a/proto/node/akash/sdl/v2.1/storage.proto b/proto/node/akash/sdl/v2.1/storage.proto new file mode 100644 index 00000000..df2c54c2 --- /dev/null +++ b/proto/node/akash/sdl/v2.1/storage.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package akash.sdl.v2_1; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2_1"; + +message ResourceStorage { + string name = 1 [ + (gogoproto.customname) = "Name", + (gogoproto.jsontag) = "name", + (gogoproto.moretags) = "yaml:\"name\"" + ]; + uint32 quantity = 2 [ + (gogoproto.casttype) = "byteQuantity", + (gogoproto.customname) = "Quantity", + (gogoproto.jsontag) = "size", + (gogoproto.moretags) = "yaml:\"size\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "storageAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/accept.proto b/proto/node/akash/sdl/v2/accept.proto new file mode 100644 index 00000000..49f060c9 --- /dev/null +++ b/proto/node/akash/sdl/v2/accept.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Accept { + repeated string items = 1 [ + (gogoproto.customname) = "Items", + (gogoproto.jsontag) = "items", + (gogoproto.moretags) = "yaml:\"items\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/coin.proto b/proto/node/akash/sdl/v2/coin.proto new file mode 100644 index 00000000..e7b2d728 --- /dev/null +++ b/proto/node/akash/sdl/v2/coin.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Coin { + cosmos.base.v1beta1.DecCoin value = 1 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Value", + (gogoproto.jsontag) = "value", + (gogoproto.moretags) = "yaml:\"value\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/compute_resources.proto b/proto/node/akash/sdl/v2/compute_resources.proto new file mode 100644 index 00000000..187f7663 --- /dev/null +++ b/proto/node/akash/sdl/v2/compute_resources.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2/cpu.proto"; +import "akash/sdl/v2/gpu.proto"; +import "akash/sdl/v2/memory.proto"; +import "akash/sdl/v2/storage.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ComputeResources { + ResourceCPU cpu = 1 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "CPU", + (gogoproto.jsontag) = "cpu", + (gogoproto.moretags) = "yaml:\"cpu\"" + ]; + ResourceGPU gpu = 2 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "GPU", + (gogoproto.jsontag) = "gpu", + (gogoproto.moretags) = "yaml:\"gpu\"" + ]; + ResourceMemory memory = 3 [ + (gogoproto.nullable) = true, + (gogoproto.customname) = "Memory", + (gogoproto.jsontag) = "memory", + (gogoproto.moretags) = "yaml:\"memory\"" + ]; + repeated ResourceStorage storage = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "StorageArray", + (gogoproto.customname) = "Storage", + (gogoproto.jsontag) = "storage", + (gogoproto.moretags) = "yaml:\"storage\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/cpu.proto b/proto/node/akash/sdl/v2/cpu.proto new file mode 100644 index 00000000..c2e6c707 --- /dev/null +++ b/proto/node/akash/sdl/v2/cpu.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ResourceCPU { + uint32 units = 1 [ + (gogoproto.casttype) = "cpuQuantity", + (gogoproto.customname) = "Units", + (gogoproto.jsontag) = "units", + (gogoproto.moretags) = "yaml:\"units\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "cpuAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/dependency.proto b/proto/node/akash/sdl/v2/dependency.proto new file mode 100644 index 00000000..446fecd0 --- /dev/null +++ b/proto/node/akash/sdl/v2/dependency.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Dependency { + string service = 1 [ + (gogoproto.customname) = "Service", + (gogoproto.jsontag) = "service", + (gogoproto.moretags) = "yaml:\"service\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/endpoint.proto b/proto/node/akash/sdl/v2/endpoint.proto new file mode 100644 index 00000000..8f5b04a3 --- /dev/null +++ b/proto/node/akash/sdl/v2/endpoint.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Endpoint { + string kind = 1 [ + (gogoproto.customname) = "Kind", + (gogoproto.jsontag) = "kind", + (gogoproto.moretags) = "yaml:\"kind\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/expose.proto b/proto/node/akash/sdl/v2/expose.proto new file mode 100644 index 00000000..c40b25b8 --- /dev/null +++ b/proto/node/akash/sdl/v2/expose.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2/accept.proto"; +import "akash/sdl/v2/expose_to.proto"; +import "akash/sdl/v2/http_options.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Expose { + uint32 port = 1 [ + (gogoproto.customname) = "Port", + (gogoproto.jsontag) = "port", + (gogoproto.moretags) = "yaml:\"port\"" + ]; + uint32 as = 2 [ + (gogoproto.customname) = "As", + (gogoproto.jsontag) = "as", + (gogoproto.moretags) = "yaml:\"as\"" + ]; + string proto = 3 [ + (gogoproto.customname) = "Proto", + (gogoproto.jsontag) = "proto", + (gogoproto.moretags) = "yaml:\"proto\"" + ]; + repeated ExposeTo to = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "ExposeToSlice", + (gogoproto.customname) = "To", + (gogoproto.jsontag) = "to", + (gogoproto.moretags) = "yaml:\"to\"" + ]; + Accept accept = 5 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Accept", + (gogoproto.jsontag) = "accept", + (gogoproto.moretags) = "yaml:\"accept\"" + ]; + HTTPOptions http_options = 6 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "HTTPOptions", + (gogoproto.jsontag) = "http_options", + (gogoproto.moretags) = "yaml:\"http_options\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/expose_to.proto b/proto/node/akash/sdl/v2/expose_to.proto new file mode 100644 index 00000000..3a969f4e --- /dev/null +++ b/proto/node/akash/sdl/v2/expose_to.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; +import "akash/sdl/v2/http_options.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ExposeTo { + string service = 1 [ + (gogoproto.customname) = "Service", + (gogoproto.jsontag) = "service", + (gogoproto.moretags) = "yaml:\"service\"" + ]; + bool Global = 2 [ + (gogoproto.customname) = "Global", + (gogoproto.jsontag) = "global", + (gogoproto.moretags) = "yaml:\"global\"" + ]; + HTTPOptions http_options = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "HTTPOptions", + (gogoproto.jsontag) = "http_options", + (gogoproto.moretags) = "yaml:\"http_options\"" + ]; + string ip = 4 [ + (gogoproto.customname) = "IP", + (gogoproto.jsontag) = "ip", + (gogoproto.moretags) = "yaml:\"ip\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/gpu.proto b/proto/node/akash/sdl/v2/gpu.proto new file mode 100644 index 00000000..e00d9041 --- /dev/null +++ b/proto/node/akash/sdl/v2/gpu.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ResourceGPU { + uint32 units = 1 [ + (gogoproto.casttype) = "gpuQuantity", + (gogoproto.customname) = "Units", + (gogoproto.jsontag) = "units", + (gogoproto.moretags) = "yaml:\"units\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "gpuAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/http_options.proto b/proto/node/akash/sdl/v2/http_options.proto new file mode 100644 index 00000000..c80230d2 --- /dev/null +++ b/proto/node/akash/sdl/v2/http_options.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message HTTPOptions { + uint32 max_body_size = 1 [ + (gogoproto.customname) = "MaxBodySize", + (gogoproto.jsontag) = "max_body_size", + (gogoproto.moretags) = "yaml:\"max_body_size\"" + ]; + uint32 read_timeout = 2 [ + (gogoproto.customname) = "ReadTimeout", + (gogoproto.jsontag) = "read_timeout", + (gogoproto.moretags) = "yaml:\"read_timeout\"" + ]; + uint32 send_timeout = 3 [ + (gogoproto.customname) = "SendTimeout", + (gogoproto.jsontag) = "send_timeout", + (gogoproto.moretags) = "yaml:\"send_timeout\"" + ]; + uint32 next_tries = 4 [ + (gogoproto.customname) = "NextTries", + (gogoproto.jsontag) = "next_tries", + (gogoproto.moretags) = "yaml:\"next_tries\"" + ]; + uint32 next_timeout = 5 [ + (gogoproto.customname) = "NextTimeout", + (gogoproto.jsontag) = "next_timeout", + (gogoproto.moretags) = "yaml:\"next_timeout\"" + ]; + repeated string next_cases = 6 [ + (gogoproto.customname) = "NextCases", + (gogoproto.jsontag) = "next_cases", + (gogoproto.moretags) = "yaml:\"next_cases\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/memory.proto b/proto/node/akash/sdl/v2/memory.proto new file mode 100644 index 00000000..0feb39fb --- /dev/null +++ b/proto/node/akash/sdl/v2/memory.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ResourceMemory { + uint32 quantity = 1 [ + (gogoproto.casttype) = "memoryQuantity", + (gogoproto.customname) = "Quantity", + (gogoproto.jsontag) = "size", + (gogoproto.moretags) = "yaml:\"size\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "memoryAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/profiles.proto b/proto/node/akash/sdl/v2/profiles.proto new file mode 100644 index 00000000..8aced987 --- /dev/null +++ b/proto/node/akash/sdl/v2/profiles.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; +import "akash/base/v1beta3/attribute.proto"; +import "akash/sdl/v2/compute_resources.proto"; +import "akash/sdl/v2/coin.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ProfileCompute { + ComputeResources resources = 1 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Resources", + (gogoproto.jsontag) = "resources", + (gogoproto.moretags) = "yaml:\"resources\"" + ]; +} + +message ProfilePlacement { + repeated akash.base.v1beta3.Attribute attributes = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "placementAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; + akash.base.v1beta3.SignedBy signed_by = 2 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "SignedBy", + (gogoproto.jsontag) = "signedBy", + (gogoproto.moretags) = "yaml:\"signedBy\"" + ]; + map pricing = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Pricing", + (gogoproto.jsontag) = "pricing", + (gogoproto.moretags) = "yaml:\"pricing\"" + ]; +} + +message Profiles { + map compute = 1 [ + (gogoproto.customname) = "Compute", + (gogoproto.jsontag) = "compute", + (gogoproto.moretags) = "yaml:\"compute\"" + ]; + map placement = 2 [ + (gogoproto.customname) = "Placement", + (gogoproto.jsontag) = "placement", + (gogoproto.moretags) = "yaml:\"placement\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/sdl.proto b/proto/node/akash/sdl/v2/sdl.proto new file mode 100644 index 00000000..ec6c21b1 --- /dev/null +++ b/proto/node/akash/sdl/v2/sdl.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; +import "google/protobuf/struct.proto"; + +import "akash/sdl/v2/service.proto"; +import "akash/sdl/v2/profiles.proto"; +import "akash/sdl/v2/endpoint.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message content { + repeated string include = 1; + map services = 2[ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Services", + (gogoproto.jsontag) = "services", + (gogoproto.moretags) = "yaml:\"services\"" + ]; + Profiles profiles = 3 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Profiles", + (gogoproto.jsontag) = "profiles", + (gogoproto.moretags) = "yaml:\"profiles\"" + ]; + google.protobuf.Struct deployments = 4 [ + (gogoproto.nullable) = false, + (gogoproto.customtype) = "Deployments", + (gogoproto.customname) = "Deployments", + (gogoproto.jsontag) = "deployments", + (gogoproto.moretags) = "yaml:\"deployments\"" + ]; + map endpoints = 5 [ + (gogoproto.nullable) = false, + (gogoproto.customname) = "Endpoints", + (gogoproto.jsontag) = "endpoints", + (gogoproto.moretags) = "yaml:\"endpoints\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/service.proto b/proto/node/akash/sdl/v2/service.proto new file mode 100644 index 00000000..c7ee6285 --- /dev/null +++ b/proto/node/akash/sdl/v2/service.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/sdl/v2/dependency.proto"; +import "akash/sdl/v2/expose.proto"; +import "akash/sdl/v2/service_params.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message Service { + string image = 1 [ + (gogoproto.customname) = "Image", + (gogoproto.jsontag) = "image", + (gogoproto.moretags) = "yaml:\"image\"" + ]; + repeated string command = 2 [ + (gogoproto.customname) = "Command", + (gogoproto.jsontag) = "command", + (gogoproto.moretags) = "yaml:\"command\"" + ]; + repeated string args = 3 [ + (gogoproto.customname) = "Args", + (gogoproto.jsontag) = "args", + (gogoproto.moretags) = "yaml:\"args\"" + ]; + repeated string env = 4 [ + (gogoproto.customname) = "Env", + (gogoproto.jsontag) = "env", + (gogoproto.moretags) = "yaml:\"env\"" + ]; + repeated Expose expose = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "Exposes", + (gogoproto.customname) = "Expose", + (gogoproto.jsontag) = "expose", + (gogoproto.moretags) = "yaml:\"expose\"" + ]; + repeated Dependency dependencies = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "Dependencies", + (gogoproto.customname) = "Dependencies", + (gogoproto.jsontag) = "dependencies", + (gogoproto.moretags) = "yaml:\"dependencies\"" + ]; + ServiceParams params = 7 [ + (gogoproto.customname) = "Params", + (gogoproto.jsontag) = "params", + (gogoproto.moretags) = "yaml:\"params\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/service_params.proto b/proto/node/akash/sdl/v2/service_params.proto new file mode 100644 index 00000000..cb7afb02 --- /dev/null +++ b/proto/node/akash/sdl/v2/service_params.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ServiceStorageParams { + string mount = 1 [ + (gogoproto.customname) = "Mount", + (gogoproto.jsontag) = "mount", + (gogoproto.moretags) = "yaml:\"mount\"" + ]; + bool read_only = 2 [ + (gogoproto.customname) = "ReadOnly", + (gogoproto.jsontag) = "readOnly", + (gogoproto.moretags) = "yaml:\"readOnly\"" + ]; +} + +message ServiceParams { + map Storage = 1 [ + (gogoproto.customname) = "Storage", + (gogoproto.jsontag) = "storage", + (gogoproto.moretags) = "yaml:\"storage\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/service_placement.proto b/proto/node/akash/sdl/v2/service_placement.proto new file mode 100644 index 00000000..4bc1ba0e --- /dev/null +++ b/proto/node/akash/sdl/v2/service_placement.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ServicePlacement { + option (gogoproto.equal) = true; + string profile = 1 [ + (gogoproto.customname) = "Profile", + (gogoproto.jsontag) = "profile", + (gogoproto.moretags) = "yaml:\"profile\"" + ]; + uint32 count = 2 [ + (gogoproto.customname) = "Count", + (gogoproto.jsontag) = "count", + (gogoproto.moretags) = "yaml:\"count\"" + ]; +} diff --git a/proto/node/akash/sdl/v2/storage.proto b/proto/node/akash/sdl/v2/storage.proto new file mode 100644 index 00000000..a60c5a16 --- /dev/null +++ b/proto/node/akash/sdl/v2/storage.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package akash.sdl.v2; + +import "gogoproto/gogo.proto"; + +import "akash/base/v1beta3/attribute.proto"; + +option go_package = "github.com/akash-network/akash-api/go/sdl/v2"; + +message ResourceStorage { + string name = 1 [ + (gogoproto.customname) = "Name", + (gogoproto.jsontag) = "name", + (gogoproto.moretags) = "yaml:\"name\"" + ]; + uint32 quantity = 2 [ + (gogoproto.casttype) = "byteQuantity", + (gogoproto.customname) = "Quantity", + (gogoproto.jsontag) = "size", + (gogoproto.moretags) = "yaml:\"size\"" + ]; + repeated akash.base.v1beta3.Attribute attributes = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "storageAttributes", + (gogoproto.customname) = "Attributes", + (gogoproto.jsontag) = "attributes", + (gogoproto.moretags) = "yaml:\"attributes\"" + ]; +} diff --git a/testdata/v2.1/deployment.yaml b/testdata/v2.1/deployment.yaml new file mode 100644 index 00000000..aaf4d294 --- /dev/null +++ b/testdata/v2.1/deployment.yaml @@ -0,0 +1,36 @@ +--- +version: "2.1" + +services: + web: + image: bubuntux/riot-web + expose: + - port: 80 + to: + - global: true + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 30 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2.1/ip-endpoint.yaml b/testdata/v2.1/ip-endpoint.yaml new file mode 100644 index 00000000..df653d52 --- /dev/null +++ b/testdata/v2.1/ip-endpoint.yaml @@ -0,0 +1,41 @@ +--- +version: "2.1" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2.1/multi-groups-ip-endpoint.yaml b/testdata/v2.1/multi-groups-ip-endpoint.yaml new file mode 100644 index 00000000..8cf888c2 --- /dev/null +++ b/testdata/v2.1/multi-groups-ip-endpoint.yaml @@ -0,0 +1,69 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "kittens" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + bob: + resources: + cpu: + units: "0.13" + memory: + size: "256Mi" + storage: + size: "99Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + bob: + pricing: + bob: + denom: uakt + amount: 99 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + bob: + profile: bob + count: 3 + +endpoints: + meow: + kind: "ip" + kittens: + kind: "ip" diff --git a/testdata/v2.1/multi-ip-endpoint.yaml b/testdata/v2.1/multi-ip-endpoint.yaml new file mode 100644 index 00000000..9fe15b17 --- /dev/null +++ b/testdata/v2.1/multi-ip-endpoint.yaml @@ -0,0 +1,56 @@ +--- +version: "2.1" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "kittens" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + global: + profile: web + count: 3 + +endpoints: + meow: + kind: "ip" + kittens: + kind: "ip" diff --git a/testdata/v2.1/private_service.yaml b/testdata/v2.1/private_service.yaml new file mode 100644 index 00000000..e4945869 --- /dev/null +++ b/testdata/v2.1/private_service.yaml @@ -0,0 +1,64 @@ +--- +version: "2.1" +services: + bind: + image: bind9 + expose: + - port: 53 + proto: udp + to: + - global: true + + pg: + image: postgresql + expose: + - port: 5463 + to: + - service: bind + +profiles: + compute: + bind: + resources: + cpu: + units: "50m" + memory: + size: "64Mi" + storage: + size: "16Mi" + pg: + resources: + cpu: + units: "500m" + memory: + size: "512Mi" + storage: + size: "1000Mi" + + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + pg: + denom: uakt + amount: 1000 + bind: + denom: uakt + amount: 333 +deployment: + pg: + westcoast: + profile: pg + count: 1 + bind: + westcoast: + profile: bind + count: 8 diff --git a/testdata/v2.1/profile-svc-name-mismatch.yaml b/testdata/v2.1/profile-svc-name-mismatch.yaml new file mode 100644 index 00000000..3128102f --- /dev/null +++ b/testdata/v2.1/profile-svc-name-mismatch.yaml @@ -0,0 +1,38 @@ +--- +version: "2.1" + +services: + webapp: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + as: 80 + accept: + - thehostname.com + to: + - global: true + +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "512Mi" + storage: + size: "512Mi" + placement: + san-jose: + attributes: + region: sjc + pricing: + web: + denom: uakt + amount: 25 + +deployment: + webapp: + san-jose: + profile: web + count: 1 diff --git a/testdata/v2.1/service-mix.yaml b/testdata/v2.1/service-mix.yaml new file mode 100644 index 00000000..82991aff --- /dev/null +++ b/testdata/v2.1/service-mix.yaml @@ -0,0 +1,80 @@ +--- +version: "2.1" +services: + svca: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + svcb: + image: nginx + expose: + - port: 80 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + +profiles: + compute: + profilea: + resources: + cpu: + units: "100m" + gpu: + units: "1" + attributes: + vendor: + nvidia: + memory: + size: "128Mi" + storage: + - size: "1Gi" + profileb: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + profilea: + denom: uakt + amount: 50 + profileb: + denom: uakt + amount: 50 + +deployment: + svca: + westcoast: + profile: profilea + count: 1 + svcb: + westcoast: + profile: profileb + count: 1 diff --git a/testdata/v2.1/service-mix2.yaml b/testdata/v2.1/service-mix2.yaml new file mode 100644 index 00000000..7109fd46 --- /dev/null +++ b/testdata/v2.1/service-mix2.yaml @@ -0,0 +1,69 @@ +--- +version: "2.1" +services: + svca: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + svcb: + image: nginx + expose: + - port: 80 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + +profiles: + compute: + profilea: + resources: + cpu: + units: "100m" + gpu: + units: "1" + attributes: + vendor: + nvidia: + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + profilea: + denom: uakt + amount: 50 + +deployment: + svca: + westcoast: + profile: profilea + count: 1 + svcb: + westcoast: + profile: profilea + count: 1 diff --git a/testdata/v2.1/shared-ip-endpoint.yaml b/testdata/v2.1/shared-ip-endpoint.yaml new file mode 100644 index 00000000..09555f76 --- /dev/null +++ b/testdata/v2.1/shared-ip-endpoint.yaml @@ -0,0 +1,55 @@ +--- +version: "2.1" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + as: 81 + to: + - global: true + ip: "meow" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + global: + profile: web + count: 3 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2.1/simple-gpu.yaml b/testdata/v2.1/simple-gpu.yaml new file mode 100644 index 00000000..cc50fd82 --- /dev/null +++ b/testdata/v2.1/simple-gpu.yaml @@ -0,0 +1,52 @@ +--- +version: "2.1" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + gpu: + units: 1 + attributes: + vendor: + nvidia: + - model: a100 + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2.1/simple-with-ip.yaml b/testdata/v2.1/simple-with-ip.yaml new file mode 100644 index 00000000..4121c0e5 --- /dev/null +++ b/testdata/v2.1/simple-with-ip.yaml @@ -0,0 +1,50 @@ +--- +version: "2.1" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + ip: "meow" + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2.1/simple.yaml b/testdata/v2.1/simple.yaml new file mode 100644 index 00000000..dc1ac315 --- /dev/null +++ b/testdata/v2.1/simple.yaml @@ -0,0 +1,45 @@ +--- +version: "2.1" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2.1/simple2.yaml b/testdata/v2.1/simple2.yaml new file mode 100644 index 00000000..08dfa81c --- /dev/null +++ b/testdata/v2.1/simple2.yaml @@ -0,0 +1,64 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + bew: + image: nginx + expose: + - port: 8080 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + - port: 12347 + to: + - global: true + proto: udp +profiles: + compute: + bew: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 + bew: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: bew + count: 2 diff --git a/testdata/v2.1/simple3.yaml b/testdata/v2.1/simple3.yaml new file mode 100644 index 00000000..b4d8713a --- /dev/null +++ b/testdata/v2.1/simple3.yaml @@ -0,0 +1,45 @@ +--- +version: "2.1" + +services: + app: + image: ubuntu:22.04 + command: + - "sh" + - "-c" + args: + - 'sleep infinity' + expose: + - port: 80 + as: 80 + to: + - global: true + - port: 22 + as: 22 + to: + - global: true + +profiles: + compute: + app: + resources: + cpu: + units: 1 + memory: + size: 2Gi + storage: + size: 10Gi + placement: + akash: + attributes: + host: akash + pricing: + app: + denom: uakt + amount: 1000000 + +deployment: + app: + akash: + profile: app + count: 1 diff --git a/testdata/v2.1/simple4.yaml b/testdata/v2.1/simple4.yaml new file mode 100644 index 00000000..6a899a90 --- /dev/null +++ b/testdata/v2.1/simple4.yaml @@ -0,0 +1,90 @@ +--- +version: '2.1' +services: + wordpress: + image: wordpress + depends_on: + - db + expose: + - port: 80 + http_options: + max_body_size: 104857600 + # accept: + # - "example.com" + to: + - global: true + env: + - WORDPRESS_DB_HOST=db + - WORDPRESS_DB_USER=wordpress + - WORDPRESS_DB_PASSWORD=testpass4you + - WORDPRESS_DB_NAME=wordpress + params: + storage: + wordpress-data: + mount: /var/www/html + readOnly: false + db: + # We use a mariadb image which supports both amd64 & arm64 architecture + image: mariadb:10.6.4 + # If you really want to use MySQL, uncomment the following line + #image: mysql:8.0.27 + expose: + - port: 3306 + to: + - service: wordpress + env: + - MYSQL_RANDOM_ROOT_PASSWORD=1 + - MYSQL_DATABASE=wordpress + - MYSQL_USER=wordpress + - MYSQL_PASSWORD=testpass4you + params: + storage: + wordpress-db: + mount: /var/lib/mysql + readOnly: false +profiles: + compute: + wordpress: + resources: + cpu: + units: 1 + memory: + size: 1Gi + storage: + - size: 1Gi + - name: wordpress-data + size: 1Gi + attributes: + persistent: true + class: beta3 + db: + resources: + cpu: + units: 1 + memory: + size: 1Gi + storage: + - size: 1Gi + - name: wordpress-db + size: 1Gi + attributes: + persistent: true + class: beta3 + placement: + akash: + pricing: + wordpress: + denom: uakt + amount: 10000 + db: + denom: uakt + amount: 10000 +deployment: + wordpress: + akash: + profile: wordpress + count: 1 + db: + akash: + profile: db + count: 1 diff --git a/testdata/v2.1/svc-mismatch.yaml b/testdata/v2.1/svc-mismatch.yaml new file mode 100644 index 00000000..59e98e00 --- /dev/null +++ b/testdata/v2.1/svc-mismatch.yaml @@ -0,0 +1,45 @@ +--- +version: "2.1" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + webapp: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2/deployment-svc-mismatch.yaml b/testdata/v2/deployment-svc-mismatch.yaml new file mode 100644 index 00000000..6bb33b41 --- /dev/null +++ b/testdata/v2/deployment-svc-mismatch.yaml @@ -0,0 +1,45 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + webapp: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2/deployment-v2-c2c.yaml b/testdata/v2/deployment-v2-c2c.yaml new file mode 100644 index 00000000..4c07ca62 --- /dev/null +++ b/testdata/v2/deployment-v2-c2c.yaml @@ -0,0 +1,58 @@ +--- +version: "2.0" + +services: + web: + image: anapsix/webdis + env: + - REDIS_HOST=redis-server + expose: + - port: 7379 + as: 80 + to: + - global: true + accept: + - webdistest.localhost + + redis-server: + image: redis:rc-alpine3.12 + expose: + - port: 6379 + +profiles: + compute: + web: + resources: + cpu: + units: 0.1 + memory: + size: 16Mi + storage: + size: 128Mi + redis-server: + resources: + cpu: + units: 0.1 + memory: + size: 64Mi + storage: + size: 128Mi + placement: + global: + pricing: + web: + denom: uakt + amount: 9000 + redis-server: + denom: uakt + amount: 9000 + +deployment: + web: + global: + profile: web + count: 1 + redis-server: + global: + profile: redis-server + count: 1 diff --git a/testdata/v2/deployment-v2-escrow.yaml b/testdata/v2/deployment-v2-escrow.yaml new file mode 100644 index 00000000..cd3fa439 --- /dev/null +++ b/testdata/v2/deployment-v2-escrow.yaml @@ -0,0 +1,58 @@ +--- +version: "2.0" + +services: + web: + image: anapsix/webdis + env: + - REDIS_HOST=redis-server + expose: + - port: 7379 + as: 80 + to: + - global: true + accept: + - webdistest.localhost + + redis-server: + image: redis:rc-alpine3.12 + expose: + - port: 6379 + +profiles: + compute: + web: + resources: + cpu: + units: 0.1 + memory: + size: 16Mi + storage: + size: 128Mi + redis-server: + resources: + cpu: + units: 0.1 + memory: + size: 64Mi + storage: + size: 128Mi + placement: + global: + pricing: + web: + denom: uakt + amount: 10000000 + redis-server: + denom: uakt + amount: 10000000 + +deployment: + web: + global: + profile: web + count: 1 + redis-server: + global: + profile: redis-server + count: 1 diff --git a/testdata/v2/deployment-v2-ip-endpoint.yaml b/testdata/v2/deployment-v2-ip-endpoint.yaml new file mode 100644 index 00000000..0727d61d --- /dev/null +++ b/testdata/v2/deployment-v2-ip-endpoint.yaml @@ -0,0 +1,41 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2/deployment-v2-migrate.yaml b/testdata/v2/deployment-v2-migrate.yaml new file mode 100644 index 00000000..3b9492b3 --- /dev/null +++ b/testdata/v2/deployment-v2-migrate.yaml @@ -0,0 +1,37 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - leaveme.com + - migrateme.com + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-multi-groups-ip-endpoint.yaml b/testdata/v2/deployment-v2-multi-groups-ip-endpoint.yaml new file mode 100644 index 00000000..8cf888c2 --- /dev/null +++ b/testdata/v2/deployment-v2-multi-groups-ip-endpoint.yaml @@ -0,0 +1,69 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "kittens" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + bob: + resources: + cpu: + units: "0.13" + memory: + size: "256Mi" + storage: + size: "99Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + bob: + pricing: + bob: + denom: uakt + amount: 99 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + bob: + profile: bob + count: 3 + +endpoints: + meow: + kind: "ip" + kittens: + kind: "ip" diff --git a/testdata/v2/deployment-v2-multi-ip-endpoint.yaml b/testdata/v2/deployment-v2-multi-ip-endpoint.yaml new file mode 100644 index 00000000..33ca42e0 --- /dev/null +++ b/testdata/v2/deployment-v2-multi-ip-endpoint.yaml @@ -0,0 +1,56 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "kittens" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + global: + profile: web + count: 3 + +endpoints: + meow: + kind: "ip" + kittens: + kind: "ip" diff --git a/testdata/v2/deployment-v2-newcontainer.yaml b/testdata/v2/deployment-v2-newcontainer.yaml new file mode 100644 index 00000000..2d3911c3 --- /dev/null +++ b/testdata/v2/deployment-v2-newcontainer.yaml @@ -0,0 +1,36 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-nodeport.yaml b/testdata/v2/deployment-v2-nodeport.yaml new file mode 100644 index 00000000..ac5ad0b0 --- /dev/null +++ b/testdata/v2/deployment-v2-nodeport.yaml @@ -0,0 +1,39 @@ +--- +version: "2.0" + +services: + web: + image: hydrogen18/hello_world:20201209 + expose: + - port: 10000 + as: 10000 + to: + - global: true + - port: 10000 + as: 10000 + proto: UDP + to: + - global: true + +profiles: + compute: + web: + resources: + cpu: + units: 0.1 + memory: + size: 16Mi + storage: + size: 128Mi + placement: + global: + pricing: + web: + denom: uakt + amount: 9000 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-nohost.yaml b/testdata/v2/deployment-v2-nohost.yaml new file mode 100644 index 00000000..195e7fa7 --- /dev/null +++ b/testdata/v2/deployment-v2-nohost.yaml @@ -0,0 +1,34 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-shared-ip-endpoint.yaml b/testdata/v2/deployment-v2-shared-ip-endpoint.yaml new file mode 100644 index 00000000..a9214b27 --- /dev/null +++ b/testdata/v2/deployment-v2-shared-ip-endpoint.yaml @@ -0,0 +1,55 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + ip: "meow" + accept: + - test.localhost + anotherweb: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + as: 81 + to: + - global: true + ip: "meow" + accept: + - extratest.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 + anotherweb: + global: + profile: web + count: 3 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2/deployment-v2-storage-beta2.yaml b/testdata/v2/deployment-v2-storage-beta2.yaml new file mode 100644 index 00000000..5607d798 --- /dev/null +++ b/testdata/v2/deployment-v2-storage-beta2.yaml @@ -0,0 +1,42 @@ +--- +version: "2.0" +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 8080 + as: 80 + to: + - global: true + accept: + - webdistest.localhost + params: + storage: + data: + mount: /var/lib/demo-app +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + - size: "512Mi" + - name: data + size: "128Mi" + attributes: + persistent: "true" + class: beta2 + placement: + global: + pricing: + web: + denom: uakt + amount: 10 +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-storage-default.yaml b/testdata/v2/deployment-v2-storage-default.yaml new file mode 100644 index 00000000..569b60f3 --- /dev/null +++ b/testdata/v2/deployment-v2-storage-default.yaml @@ -0,0 +1,40 @@ +version: "2.0" +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 8080 + as: 80 + to: + - global: true + accept: + - webdistest.localhost + params: + storage: + data: + mount: "/var/lib/demo-app/data" +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + - size: "512Mi" + - name: data + size: "128Mi" + attributes: + persistent: "true" + placement: + global: + pricing: + web: + denom: uakt + amount: 10 +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-storage-updateC.yaml b/testdata/v2/deployment-v2-storage-updateC.yaml new file mode 100644 index 00000000..4abdca3e --- /dev/null +++ b/testdata/v2/deployment-v2-storage-updateC.yaml @@ -0,0 +1,43 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - testupdatea.localhost + - testupdateb.localhost + params: + storage: + data: + mount: /var/lib/e2e-test +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + - size: "512Mi" + - name: data + size: "256Mi" + attributes: + persistent: "true" + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-updateA.yaml b/testdata/v2/deployment-v2-updateA.yaml new file mode 100644 index 00000000..cd47a4be --- /dev/null +++ b/testdata/v2/deployment-v2-updateA.yaml @@ -0,0 +1,36 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - testupdatea.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2-updateB.yaml b/testdata/v2/deployment-v2-updateB.yaml new file mode 100644 index 00000000..6e480e66 --- /dev/null +++ b/testdata/v2/deployment-v2-updateB.yaml @@ -0,0 +1,37 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - testupdatea.localhost + - testupdateb.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment-v2.yaml b/testdata/v2/deployment-v2.yaml new file mode 100644 index 00000000..2d3911c3 --- /dev/null +++ b/testdata/v2/deployment-v2.yaml @@ -0,0 +1,36 @@ +--- +version: "2.0" + +services: + web: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + to: + - global: true + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 10 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/deployment.yaml b/testdata/v2/deployment.yaml new file mode 100644 index 00000000..f653f4c6 --- /dev/null +++ b/testdata/v2/deployment.yaml @@ -0,0 +1,36 @@ +--- +version: "2.0" + +services: + web: + image: bubuntux/riot-web + expose: + - port: 80 + to: + - global: true + accept: + - test.localhost + +profiles: + compute: + web: + resources: + cpu: + units: "0.01" + memory: + size: "128Mi" + storage: + size: "512Mi" + + placement: + global: + pricing: + web: + denom: uakt + amount: 30 + +deployment: + web: + global: + profile: web + count: 1 diff --git a/testdata/v2/private_service.yaml b/testdata/v2/private_service.yaml new file mode 100644 index 00000000..73db7d96 --- /dev/null +++ b/testdata/v2/private_service.yaml @@ -0,0 +1,64 @@ +--- +version: "2.0" +services: + bind: + image: bind9 + expose: + - port: 53 + proto: udp + to: + - global: true + + pg: + image: postgresql + expose: + - port: 5463 + to: + - service: bind + +profiles: + compute: + bind: + resources: + cpu: + units: "50m" + memory: + size: "64Mi" + storage: + size: "16Mi" + pg: + resources: + cpu: + units: "500m" + memory: + size: "512Mi" + storage: + size: "1000Mi" + + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + pg: + denom: uakt + amount: 1000 + bind: + denom: uakt + amount: 333 +deployment: + pg: + westcoast: + profile: pg + count: 1 + bind: + westcoast: + profile: bind + count: 8 diff --git a/testdata/v2/profile-svc-name-mismatch.yaml b/testdata/v2/profile-svc-name-mismatch.yaml new file mode 100644 index 00000000..ea88ff49 --- /dev/null +++ b/testdata/v2/profile-svc-name-mismatch.yaml @@ -0,0 +1,38 @@ +--- +version: "2.0" + +services: + webapp: + image: ghcr.io/akash-network/demo-app + expose: + - port: 80 + as: 80 + accept: + - thehostname.com + to: + - global: true + +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "512Mi" + storage: + size: "512Mi" + placement: + san-jose: + attributes: + region: sjc + pricing: + web: + denom: uakt + amount: 25 + +deployment: + webapp: + san-jose: + profile: web + count: 1 diff --git a/testdata/v2/service-mix.yaml b/testdata/v2/service-mix.yaml new file mode 100644 index 00000000..51a21a01 --- /dev/null +++ b/testdata/v2/service-mix.yaml @@ -0,0 +1,80 @@ +--- +version: "2.0" +services: + svca: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + svcb: + image: nginx + expose: + - port: 80 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + +profiles: + compute: + profilea: + resources: + cpu: + units: "100m" + gpu: + units: "1" + attributes: + vendor: + nvidia: + memory: + size: "128Mi" + storage: + - size: "1Gi" + profileb: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + profilea: + denom: uakt + amount: 50 + profileb: + denom: uakt + amount: 50 + +deployment: + svca: + westcoast: + profile: profilea + count: 1 + svcb: + westcoast: + profile: profileb + count: 1 diff --git a/testdata/v2/service-mix2.yaml b/testdata/v2/service-mix2.yaml new file mode 100644 index 00000000..3eb556d9 --- /dev/null +++ b/testdata/v2/service-mix2.yaml @@ -0,0 +1,69 @@ +--- +version: "2.0" +services: + svca: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + svcb: + image: nginx + expose: + - port: 80 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + +profiles: + compute: + profilea: + resources: + cpu: + units: "100m" + gpu: + units: "1" + attributes: + vendor: + nvidia: + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + profilea: + denom: uakt + amount: 50 + +deployment: + svca: + westcoast: + profile: profilea + count: 1 + svcb: + westcoast: + profile: profilea + count: 1 diff --git a/testdata/v2/simple-double-ram.yaml b/testdata/v2/simple-double-ram.yaml new file mode 100644 index 00000000..6e1bdb5c --- /dev/null +++ b/testdata/v2/simple-double-ram.yaml @@ -0,0 +1,45 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "256Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2/simple-gpu.yaml b/testdata/v2/simple-gpu.yaml new file mode 100644 index 00000000..84048e6f --- /dev/null +++ b/testdata/v2/simple-gpu.yaml @@ -0,0 +1,52 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + gpu: + units: 1 + attributes: + vendor: + nvidia: + - model: a100 + memory: + size: "128Mi" + storage: + - size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + blalbla: foo + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2/simple-with-ip.yaml b/testdata/v2/simple-with-ip.yaml new file mode 100644 index 00000000..4308f095 --- /dev/null +++ b/testdata/v2/simple-with-ip.yaml @@ -0,0 +1,50 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + ip: "meow" + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 + +endpoints: + meow: + kind: "ip" diff --git a/testdata/v2/simple.yaml b/testdata/v2/simple.yaml new file mode 100644 index 00000000..d164e60e --- /dev/null +++ b/testdata/v2/simple.yaml @@ -0,0 +1,45 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 2 diff --git a/testdata/v2/simple2.yaml b/testdata/v2/simple2.yaml new file mode 100644 index 00000000..08dfa81c --- /dev/null +++ b/testdata/v2/simple2.yaml @@ -0,0 +1,64 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + bew: + image: nginx + expose: + - port: 8080 + accept: + - bhostname.com + to: + - global: true + - port: 12346 + to: + - global: true + proto: udp + - port: 12347 + to: + - global: true + proto: udp +profiles: + compute: + bew: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + size: "1Gi" + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 + bew: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: bew + count: 2 diff --git a/testdata/v2/simple3.yaml b/testdata/v2/simple3.yaml new file mode 100644 index 00000000..9e016208 --- /dev/null +++ b/testdata/v2/simple3.yaml @@ -0,0 +1,45 @@ +--- +version: "2.0" + +services: + app: + image: ubuntu:22.04 + command: + - "sh" + - "-c" + args: + - 'sleep infinity' + expose: + - port: 80 + as: 80 + to: + - global: true + - port: 22 + as: 22 + to: + - global: true + +profiles: + compute: + app: + resources: + cpu: + units: 1 + memory: + size: 2Gi + storage: + size: 10Gi + placement: + akash: + attributes: + host: akash + pricing: + app: + denom: uakt + amount: 1000000 + +deployment: + app: + akash: + profile: app + count: 1 diff --git a/testdata/v2/simple4.yaml b/testdata/v2/simple4.yaml new file mode 100644 index 00000000..1f555485 --- /dev/null +++ b/testdata/v2/simple4.yaml @@ -0,0 +1,90 @@ +--- +version: '2.0' +services: + wordpress: + image: wordpress + depends_on: + - db + expose: + - port: 80 + http_options: + max_body_size: 104857600 + # accept: + # - "example.com" + to: + - global: true + env: + - WORDPRESS_DB_HOST=db + - WORDPRESS_DB_USER=wordpress + - WORDPRESS_DB_PASSWORD=testpass4you + - WORDPRESS_DB_NAME=wordpress + params: + storage: + wordpress-data: + mount: /var/www/html + readOnly: false + db: + # We use a mariadb image which supports both amd64 & arm64 architecture + image: mariadb:10.6.4 + # If you really want to use MySQL, uncomment the following line + #image: mysql:8.0.27 + expose: + - port: 3306 + to: + - service: wordpress + env: + - MYSQL_RANDOM_ROOT_PASSWORD=1 + - MYSQL_DATABASE=wordpress + - MYSQL_USER=wordpress + - MYSQL_PASSWORD=testpass4you + params: + storage: + wordpress-db: + mount: /var/lib/mysql + readOnly: false +profiles: + compute: + wordpress: + resources: + cpu: + units: 1 + memory: + size: 1Gi + storage: + - size: 1Gi + - name: wordpress-data + size: 1Gi + attributes: + persistent: true + class: beta3 + db: + resources: + cpu: + units: 1 + memory: + size: 1Gi + storage: + - size: 1Gi + - name: wordpress-db + size: 1Gi + attributes: + persistent: true + class: beta3 + placement: + akash: + pricing: + wordpress: + denom: uakt + amount: 10000 + db: + denom: uakt + amount: 10000 +deployment: + wordpress: + akash: + profile: wordpress + count: 1 + db: + akash: + profile: db + count: 1 diff --git a/testdata/v2/storageClass1.yaml b/testdata/v2/storageClass1.yaml new file mode 100644 index 00000000..695e0b64 --- /dev/null +++ b/testdata/v2/storageClass1.yaml @@ -0,0 +1,52 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: + configs: +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: "1Gi" + - size: 1Gi + name: configs + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1 diff --git a/testdata/v2/storageClass2.yaml b/testdata/v2/storageClass2.yaml new file mode 100644 index 00000000..5f907cf0 --- /dev/null +++ b/testdata/v2/storageClass2.yaml @@ -0,0 +1,53 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: + configs: + mount: etc/nginx +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: 1Gi + - size: 1Gi + name: configs + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1 diff --git a/testdata/v2/storageClass3.yaml b/testdata/v2/storageClass3.yaml new file mode 100644 index 00000000..1e0bae8e --- /dev/null +++ b/testdata/v2/storageClass3.yaml @@ -0,0 +1,52 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: + data: +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: 1Gi + - size: 1Gi + name: configs + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1 diff --git a/testdata/v2/storageClass4.yaml b/testdata/v2/storageClass4.yaml new file mode 100644 index 00000000..5ca8af53 --- /dev/null +++ b/testdata/v2/storageClass4.yaml @@ -0,0 +1,59 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: + config: + mount: /etc/nginx + data: + mount: /etc/nginx +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: 1Gi + - size: 1Gi + name: config + attributes: + persistent: true + - size: 1Gi + name: data + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1 diff --git a/testdata/v2/storageClass5.yaml b/testdata/v2/storageClass5.yaml new file mode 100644 index 00000000..5c280bb1 --- /dev/null +++ b/testdata/v2/storageClass5.yaml @@ -0,0 +1,51 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: "1Gi" + - size: 1Gi + name: configs + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1 diff --git a/testdata/v2/storageClass6.yaml b/testdata/v2/storageClass6.yaml new file mode 100644 index 00000000..fccfb944 --- /dev/null +++ b/testdata/v2/storageClass6.yaml @@ -0,0 +1,53 @@ +--- +version: "2.0" +services: + web: + image: nginx + expose: + - port: 80 + accept: + - ahostname.com + to: + - global: true + - port: 12345 + to: + - global: true + proto: udp + params: + storage: + configs: + mount: /test +profiles: + compute: + web: + resources: + cpu: + units: "100m" + memory: + size: "128Mi" + storage: + - size: "1Gi" + - size: 1Gi + name: configs + attributes: + persistent: true + placement: + westcoast: + attributes: + region: us-west + signedBy: + anyOf: + - 1 + - 2 + allOf: + - 3 + - 4 + pricing: + web: + denom: uakt + amount: 50 +deployment: + web: + westcoast: + profile: web + count: 1