diff --git a/.kres.yaml b/.kres.yaml index 5ff13463..8a07070a 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -74,7 +74,7 @@ spec: COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 GO_LDFLAGS="$(GO_LDFLAGS)" - docker compose --file ./hack/compose/docker-compose.yml --file ./hack/compose/docker-compose.override.yml up --it -d --build + docker compose --file ./hack/compose/docker-compose.yml --file ./hack/compose/docker-compose.override.yml up --build --- kind: custom.Step name: mkcert-generate @@ -351,8 +351,8 @@ spec: - source: client/api/omni/specs/auth.proto subdirectory: omni/specs genGateway: true - - source: client/api/omni/specs/cloud/cloud.proto - subdirectory: omni/specs/cloud + - source: client/api/omni/specs/infra/infra.proto + subdirectory: omni/specs/infra genGateway: true - source: client/api/omni/specs/virtual.proto subdirectory: omni/specs @@ -443,8 +443,8 @@ spec: - source: client/api/omni/specs/auth.proto subdirectory: omni/specs genGateway: true - - source: client/api/omni/specs/cloud/cloud.proto - subdirectory: omni/specs/cloud + - source: client/api/omni/specs/infra/infra.proto + subdirectory: omni/specs/infra genGateway: true - source: client/api/omni/specs/virtual.proto subdirectory: omni/specs diff --git a/Dockerfile b/Dockerfile index 4c12160f..87bcdb61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-08-19T16:13:30Z by kres 7be2a05. +# Generated on 2024-08-30T15:41:41Z by kres b5ca957. ARG JS_TOOLCHAIN ARG TOOLCHAIN @@ -20,7 +20,7 @@ ENV GOPATH=/go ENV PATH=${PATH}:/usr/local/go/bin # runs markdownlint -FROM docker.io/oven/bun:1.1.22-alpine AS lint-markdown +FROM docker.io/oven/bun:1.1.26-alpine AS lint-markdown WORKDIR /src RUN bun i markdownlint-cli@0.41.0 sentences-per-line@0.2.1 COPY .markdownlint.json . @@ -38,7 +38,7 @@ ADD client/api/omni/resources/resources.proto /client/api/omni/resources/ ADD client/api/omni/management/management.proto /client/api/omni/management/ ADD client/api/omni/oidc/oidc.proto /client/api/omni/oidc/ ADD client/api/omni/specs/auth.proto /client/api/omni/specs/ -ADD client/api/omni/specs/cloud/cloud.proto /client/api/omni/specs/cloud/ +ADD client/api/omni/specs/infra/infra.proto /client/api/omni/specs/infra/ ADD client/api/omni/specs/virtual.proto /client/api/omni/specs/ ADD client/api/omni/specs/ephemeral.proto /client/api/omni/specs/ ADD client/api/omni/specs/oidc.proto /client/api/omni/specs/ @@ -61,7 +61,7 @@ ADD client/api/omni/specs/omni.proto /frontend/src/api/omni/specs/ ADD client/api/omni/specs/siderolink.proto /frontend/src/api/omni/specs/ ADD client/api/omni/specs/system.proto /frontend/src/api/omni/specs/ ADD client/api/omni/specs/auth.proto /frontend/src/api/omni/specs/ -ADD client/api/omni/specs/cloud/cloud.proto /frontend/src/api/omni/specs/cloud/ +ADD client/api/omni/specs/infra/infra.proto /frontend/src/api/omni/specs/infra/ ADD client/api/omni/specs/virtual.proto /frontend/src/api/omni/specs/ ADD client/api/omni/specs/ephemeral.proto /frontend/src/api/omni/specs/ ADD https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/status.proto /frontend/src/api/google/rpc/ @@ -156,7 +156,7 @@ RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/s RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/siderolink.proto RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/system.proto RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/auth.proto -RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/cloud/cloud.proto +RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/infra/infra.proto RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/virtual.proto RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/omni/specs/ephemeral.proto RUN protoc -I/frontend/src/api --grpc-gateway-ts_out=source_relative:/frontend/src/api --grpc-gateway-ts_opt=use_proto_names=true /frontend/src/api/google/rpc/status.proto @@ -176,7 +176,7 @@ RUN rm /frontend/src/api/omni/specs/omni.proto RUN rm /frontend/src/api/omni/specs/siderolink.proto RUN rm /frontend/src/api/omni/specs/system.proto RUN rm /frontend/src/api/omni/specs/auth.proto -RUN rm /frontend/src/api/omni/specs/cloud/cloud.proto +RUN rm /frontend/src/api/omni/specs/infra/infra.proto RUN rm /frontend/src/api/omni/specs/virtual.proto RUN rm /frontend/src/api/omni/specs/ephemeral.proto @@ -197,14 +197,14 @@ RUN mkdir -p internal/version/data && \ FROM tools AS proto-compile COPY --from=proto-specs / / RUN protoc -I/client/api --go_out=paths=source_relative:/client/api --go-grpc_out=paths=source_relative:/client/api --go-vtproto_out=paths=source_relative:/client/api --go-vtproto_opt=features=marshal+unmarshal+size+equal+clone /client/api/common/omni.proto -RUN protoc -I/client/api --grpc-gateway_out=paths=source_relative:/client/api --grpc-gateway_opt=generate_unbound_methods=true --go_out=paths=source_relative:/client/api --go-grpc_out=paths=source_relative:/client/api --go-vtproto_out=paths=source_relative:/client/api --go-vtproto_opt=features=marshal+unmarshal+size+equal+clone /client/api/omni/resources/resources.proto /client/api/omni/management/management.proto /client/api/omni/oidc/oidc.proto /client/api/omni/specs/auth.proto /client/api/omni/specs/cloud/cloud.proto /client/api/omni/specs/virtual.proto /client/api/omni/specs/ephemeral.proto /client/api/omni/specs/oidc.proto /client/api/omni/specs/omni.proto /client/api/omni/specs/siderolink.proto /client/api/omni/specs/system.proto +RUN protoc -I/client/api --grpc-gateway_out=paths=source_relative:/client/api --grpc-gateway_opt=generate_unbound_methods=true --go_out=paths=source_relative:/client/api --go-grpc_out=paths=source_relative:/client/api --go-vtproto_out=paths=source_relative:/client/api --go-vtproto_opt=features=marshal+unmarshal+size+equal+clone /client/api/omni/resources/resources.proto /client/api/omni/management/management.proto /client/api/omni/oidc/oidc.proto /client/api/omni/specs/auth.proto /client/api/omni/specs/infra/infra.proto /client/api/omni/specs/virtual.proto /client/api/omni/specs/ephemeral.proto /client/api/omni/specs/oidc.proto /client/api/omni/specs/omni.proto /client/api/omni/specs/siderolink.proto /client/api/omni/specs/system.proto RUN protoc -I/client/api --grpc-gateway_out=paths=source_relative:/client/api --grpc-gateway_opt=generate_unbound_methods=true --grpc-gateway_opt=standalone=true /client/api/google/rpc/status.proto /client/api/common/common.proto /client/api/talos/machine/machine.proto /client/api/v1alpha1/resource.proto RUN rm /client/api/common/omni.proto RUN rm /client/api/omni/resources/resources.proto RUN rm /client/api/omni/management/management.proto RUN rm /client/api/omni/oidc/oidc.proto RUN rm /client/api/omni/specs/auth.proto -RUN rm /client/api/omni/specs/cloud/cloud.proto +RUN rm /client/api/omni/specs/infra/infra.proto RUN rm /client/api/omni/specs/virtual.proto RUN rm /client/api/omni/specs/ephemeral.proto RUN rm /client/api/omni/specs/oidc.proto diff --git a/Makefile b/Makefile index b5dbf3e0..7d9cfc1a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-08-19T16:13:30Z by kres 7be2a05. +# Generated on 2024-08-30T15:41:41Z by kres b5ca957. # common variables @@ -22,12 +22,12 @@ TESTPKGS ?= ./... JS_BUILD_ARGS ?= PROTOBUF_GO_VERSION ?= 1.34.2 GRPC_GO_VERSION ?= 1.5.1 -GRPC_GATEWAY_VERSION ?= 2.21.0 +GRPC_GATEWAY_VERSION ?= 2.22.0 VTPROTOBUF_VERSION ?= 0.6.0 GOIMPORTS_VERSION ?= 0.24.0 DEEPCOPY_VERSION ?= v0.5.6 -GOLANGCILINT_VERSION ?= v1.60.1 -GOFUMPT_VERSION ?= v0.6.0 +GOLANGCILINT_VERSION ?= v1.60.3 +GOFUMPT_VERSION ?= v0.7.0 GO_VERSION ?= 1.23.0 GO_BUILDFLAGS ?= GO_LDFLAGS ?= @@ -72,7 +72,7 @@ COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)" COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)" COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)" COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)" -JS_TOOLCHAIN ?= docker.io/oven/bun:1.1.22-alpine +JS_TOOLCHAIN ?= docker.io/oven/bun:1.1.26-alpine TOOLCHAIN ?= docker.io/golang:1.23-alpine # extra variables diff --git a/client/api/omni/specs/cloud/cloud.pb.go b/client/api/omni/specs/infra/infra.pb.go similarity index 76% rename from client/api/omni/specs/cloud/cloud.pb.go rename to client/api/omni/specs/infra/infra.pb.go index 607cd496..cecc923c 100644 --- a/client/api/omni/specs/cloud/cloud.pb.go +++ b/client/api/omni/specs/infra/infra.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.34.2 // protoc v4.24.4 -// source: omni/specs/cloud/cloud.proto +// source: omni/specs/infra/infra.proto -package cloudspecs +package infra import ( reflect "reflect" @@ -57,11 +57,11 @@ func (x MachineRequestStatusSpec_Stage) String() string { } func (MachineRequestStatusSpec_Stage) Descriptor() protoreflect.EnumDescriptor { - return file_omni_specs_cloud_cloud_proto_enumTypes[0].Descriptor() + return file_omni_specs_infra_infra_proto_enumTypes[0].Descriptor() } func (MachineRequestStatusSpec_Stage) Type() protoreflect.EnumType { - return &file_omni_specs_cloud_cloud_proto_enumTypes[0] + return &file_omni_specs_infra_infra_proto_enumTypes[0] } func (x MachineRequestStatusSpec_Stage) Number() protoreflect.EnumNumber { @@ -70,7 +70,7 @@ func (x MachineRequestStatusSpec_Stage) Number() protoreflect.EnumNumber { // Deprecated: Use MachineRequestStatusSpec_Stage.Descriptor instead. func (MachineRequestStatusSpec_Stage) EnumDescriptor() ([]byte, []int) { - return file_omni_specs_cloud_cloud_proto_rawDescGZIP(), []int{1, 0} + return file_omni_specs_infra_infra_proto_rawDescGZIP(), []int{1, 0} } type MachineRequestSpec struct { @@ -85,7 +85,7 @@ type MachineRequestSpec struct { func (x *MachineRequestSpec) Reset() { *x = MachineRequestSpec{} if protoimpl.UnsafeEnabled { - mi := &file_omni_specs_cloud_cloud_proto_msgTypes[0] + mi := &file_omni_specs_infra_infra_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +98,7 @@ func (x *MachineRequestSpec) String() string { func (*MachineRequestSpec) ProtoMessage() {} func (x *MachineRequestSpec) ProtoReflect() protoreflect.Message { - mi := &file_omni_specs_cloud_cloud_proto_msgTypes[0] + mi := &file_omni_specs_infra_infra_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +111,7 @@ func (x *MachineRequestSpec) ProtoReflect() protoreflect.Message { // Deprecated: Use MachineRequestSpec.ProtoReflect.Descriptor instead. func (*MachineRequestSpec) Descriptor() ([]byte, []int) { - return file_omni_specs_cloud_cloud_proto_rawDescGZIP(), []int{0} + return file_omni_specs_infra_infra_proto_rawDescGZIP(), []int{0} } func (x *MachineRequestSpec) GetTalosVersion() string { @@ -141,7 +141,7 @@ type MachineRequestStatusSpec struct { func (x *MachineRequestStatusSpec) Reset() { *x = MachineRequestStatusSpec{} if protoimpl.UnsafeEnabled { - mi := &file_omni_specs_cloud_cloud_proto_msgTypes[1] + mi := &file_omni_specs_infra_infra_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -154,7 +154,7 @@ func (x *MachineRequestStatusSpec) String() string { func (*MachineRequestStatusSpec) ProtoMessage() {} func (x *MachineRequestStatusSpec) ProtoReflect() protoreflect.Message { - mi := &file_omni_specs_cloud_cloud_proto_msgTypes[1] + mi := &file_omni_specs_infra_infra_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -167,7 +167,7 @@ func (x *MachineRequestStatusSpec) ProtoReflect() protoreflect.Message { // Deprecated: Use MachineRequestStatusSpec.ProtoReflect.Descriptor instead. func (*MachineRequestStatusSpec) Descriptor() ([]byte, []int) { - return file_omni_specs_cloud_cloud_proto_rawDescGZIP(), []int{1} + return file_omni_specs_infra_infra_proto_rawDescGZIP(), []int{1} } func (x *MachineRequestStatusSpec) GetId() string { @@ -191,11 +191,11 @@ func (x *MachineRequestStatusSpec) GetError() string { return "" } -var File_omni_specs_cloud_cloud_proto protoreflect.FileDescriptor +var File_omni_specs_infra_infra_proto protoreflect.FileDescriptor -var file_omni_specs_cloud_cloud_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x6f, 0x6d, 0x6e, 0x69, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2f, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, +var file_omni_specs_infra_infra_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x6f, 0x6d, 0x6e, 0x69, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2f, 0x69, 0x6e, 0x66, + 0x72, 0x61, 0x2f, 0x69, 0x6e, 0x66, 0x72, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x73, 0x70, 0x65, 0x63, 0x73, 0x22, 0x5c, 0x0a, 0x12, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x70, 0x65, 0x63, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x61, 0x6c, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, @@ -214,33 +214,33 @@ var file_omni_specs_cloud_cloud_proto_rawDesc = []byte{ 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, + 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x69, 0x64, 0x65, 0x72, 0x6f, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6f, 0x6d, 0x6e, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, - 0x69, 0x2f, 0x6f, 0x6d, 0x6e, 0x69, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2f, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x73, 0x70, 0x65, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x2f, 0x6f, 0x6d, 0x6e, 0x69, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2f, 0x69, 0x6e, 0x66, + 0x72, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_omni_specs_cloud_cloud_proto_rawDescOnce sync.Once - file_omni_specs_cloud_cloud_proto_rawDescData = file_omni_specs_cloud_cloud_proto_rawDesc + file_omni_specs_infra_infra_proto_rawDescOnce sync.Once + file_omni_specs_infra_infra_proto_rawDescData = file_omni_specs_infra_infra_proto_rawDesc ) -func file_omni_specs_cloud_cloud_proto_rawDescGZIP() []byte { - file_omni_specs_cloud_cloud_proto_rawDescOnce.Do(func() { - file_omni_specs_cloud_cloud_proto_rawDescData = protoimpl.X.CompressGZIP(file_omni_specs_cloud_cloud_proto_rawDescData) +func file_omni_specs_infra_infra_proto_rawDescGZIP() []byte { + file_omni_specs_infra_infra_proto_rawDescOnce.Do(func() { + file_omni_specs_infra_infra_proto_rawDescData = protoimpl.X.CompressGZIP(file_omni_specs_infra_infra_proto_rawDescData) }) - return file_omni_specs_cloud_cloud_proto_rawDescData + return file_omni_specs_infra_infra_proto_rawDescData } -var file_omni_specs_cloud_cloud_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_omni_specs_cloud_cloud_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_omni_specs_cloud_cloud_proto_goTypes = []any{ +var file_omni_specs_infra_infra_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_omni_specs_infra_infra_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_omni_specs_infra_infra_proto_goTypes = []any{ (MachineRequestStatusSpec_Stage)(0), // 0: specs.MachineRequestStatusSpec.Stage (*MachineRequestSpec)(nil), // 1: specs.MachineRequestSpec (*MachineRequestStatusSpec)(nil), // 2: specs.MachineRequestStatusSpec } -var file_omni_specs_cloud_cloud_proto_depIdxs = []int32{ +var file_omni_specs_infra_infra_proto_depIdxs = []int32{ 0, // 0: specs.MachineRequestStatusSpec.stage:type_name -> specs.MachineRequestStatusSpec.Stage 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type @@ -249,13 +249,13 @@ var file_omni_specs_cloud_cloud_proto_depIdxs = []int32{ 0, // [0:1] is the sub-list for field type_name } -func init() { file_omni_specs_cloud_cloud_proto_init() } -func file_omni_specs_cloud_cloud_proto_init() { - if File_omni_specs_cloud_cloud_proto != nil { +func init() { file_omni_specs_infra_infra_proto_init() } +func file_omni_specs_infra_infra_proto_init() { + if File_omni_specs_infra_infra_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_omni_specs_cloud_cloud_proto_msgTypes[0].Exporter = func(v any, i int) any { + file_omni_specs_infra_infra_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*MachineRequestSpec); i { case 0: return &v.state @@ -267,7 +267,7 @@ func file_omni_specs_cloud_cloud_proto_init() { return nil } } - file_omni_specs_cloud_cloud_proto_msgTypes[1].Exporter = func(v any, i int) any { + file_omni_specs_infra_infra_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*MachineRequestStatusSpec); i { case 0: return &v.state @@ -284,19 +284,19 @@ func file_omni_specs_cloud_cloud_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_omni_specs_cloud_cloud_proto_rawDesc, + RawDescriptor: file_omni_specs_infra_infra_proto_rawDesc, NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_omni_specs_cloud_cloud_proto_goTypes, - DependencyIndexes: file_omni_specs_cloud_cloud_proto_depIdxs, - EnumInfos: file_omni_specs_cloud_cloud_proto_enumTypes, - MessageInfos: file_omni_specs_cloud_cloud_proto_msgTypes, + GoTypes: file_omni_specs_infra_infra_proto_goTypes, + DependencyIndexes: file_omni_specs_infra_infra_proto_depIdxs, + EnumInfos: file_omni_specs_infra_infra_proto_enumTypes, + MessageInfos: file_omni_specs_infra_infra_proto_msgTypes, }.Build() - File_omni_specs_cloud_cloud_proto = out.File - file_omni_specs_cloud_cloud_proto_rawDesc = nil - file_omni_specs_cloud_cloud_proto_goTypes = nil - file_omni_specs_cloud_cloud_proto_depIdxs = nil + File_omni_specs_infra_infra_proto = out.File + file_omni_specs_infra_infra_proto_rawDesc = nil + file_omni_specs_infra_infra_proto_goTypes = nil + file_omni_specs_infra_infra_proto_depIdxs = nil } diff --git a/client/api/omni/specs/cloud/cloud.proto b/client/api/omni/specs/infra/infra.proto similarity index 95% rename from client/api/omni/specs/cloud/cloud.proto rename to client/api/omni/specs/infra/infra.proto index 25a870ec..1901dd9e 100644 --- a/client/api/omni/specs/cloud/cloud.proto +++ b/client/api/omni/specs/infra/infra.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package specs; -option go_package = "github.com/siderolabs/omni/client/api/omni/specs/cloudspecs"; +option go_package = "github.com/siderolabs/omni/client/api/omni/specs/infra"; message MachineRequestSpec { string talos_version = 1; diff --git a/client/api/omni/specs/cloud/cloud_vtproto.pb.go b/client/api/omni/specs/infra/infra_vtproto.pb.go similarity index 99% rename from client/api/omni/specs/cloud/cloud_vtproto.pb.go rename to client/api/omni/specs/infra/infra_vtproto.pb.go index f5906114..a6df2914 100644 --- a/client/api/omni/specs/cloud/cloud_vtproto.pb.go +++ b/client/api/omni/specs/infra/infra_vtproto.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. // protoc-gen-go-vtproto version: v0.6.0 -// source: omni/specs/cloud/cloud.proto +// source: omni/specs/infra/infra.proto -package cloudspecs +package infra import ( fmt "fmt" diff --git a/client/pkg/access/serviceaccount.go b/client/pkg/access/serviceaccount.go index 76f4130b..fb632136 100644 --- a/client/pkg/access/serviceaccount.go +++ b/client/pkg/access/serviceaccount.go @@ -8,16 +8,16 @@ import "strings" const ( serviceAccountDomain = "serviceaccount.omni.sidero.dev" - cloudProviderServiceAccountDomain = "cloud-provider." + serviceAccountDomain + infraProviderServiceAccountDomain = "infra-provider." + serviceAccountDomain // ServiceAccountNameSuffix is appended to the name of all service accounts. ServiceAccountNameSuffix = "@" + serviceAccountDomain - // CloudProviderServiceAccountPrefix is the prefix required for cloud provider service accounts. - CloudProviderServiceAccountPrefix = "cloud-provider:" + // InfraProviderServiceAccountPrefix is the prefix required for infra provider service accounts. + InfraProviderServiceAccountPrefix = "infra-provider:" - // cloudProviderServiceAccountNameSuffix is appended to the name of all cloud provider service accounts. - cloudProviderServiceAccountNameSuffix = "@" + cloudProviderServiceAccountDomain + // infraProviderServiceAccountNameSuffix is appended to the name of all infra provider service accounts. + infraProviderServiceAccountNameSuffix = "@" + infraProviderServiceAccountDomain ) // ServiceAccount represents a service account. @@ -29,19 +29,19 @@ type ServiceAccount struct { // Suffix is the suffix of the service account. // - // Example: "@cloud-provider.serviceaccount.omni.sidero.dev" + // Example: "@infra-provider.serviceaccount.omni.sidero.dev" Suffix string - // IsCloudProvider indicates whether the service account is a cloud provider service account. - IsCloudProvider bool + // IsInfraProvider indicates whether the service account is a infra provider service account. + IsInfraProvider bool } // NameWithPrefix returns the name of the service account with the appropriate prefix. // -// Example: cloud-provider:aws-1. +// Example: infra-provider:aws-1. func (sa ServiceAccount) NameWithPrefix() string { - if sa.IsCloudProvider { - return CloudProviderServiceAccountPrefix + sa.BaseName + if sa.IsInfraProvider { + return InfraProviderServiceAccountPrefix + sa.BaseName } return sa.BaseName @@ -49,58 +49,58 @@ func (sa ServiceAccount) NameWithPrefix() string { // FullID returns the full ID (Identity resource ID / e-mail) of the service account. // -// Example: aws-1@cloud-provider.serviceaccount.omni.sidero.dev. +// Example: aws-1@infra-provider.serviceaccount.omni.sidero.dev. func (sa ServiceAccount) FullID() string { return sa.BaseName + sa.Suffix } // ParseServiceAccountFromName parses a service account from a name with a potential prefix. // -// Example: name: "cloud-provider:aws-1" +// Example: name: "infra-provider:aws-1" // -// Result: ServiceAccount{BaseName: "aws-1", Suffix: "@cloud-provider.serviceaccount.omni.sidero.dev", IsCloudProvider: true}. +// Result: ServiceAccount{BaseName: "aws-1", Suffix: "@infra-provider.serviceaccount.omni.sidero.dev", IsInfraProvider: true}. func ParseServiceAccountFromName(name string) ServiceAccount { baseName := name - isCloudProvider := false + isInfraProvider := false suffix := ServiceAccountNameSuffix - if strings.HasPrefix(name, CloudProviderServiceAccountPrefix) { - isCloudProvider = true - baseName = strings.TrimPrefix(name, CloudProviderServiceAccountPrefix) - suffix = cloudProviderServiceAccountNameSuffix + if strings.HasPrefix(name, InfraProviderServiceAccountPrefix) { + isInfraProvider = true + baseName = strings.TrimPrefix(name, InfraProviderServiceAccountPrefix) + suffix = infraProviderServiceAccountNameSuffix } return ServiceAccount{ BaseName: baseName, Suffix: suffix, - IsCloudProvider: isCloudProvider, + IsInfraProvider: isInfraProvider, } } // ParseServiceAccountFromFullID parses a service account from a full ID (Identity resource ID / e-mail). // -// Example: fullID: aws-1@cloud-provider.serviceaccount.omni.sidero.dev +// Example: fullID: aws-1@infra-provider.serviceaccount.omni.sidero.dev // -// Result: ServiceAccount{BaseName: "aws-1", Suffix: "@cloud-provider.serviceaccount.omni.sidero.dev", IsCloudProvider: true}. +// Result: ServiceAccount{BaseName: "aws-1", Suffix: "@infra-provider.serviceaccount.omni.sidero.dev", IsInfraProvider: true}. func ParseServiceAccountFromFullID(fullID string) (sa ServiceAccount, isSa bool) { hasServiceAccountSuffix := strings.HasSuffix(fullID, ServiceAccountNameSuffix) - hasCloudProviderServiceAccountSuffix := strings.HasSuffix(fullID, cloudProviderServiceAccountNameSuffix) + hasInfraProviderServiceAccountSuffix := strings.HasSuffix(fullID, infraProviderServiceAccountNameSuffix) - if !hasServiceAccountSuffix && !hasCloudProviderServiceAccountSuffix { + if !hasServiceAccountSuffix && !hasInfraProviderServiceAccountSuffix { return ServiceAccount{}, false } - isCloudProvider := false + isInfraProvider := false suffix := ServiceAccountNameSuffix - if hasCloudProviderServiceAccountSuffix { - isCloudProvider = true - suffix = cloudProviderServiceAccountNameSuffix + if hasInfraProviderServiceAccountSuffix { + isInfraProvider = true + suffix = infraProviderServiceAccountNameSuffix } return ServiceAccount{ BaseName: strings.TrimSuffix(fullID, suffix), Suffix: suffix, - IsCloudProvider: isCloudProvider, + IsInfraProvider: isInfraProvider, }, true } diff --git a/client/pkg/access/serviceaccount_test.go b/client/pkg/access/serviceaccount_test.go index bd23bb3d..4d9782bc 100644 --- a/client/pkg/access/serviceaccount_test.go +++ b/client/pkg/access/serviceaccount_test.go @@ -30,24 +30,24 @@ func TestParseFromFullID(t *testing.T) { assert.Equal(t, "foobar", sa.BaseName) assert.Equal(t, "@serviceaccount.omni.sidero.dev", sa.Suffix) - assert.False(t, sa.IsCloudProvider) + assert.False(t, sa.IsInfraProvider) assert.Equal(t, "foobar", sa.NameWithPrefix()) assert.Equal(t, "foobar@serviceaccount.omni.sidero.dev", sa.FullID()) }) - t.Run("cloud provider service account", func(t *testing.T) { + t.Run("infra provider service account", func(t *testing.T) { t.Parallel() - sa, isSa := access.ParseServiceAccountFromFullID("aws-1@cloud-provider.serviceaccount.omni.sidero.dev") + sa, isSa := access.ParseServiceAccountFromFullID("aws-1@infra-provider.serviceaccount.omni.sidero.dev") assert.True(t, isSa) assert.Equal(t, "aws-1", sa.BaseName) - assert.Equal(t, "@cloud-provider.serviceaccount.omni.sidero.dev", sa.Suffix) - assert.True(t, sa.IsCloudProvider) + assert.Equal(t, "@infra-provider.serviceaccount.omni.sidero.dev", sa.Suffix) + assert.True(t, sa.IsInfraProvider) - assert.Equal(t, "cloud-provider:aws-1", sa.NameWithPrefix()) - assert.Equal(t, "aws-1@cloud-provider.serviceaccount.omni.sidero.dev", sa.FullID()) + assert.Equal(t, "infra-provider:aws-1", sa.NameWithPrefix()) + assert.Equal(t, "aws-1@infra-provider.serviceaccount.omni.sidero.dev", sa.FullID()) }) } @@ -61,22 +61,22 @@ func TestParseFromName(t *testing.T) { assert.Equal(t, "foobar", sa.BaseName) assert.Equal(t, "@serviceaccount.omni.sidero.dev", sa.Suffix) - assert.False(t, sa.IsCloudProvider) + assert.False(t, sa.IsInfraProvider) assert.Equal(t, "foobar", sa.NameWithPrefix()) assert.Equal(t, "foobar@serviceaccount.omni.sidero.dev", sa.FullID()) }) - t.Run("cloud provider service account", func(t *testing.T) { + t.Run("infra provider service account", func(t *testing.T) { t.Parallel() - sa := access.ParseServiceAccountFromName("cloud-provider:aws-1") + sa := access.ParseServiceAccountFromName("infra-provider:aws-1") assert.Equal(t, "aws-1", sa.BaseName) - assert.Equal(t, "@cloud-provider.serviceaccount.omni.sidero.dev", sa.Suffix) - assert.True(t, sa.IsCloudProvider) + assert.Equal(t, "@infra-provider.serviceaccount.omni.sidero.dev", sa.Suffix) + assert.True(t, sa.IsInfraProvider) - assert.Equal(t, "cloud-provider:aws-1", sa.NameWithPrefix()) - assert.Equal(t, "aws-1@cloud-provider.serviceaccount.omni.sidero.dev", sa.FullID()) + assert.Equal(t, "infra-provider:aws-1", sa.NameWithPrefix()) + assert.Equal(t, "aws-1@infra-provider.serviceaccount.omni.sidero.dev", sa.FullID()) }) } diff --git a/client/pkg/client/omni/omni.go b/client/pkg/client/omni/omni.go index 29c1b15b..b51f1cb1 100644 --- a/client/pkg/client/omni/omni.go +++ b/client/pkg/client/omni/omni.go @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc" _ "github.com/siderolabs/omni/client/pkg/omni/resources/auth" // import resources to register protobufs - _ "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + _ "github.com/siderolabs/omni/client/pkg/omni/resources/infra" _ "github.com/siderolabs/omni/client/pkg/omni/resources/k8s" _ "github.com/siderolabs/omni/client/pkg/omni/resources/oidc" _ "github.com/siderolabs/omni/client/pkg/omni/resources/omni" diff --git a/client/pkg/infra/controllers/provision.go b/client/pkg/infra/controllers/provision.go index 9fd488eb..1c37575e 100644 --- a/client/pkg/infra/controllers/provision.go +++ b/client/pkg/infra/controllers/provision.go @@ -17,11 +17,11 @@ import ( "github.com/siderolabs/gen/xerrors" "go.uber.org/zap" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + infraspecs "github.com/siderolabs/omni/client/api/omni/specs/infra" infrares "github.com/siderolabs/omni/client/pkg/infra/internal/resources" "github.com/siderolabs/omni/client/pkg/infra/provision" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" ) @@ -53,13 +53,13 @@ func (ctrl *ProvisionController[T]) Settings() controller.QSettings { return controller.QSettings{ Inputs: []controller.Input{ { - Namespace: resources.CloudProviderNamespace, - Type: cloud.MachineRequestType, + Namespace: resources.InfraProviderNamespace, + Type: infra.MachineRequestType, Kind: controller.InputQPrimary, }, { - Namespace: resources.CloudProviderNamespace, - Type: cloud.MachineRequestStatusType, + Namespace: resources.InfraProviderNamespace, + Type: infra.MachineRequestStatusType, Kind: controller.InputQMappedDestroyReady, }, { @@ -77,7 +77,7 @@ func (ctrl *ProvisionController[T]) Settings() controller.QSettings { Outputs: []controller.Output{ { Kind: controller.OutputExclusive, - Type: cloud.MachineRequestStatusType, + Type: infra.MachineRequestStatusType, }, { Kind: controller.OutputShared, @@ -97,7 +97,7 @@ func (ctrl *ProvisionController[T]) MapInput(_ context.Context, _ *zap.Logger, } return []resource.Pointer{ - cloud.NewMachineRequest(ptr.ID()).Metadata(), + infra.NewMachineRequest(ptr.ID()).Metadata(), }, nil } @@ -105,7 +105,7 @@ func (ctrl *ProvisionController[T]) MapInput(_ context.Context, _ *zap.Logger, func (ctrl *ProvisionController[T]) Reconcile(ctx context.Context, logger *zap.Logger, r controller.QRuntime, ptr resource.Pointer, ) error { - machineRequest, err := safe.ReaderGet[*cloud.MachineRequest](ctx, r, cloud.NewMachineRequest(ptr.ID()).Metadata()) + machineRequest, err := safe.ReaderGet[*infra.MachineRequest](ctx, r, infra.NewMachineRequest(ptr.ID()).Metadata()) if err != nil { if state.IsNotFoundError(err) { return nil @@ -129,13 +129,13 @@ func (ctrl *ProvisionController[T]) Reconcile(ctx context.Context, return err } - return safe.WriterModify(ctx, r, machineRequestStatus, func(res *cloud.MachineRequestStatus) error { + return safe.WriterModify(ctx, r, machineRequestStatus, func(res *infra.MachineRequestStatus) error { return ctrl.reconcileRunning(ctx, r, logger, machineRequest, res) }) } func (ctrl *ProvisionController[T]) reconcileRunning(ctx context.Context, r controller.QRuntime, logger *zap.Logger, - machineRequest *cloud.MachineRequest, machineRequestStatus *cloud.MachineRequestStatus, + machineRequest *infra.MachineRequest, machineRequestStatus *infra.MachineRequestStatus, ) error { connectionParams, err := safe.ReaderGetByID[*siderolink.ConnectionParams](ctx, r, siderolink.ConfigID) if err != nil { @@ -161,13 +161,13 @@ func (ctrl *ProvisionController[T]) reconcileRunning(ctx context.Context, r cont } machineRequestStatus.TypedSpec().Value.Error = err.Error() - machineRequestStatus.TypedSpec().Value.Stage = cloudspecs.MachineRequestStatusSpec_FAILED + machineRequestStatus.TypedSpec().Value.Stage = infraspecs.MachineRequestStatusSpec_FAILED return nil } machineRequestStatus.TypedSpec().Value.Id = provisionResult.UUID - machineRequestStatus.TypedSpec().Value.Stage = cloudspecs.MachineRequestStatusSpec_PROVISIONED + machineRequestStatus.TypedSpec().Value.Stage = infraspecs.MachineRequestStatusSpec_PROVISIONED *machineRequestStatus.Metadata().Labels() = *machineRequest.Metadata().Labels() @@ -181,8 +181,8 @@ func (ctrl *ProvisionController[T]) reconcileRunning(ctx context.Context, r cont return nil } -func (ctrl *ProvisionController[T]) initializeStatus(ctx context.Context, r controller.QRuntime, logger *zap.Logger, machineRequest *cloud.MachineRequest) (*cloud.MachineRequestStatus, error) { - mrs, err := safe.ReaderGetByID[*cloud.MachineRequestStatus](ctx, r, machineRequest.Metadata().ID()) +func (ctrl *ProvisionController[T]) initializeStatus(ctx context.Context, r controller.QRuntime, logger *zap.Logger, machineRequest *infra.MachineRequest) (*infra.MachineRequestStatus, error) { + mrs, err := safe.ReaderGetByID[*infra.MachineRequestStatus](ctx, r, machineRequest.Metadata().ID()) if err != nil && !state.IsNotFoundError(err) { return nil, err } @@ -191,9 +191,9 @@ func (ctrl *ProvisionController[T]) initializeStatus(ctx context.Context, r cont return mrs, nil } - return safe.WriterModifyWithResult(ctx, r, cloud.NewMachineRequestStatus(machineRequest.Metadata().ID()), func(res *cloud.MachineRequestStatus) error { - if res.TypedSpec().Value.Stage == cloudspecs.MachineRequestStatusSpec_UNKNOWN { - res.TypedSpec().Value.Stage = cloudspecs.MachineRequestStatusSpec_PROVISIONING + return safe.WriterModifyWithResult(ctx, r, infra.NewMachineRequestStatus(machineRequest.Metadata().ID()), func(res *infra.MachineRequestStatus) error { + if res.TypedSpec().Value.Stage == infraspecs.MachineRequestStatusSpec_UNKNOWN { + res.TypedSpec().Value.Stage = infraspecs.MachineRequestStatusSpec_PROVISIONING *res.Metadata().Labels() = *machineRequest.Metadata().Labels() logger.Info("machine provision started", zap.String("request_id", machineRequest.Metadata().ID())) @@ -203,7 +203,7 @@ func (ctrl *ProvisionController[T]) initializeStatus(ctx context.Context, r cont }) } -func (ctrl *ProvisionController[T]) reconcileTearingDown(ctx context.Context, r controller.QRuntime, logger *zap.Logger, machineRequest *cloud.MachineRequest) error { +func (ctrl *ProvisionController[T]) reconcileTearingDown(ctx context.Context, r controller.QRuntime, logger *zap.Logger, machineRequest *infra.MachineRequest) error { t, err := safe.ReaderGetByID[T](ctx, r, machineRequest.Metadata().ID()) if err != nil && !state.IsNotFoundError(err) { return err @@ -215,7 +215,7 @@ func (ctrl *ProvisionController[T]) reconcileTearingDown(ctx context.Context, r resources := []resource.Metadata{ resource.NewMetadata(t.ResourceDefinition().DefaultNamespace, t.ResourceDefinition().Type, machineRequest.Metadata().ID(), resource.VersionUndefined), - *cloud.NewMachineRequestStatus(machineRequest.Metadata().ID()).Metadata(), + *infra.NewMachineRequestStatus(machineRequest.Metadata().ID()).Metadata(), } for _, md := range resources { diff --git a/client/pkg/infra/infra_test.go b/client/pkg/infra/infra_test.go index 2f9c837b..8e9aeec1 100644 --- a/client/pkg/infra/infra_test.go +++ b/client/pkg/infra/infra_test.go @@ -25,11 +25,11 @@ import ( "golang.org/x/sync/errgroup" "github.com/siderolabs/omni/client/api/omni/specs" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + infraspec "github.com/siderolabs/omni/client/api/omni/specs/infra" "github.com/siderolabs/omni/client/pkg/infra" "github.com/siderolabs/omni/client/pkg/infra/provision" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + infrares "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" ) @@ -46,7 +46,7 @@ type provisioner struct { } // Provision implements provision.Provisioner interface. -func (p *provisioner) Provision(ctx context.Context, _ *zap.Logger, state *TestResource, request *cloud.MachineRequest, _ *siderolink.ConnectionParams) (provision.Result, error) { +func (p *provisioner) Provision(ctx context.Context, _ *zap.Logger, state *TestResource, request *infrares.MachineRequest, _ *siderolink.ConnectionParams) (provision.Result, error) { p.machinesMu.Lock() defer p.machinesMu.Unlock() @@ -84,7 +84,7 @@ func (p *provisioner) Provision(ctx context.Context, _ *zap.Logger, state *TestR } // Deprovision implements provision.Provisioner interface. -func (p *provisioner) Deprovision(_ context.Context, _ *zap.Logger, _ *TestResource, request *cloud.MachineRequest) error { +func (p *provisioner) Deprovision(_ context.Context, _ *zap.Logger, _ *TestResource, request *infrares.MachineRequest) error { p.machinesMu.Lock() defer p.machinesMu.Unlock() @@ -126,8 +126,8 @@ func TestInfra(t *testing.T) { customLabel := "custom" customValue := "hello" - machineRequest := cloud.NewMachineRequest("test1") - machineRequest.Metadata().Labels().Set(omni.LabelCloudProviderID, providerID) + machineRequest := infrares.NewMachineRequest("test1") + machineRequest.Metadata().Labels().Set(omni.LabelInfraProviderID, providerID) machineRequest.Metadata().Labels().Set(customLabel, customValue) require.NoError(t, state.Create(ctx, machineRequest)) @@ -136,8 +136,8 @@ func TestInfra(t *testing.T) { require.NoError(t, state.Create(ctx, connectionParams)) - rtestutils.AssertResources(ctx, t, state, []string{machineRequest.Metadata().ID()}, func(machineRequestStatus *cloud.MachineRequestStatus, assert *assert.Assertions) { - val, ok := machineRequestStatus.Metadata().Labels().Get(omni.LabelCloudProviderID) + rtestutils.AssertResources(ctx, t, state, []string{machineRequest.Metadata().ID()}, func(machineRequestStatus *infrares.MachineRequestStatus, assert *assert.Assertions) { + val, ok := machineRequestStatus.Metadata().Labels().Get(omni.LabelInfraProviderID) assert.True(ok) assert.Equal(providerID, val) @@ -146,13 +146,13 @@ func TestInfra(t *testing.T) { assert.True(ok) assert.Equal(customValue, val) - assert.Equal(cloudspecs.MachineRequestStatusSpec_PROVISIONING, machineRequestStatus.TypedSpec().Value.Stage) + assert.Equal(infraspec.MachineRequestStatusSpec_PROVISIONING, machineRequestStatus.TypedSpec().Value.Stage) }) require.True(t, channel.SendWithContext(ctx, provisionChannel, struct{}{})) - rtestutils.AssertResources(ctx, t, state, []string{machineRequest.Metadata().ID()}, func(machineRequestStatus *cloud.MachineRequestStatus, assert *assert.Assertions) { - assert.Equal(cloudspecs.MachineRequestStatusSpec_PROVISIONED, machineRequestStatus.TypedSpec().Value.Stage) + rtestutils.AssertResources(ctx, t, state, []string{machineRequest.Metadata().ID()}, func(machineRequestStatus *infrares.MachineRequestStatus, assert *assert.Assertions) { + assert.Equal(infraspec.MachineRequestStatusSpec_PROVISIONED, machineRequestStatus.TypedSpec().Value.Stage) }) rtestutils.AssertResources(ctx, t, state, []string{machineRequest.Metadata().ID()}, func(testResource *TestResource, assert *assert.Assertions) { @@ -161,9 +161,9 @@ func TestInfra(t *testing.T) { require.NotNil(t, p.getMachine(machineRequest.Metadata().ID())) - rtestutils.Destroy[*cloud.MachineRequest](ctx, t, state, []string{machineRequest.Metadata().ID()}) + rtestutils.Destroy[*infrares.MachineRequest](ctx, t, state, []string{machineRequest.Metadata().ID()}) - rtestutils.AssertNoResource[*cloud.MachineRequestStatus](ctx, t, state, machineRequest.Metadata().ID()) + rtestutils.AssertNoResource[*infrares.MachineRequestStatus](ctx, t, state, machineRequest.Metadata().ID()) rtestutils.AssertNoResource[*TestResource](ctx, t, state, machineRequest.Metadata().ID()) require.Nil(t, p.getMachine(machineRequest.Metadata().ID())) diff --git a/client/pkg/infra/internal/resources/resources.go b/client/pkg/infra/internal/resources/resources.go index 1ed25564..b78c6bbc 100644 --- a/client/pkg/infra/internal/resources/resources.go +++ b/client/pkg/infra/internal/resources/resources.go @@ -9,10 +9,10 @@ import "github.com/siderolabs/omni/client/pkg/omni/resources" // ResourceType generates the correct resource name for the resources managed by the infra providers. func ResourceType(name, providerID string) string { - return name + "." + providerID + ".cloudprovider.sidero.dev" + return name + "." + providerID + ".infraprovider.sidero.dev" } // ResourceNamespace generates the correct namespace name for the infra provider state. func ResourceNamespace(providerID string) string { - return resources.CloudProviderSpecificNamespacePrefix + providerID + return resources.InfraProviderSpecificNamespacePrefix + providerID } diff --git a/client/pkg/infra/provision/provision.go b/client/pkg/infra/provision/provision.go index dfd72846..69b1e8f3 100644 --- a/client/pkg/infra/provision/provision.go +++ b/client/pkg/infra/provision/provision.go @@ -11,7 +11,7 @@ import ( "github.com/cosi-project/runtime/pkg/resource" "go.uber.org/zap" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" ) @@ -25,6 +25,6 @@ type Result struct { // Provisioner is the interface that should be implemented by an infra provider. type Provisioner[T resource.Resource] interface { - Provision(context.Context, *zap.Logger, T, *cloud.MachineRequest, *siderolink.ConnectionParams) (Result, error) - Deprovision(context.Context, *zap.Logger, T, *cloud.MachineRequest) error + Provision(context.Context, *zap.Logger, T, *infra.MachineRequest, *siderolink.ConnectionParams) (Result, error) + Deprovision(context.Context, *zap.Logger, T, *infra.MachineRequest) error } diff --git a/client/pkg/infra/state.go b/client/pkg/infra/state.go index dd3d4ec2..3d51373c 100644 --- a/client/pkg/infra/state.go +++ b/client/pkg/infra/state.go @@ -10,12 +10,12 @@ import ( "github.com/siderolabs/omni/client/pkg/client" ) -// State creates new cloud provider state. +// State creates new infra provider state. type State struct { Client *client.Client } -// NewState creates new cloud provider state. +// NewState creates new infra provider state. func NewState(endpoint string, opts ...client.Option) (*State, error) { client, err := client.New(endpoint, opts...) if err != nil { diff --git a/client/pkg/omni/resources/auth/labels.go b/client/pkg/omni/resources/auth/labels.go index 3656a889..d861f1ab 100644 --- a/client/pkg/omni/resources/auth/labels.go +++ b/client/pkg/omni/resources/auth/labels.go @@ -24,8 +24,8 @@ const ( // tsgen:LabelIdentityTypeServiceAccount LabelIdentityTypeServiceAccount = "type-service-account" - // LabelCloudProvider is set when the service account is a cloud provider service account. - LabelCloudProvider = omni.SystemLabelPrefix + "cloud-provider" + // LabelInfraProvider is set when the service account is a infra provider service account. + LabelInfraProvider = omni.SystemLabelPrefix + "infra-provider" ) const ( diff --git a/client/pkg/omni/resources/cloud/cloud.go b/client/pkg/omni/resources/infra/cloud.go similarity index 85% rename from client/pkg/omni/resources/cloud/cloud.go rename to client/pkg/omni/resources/infra/cloud.go index c4b62bca..2c2dd2fa 100644 --- a/client/pkg/omni/resources/cloud/cloud.go +++ b/client/pkg/omni/resources/infra/cloud.go @@ -2,8 +2,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Package cloud provides resources for managing cloud resources. -package cloud +// Package infra provides resources for managing infra resources. +package infra import "github.com/siderolabs/omni/client/pkg/omni/resources/registry" diff --git a/client/pkg/omni/resources/cloud/machine_request.go b/client/pkg/omni/resources/infra/machine_request.go similarity index 81% rename from client/pkg/omni/resources/cloud/machine_request.go rename to client/pkg/omni/resources/infra/machine_request.go index 902f6ce5..0ddf27fe 100644 --- a/client/pkg/omni/resources/cloud/machine_request.go +++ b/client/pkg/omni/resources/infra/machine_request.go @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package cloud +package infra import ( "github.com/cosi-project/runtime/pkg/resource" @@ -10,15 +10,15 @@ import ( "github.com/cosi-project/runtime/pkg/resource/protobuf" "github.com/cosi-project/runtime/pkg/resource/typed" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + "github.com/siderolabs/omni/client/api/omni/specs/infra" "github.com/siderolabs/omni/client/pkg/omni/resources" ) // NewMachineRequest creates a new MachineRequest resource. func NewMachineRequest(id string) *MachineRequest { return typed.NewResource[MachineRequestSpec, MachineRequestExtension]( - resource.NewMetadata(resources.CloudProviderNamespace, MachineRequestType, id, resource.VersionUndefined), - protobuf.NewResourceSpec(&cloudspecs.MachineRequestSpec{}), + resource.NewMetadata(resources.InfraProviderNamespace, MachineRequestType, id, resource.VersionUndefined), + protobuf.NewResourceSpec(&infra.MachineRequestSpec{}), ) } @@ -33,7 +33,7 @@ const ( type MachineRequest = typed.Resource[MachineRequestSpec, MachineRequestExtension] // MachineRequestSpec wraps specs.MachineRequestSpec. -type MachineRequestSpec = protobuf.ResourceSpec[cloudspecs.MachineRequestSpec, *cloudspecs.MachineRequestSpec] +type MachineRequestSpec = protobuf.ResourceSpec[infra.MachineRequestSpec, *infra.MachineRequestSpec] // MachineRequestExtension providers auxiliary methods for MachineRequest resource. type MachineRequestExtension struct{} @@ -43,7 +43,7 @@ func (MachineRequestExtension) ResourceDefinition() meta.ResourceDefinitionSpec return meta.ResourceDefinitionSpec{ Type: MachineRequestType, Aliases: []resource.Type{}, - DefaultNamespace: resources.CloudProviderNamespace, + DefaultNamespace: resources.InfraProviderNamespace, PrintColumns: []meta.PrintColumn{ { Name: "Talos Version", diff --git a/client/pkg/omni/resources/cloud/machine_request_status.go b/client/pkg/omni/resources/infra/machine_request_status.go similarity index 80% rename from client/pkg/omni/resources/cloud/machine_request_status.go rename to client/pkg/omni/resources/infra/machine_request_status.go index 8d5c1b40..c9b6cb92 100644 --- a/client/pkg/omni/resources/cloud/machine_request_status.go +++ b/client/pkg/omni/resources/infra/machine_request_status.go @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -package cloud +package infra import ( "github.com/cosi-project/runtime/pkg/resource" @@ -10,15 +10,15 @@ import ( "github.com/cosi-project/runtime/pkg/resource/protobuf" "github.com/cosi-project/runtime/pkg/resource/typed" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + "github.com/siderolabs/omni/client/api/omni/specs/infra" "github.com/siderolabs/omni/client/pkg/omni/resources" ) // NewMachineRequestStatus creates a new MachineRequestStatus resource. func NewMachineRequestStatus(id string) *MachineRequestStatus { return typed.NewResource[MachineRequestStatusSpec, MachineRequestStatusExtension]( - resource.NewMetadata(resources.CloudProviderNamespace, MachineRequestStatusType, id, resource.VersionUndefined), - protobuf.NewResourceSpec(&cloudspecs.MachineRequestStatusSpec{}), + resource.NewMetadata(resources.InfraProviderNamespace, MachineRequestStatusType, id, resource.VersionUndefined), + protobuf.NewResourceSpec(&infra.MachineRequestStatusSpec{}), ) } @@ -33,7 +33,7 @@ const ( type MachineRequestStatus = typed.Resource[MachineRequestStatusSpec, MachineRequestStatusExtension] // MachineRequestStatusSpec wraps specs.MachineRequestStatusSpec. -type MachineRequestStatusSpec = protobuf.ResourceSpec[cloudspecs.MachineRequestStatusSpec, *cloudspecs.MachineRequestStatusSpec] +type MachineRequestStatusSpec = protobuf.ResourceSpec[infra.MachineRequestStatusSpec, *infra.MachineRequestStatusSpec] // MachineRequestStatusExtension providers auxiliary methods for MachineRequestStatus resource. type MachineRequestStatusExtension struct{} @@ -43,7 +43,7 @@ func (MachineRequestStatusExtension) ResourceDefinition() meta.ResourceDefinitio return meta.ResourceDefinitionSpec{ Type: MachineRequestStatusType, Aliases: []resource.Type{}, - DefaultNamespace: resources.CloudProviderNamespace, + DefaultNamespace: resources.InfraProviderNamespace, PrintColumns: []meta.PrintColumn{}, } } diff --git a/client/pkg/omni/resources/omni/labels.go b/client/pkg/omni/resources/omni/labels.go index 957328b0..89c3d56f 100644 --- a/client/pkg/omni/resources/omni/labels.go +++ b/client/pkg/omni/resources/omni/labels.go @@ -54,8 +54,8 @@ const ( // tsgen:LabelExposedServiceAlias LabelExposedServiceAlias = SystemLabelPrefix + "exposed-service-alias" - // LabelCloudProviderID is the cloud provider ID for the resources managed by cloud providers, e.g., cloud.MachineRequest, cloud.MachineRequestStatus. - LabelCloudProviderID = SystemLabelPrefix + "cloud-provider-id" + // LabelInfraProviderID is the infra provider ID for the resources managed by infra providers, e.g., infra.MachineRequest, infra.MachineRequestStatus. + LabelInfraProviderID = SystemLabelPrefix + "infra-provider-id" // LabelMachineClassName is the name of the machine class. LabelMachineClassName = SystemLabelPrefix + "machine-class-name" diff --git a/client/pkg/omni/resources/resources.go b/client/pkg/omni/resources/resources.go index 3c0f5f8e..a46a7593 100644 --- a/client/pkg/omni/resources/resources.go +++ b/client/pkg/omni/resources/resources.go @@ -43,14 +43,14 @@ const VirtualNamespace resource.Namespace = "virtual" // tsgen:ExternalNamespace const ExternalNamespace resource.Namespace = "external" -// CloudProviderNamespace is the namespace for cloud provider specific resources, e.g., `MachineRequest` and `MachineRequestStatus`. +// InfraProviderNamespace is the namespace for infra provider specific resources, e.g., `MachineRequest` and `MachineRequestStatus`. // -// tsgen:CloudProviderNamespace -const CloudProviderNamespace resource.Namespace = "cloud-provider" +// tsgen:InfraProviderNamespace +const InfraProviderNamespace resource.Namespace = "infra-provider" -// CloudProviderSpecificNamespacePrefix is the prefix for cloud provider specific namespaces. +// InfraProviderSpecificNamespacePrefix is the prefix for infra provider specific namespaces. // -// A cloud-provider specific namespace is a namespace in which cloud provider has full access. +// A infra-provider specific namespace is a namespace in which infra provider has full access. // -// For example, a cloud provider named `qemu-1` would have full access on namespace `cloud-provider:qemu-1`. -const CloudProviderSpecificNamespacePrefix resource.Namespace = CloudProviderNamespace + ":" +// For example, a infra provider named `qemu-1` would have full access on namespace `infra-provider:qemu-1`. +const InfraProviderSpecificNamespacePrefix resource.Namespace = InfraProviderNamespace + ":" diff --git a/cmd/integration-test/pkg/tests/auth.go b/cmd/integration-test/pkg/tests/auth.go index e87abf87..837ac0fb 100644 --- a/cmd/integration-test/pkg/tests/auth.go +++ b/cmd/integration-test/pkg/tests/auth.go @@ -48,7 +48,7 @@ import ( "github.com/siderolabs/omni/client/pkg/constants" "github.com/siderolabs/omni/client/pkg/omni/resources" authres "github.com/siderolabs/omni/client/pkg/omni/resources/auth" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/k8s" "github.com/siderolabs/omni/client/pkg/omni/resources/oidc" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" @@ -1036,9 +1036,9 @@ func AssertResourceAuthz(rootCtx context.Context, rootCli *client.Client, client delete(untestedResourceTypes, k8s.KubernetesResourceType) delete(untestedResourceTypes, siderolink.DeprecatedLinkCounterType) - // cloud provider resources have their custom authz logic, they are unit-tested in their package - delete(untestedResourceTypes, cloud.MachineRequestType) - delete(untestedResourceTypes, cloud.MachineRequestStatusType) + // infra provider resources have their custom authz logic, they are unit-tested in their package + delete(untestedResourceTypes, infra.MachineRequestType) + delete(untestedResourceTypes, infra.MachineRequestStatusType) for _, tc := range testCases { for _, testVerb := range allVerbs { diff --git a/frontend/src/api/omni/specs/infra/infra.pb.ts b/frontend/src/api/omni/specs/infra/infra.pb.ts new file mode 100644 index 00000000..82d5fbf6 --- /dev/null +++ b/frontend/src/api/omni/specs/infra/infra.pb.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-nocheck +/* +* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY +*/ + +export enum MachineRequestStatusSpecStage { + UNKNOWN = 0, + PROVISIONING = 1, + PROVISIONED = 2, + FAILED = 3, +} + +export type MachineRequestSpec = { + talos_version?: string + schematic_id?: string +} + +export type MachineRequestStatusSpec = { + id?: string + stage?: MachineRequestStatusSpecStage + error?: string +} \ No newline at end of file diff --git a/frontend/src/api/resources.ts b/frontend/src/api/resources.ts index 48aea9e1..1dd91908 100644 --- a/frontend/src/api/resources.ts +++ b/frontend/src/api/resources.ts @@ -6,7 +6,7 @@ // THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. export const RoleNone = "None"; -export const RoleCloudProvider = "CloudProvider"; +export const RoleInfraProvider = "InfraProvider"; export const RoleReader = "Reader"; export const RoleOperator = "Operator"; export const RoleAdmin = "Admin"; @@ -34,7 +34,7 @@ export const EphemeralNamespace = "ephemeral"; export const MetricsNamespace = "metrics"; export const VirtualNamespace = "virtual"; export const ExternalNamespace = "external"; -export const CloudProviderNamespace = "cloud-provider"; +export const InfraProviderNamespace = "infra-provider"; export const MachineLocked = "omni.sidero.dev/locked"; export const UpdateLocked = "omni.sidero.dev/locked-update"; export const ResourceManagedByClusterTemplates = "omni.sidero.dev/managed-by-cluster-templates"; diff --git a/hack/release.sh b/hack/release.sh index 639d796a..027ac775 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -1,8 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-08-23T08:33:12Z by kres 8e4bbb4. +# Generated on 2024-08-30T15:41:41Z by kres b5ca957. set -e diff --git a/internal/backend/grpc/serviceaccount.go b/internal/backend/grpc/serviceaccount.go index 7334de66..f957fcb5 100644 --- a/internal/backend/grpc/serviceaccount.go +++ b/internal/backend/grpc/serviceaccount.go @@ -46,8 +46,8 @@ func (s *managementServer) CreateServiceAccount(ctx context.Context, req *manage sa := pkgaccess.ParseServiceAccountFromName(req.Name) saRole := role.Admin - if req.UseUserRole && sa.IsCloudProvider { - return nil, fmt.Errorf("cloud provider service accounts must have the role %q, but use-user-role was requested", role.CloudProvider) + if req.UseUserRole && sa.IsInfraProvider { + return nil, fmt.Errorf("infra provider service accounts must have the role %q, but use-user-role was requested", role.InfraProvider) } if !req.UseUserRole { @@ -57,12 +57,12 @@ func (s *managementServer) CreateServiceAccount(ctx context.Context, req *manage return nil, err } - if sa.IsCloudProvider && saRole != role.CloudProvider { - return nil, fmt.Errorf("cloud-provider service accounts must have the role %q", role.CloudProvider) + if sa.IsInfraProvider && saRole != role.InfraProvider { + return nil, fmt.Errorf("infra-provider service accounts must have the role %q", role.InfraProvider) } - if saRole == role.CloudProvider && !sa.IsCloudProvider { - return nil, fmt.Errorf("service accounts with role %q must be prefixed with %q", role.CloudProvider, pkgaccess.CloudProviderServiceAccountPrefix) + if saRole == role.InfraProvider && !sa.IsInfraProvider { + return nil, fmt.Errorf("service accounts with role %q must be prefixed with %q", role.InfraProvider, pkgaccess.InfraProviderServiceAccountPrefix) } } @@ -92,8 +92,8 @@ func (s *managementServer) CreateServiceAccount(ctx context.Context, req *manage publicKeyResource := authres.NewPublicKey(resources.DefaultNamespace, key.id) publicKeyResource.Metadata().Labels().Set(authres.LabelPublicKeyUserID, newUserID) - if sa.IsCloudProvider { - publicKeyResource.Metadata().Labels().Set(authres.LabelCloudProvider, "") + if sa.IsInfraProvider { + publicKeyResource.Metadata().Labels().Set(authres.LabelInfraProvider, "") } publicKeyResource.TypedSpec().Value.PublicKey = key.data @@ -116,8 +116,8 @@ func (s *managementServer) CreateServiceAccount(ctx context.Context, req *manage user := authres.NewUser(resources.DefaultNamespace, newUserID) user.TypedSpec().Value.Role = publicKeyResource.TypedSpec().Value.GetRole() - if sa.IsCloudProvider { - user.Metadata().Labels().Set(authres.LabelCloudProvider, "") + if sa.IsInfraProvider { + user.Metadata().Labels().Set(authres.LabelInfraProvider, "") } err = s.omniState.Create(ctx, user) @@ -131,8 +131,8 @@ func (s *managementServer) CreateServiceAccount(ctx context.Context, req *manage identity.Metadata().Labels().Set(authres.LabelIdentityUserID, newUserID) identity.Metadata().Labels().Set(authres.LabelIdentityTypeServiceAccount, "") - if sa.IsCloudProvider { - identity.Metadata().Labels().Set(authres.LabelCloudProvider, "") + if sa.IsInfraProvider { + identity.Metadata().Labels().Set(authres.LabelInfraProvider, "") } err = s.omniState.Create(ctx, identity) diff --git a/internal/backend/runtime/omni/controllers/omni/machine_request_cleanup.go b/internal/backend/runtime/omni/controllers/omni/machine_request_cleanup.go index 7bfa4544..b8ad92a8 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_request_cleanup.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_request_cleanup.go @@ -16,30 +16,30 @@ import ( "github.com/siderolabs/gen/xerrors" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/helpers" ) // MachineRequestStatusCleanupController manages MachineRequestStatusStatus resource lifecycle. -type MachineRequestStatusCleanupController = cleanup.Controller[*cloud.MachineRequestStatus] +type MachineRequestStatusCleanupController = cleanup.Controller[*infra.MachineRequestStatus] // NewMachineRequestStatusCleanupController returns a new MachineRequestStatusCleanup controller. // This controller should remove all links for a tearing down machine request. func NewMachineRequestStatusCleanupController() *MachineRequestStatusCleanupController { return cleanup.NewController( - cleanup.Settings[*cloud.MachineRequestStatus]{ + cleanup.Settings[*infra.MachineRequestStatus]{ Name: "MachineRequestStatusCleanupController", Handler: cleanup.Combine( - helpers.NewCustomHandler[*cloud.MachineRequestStatus, *omni.MachineSetNode]( - helpers.MapID[*cloud.MachineRequestStatus, *omni.MachineSetNode](func(req *cloud.MachineRequestStatus) resource.ID { + helpers.NewCustomHandler[*infra.MachineRequestStatus, *omni.MachineSetNode]( + helpers.MapID[*infra.MachineRequestStatus, *omni.MachineSetNode](func(req *infra.MachineRequestStatus) resource.ID { return req.TypedSpec().Value.Id }, true), false, ), - helpers.NewCustomHandler[*cloud.MachineRequestStatus, *omni.ClusterMachine]( - func(ctx context.Context, r controller.Runtime, req *cloud.MachineRequestStatus, _ string) error { + helpers.NewCustomHandler[*infra.MachineRequestStatus, *omni.ClusterMachine]( + func(ctx context.Context, r controller.Runtime, req *infra.MachineRequestStatus, _ string) error { _, err := safe.ReaderGetByID[*omni.ClusterMachine](ctx, r, req.TypedSpec().Value.Id) if err != nil { if state.IsNotFoundError(err) { @@ -53,8 +53,8 @@ func NewMachineRequestStatusCleanupController() *MachineRequestStatusCleanupCont }, true, ), - helpers.NewCustomHandler[*cloud.MachineRequestStatus, *siderolink.Link]( - func(ctx context.Context, r controller.Runtime, req *cloud.MachineRequestStatus, _ string) error { + helpers.NewCustomHandler[*infra.MachineRequestStatus, *siderolink.Link]( + func(ctx context.Context, r controller.Runtime, req *infra.MachineRequestStatus, _ string) error { _, err := r.Teardown(ctx, siderolink.NewLink(resources.DefaultNamespace, req.TypedSpec().Value.Id, nil).Metadata(), controller.WithOwner("")) if err != nil { if state.IsNotFoundError(err) { diff --git a/internal/backend/runtime/omni/controllers/omni/machine_request_link.go b/internal/backend/runtime/omni/controllers/omni/machine_request_link.go index 687c15b4..fb561236 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_request_link.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_request_link.go @@ -18,7 +18,7 @@ import ( "go.uber.org/zap" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/helpers" @@ -48,8 +48,8 @@ func (ctrl *MachineRequestLinkController) Settings() controller.QSettings { return controller.QSettings{ Inputs: []controller.Input{ { - Namespace: resources.CloudProviderNamespace, - Type: cloud.MachineRequestStatusType, + Namespace: resources.InfraProviderNamespace, + Type: infra.MachineRequestStatusType, Kind: controller.InputQPrimary, }, }, @@ -68,7 +68,7 @@ func (ctrl *MachineRequestLinkController) MapInput(context.Context, *zap.Logger, func (ctrl *MachineRequestLinkController) Reconcile(ctx context.Context, _ *zap.Logger, r controller.QRuntime, ptr resource.Pointer, ) error { - machineRequestStatus, err := safe.ReaderGet[*cloud.MachineRequestStatus](ctx, r, cloud.NewMachineRequestStatus(ptr.ID()).Metadata()) + machineRequestStatus, err := safe.ReaderGet[*infra.MachineRequestStatus](ctx, r, infra.NewMachineRequestStatus(ptr.ID()).Metadata()) if err != nil { if state.IsNotFoundError(err) { return nil diff --git a/internal/backend/runtime/omni/controllers/omni/machine_request_link_test.go b/internal/backend/runtime/omni/controllers/omni/machine_request_link_test.go index d11e97d5..cebba43c 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_request_link_test.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_request_link_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" omnictrl "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/omni" @@ -38,7 +38,7 @@ func (suite *MachineRequestLinkSuite) TestReconcile() { uuid := "aabb" requestID := "request-1" - status := cloud.NewMachineRequestStatus(requestID) + status := infra.NewMachineRequestStatus(requestID) status.TypedSpec().Value.Id = uuid suite.Require().NoError(suite.state.Create(ctx, status)) diff --git a/internal/backend/runtime/omni/controllers/omni/machine_request_set_status.go b/internal/backend/runtime/omni/controllers/omni/machine_request_set_status.go index bde92400..861df114 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_request_set_status.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_request_set_status.go @@ -22,7 +22,7 @@ import ( "github.com/siderolabs/omni/client/api/omni/specs" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/system" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/omni/internal/mappers" @@ -53,13 +53,13 @@ func NewMachineRequestSetStatusController(imageFactory SchematicEnsurer) *Machin FinalizerRemovalExtraOutputFunc: h.reconcileTearingDown, }, qtransform.WithExtraMappedDestroyReadyInput( - mappers.MapExtractLabelValue[*cloud.MachineRequest, *omni.MachineRequestSet](omni.LabelMachineRequestSet), + mappers.MapExtractLabelValue[*infra.MachineRequest, *omni.MachineRequestSet](omni.LabelMachineRequestSet), ), qtransform.WithExtraMappedInput( mapMachineToMachineRequest, ), qtransform.WithExtraOutputs(controller.Output{ - Type: cloud.MachineRequestType, + Type: infra.MachineRequestType, Kind: controller.OutputShared, }), qtransform.WithConcurrency(16), @@ -78,16 +78,16 @@ func (h *machineRequestSetStatusHandler) reconcileRunning(ctx context.Context, r return err } - machineRequests, err := safe.ReaderListAll[*cloud.MachineRequest](ctx, r, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) + machineRequests, err := safe.ReaderListAll[*infra.MachineRequest](ctx, r, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) if err != nil { return err } - requests := make([]*cloud.MachineRequest, 0, machineRequests.Len()) + requests := make([]*infra.MachineRequest, 0, machineRequests.Len()) // delete tearing down requests // delete requests when machines are tearing down - err = machineRequests.ForEachErr(func(request *cloud.MachineRequest) error { + err = machineRequests.ForEachErr(func(request *infra.MachineRequest) error { var machine *machineStatusLabels list := machineStatuses.FilterLabelQuery(resource.LabelEqual(omni.LabelMachineRequest, request.Metadata().ID())) @@ -129,7 +129,7 @@ func (h *machineRequestSetStatusHandler) reconcileRunning(ctx context.Context, r } func (h *machineRequestSetStatusHandler) reconcileRequests(ctx context.Context, r controller.ReaderWriter, machineRequestSet *omni.MachineRequestSet, - machineRequests []*cloud.MachineRequest, machineStatusList safe.List[*machineStatusLabels], + machineRequests []*infra.MachineRequest, machineStatusList safe.List[*machineStatusLabels], ) error { machineStatuses := toMap(machineStatusList) @@ -151,14 +151,14 @@ func (h *machineRequestSetStatusHandler) scaleUp(ctx context.Context, r controll for range 100 { alias := rand.String(6) - if err := safe.WriterModify(ctx, r, cloud.NewMachineRequest(machineRequestSet.Metadata().ID()+"-"+alias), func(request *cloud.MachineRequest) error { + if err := safe.WriterModify(ctx, r, infra.NewMachineRequest(machineRequestSet.Metadata().ID()+"-"+alias), func(request *infra.MachineRequest) error { var err error request.TypedSpec().Value.TalosVersion = machineRequestSet.TypedSpec().Value.TalosVersion request.TypedSpec().Value.SchematicId = schematicID - request.Metadata().Labels().Set(omni.LabelCloudProviderID, machineRequestSet.TypedSpec().Value.ProviderId) + request.Metadata().Labels().Set(omni.LabelInfraProviderID, machineRequestSet.TypedSpec().Value.ProviderId) request.Metadata().Labels().Set(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()) return err @@ -213,7 +213,7 @@ func (h *machineRequestSetStatusHandler) ensureSchematic(ctx context.Context, ma return ensuredSchematic.FullID, nil } -func scaleDown(ctx context.Context, r controller.ReaderWriter, machineRequests []*cloud.MachineRequest, machineStatuses map[resource.ID]*machineStatusLabels, count int) error { +func scaleDown(ctx context.Context, r controller.ReaderWriter, machineRequests []*infra.MachineRequest, machineStatuses map[resource.ID]*machineStatusLabels, count int) error { inUse := make(map[resource.ID]struct{}, len(machineStatuses)) isCp := make(map[resource.ID]struct{}, len(machineStatuses)) @@ -240,7 +240,7 @@ func scaleDown(ctx context.Context, r controller.ReaderWriter, machineRequests [ } } - compareFlags := func(flags map[resource.ID]struct{}, a, b *cloud.MachineRequest) int { + compareFlags := func(flags map[resource.ID]struct{}, a, b *infra.MachineRequest) int { _, aflag := flags[a.Metadata().ID()] _, bflag := flags[b.Metadata().ID()] @@ -257,7 +257,7 @@ func scaleDown(ctx context.Context, r controller.ReaderWriter, machineRequests [ // sort by in use first, then if both are in use compare by the role, control planes should go last // the last check is by the creation time - slices.SortFunc(machineRequests, func(a, b *cloud.MachineRequest) int { + slices.SortFunc(machineRequests, func(a, b *infra.MachineRequest) int { if val := compareFlags(inUse, a, b); val != 0 { return val } @@ -289,7 +289,7 @@ func scaleDown(ctx context.Context, r controller.ReaderWriter, machineRequests [ return nil } -func deleteMachineRequest(ctx context.Context, r controller.ReaderWriter, request *cloud.MachineRequest, machine *machineStatusLabels) error { +func deleteMachineRequest(ctx context.Context, r controller.ReaderWriter, request *infra.MachineRequest, machine *machineStatusLabels) error { // delete the machine request if the link is removed var deleted bool @@ -310,14 +310,14 @@ func deleteMachineRequest(ctx context.Context, r controller.ReaderWriter, reques } func (h *machineRequestSetStatusHandler) reconcileTearingDown(ctx context.Context, r controller.ReaderWriter, _ *zap.Logger, machineRequestSet *omni.MachineRequestSet) error { - machineRequests, err := safe.ReaderListAll[*cloud.MachineRequest](ctx, r, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) + machineRequests, err := safe.ReaderListAll[*infra.MachineRequest](ctx, r, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) if err != nil { return err } destroyReady := true - err = machineRequests.ForEachErr(func(res *cloud.MachineRequest) error { + err = machineRequests.ForEachErr(func(res *infra.MachineRequest) error { var ready bool ready, err = teardownResource(ctx, r, res.Metadata()) @@ -371,7 +371,7 @@ func mapMachineToMachineRequest(ctx context.Context, _ *zap.Logger, r controller return nil, nil } - request, err := safe.ReaderGetByID[*cloud.MachineRequest](ctx, r, machineRequest) + request, err := safe.ReaderGetByID[*infra.MachineRequest](ctx, r, machineRequest) if err != nil { if state.IsNotFoundError(err) { return nil, nil diff --git a/internal/backend/runtime/omni/controllers/omni/machine_request_set_status_test.go b/internal/backend/runtime/omni/controllers/omni/machine_request_set_status_test.go index bc0ca9db..0ab6f423 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_request_set_status_test.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_request_set_status_test.go @@ -24,9 +24,9 @@ import ( "go.uber.org/zap" "golang.org/x/sync/errgroup" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + infraspecs "github.com/siderolabs/omni/client/api/omni/specs/infra" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/system" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/helpers" @@ -37,26 +37,26 @@ type MachineRequestSetStatusSuite struct { OmniSuite } -type testCloudProvider = qtransform.QController[*cloud.MachineRequest, *cloud.MachineRequestStatus] +type testInfraProvider = qtransform.QController[*infra.MachineRequest, *infra.MachineRequestStatus] -func newTestCloudProvider() *testCloudProvider { +func newTestInfraProvider() *testInfraProvider { return qtransform.NewQController( - qtransform.Settings[*cloud.MachineRequest, *cloud.MachineRequestStatus]{ - Name: "testCloudProvider", - MapMetadataFunc: func(request *cloud.MachineRequest) *cloud.MachineRequestStatus { - return cloud.NewMachineRequestStatus(request.Metadata().ID()) + qtransform.Settings[*infra.MachineRequest, *infra.MachineRequestStatus]{ + Name: "testInfraProvider", + MapMetadataFunc: func(request *infra.MachineRequest) *infra.MachineRequestStatus { + return infra.NewMachineRequestStatus(request.Metadata().ID()) }, - UnmapMetadataFunc: func(status *cloud.MachineRequestStatus) *cloud.MachineRequest { - return cloud.NewMachineRequest(status.Metadata().ID()) + UnmapMetadataFunc: func(status *infra.MachineRequestStatus) *infra.MachineRequest { + return infra.NewMachineRequest(status.Metadata().ID()) }, - TransformExtraOutputFunc: func(_ context.Context, _ controller.ReaderWriter, _ *zap.Logger, machineRequest *cloud.MachineRequest, - machineRequestStatus *cloud.MachineRequestStatus, + TransformExtraOutputFunc: func(_ context.Context, _ controller.ReaderWriter, _ *zap.Logger, machineRequest *infra.MachineRequest, + machineRequestStatus *infra.MachineRequestStatus, ) error { if machineRequestStatus.TypedSpec().Value.Id == "" { machineRequestStatus.TypedSpec().Value.Id = uuid.New().String() } - machineRequestStatus.TypedSpec().Value.Stage = cloudspecs.MachineRequestStatusSpec_PROVISIONED + machineRequestStatus.TypedSpec().Value.Stage = infraspecs.MachineRequestStatusSpec_PROVISIONED helpers.CopyAllLabels(machineRequest, machineRequestStatus) @@ -88,7 +88,7 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { imageFactory := imageFactoryClientMock{} require.NoError(suite.runtime.RegisterQController(omnictrl.NewMachineRequestSetStatusController(&imageFactory))) - require.NoError(suite.runtime.RegisterQController(newTestCloudProvider())) + require.NoError(suite.runtime.RegisterQController(newTestInfraProvider())) machineRequestSet := omni.NewMachineRequestSet(resources.DefaultNamespace, "test") @@ -111,7 +111,7 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { var ids []resource.ID err = retry.Constant(time.Second*5).RetryWithContext(ctx, func(ctx context.Context) error { - ids = rtestutils.ResourceIDs[*cloud.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) + ids = rtestutils.ResourceIDs[*infra.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) if len(ids) != int(machineRequestSet.TypedSpec().Value.MachineCount) { return retry.ExpectedErrorf("expected %d requests got %d", machineRequestSet.TypedSpec().Value.MachineCount, len(ids)) @@ -122,13 +122,13 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { suite.Require().NoError(err) - rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(r *cloud.MachineRequest, assert *assert.Assertions) { + rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(r *infra.MachineRequest, assert *assert.Assertions) { l, ok := r.Metadata().Labels().Get(omni.LabelMachineRequestSet) assert.True(ok) assert.Equal(l, machineRequestSet.Metadata().ID()) - l, ok = r.Metadata().Labels().Get(omni.LabelCloudProviderID) + l, ok = r.Metadata().Labels().Get(omni.LabelInfraProviderID) assert.True(ok) assert.Equal(l, machineRequestSet.TypedSpec().Value.ProviderId) @@ -137,9 +137,9 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { assert.Equal(defaultSchematic, r.TypedSpec().Value.SchematicId) }) - rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(*cloud.MachineRequestStatus, *assert.Assertions) {}) + rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(*infra.MachineRequestStatus, *assert.Assertions) {}) - requestStatuses, err := safe.ReaderListAll[*cloud.MachineRequestStatus](ctx, suite.state, + requestStatuses, err := safe.ReaderListAll[*infra.MachineRequestStatus](ctx, suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID())), ) @@ -154,10 +154,10 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { rtestutils.Destroy[*system.ResourceLabels[*omni.MachineStatus]](ctx, suite.T(), suite.state, machineIDs) - rtestutils.AssertNoResource[*cloud.MachineRequest](ctx, suite.T(), suite.state, ids[0]) + rtestutils.AssertNoResource[*infra.MachineRequest](ctx, suite.T(), suite.state, ids[0]) err = retry.Constant(time.Second*5).RetryWithContext(ctx, func(ctx context.Context) error { - ids = rtestutils.ResourceIDs[*cloud.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) + ids = rtestutils.ResourceIDs[*infra.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) if len(ids) != int(machineRequestSet.TypedSpec().Value.MachineCount) { return retry.ExpectedErrorf("expected %d requests got %d", machineRequestSet.TypedSpec().Value.MachineCount, len(ids)) @@ -168,13 +168,13 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { suite.Require().NoError(err) - rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(r *cloud.MachineRequest, assert *assert.Assertions) { + rtestutils.AssertResources(ctx, suite.T(), suite.state, ids, func(r *infra.MachineRequest, assert *assert.Assertions) { l, ok := r.Metadata().Labels().Get(omni.LabelMachineRequestSet) assert.True(ok) assert.Equal(l, machineRequestSet.Metadata().ID()) - l, ok = r.Metadata().Labels().Get(omni.LabelCloudProviderID) + l, ok = r.Metadata().Labels().Get(omni.LabelInfraProviderID) assert.True(ok) assert.Equal(l, machineRequestSet.TypedSpec().Value.ProviderId) @@ -193,7 +193,7 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { suite.Require().NoError(err) err = retry.Constant(time.Second*5).RetryWithContext(ctx, func(ctx context.Context) error { - ids = rtestutils.ResourceIDs[*cloud.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) + ids = rtestutils.ResourceIDs[*infra.MachineRequest](ctx, suite.T(), suite.state, state.WithLabelQuery(resource.LabelEqual(omni.LabelMachineRequestSet, machineRequestSet.Metadata().ID()))) if len(ids) != int(machineRequestSet.TypedSpec().Value.MachineCount) { return retry.ExpectedErrorf("expected %d requests got %d", machineRequestSet.TypedSpec().Value.MachineCount, len(ids)) @@ -207,7 +207,7 @@ func (suite *MachineRequestSetStatusSuite) TestReconcile() { // remove the machine request set rtestutils.DestroyAll[*omni.MachineRequestSet](ctx, suite.T(), suite.state) - requests, err := safe.ReaderListAll[*cloud.MachineRequest](ctx, suite.state) + requests, err := safe.ReaderListAll[*infra.MachineRequest](ctx, suite.state) suite.Require().NoError(err) suite.Require().True(requests.Len() == 0) @@ -218,7 +218,7 @@ func (suite *MachineRequestSetStatusSuite) reconcileLabels(ctx context.Context) return func() error { ch := make(chan state.Event) - err := suite.state.WatchKind(ctx, cloud.NewMachineRequestStatus("").Metadata(), ch) + err := suite.state.WatchKind(ctx, infra.NewMachineRequestStatus("").Metadata(), ch) if err != nil { return err } @@ -233,7 +233,7 @@ func (suite *MachineRequestSetStatusSuite) reconcileLabels(ctx context.Context) case state.Errored: return event.Error case state.Destroyed: - status := event.Resource.(*cloud.MachineRequestStatus) //nolint:errcheck,forcetypeassert + status := event.Resource.(*infra.MachineRequestStatus) //nolint:errcheck,forcetypeassert res := system.NewResourceLabels[*omni.MachineStatus](status.TypedSpec().Value.Id) _, err = suite.state.Teardown(ctx, res.Metadata()) @@ -263,7 +263,7 @@ func (suite *MachineRequestSetStatusSuite) reconcileLabels(ctx context.Context) return err } case state.Created, state.Updated: - status := event.Resource.(*cloud.MachineRequestStatus) //nolint:errcheck,forcetypeassert + status := event.Resource.(*infra.MachineRequestStatus) //nolint:errcheck,forcetypeassert res := system.NewResourceLabels[*omni.MachineStatus](status.TypedSpec().Value.Id) diff --git a/internal/backend/runtime/omni/controllers/omni/machine_set_node.go b/internal/backend/runtime/omni/controllers/omni/machine_set_node.go index cf8d0ad5..7d2a683b 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_set_node.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_set_node.go @@ -23,7 +23,7 @@ import ( "github.com/siderolabs/omni/client/api/omni/specs" "github.com/siderolabs/omni/client/pkg/cosi/labels" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/system" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/helpers" @@ -85,8 +85,8 @@ func (ctrl *MachineSetNodeController) Inputs() []controller.Input { Kind: controller.InputDestroyReady, }, { - Namespace: resources.CloudProviderNamespace, - Type: cloud.MachineRequestStatusType, + Namespace: resources.InfraProviderNamespace, + Type: infra.MachineRequestStatusType, Kind: controller.InputStrong, }, } @@ -139,7 +139,7 @@ func (ctrl *MachineSetNodeController) Run(ctx context.Context, r controller.Runt err = allMachines.ForEachErr(func(machine *omni.Machine) error { requestName, ok := machine.Metadata().Labels().Get(omni.LabelMachineRequest) if ok { - request, e := safe.ReaderGetByID[*cloud.MachineRequestStatus](ctx, r, requestName) + request, e := safe.ReaderGetByID[*infra.MachineRequestStatus](ctx, r, requestName) if e != nil && !state.IsNotFoundError(e) { return e } diff --git a/internal/backend/runtime/omni/cloudprovider/cloudprovider.go b/internal/backend/runtime/omni/infraprovider/infraprovider.go similarity index 54% rename from internal/backend/runtime/omni/cloudprovider/cloudprovider.go rename to internal/backend/runtime/omni/infraprovider/infraprovider.go index d88feced..b5b6b0e8 100644 --- a/internal/backend/runtime/omni/cloudprovider/cloudprovider.go +++ b/internal/backend/runtime/omni/infraprovider/infraprovider.go @@ -3,5 +3,5 @@ // Use of this software is governed by the Business Source License // included in the LICENSE file. -// Package cloudprovider provides the state validation options for the cloud provider resources. -package cloudprovider +// Package infraprovider provides the state validation options for the infra provider resources. +package infraprovider diff --git a/internal/backend/runtime/omni/cloudprovider/state.go b/internal/backend/runtime/omni/infraprovider/state.go similarity index 65% rename from internal/backend/runtime/omni/cloudprovider/state.go rename to internal/backend/runtime/omni/infraprovider/state.go index fe145aa1..a0439752 100644 --- a/internal/backend/runtime/omni/cloudprovider/state.go +++ b/internal/backend/runtime/omni/infraprovider/state.go @@ -3,7 +3,7 @@ // Use of this software is governed by the Business Source License // included in the LICENSE file. -package cloudprovider +package infraprovider import ( "context" @@ -17,7 +17,7 @@ import ( "google.golang.org/grpc/status" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/panichandler" "github.com/siderolabs/omni/internal/backend/runtime/omni/validated" @@ -26,12 +26,12 @@ import ( "github.com/siderolabs/omni/internal/pkg/auth/role" ) -// cloudProviderResourceSuffix is the suffix of the cloud provider specific resources. +// infraProviderResourceSuffix is the suffix of the infra provider specific resources. // -// They must follow the pattern: ..cloudprovider.sidero.dev. -const cloudProviderResourceSuffix = ".cloudprovider.sidero.dev" +// They must follow the pattern: ..infraprovider.sidero.dev. +const infraProviderResourceSuffix = ".infraprovider.sidero.dev" -// State is a state implementation doing special handling of the cloud-provider specific resources. +// State is a state implementation doing special handling of the infra-provider specific resources. type State struct { innerState state.CoreState logger *zap.Logger @@ -51,7 +51,7 @@ func NewState(innerState state.CoreState, logger *zap.Logger) *State { // Get implements state.CoreState interface. func (st *State) Get(ctx context.Context, pointer resource.Pointer, option ...state.GetOption) (resource.Resource, error) { - cloudProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) + infraProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) if err != nil { return nil, err } @@ -61,12 +61,12 @@ func (st *State) Get(ctx context.Context, pointer resource.Pointer, option ...st return nil, err } - if cloudProviderID == "" { + if infraProviderID == "" { return res, nil } - resCloudProviderID, ok := res.Metadata().Labels().Get(omni.LabelCloudProviderID) - if ok && cloudProviderID == resCloudProviderID { + resInfraProviderID, ok := res.Metadata().Labels().Get(omni.LabelInfraProviderID) + if ok && infraProviderID == resInfraProviderID { return res, nil } @@ -75,7 +75,7 @@ func (st *State) Get(ctx context.Context, pointer resource.Pointer, option ...st // List implements state.CoreState interface. func (st *State) List(ctx context.Context, kind resource.Kind, option ...state.ListOption) (resource.List, error) { - cloudProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) + infraProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) if err != nil { return resource.List{}, err } @@ -85,15 +85,15 @@ func (st *State) List(ctx context.Context, kind resource.Kind, option ...state.L return resource.List{}, err } - if cloudProviderID == "" { + if infraProviderID == "" { return list, nil } filteredList := make([]resource.Resource, 0, len(list.Items)) for _, item := range list.Items { - resCloudProviderID, ok := item.Metadata().Labels().Get(omni.LabelCloudProviderID) - if ok && cloudProviderID == resCloudProviderID { + resInfraProviderID, ok := item.Metadata().Labels().Get(omni.LabelInfraProviderID) + if ok && infraProviderID == resInfraProviderID { filteredList = append(filteredList, item) } } @@ -103,27 +103,27 @@ func (st *State) List(ctx context.Context, kind resource.Kind, option ...state.L // Create implements state.CoreState interface. func (st *State) Create(ctx context.Context, resource resource.Resource, option ...state.CreateOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, resource.Metadata().Namespace(), resource.Metadata().Type()) + infraProviderID, err := st.checkAuthorization(ctx, resource.Metadata().Namespace(), resource.Metadata().Type()) if err != nil { return err } - if cloudProviderID != "" && resource.Metadata().Type() == cloud.MachineRequestType { - return status.Errorf(codes.PermissionDenied, "cloud providers are not allowed to create machine requests") + if infraProviderID != "" && resource.Metadata().Type() == infra.MachineRequestType { + return status.Errorf(codes.PermissionDenied, "infra providers are not allowed to create machine requests") } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.Create(ctx, resource, option...) } - resource.Metadata().Labels().Set(omni.LabelCloudProviderID, cloudProviderID) + resource.Metadata().Labels().Set(omni.LabelInfraProviderID, infraProviderID) return st.innerState.Create(ctx, resource, option...) } // Update implements state.CoreState interface. func (st *State) Update(ctx context.Context, newResource resource.Resource, opts ...state.UpdateOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, newResource.Metadata().Namespace(), newResource.Metadata().Type()) + infraProviderID, err := st.checkAuthorization(ctx, newResource.Metadata().Namespace(), newResource.Metadata().Type()) if err != nil { return err } @@ -133,11 +133,11 @@ func (st *State) Update(ctx context.Context, newResource resource.Resource, opts return err } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.Update(ctx, newResource, opts...) } - if newResource.Metadata().Type() == cloud.MachineRequestType { + if newResource.Metadata().Type() == infra.MachineRequestType { oldMd := oldResource.Metadata().Copy() oldMd.Finalizers().Set(resource.Finalizers{}) @@ -145,13 +145,13 @@ func (st *State) Update(ctx context.Context, newResource resource.Resource, opts newMd.Finalizers().Set(resource.Finalizers{}) if !oldMd.Equal(newMd) { - return status.Errorf(codes.PermissionDenied, "cloud providers are not allowed to update machine requests other than setting finalizers") + return status.Errorf(codes.PermissionDenied, "infra providers are not allowed to update machine requests other than setting finalizers") } } - oldResCloudProviderID, ok := oldResource.Metadata().Labels().Get(omni.LabelCloudProviderID) - if ok && oldResCloudProviderID == cloudProviderID { - newResource.Metadata().Labels().Set(omni.LabelCloudProviderID, cloudProviderID) + oldResInfraProviderID, ok := oldResource.Metadata().Labels().Get(omni.LabelInfraProviderID) + if ok && oldResInfraProviderID == infraProviderID { + newResource.Metadata().Labels().Set(omni.LabelInfraProviderID, infraProviderID) return st.innerState.Update(ctx, newResource, opts...) } @@ -161,7 +161,7 @@ func (st *State) Update(ctx context.Context, newResource resource.Resource, opts // Destroy implements state.CoreState interface. func (st *State) Destroy(ctx context.Context, pointer resource.Pointer, option ...state.DestroyOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) + infraProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) if err != nil { return err } @@ -171,12 +171,12 @@ func (st *State) Destroy(ctx context.Context, pointer resource.Pointer, option . return err } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.Destroy(ctx, pointer, option...) } - resCloudProviderID, ok := res.Metadata().Labels().Get(omni.LabelCloudProviderID) - if ok && cloudProviderID == resCloudProviderID { + resInfraProviderID, ok := res.Metadata().Labels().Get(omni.LabelInfraProviderID) + if ok && infraProviderID == resInfraProviderID { return st.innerState.Destroy(ctx, pointer, option...) } @@ -185,82 +185,82 @@ func (st *State) Destroy(ctx context.Context, pointer resource.Pointer, option . // Watch implements state.CoreState interface. func (st *State) Watch(ctx context.Context, pointer resource.Pointer, eventCh chan<- state.Event, option ...state.WatchOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) + infraProviderID, err := st.checkAuthorization(ctx, pointer.Namespace(), pointer.Type()) if err != nil { return err } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.Watch(ctx, pointer, eventCh, option...) } - innerEventCh := st.filterEvents(ctx, cloudProviderID, eventCh) + innerEventCh := st.filterEvents(ctx, infraProviderID, eventCh) return st.innerState.Watch(ctx, pointer, innerEventCh, option...) } // WatchKind implements state.CoreState interface. func (st *State) WatchKind(ctx context.Context, kind resource.Kind, eventCh chan<- state.Event, option ...state.WatchKindOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) + infraProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) if err != nil { return err } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.WatchKind(ctx, kind, eventCh, option...) } - innerEventCh := st.filterEvents(ctx, cloudProviderID, eventCh) + innerEventCh := st.filterEvents(ctx, infraProviderID, eventCh) return st.innerState.WatchKind(ctx, kind, innerEventCh, option...) } // WatchKindAggregated implements state.CoreState interface. func (st *State) WatchKindAggregated(ctx context.Context, kind resource.Kind, eventsCh chan<- []state.Event, option ...state.WatchKindOption) error { - cloudProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) + infraProviderID, err := st.checkAuthorization(ctx, kind.Namespace(), kind.Type()) if err != nil { return err } - if cloudProviderID == "" { + if infraProviderID == "" { return st.innerState.WatchKindAggregated(ctx, kind, eventsCh, option...) } - innerEventsCh := st.filterEventsAggregated(ctx, cloudProviderID, eventsCh) + innerEventsCh := st.filterEventsAggregated(ctx, infraProviderID, eventsCh) return st.innerState.WatchKindAggregated(ctx, kind, innerEventsCh, option...) } -func (st *State) checkAuthorization(ctx context.Context, ns resource.Namespace, resType resource.Type) (cloudProviderID string, err error) { +func (st *State) checkAuthorization(ctx context.Context, ns resource.Namespace, resType resource.Type) (infraProviderID string, err error) { if actor.ContextIsInternalActor(ctx) { return "", nil } - checkResult, err := auth.CheckGRPC(ctx, auth.WithRole(role.CloudProvider)) + checkResult, err := auth.CheckGRPC(ctx, auth.WithRole(role.InfraProvider)) if err != nil { return "", err } - // if the role is exactly CloudProvider, additionally, check for the label match - if checkResult.Role == role.CloudProvider { + // if the role is exactly InfraProvider, additionally, check for the label match + if checkResult.Role == role.InfraProvider { var checkLabel bool - checkLabel, err = st.checkNamespaceAndType(ns, checkResult.CloudProviderID, resType) + checkLabel, err = st.checkNamespaceAndType(ns, checkResult.InfraProviderID, resType) if err != nil { return "", err } - // return the cloud provider ID only for the resource live in a shared namespace, i.e., "cloud-provider" - // as their cloud provider ID label needs to be checked. + // return the infra provider ID only for the resource live in a shared namespace, i.e., "infra-provider" + // as their infra provider ID label needs to be checked. if checkLabel { - return checkResult.CloudProviderID, nil + return checkResult.InfraProviderID, nil } } return "", nil } -func (st *State) filterEvents(ctx context.Context, cloudProviderID string, eventCh chan<- state.Event) chan state.Event { +func (st *State) filterEvents(ctx context.Context, infraProviderID string, eventCh chan<- state.Event) chan state.Event { innerEventCh := make(chan state.Event) panichandler.Go(func() { @@ -283,8 +283,8 @@ func (st *State) filterEvents(ctx context.Context, cloudProviderID string, event } if event.Resource != nil { - resCloudProviderID, cpOk := event.Resource.Metadata().Labels().Get(omni.LabelCloudProviderID) - if !cpOk || cloudProviderID != resCloudProviderID { + resInfraProviderID, cpOk := event.Resource.Metadata().Labels().Get(omni.LabelInfraProviderID) + if !cpOk || infraProviderID != resInfraProviderID { continue // discard } } @@ -297,7 +297,7 @@ func (st *State) filterEvents(ctx context.Context, cloudProviderID string, event return innerEventCh } -func (st *State) filterEventsAggregated(ctx context.Context, cloudProviderID string, eventsCh chan<- []state.Event) chan []state.Event { +func (st *State) filterEventsAggregated(ctx context.Context, infraProviderID string, eventsCh chan<- []state.Event) chan []state.Event { innerEventsCh := make(chan []state.Event) panichandler.Go(func() { @@ -317,8 +317,8 @@ func (st *State) filterEventsAggregated(ctx context.Context, cloudProviderID str for _, event := range events { if event.Resource != nil { - resCloudProviderID, cpOk := event.Resource.Metadata().Labels().Get(omni.LabelCloudProviderID) - if !cpOk || cloudProviderID != resCloudProviderID { + resInfraProviderID, cpOk := event.Resource.Metadata().Labels().Get(omni.LabelInfraProviderID) + if !cpOk || infraProviderID != resInfraProviderID { continue // discard } } @@ -334,14 +334,14 @@ func (st *State) filterEventsAggregated(ctx context.Context, cloudProviderID str return innerEventsCh } -func (st *State) checkNamespaceAndType(ns resource.Namespace, cloudProviderID string, resType resource.Type) (checkLabel bool, err error) { - if ns == resources.CloudProviderNamespace { +func (st *State) checkNamespaceAndType(ns resource.Namespace, infraProviderID string, resType resource.Type) (checkLabel bool, err error) { + if ns == resources.InfraProviderNamespace { return true, nil } - cloudProviderSpecificNamespace := resources.CloudProviderSpecificNamespacePrefix + cloudProviderID - if ns == cloudProviderSpecificNamespace { - resTypeSuffix := "." + cloudProviderID + cloudProviderResourceSuffix + infraProviderSpecificNamespace := resources.InfraProviderSpecificNamespacePrefix + infraProviderID + if ns == infraProviderSpecificNamespace { + resTypeSuffix := "." + infraProviderID + infraProviderResourceSuffix if !strings.HasSuffix(resType, resTypeSuffix) { return false, status.Errorf(codes.InvalidArgument, "resources in namespace %q must have a type suffix %q", ns, resTypeSuffix) @@ -351,5 +351,5 @@ func (st *State) checkNamespaceAndType(ns resource.Namespace, cloudProviderID st } return false, status.Errorf(codes.PermissionDenied, "namespace not allowed, must be one of %s or %s", - resources.CloudProviderNamespace, cloudProviderSpecificNamespace) + resources.InfraProviderNamespace, infraProviderSpecificNamespace) } diff --git a/internal/backend/runtime/omni/cloudprovider/state_test.go b/internal/backend/runtime/omni/infraprovider/state_test.go similarity index 69% rename from internal/backend/runtime/omni/cloudprovider/state_test.go rename to internal/backend/runtime/omni/infraprovider/state_test.go index b8e3f3bb..0bd2d863 100644 --- a/internal/backend/runtime/omni/cloudprovider/state_test.go +++ b/internal/backend/runtime/omni/infraprovider/state_test.go @@ -3,7 +3,7 @@ // Use of this software is governed by the Business Source License // included in the LICENSE file. -package cloudprovider_test +package infraprovider_test import ( "context" @@ -23,11 +23,11 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - cloudspecs "github.com/siderolabs/omni/client/api/omni/specs/cloud" + infraspecs "github.com/siderolabs/omni/client/api/omni/specs/infra" "github.com/siderolabs/omni/client/pkg/omni/resources" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" - "github.com/siderolabs/omni/internal/backend/runtime/omni/cloudprovider" + "github.com/siderolabs/omni/internal/backend/runtime/omni/infraprovider" "github.com/siderolabs/omni/internal/backend/runtime/omni/validated" "github.com/siderolabs/omni/internal/pkg/auth" "github.com/siderolabs/omni/internal/pkg/auth/actor" @@ -36,34 +36,34 @@ import ( ) const ( - cloudProviderID = "qemu-1" + infraProviderID = "qemu-1" talosVersion = "v1.2.3" schematicID = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" - cloudProviderResNamespace = resources.CloudProviderSpecificNamespacePrefix + cloudProviderID + infraProviderResNamespace = resources.InfraProviderSpecificNamespacePrefix + infraProviderID ) -func TestCloudProviderAccess(t *testing.T) { +func TestInfraProviderAccess(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) t.Cleanup(cancel) - ctx = prepareCloudProviderServiceAccount(ctx) + ctx = prepareInfraProviderServiceAccount(ctx) logger := zaptest.NewLogger(t) innerSt := namespaced.NewState(inmem.Build) - st := state.WrapCore(cloudprovider.NewState(innerSt, logger)) + st := state.WrapCore(infraprovider.NewState(innerSt, logger)) // MachineRequest - mr := cloud.NewMachineRequest("test-mr") + mr := infra.NewMachineRequest("test-mr") // create err := st.Create(ctx, mr) - assert.ErrorContains(t, err, "cloud providers are not allowed to create machine requests") + assert.ErrorContains(t, err, "infra providers are not allowed to create machine requests") // prepare for update - mr.Metadata().Labels().Set(omni.LabelCloudProviderID, cloudProviderID) + mr.Metadata().Labels().Set(omni.LabelInfraProviderID, infraProviderID) mr.TypedSpec().Value.TalosVersion = talosVersion mr.TypedSpec().Value.SchematicId = schematicID @@ -71,7 +71,7 @@ func TestCloudProviderAccess(t *testing.T) { require.NoError(t, innerSt.Create(ctx, mr)) // update spec - _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *cloud.MachineRequest) error { + _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *infra.MachineRequest) error { res.TypedSpec().Value.TalosVersion = "v1.2.4" return nil @@ -80,15 +80,15 @@ func TestCloudProviderAccess(t *testing.T) { assert.ErrorContains(t, err, "machine request spec is immutable") // update metadata labels - _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *cloud.MachineRequest) error { + _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *infra.MachineRequest) error { res.Metadata().Labels().Set("foo", "bar") return nil }) - assert.ErrorContains(t, err, "cloud providers are not allowed to update machine requests other than setting finalizers") + assert.ErrorContains(t, err, "infra providers are not allowed to update machine requests other than setting finalizers") // update metadata - add finalizer - _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *cloud.MachineRequest) error { + _, err = safe.StateUpdateWithConflicts(ctx, st, mr.Metadata(), func(res *infra.MachineRequest) error { res.Metadata().Finalizers().Add("foobar") return nil @@ -97,7 +97,7 @@ func TestCloudProviderAccess(t *testing.T) { // MachineRequestStatus - mrs := cloud.NewMachineRequestStatus("test-mrs") + mrs := infra.NewMachineRequestStatus("test-mrs") // create assert.NoError(t, st.Create(ctx, mrs)) @@ -106,15 +106,15 @@ func TestCloudProviderAccess(t *testing.T) { res, err := innerSt.Get(ctx, mrs.Metadata()) require.NoError(t, err) - cpID, _ := res.Metadata().Labels().Get(omni.LabelCloudProviderID) - assert.Equal(t, cloudProviderID, cpID) + cpID, _ := res.Metadata().Labels().Get(omni.LabelInfraProviderID) + assert.Equal(t, infraProviderID, cpID) // update - _, err = safe.StateUpdateWithConflicts(ctx, st, mrs.Metadata(), func(res *cloud.MachineRequestStatus) error { + _, err = safe.StateUpdateWithConflicts(ctx, st, mrs.Metadata(), func(res *infra.MachineRequestStatus) error { res.Metadata().Labels().Set("foo", "bar") res.TypedSpec().Value.Id = "12345" - res.TypedSpec().Value.Stage = cloudspecs.MachineRequestStatusSpec_PROVISIONING + res.TypedSpec().Value.Stage = infraspecs.MachineRequestStatusSpec_PROVISIONING return nil }) @@ -132,8 +132,8 @@ func TestInternalAccess(t *testing.T) { logger := zaptest.NewLogger(t) innerSt := namespaced.NewState(inmem.Build) - st := state.WrapCore(cloudprovider.NewState(innerSt, logger)) - mr := cloud.NewMachineRequest("test-mr") + st := state.WrapCore(infraprovider.NewState(innerSt, logger)) + mr := infra.NewMachineRequest("test-mr") err := st.Create(ctx, mr) assert.True(t, validated.IsValidationError(err)) @@ -147,21 +147,21 @@ func TestInternalAccess(t *testing.T) { assert.NoError(t, err) } -func TestCloudProviderSpecificNamespace(t *testing.T) { +func TestInfraProviderSpecificNamespace(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) t.Cleanup(cancel) - ctx = prepareCloudProviderServiceAccount(ctx) + ctx = prepareInfraProviderServiceAccount(ctx) logger := zaptest.NewLogger(t) innerSt := namespaced.NewState(inmem.Build) - st := state.WrapCore(cloudprovider.NewState(innerSt, logger)) + st := state.WrapCore(infraprovider.NewState(innerSt, logger)) - // try to create and update a resource in the cloud-provider specific namespace, i.e., "cloud-provider:qemu-1", assert that it is allowed + // try to create and update a resource in the infra-provider specific namespace, i.e., "infra-provider:qemu-1", assert that it is allowed - res1 := newTestRes(cloudProviderResNamespace, "test-res-1", testResSpec{str: "foo"}) + res1 := newTestRes(infraProviderResNamespace, "test-res-1", testResSpec{str: "foo"}) require.NoError(t, st.Create(ctx, res1)) @@ -174,62 +174,62 @@ func TestCloudProviderSpecificNamespace(t *testing.T) { assert.NoError(t, st.Destroy(ctx, res1.Metadata())) - // try to create a resource in the cloud-provider specific namespace of a different cloud provider, i.e., "cloud-provider:qemu-2", assert that it is not allowed + // try to create a resource in the infra-provider specific namespace of a different infra provider, i.e., "infra-provider:qemu-2", assert that it is not allowed - res2 := newTestRes(resources.CloudProviderSpecificNamespacePrefix+"qemu-2", "test-res-2", testResSpec{str: "foo"}) + res2 := newTestRes(resources.InfraProviderSpecificNamespacePrefix+"qemu-2", "test-res-2", testResSpec{str: "foo"}) err = st.Create(ctx, res2) assert.Equal(t, codes.PermissionDenied, status.Code(err)) assert.ErrorContains(t, err, "namespace not allowed, must be one of") - // try to create a resource with omni-internal type, i.e., "ExposedServices.omni.sidero.dev" in the cloud-provider specific namespace - assert that it is not allowed + // try to create a resource with omni-internal type, i.e., "ExposedServices.omni.sidero.dev" in the infra-provider specific namespace - assert that it is not allowed - omniRes := omni.NewExposedService(cloudProviderResNamespace, "test-res-3") + omniRes := omni.NewExposedService(infraProviderResNamespace, "test-res-3") err = st.Create(ctx, omniRes) assert.Equal(t, codes.InvalidArgument, status.Code(err)) - assert.ErrorContains(t, err, `resources in namespace "cloud-provider:qemu-1" must have a type suffix ".qemu-1.cloudprovider.sidero.dev"`) + assert.ErrorContains(t, err, `resources in namespace "infra-provider:qemu-1" must have a type suffix ".qemu-1.infraprovider.sidero.dev"`) } -func TestCloudProviderIDChecks(t *testing.T) { +func TestInfraProviderIDChecks(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) t.Cleanup(cancel) - ctx = prepareCloudProviderServiceAccount(ctx) + ctx = prepareInfraProviderServiceAccount(ctx) logger := zaptest.NewLogger(t) innerSt := namespaced.NewState(inmem.Build) - st := state.WrapCore(cloudprovider.NewState(innerSt, logger)) + st := state.WrapCore(infraprovider.NewState(innerSt, logger)) prepareResources(ctx, t, innerSt) - // Get - assert that it is checked against cloud provider id + // Get - assert that it is checked against infra provider id - _, err := st.Get(ctx, cloud.NewMachineRequest("mr-1").Metadata()) + _, err := st.Get(ctx, infra.NewMachineRequest("mr-1").Metadata()) assert.NoError(t, err) - _, err = st.Get(ctx, cloud.NewMachineRequest("mr-2").Metadata()) + _, err = st.Get(ctx, infra.NewMachineRequest("mr-2").Metadata()) assert.Equal(t, codes.NotFound, status.Code(err)) - // List - assert that it is filtered by cloud provider id + // List - assert that it is filtered by infra provider id - list, err := st.List(ctx, cloud.NewMachineRequest("").Metadata()) + list, err := st.List(ctx, infra.NewMachineRequest("").Metadata()) assert.NoError(t, err) if assert.Len(t, list.Items, 1) { assert.Equal(t, "mr-1", list.Items[0].Metadata().ID()) } - // Watch - assert that it is filtered by cloud provider id + // Watch - assert that it is filtered by infra provider id watchCtx, cancel := context.WithTimeout(ctx, 500*time.Millisecond) t.Cleanup(cancel) eventCh := make(chan state.Event) - err = st.Watch(watchCtx, cloud.NewMachineRequest("mr-1").Metadata(), eventCh) + err = st.Watch(watchCtx, infra.NewMachineRequest("mr-1").Metadata(), eventCh) require.NoError(t, err) assertEvents(watchCtx, t, eventCh, []eventInfo{ @@ -246,21 +246,21 @@ func TestCloudProviderIDChecks(t *testing.T) { eventCh = make(chan state.Event) - err = st.Watch(watchCtx, cloud.NewMachineRequest("mr-2").Metadata(), eventCh) + err = st.Watch(watchCtx, infra.NewMachineRequest("mr-2").Metadata(), eventCh) require.NoError(t, err) assertEvents(watchCtx, t, eventCh, nil) cancel() - // WatchKind - assert that it is filtered by cloud provider id + // WatchKind - assert that it is filtered by infra provider id watchCtx, cancel = context.WithTimeout(ctx, 500*time.Millisecond) t.Cleanup(cancel) eventCh = make(chan state.Event) - err = st.WatchKind(watchCtx, cloud.NewMachineRequest("").Metadata(), eventCh, state.WithBootstrapContents(true)) + err = st.WatchKind(watchCtx, infra.NewMachineRequest("").Metadata(), eventCh, state.WithBootstrapContents(true)) require.NoError(t, err) assertEvents(watchCtx, t, eventCh, []eventInfo{ @@ -275,12 +275,12 @@ func TestCloudProviderIDChecks(t *testing.T) { cancel() - // Destroy - assert that it is checked against cloud provider id + // Destroy - assert that it is checked against infra provider id - err = st.Destroy(ctx, cloud.NewMachineRequest("mr-1").Metadata()) + err = st.Destroy(ctx, infra.NewMachineRequest("mr-1").Metadata()) assert.NoError(t, err) - err = st.Destroy(ctx, cloud.NewMachineRequest("mr-2").Metadata()) + err = st.Destroy(ctx, infra.NewMachineRequest("mr-2").Metadata()) assert.Equal(t, codes.NotFound, status.Code(err)) } @@ -320,35 +320,35 @@ func assertEvents(ctx context.Context, t *testing.T, eventCh chan state.Event, e } func prepareResources(ctx context.Context, t *testing.T, innerSt state.CoreState) { - mr1 := cloud.NewMachineRequest("mr-1") + mr1 := infra.NewMachineRequest("mr-1") mr1.TypedSpec().Value.TalosVersion = talosVersion mr1.TypedSpec().Value.SchematicId = schematicID - mr1.Metadata().Labels().Set(omni.LabelCloudProviderID, cloudProviderID) + mr1.Metadata().Labels().Set(omni.LabelInfraProviderID, infraProviderID) - mr2 := cloud.NewMachineRequest("mr-2") + mr2 := infra.NewMachineRequest("mr-2") mr2.TypedSpec().Value.TalosVersion = "v1.2.4" mr2.TypedSpec().Value.SchematicId = "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" - mr2.Metadata().Labels().Set(omni.LabelCloudProviderID, "aws-2") + mr2.Metadata().Labels().Set(omni.LabelInfraProviderID, "aws-2") require.NoError(t, innerSt.Create(ctx, mr1)) require.NoError(t, innerSt.Create(ctx, mr2)) } -func prepareCloudProviderServiceAccount(ctx context.Context) context.Context { - fullID := cloudProviderID + "@cloud-provider.serviceaccount.omni.sidero.dev" +func prepareInfraProviderServiceAccount(ctx context.Context) context.Context { + fullID := infraProviderID + "@infra-provider.serviceaccount.omni.sidero.dev" ctx = ctxstore.WithValue(ctx, auth.EnabledAuthContextKey{Enabled: true}) ctx = ctxstore.WithValue(ctx, auth.IdentityContextKey{Identity: fullID}) ctx = ctxstore.WithValue(ctx, auth.VerifiedEmailContextKey{Email: fullID}) - ctx = ctxstore.WithValue(ctx, auth.RoleContextKey{Role: role.CloudProvider}) + ctx = ctxstore.WithValue(ctx, auth.RoleContextKey{Role: role.InfraProvider}) return ctx } // testResType is the type of testRes. -const testResType = resource.Type("TestRess." + cloudProviderID + ".cloudprovider.sidero.dev") +const testResType = resource.Type("TestRess." + infraProviderID + ".infraprovider.sidero.dev") // testRes is a test resource. type testRes = typed.Resource[testResSpec, testResExtension] @@ -368,7 +368,7 @@ type testResExtension struct{} func (testResExtension) ResourceDefinition() meta.ResourceDefinitionSpec { return meta.ResourceDefinitionSpec{ Type: testResType, - DefaultNamespace: cloudProviderResNamespace, + DefaultNamespace: infraProviderResNamespace, } } diff --git a/internal/backend/runtime/omni/cloudprovider/validation.go b/internal/backend/runtime/omni/infraprovider/validation.go similarity index 83% rename from internal/backend/runtime/omni/cloudprovider/validation.go rename to internal/backend/runtime/omni/infraprovider/validation.go index d7686ee9..c3578b04 100644 --- a/internal/backend/runtime/omni/cloudprovider/validation.go +++ b/internal/backend/runtime/omni/infraprovider/validation.go @@ -3,7 +3,7 @@ // Use of this software is governed by the Business Source License // included in the LICENSE file. -package cloudprovider +package infraprovider import ( "context" @@ -14,13 +14,13 @@ import ( "github.com/cosi-project/runtime/pkg/state" "github.com/hashicorp/go-multierror" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/internal/backend/runtime/omni/validated" ) func validationOptions() []validated.StateOption { return []validated.StateOption{ - validated.WithCreateValidations(validated.NewCreateValidationForType(func(_ context.Context, res *cloud.MachineRequest, _ ...state.CreateOption) error { + validated.WithCreateValidations(validated.NewCreateValidationForType(func(_ context.Context, res *infra.MachineRequest, _ ...state.CreateOption) error { var errs error if _, err := semver.ParseTolerant(res.TypedSpec().Value.TalosVersion); err != nil { @@ -33,7 +33,7 @@ func validationOptions() []validated.StateOption { return errs })), - validated.WithUpdateValidations(validated.NewUpdateValidationForType(func(_ context.Context, oldRes *cloud.MachineRequest, newRes *cloud.MachineRequest, _ ...state.UpdateOption) error { + validated.WithUpdateValidations(validated.NewUpdateValidationForType(func(_ context.Context, oldRes *infra.MachineRequest, newRes *infra.MachineRequest, _ ...state.UpdateOption) error { if !oldRes.TypedSpec().Value.EqualVT(newRes.TypedSpec().Value) { return errors.New("machine request spec is immutable") } diff --git a/internal/backend/runtime/omni/state.go b/internal/backend/runtime/omni/state.go index b5ebf03b..af4bc2d4 100644 --- a/internal/backend/runtime/omni/state.go +++ b/internal/backend/runtime/omni/state.go @@ -30,9 +30,9 @@ import ( "github.com/siderolabs/omni/internal/backend/logging" "github.com/siderolabs/omni/internal/backend/runtime/omni/audit" "github.com/siderolabs/omni/internal/backend/runtime/omni/audit/hooks" - "github.com/siderolabs/omni/internal/backend/runtime/omni/cloudprovider" "github.com/siderolabs/omni/internal/backend/runtime/omni/controllers/omni/etcdbackup/store" "github.com/siderolabs/omni/internal/backend/runtime/omni/external" + "github.com/siderolabs/omni/internal/backend/runtime/omni/infraprovider" "github.com/siderolabs/omni/internal/backend/runtime/omni/migration" "github.com/siderolabs/omni/internal/backend/runtime/omni/virtual" "github.com/siderolabs/omni/internal/pkg/config" @@ -90,7 +90,7 @@ func newNamespacedState(params *config.Params, primaryStorageCoreState state.Cor return nil, nil, fmt.Errorf("failed to create etcd backup store: %w", err) } - cloudProviderState := cloudprovider.NewState(primaryStorageCoreState, logger.With(logging.Component("cloudprovider_state"))) + infraProviderState := infraprovider.NewState(primaryStorageCoreState, logger.With(logging.Component("infraprovider_state"))) namespacedState := namespaced.NewState(func(ns resource.Namespace) state.CoreState { switch ns { @@ -106,11 +106,11 @@ func newNamespacedState(params *config.Params, primaryStorageCoreState state.Cor StoreFactory: storeFactory, Logger: logger, } - case resources.CloudProviderNamespace: - return cloudProviderState + case resources.InfraProviderNamespace: + return infraProviderState default: - if strings.HasPrefix(ns, resources.CloudProviderSpecificNamespacePrefix) { - return cloudProviderState + if strings.HasPrefix(ns, resources.InfraProviderSpecificNamespacePrefix) { + return infraProviderState } return primaryStorageCoreState diff --git a/internal/backend/runtime/omni/state_access.go b/internal/backend/runtime/omni/state_access.go index 7a7efe93..cd477e4f 100644 --- a/internal/backend/runtime/omni/state_access.go +++ b/internal/backend/runtime/omni/state_access.go @@ -19,8 +19,8 @@ import ( "github.com/siderolabs/omni/client/pkg/omni/resources" authres "github.com/siderolabs/omni/client/pkg/omni/resources/auth" - "github.com/siderolabs/omni/client/pkg/omni/resources/cloud" "github.com/siderolabs/omni/client/pkg/omni/resources/common" + "github.com/siderolabs/omni/client/pkg/omni/resources/infra" "github.com/siderolabs/omni/client/pkg/omni/resources/omni" "github.com/siderolabs/omni/client/pkg/omni/resources/siderolink" "github.com/siderolabs/omni/client/pkg/omni/resources/system" @@ -351,8 +351,8 @@ func filterAccess(ctx context.Context, access state.Access) error { return nil } - // check if the resource is a cloud provider resource - if it is, the access is managed in cloudprovider.State - if strings.HasPrefix(access.ResourceNamespace, resources.CloudProviderSpecificNamespacePrefix) || access.ResourceNamespace == resources.CloudProviderNamespace { + // check if the resource is a infra provider resource - if it is, the access is managed in infraprovider.State + if strings.HasPrefix(access.ResourceNamespace, resources.InfraProviderSpecificNamespacePrefix) || access.ResourceNamespace == resources.InfraProviderNamespace { return nil } @@ -360,9 +360,9 @@ func filterAccess(ctx context.Context, access state.Access) error { // authentication and authorization checks switch access.ResourceType { - case omni.MachineType, // cloud provider needs to be able to read machines to find out force-deleted ones and deprovision them - siderolink.ConnectionParamsType: // cloud provider needs to be able to read connection params to join nodes to Omni - _, err = auth.CheckGRPC(ctx, auth.WithRole(role.CloudProvider)) + case omni.MachineType, // infra provider needs to be able to read machines to find out force-deleted ones and deprovision them + siderolink.ConnectionParamsType: // infra provider needs to be able to read connection params to join nodes to Omni + _, err = auth.CheckGRPC(ctx, auth.WithRole(role.InfraProvider)) case omni.ClusterType, omni.ClusterBootstrapStatusType, @@ -503,8 +503,8 @@ func filterAccessByType(access state.Access) error { return status.Error(codes.PermissionDenied, "only read, update and delete access is permitted") case - cloud.MachineRequestType, // read-only for all except for CloudProvider role (checked in filterAccess) - cloud.MachineRequestStatusType, // read-only for all except for CloudProvider role (checked in filterAccess) + infra.MachineRequestType, // read-only for all except for InfraProvider role (checked in filterAccess) + infra.MachineRequestStatusType, // read-only for all except for InfraProvider role (checked in filterAccess) omni.ClusterBootstrapStatusType, omni.ClusterDestroyStatusType, omni.ClusterEndpointType, @@ -569,7 +569,7 @@ func filterAccessByType(access state.Access) error { virtual.KubernetesUsageType, virtual.LabelsCompletionType, virtual.ClusterPermissionsType: - // allow read access only, these resources are either managed by controllers or plugins (e.g., cloud provider plugins) + // allow read access only, these resources are either managed by controllers or plugins (e.g., infra provider plugins) if access.Verb.Readonly() { return nil } diff --git a/internal/pkg/auth/check.go b/internal/pkg/auth/check.go index 16695351..bd59a461 100644 --- a/internal/pkg/auth/check.go +++ b/internal/pkg/auth/check.go @@ -47,8 +47,8 @@ type CheckResult struct { Identity string UserID string - // CloudProviderID is the ID of the cloud provider if the identity is a cloud provider service account. - CloudProviderID string + // InfraProviderID is the ID of the infra provider if the identity is a infra provider service account. + InfraProviderID string Labels map[string]string Role role.Role @@ -176,8 +176,8 @@ func Check(ctx context.Context, opt ...CheckOption) (CheckResult, error) { result.Identity = val.Identity } - if sa, isSa := pkgaccess.ParseServiceAccountFromFullID(result.Identity); isSa && sa.IsCloudProvider { - result.CloudProviderID = sa.BaseName + if sa, isSa := pkgaccess.ParseServiceAccountFromFullID(result.Identity); isSa && sa.IsInfraProvider { + result.InfraProviderID = sa.BaseName } if val, ok := ctxstore.Value[UserIDContextKey](ctx); ok { diff --git a/internal/pkg/auth/role/role.go b/internal/pkg/auth/role/role.go index a815c2aa..60ecb37f 100644 --- a/internal/pkg/auth/role/role.go +++ b/internal/pkg/auth/role/role.go @@ -19,10 +19,10 @@ const ( // tsgen:RoleNone None Role = "None" - // CloudProvider is a role to be used solely by cloud providers. + // InfraProvider is a role to be used solely by infra providers. // - // tsgen:RoleCloudProvider - CloudProvider Role = "CloudProvider" + // tsgen:RoleInfraProvider + InfraProvider Role = "InfraProvider" // Reader is a role that has read-only capability. // @@ -40,7 +40,7 @@ const ( Admin Role = "Admin" ) -var roles = []Role{None, CloudProvider, Reader, Operator, Admin} +var roles = []Role{None, InfraProvider, Reader, Operator, Admin} var indexes = func() map[Role]int { result := make(map[Role]int, len(roles))