diff --git a/Dockerfile b/Dockerfile index 36e5cd8..5bc7a67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,28 @@ # Build the manager binary -FROM golang:1.21 as builder -ARG TARGETOS -ARG TARGETARCH +FROM golang:1.22.0 as builder + +ARG GOARCH WORKDIR /workspace # Copy the Go Modules manifests COPY go.mod go.mod COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer + RUN go mod download # Copy the go source -COPY cmd/main.go cmd/main.go +COPY cmd/lifecycle-controller-manager/main.go cmd/lifecycle-controller-manager/main.go COPY api/ api/ +COPY lcmi/ lcmi/ COPY internal/ internal/ +COPY util/ util/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -a -o manager cmd/lifecycle-controller-manager/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index b82a184..5727799 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +IMG ?= controller:latest +DOCKERFILE ?= . + .PHONY: fmt fmt: goimports go fmt ./... @@ -51,6 +54,42 @@ format: generate manifests add-license fmt lint-fix docs: gen-crd-api-reference-docs ## Run go generate to generate API reference documentation. $(GEN_CRD_API_REFERENCE_DOCS) -api-dir ./api/lifecycle/v1alpha1 -config ./hack/api-reference/config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/lifecycle.md +### BUILD IMAGES ### +.PHONY: docker-build-controller-manager +docker-build: ## Build docker image with the manager. + docker build . -t ${IMG} + +.PHONY: docker-build-lifecycle-service +docker-build-lcmi: ## Build docker image with the manager. + docker build . -t ${IMG} -f ${DOCKERFILE} + +### INSTALL AND DEPLOY ### +.PHONY: install +install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/crd | kubectl apply -f - + +.PHONY: uninstall +uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/crd | kubectl delete -f - + +.PHONY: deploy-controller-manager +deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} + $(KUSTOMIZE) build config/default | kubectl apply -f - + +.PHONY: undeploy-controller-manager +undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/default | kubectl delete -f - + +.PHONY: deploy-lifecycle-service +deploy-lcmi: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. + cd config/lcmi/manager && $(KUSTOMIZE) edit set image controller=${IMG} + $(KUSTOMIZE) build config/lcmi/default | kubectl apply -f - + +.PHONY: undeploy-lifecycle-service +undeploy-lcmi: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. + $(KUSTOMIZE) build config/lcmi/default | kubectl delete -f - + ### AUXILIARY ### LOCAL_BIN ?= $(shell pwd)/bin $(LOCAL_BIN): @@ -74,6 +113,7 @@ MODELS_SCHEMA ?= $(LOCAL_BIN)/models-schema VGOPATH ?= $(LOCAL_BIN)/vgopath GEN_CRD_API_REFERENCE_DOCS ?= $(LOCAL_BIN)/gen-crd-api-reference-docs BUF ?= $(LOCAL_BIN)/buf +KUSTOMIZE ?= $(LOCAL_BIN)/kustomize ## Tools versions ADDLICENSE_VERSION ?= v1.1.1 @@ -86,6 +126,7 @@ VGOPATH_VERSION ?= v0.1.3 GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0 MODELS_SCHEMA_VERSION ?= main BUF_VERSION ?= v1.29.0 +KUSTOMIZE_VERSION ?= v5.3.0 .PHONY: code-gen code-gen: vgopath deepcopy-gen models-schema openapi-gen applyconfiguration-gen client-gen @@ -168,7 +209,7 @@ $(CLIENT_GEN): $(LOCAL_BIN) .PHONY: kustomize kustomize: $(KUSTOMIZE) $(KUSTOMIZE): $(LOCAL_BIN) - @test -s $(KUSTOMIZE) || GOBIN=$(LOCAL_BIN) go install sigs.k8s.io/kustomize/kustomize/v4@$(KUSTOMIZE_VERSION) + @test -s $(KUSTOMIZE) || GOBIN=$(LOCAL_BIN) go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION) .PHONY: buf buf: $(BUF) diff --git a/api/lifecycle/v1alpha1/common_types.go b/api/lifecycle/v1alpha1/common_types.go index bcccaa8..31b6565 100644 --- a/api/lifecycle/v1alpha1/common_types.go +++ b/api/lifecycle/v1alpha1/common_types.go @@ -22,6 +22,7 @@ type PackageVersion struct { type ScanResult string const ( + Unspecified ScanResult = "" ScanFailure ScanResult = "Failure" ScanSuccess ScanResult = "Success" ) diff --git a/api/lifecycle/v1alpha1/machine_types.go b/api/lifecycle/v1alpha1/machine_types.go index 1754817..247f582 100644 --- a/api/lifecycle/v1alpha1/machine_types.go +++ b/api/lifecycle/v1alpha1/machine_types.go @@ -47,6 +47,7 @@ type MachineStatus struct { Message string `json:"message"` // Conditions reflects Machine conditions and their state + // +kubebuilder:validation:Optional Conditions []metav1.Condition `json:"conditions"` } diff --git a/api/lifecycle/v1alpha1/machinetype_types.go b/api/lifecycle/v1alpha1/machinetype_types.go index 2a8ff73..634584d 100644 --- a/api/lifecycle/v1alpha1/machinetype_types.go +++ b/api/lifecycle/v1alpha1/machinetype_types.go @@ -50,7 +50,6 @@ type MachineTypeStatus struct { // LastScanResult reflects the result of the last scan. // +kubebuilder:validation:Optional - // +kubebuilder:validation:Enum=Success;Failure LastScanResult ScanResult `json:"lastScanResult"` // AvailablePackages reflects the list of AvailablePackageVersion diff --git a/clientgo/openapi/zz_generated.openapi.go b/clientgo/openapi/zz_generated.openapi.go index 6beb2f4..49b27dd 100644 --- a/clientgo/openapi/zz_generated.openapi.go +++ b/clientgo/openapi/zz_generated.openapi.go @@ -7632,7 +7632,7 @@ func schema_k8sio_api_core_v1_PersistentVolumeStatus(ref common.ReferenceCallbac }, "lastPhaseTransitionTime": { SchemaProps: spec.SchemaProps{ - Description: "lastPhaseTransitionTime is the time the phase transitioned from one to another and automatically resets to current time everytime a volume phase transitions. This is an alpha field and requires enabling PersistentVolumeLastPhaseTransitionTime feature.", + Description: "lastPhaseTransitionTime is the time the phase transitioned from one to another and automatically resets to current time everytime a volume phase transitions. This is a beta field and requires the PersistentVolumeLastPhaseTransitionTime feature to be enabled (enabled by default).", Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), }, }, diff --git a/cmd/lifecycle-controller-manager/main.go b/cmd/lifecycle-controller-manager/main.go index e1ebc9f..5028326 100644 --- a/cmd/lifecycle-controller-manager/main.go +++ b/cmd/lifecycle-controller-manager/main.go @@ -4,10 +4,19 @@ package main import ( + "context" + "crypto/tls" "flag" + "net" + "net/http" "os" "time" + "connectrpc.com/connect" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1/machinev1alpha1connect" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect" + oobv1alpha1 "github.com/ironcore-dev/oob/api/v1alpha1" + "golang.org/x/net/http2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/healthz" @@ -30,11 +39,14 @@ import ( var ( scheme = runtime.NewScheme() setupLog = ctrl.Log.WithName("setup") + + lcmiEndpoint = "http://lifecycle-service-svc:8080" ) func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(lifecyclev1alpha1.AddToScheme(scheme)) + utilruntime.Must(oobv1alpha1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme } @@ -42,6 +54,8 @@ func main() { var metricsAddr string var enableLeaderElection bool var probeAddr string + var lcmiServiceAddr string + flag.StringVar(&lcmiServiceAddr, "lcmi-address", lcmiEndpoint, "The address lifecycle-service running on.") flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, @@ -67,7 +81,7 @@ func main() { os.Exit(1) } - if err = setupControllers(mgr); err != nil { + if err = setupControllers(mgr, lcmiServiceAddr); err != nil { os.Exit(1) } if err = setupHandlers(mgr); err != nil { @@ -81,19 +95,22 @@ func main() { } } -func setupControllers(mgr ctrl.Manager) error { +func setupControllers(mgr ctrl.Manager, endpoint string) error { + httpClient := setupHTTPClient() if err := (&controllers.MachineReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Log: mgr.GetLogger().WithName("lifecycle-machine-controller"), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Log: mgr.GetLogger().WithName("lifecycle-machine-controller"), + MachineServiceClient: setupMachineClient(endpoint, httpClient), }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Machine") return err } if err := (&controllers.MachineTypeReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Log: mgr.GetLogger().WithName("lifecycle-machinetype-controller"), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Log: mgr.GetLogger().WithName("lifecycle-machinetype-controller"), + MachineTypeServiceClient: setupMachineTypeClient(endpoint, httpClient), }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "MachineType") return err @@ -123,3 +140,22 @@ func setupHandlers(mgr ctrl.Manager) error { } return nil } + +func setupHTTPClient() *http.Client { + return &http.Client{ + Transport: &http2.Transport{ + AllowHTTP: true, + DialTLSContext: func(_ context.Context, network, addr string, _ *tls.Config) (net.Conn, error) { + return net.Dial(network, addr) + }, + }, + } +} + +func setupMachineClient(endpoint string, cl *http.Client) machinev1alpha1connect.MachineServiceClient { + return machinev1alpha1connect.NewMachineServiceClient(cl, endpoint, connect.WithGRPC()) +} + +func setupMachineTypeClient(endpoint string, cl *http.Client) machinetypev1alpha1connect.MachineTypeServiceClient { + return machinetypev1alpha1connect.NewMachineTypeServiceClient(cl, endpoint, connect.WithGRPC()) +} diff --git a/cmd/lifecycle-service/Dockerfile b/cmd/lifecycle-service/Dockerfile new file mode 100644 index 0000000..1baf0b9 --- /dev/null +++ b/cmd/lifecycle-service/Dockerfile @@ -0,0 +1,35 @@ +# Build the manager binary +FROM golang:1.22.0 as builder + +ARG GOARCH + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum + +RUN go mod download + +# Copy the go source +COPY cmd/lifecycle-service/ cmd/lifecycle-service +COPY api/ api/ +COPY clientgo/applyconfiguration clientgo/applyconfiguration +COPY clientgo/lifecycle clientgo/lifecycle +COPY lcmi/ lcmi/ +COPY util/ util/ + +# Build +# the GOARCH has not a default value to allow the binary be built according to the host where the command +# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO +# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, +# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -a -o manager cmd/lifecycle-service/main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:nonroot +WORKDIR / +COPY --from=builder /workspace/manager . +USER 65532:65532 + +ENTRYPOINT ["/manager"] diff --git a/cmd/lifecycle-service/app/app.go b/cmd/lifecycle-service/app/app.go index 06df137..263e20d 100644 --- a/cmd/lifecycle-service/app/app.go +++ b/cmd/lifecycle-service/app/app.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + package app import ( @@ -6,7 +9,7 @@ import ( "os" "time" - "github.com/ironcore-dev/lifecycle-manager/lcmi/server" + "github.com/ironcore-dev/lifecycle-manager/lcmi/svc" "github.com/spf13/cobra" "github.com/spf13/pflag" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -30,20 +33,24 @@ type Options struct { kubeconfig string logLevel string logFormat string + host string port int namespace string scanPeriod time.Duration horizon time.Duration + dev bool } func (o *Options) addFlags(fs *pflag.FlagSet) { fs.StringVar(&o.kubeconfig, "kubeconfig", "", "path to kubeconfig file") fs.StringVar(&o.logLevel, "log-level", "info", "logging level") fs.StringVar(&o.logFormat, "log-format", "json", "logging format") - fs.IntVar(&o.port, "port", 26500, "bind port") + fs.StringVar(&o.host, "host", "", "bind host") + fs.IntVar(&o.port, "port", 8080, "bind port") fs.StringVar(&o.namespace, "namespace", "default", "default namespace name") fs.DurationVar(&o.scanPeriod, "scan-period", time.Hour*24, "scan period") fs.DurationVar(&o.horizon, "horizon", time.Minute*30, "allowed lag for scan period check") + fs.BoolVar(&o.dev, "dev", false, "development mode flag") } func Command() *cobra.Command { @@ -70,28 +77,29 @@ func Run(ctx context.Context, opts Options) error { return err } - srvOpts := server.Options{ + srvOpts := svc.Options{ Cfg: cfg, - Log: setupLogger(LogFormat(opts.logFormat), logLevelMapping[opts.logLevel]), + Log: setupLogger(LogFormat(opts.logFormat), logLevelMapping[opts.logLevel], opts.dev), + Host: opts.host, Port: opts.port, Namespace: opts.namespace, ScanPeriod: opts.scanPeriod, Horizon: opts.horizon, } - srv := server.NewLifecycleGRPCServer(srvOpts) + srv := svc.NewGrpcServer(srvOpts) return srv.Start(ctx) } -func setupLogger(format LogFormat, level slog.Leveler) *slog.Logger { +func setupLogger(format LogFormat, level slog.Leveler, dev bool) *slog.Logger { switch format { case JSON: return slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{ - AddSource: true, + AddSource: dev, Level: level, })) case Text: return slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ - AddSource: true, + AddSource: dev, Level: level, })) } diff --git a/cmd/lifecycle-service/app/signal.go b/cmd/lifecycle-service/app/signal.go new file mode 100644 index 0000000..f263eff --- /dev/null +++ b/cmd/lifecycle-service/app/signal.go @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package app + +import ( + "context" + "os" + "os/signal" + "syscall" +) + +var ( + shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} + onlyOneSignalHandler = make(chan struct{}) +) + +// SetupSignalHandler registers for SIGTERM and SIGINT. A context is returned +// which is canceled on one of these signals. +func SetupSignalHandler() context.Context { + close(onlyOneSignalHandler) // panics when called twice + + ctx, cancel := context.WithCancel(context.Background()) + c := make(chan os.Signal, 1) + signal.Notify(c, shutdownSignals...) + go func() { + <-c + cancel() + }() + + return ctx +} diff --git a/cmd/lifecycle-service/main.go b/cmd/lifecycle-service/main.go index 2dcf96f..f8119be 100644 --- a/cmd/lifecycle-service/main.go +++ b/cmd/lifecycle-service/main.go @@ -11,12 +11,11 @@ import ( // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" - controllerruntime "sigs.k8s.io/controller-runtime" // +kubebuilder:scaffold:imports ) func main() { - ctx := controllerruntime.SetupSignalHandler() + ctx := app.SetupSignalHandler() if err := app.Command().ExecuteContext(ctx); err != nil { fmt.Println(err.Error()) diff --git a/config/crd/bases/lifecycle.ironcore.dev_machines.yaml b/config/crd/bases/lifecycle.ironcore.dev_machines.yaml index 821dc89..162ddee 100644 --- a/config/crd/bases/lifecycle.ironcore.dev_machines.yaml +++ b/config/crd/bases/lifecycle.ironcore.dev_machines.yaml @@ -179,8 +179,6 @@ spec: message: description: Message contains verbose message explaining current state type: string - required: - - conditions type: object type: object served: true diff --git a/config/crd/bases/lifecycle.ironcore.dev_machinetypes.yaml b/config/crd/bases/lifecycle.ironcore.dev_machinetypes.yaml index f7de010..db9ee81 100644 --- a/config/crd/bases/lifecycle.ironcore.dev_machinetypes.yaml +++ b/config/crd/bases/lifecycle.ironcore.dev_machinetypes.yaml @@ -155,9 +155,6 @@ spec: type: array lastScanResult: description: LastScanResult reflects the result of the last scan. - enum: - - Success - - Failure type: string lastScanTime: description: LastScanTime reflects the timestamp when the last scan diff --git a/config/lcmi/default/kustomization.yaml b/config/lcmi/default/kustomization.yaml new file mode 100644 index 0000000..c8d5ce8 --- /dev/null +++ b/config/lcmi/default/kustomization.yaml @@ -0,0 +1,7 @@ +namespace: lifecycle-manager-system +namePrefix: lifecycle- +resources: + - ../rbac + - ../manager +patches: + - path: manager_auth_proxy_patch.yaml \ No newline at end of file diff --git a/config/lcmi/default/manager_auth_proxy_patch.yaml b/config/lcmi/default/manager_auth_proxy_patch.yaml new file mode 100644 index 0000000..0638f38 --- /dev/null +++ b/config/lcmi/default/manager_auth_proxy_patch.yaml @@ -0,0 +1,34 @@ +# This patch inject a sidecar container which is a HTTP proxy for the +# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: service + namespace: system +spec: + template: + spec: + containers: + - name: kube-rbac-proxy + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - "ALL" + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0 + args: + - "--secure-listen-address=0.0.0.0:8443" + - "--upstream=http://127.0.0.1:8080/" + - "--logtostderr=true" + - "--v=0" + ports: + - containerPort: 8443 + protocol: TCP + name: https + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi diff --git a/config/lcmi/manager/kustomization.yaml b/config/lcmi/manager/kustomization.yaml new file mode 100644 index 0000000..76a7774 --- /dev/null +++ b/config/lcmi/manager/kustomization.yaml @@ -0,0 +1,9 @@ +resources: +- manager.yaml +- service.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ironcore-dev/lifecycle-service + newTag: v0.0.1-dev-202403061552 diff --git a/config/lcmi/manager/manager.yaml b/config/lcmi/manager/manager.yaml new file mode 100644 index 0000000..01ff2e4 --- /dev/null +++ b/config/lcmi/manager/manager.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: service + namespace: system + labels: + control-plane: lifecycle-service + app.kubernetes.io/name: deployment + app.kubernetes.io/instance: controller-manager + app.kubernetes.io/component: manager + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize +spec: + selector: + matchLabels: + control-plane: lifecycle-service + replicas: 1 + template: + metadata: + annotations: + kubectl.kubernetes.io/default-container: manager + labels: + control-plane: lifecycle-service + spec: + securityContext: + runAsNonRoot: true + containers: + - name: manager + image: controller:latest + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + command: + - /manager + args: + - --namespace=POD_NAMESPACE + ports: + - containerPort: 8080 + protocol: TCP + name: http + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - "ALL" + livenessProbe: + grpc: + port: 8080 + initialDelaySeconds: 15 + periodSeconds: 20 + readinessProbe: + grpc: + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 5 + serviceAccountName: service-sa diff --git a/config/lcmi/manager/service.yaml b/config/lcmi/manager/service.yaml new file mode 100644 index 0000000..cfd4383 --- /dev/null +++ b/config/lcmi/manager/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: service-svc + namespace: system + labels: + control-plane: lifecycle-service + app.kubernetes.io/name: service + app.kubernetes.io/instance: controller-manager-metrics-service + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize +spec: + selector: + control-plane: lifecycle-service + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: http \ No newline at end of file diff --git a/config/lcmi/rbac/auth_proxy_client_clusterrole.yaml b/config/lcmi/rbac/auth_proxy_client_clusterrole.yaml new file mode 100644 index 0000000..64c60e4 --- /dev/null +++ b/config/lcmi/rbac/auth_proxy_client_clusterrole.yaml @@ -0,0 +1,16 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: metrics-reader + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: metrics-reader +rules: +- nonResourceURLs: + - "/metrics" + verbs: + - get diff --git a/config/lcmi/rbac/auth_proxy_role.yaml b/config/lcmi/rbac/auth_proxy_role.yaml new file mode 100644 index 0000000..6352114 --- /dev/null +++ b/config/lcmi/rbac/auth_proxy_role.yaml @@ -0,0 +1,24 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: proxy-role + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: proxy-role +rules: +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create diff --git a/config/lcmi/rbac/auth_proxy_role_binding.yaml b/config/lcmi/rbac/auth_proxy_role_binding.yaml new file mode 100644 index 0000000..423cc41 --- /dev/null +++ b/config/lcmi/rbac/auth_proxy_role_binding.yaml @@ -0,0 +1,19 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/name: clusterrolebinding + app.kubernetes.io/instance: proxy-rolebinding + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: proxy-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: proxy-role +subjects: +- kind: ServiceAccount + name: service-sa + namespace: system diff --git a/config/lcmi/rbac/auth_proxy_service.yaml b/config/lcmi/rbac/auth_proxy_service.yaml new file mode 100644 index 0000000..ad6ebbe --- /dev/null +++ b/config/lcmi/rbac/auth_proxy_service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + control-plane: lifecycle-service + app.kubernetes.io/name: service + app.kubernetes.io/instance: controller-manager-metrics-service + app.kubernetes.io/component: kube-rbac-proxy + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: controller-manager-metrics-service + namespace: system +spec: + ports: + - name: https + port: 8443 + protocol: TCP + targetPort: https + selector: + control-plane: lifecycle-service diff --git a/config/lcmi/rbac/kustomization.yaml b/config/lcmi/rbac/kustomization.yaml new file mode 100644 index 0000000..4e42541 --- /dev/null +++ b/config/lcmi/rbac/kustomization.yaml @@ -0,0 +1,16 @@ +resources: +# All RBAC will be applied under this service account in +# the deployment namespace. You may comment out this resource +# if your manager will use a service account that exists at +# runtime. Be sure to update RoleBinding and ClusterRoleBinding +# subjects if changing service account names. +- service_account.yaml +- role.yaml +- role_binding.yaml +# Comment the following 4 lines if you want to disable +# the auth proxy (https://github.com/brancz/kube-rbac-proxy) +# which protects your /metrics endpoint. +- auth_proxy_service.yaml +- auth_proxy_role.yaml +- auth_proxy_role_binding.yaml +- auth_proxy_client_clusterrole.yaml diff --git a/config/lcmi/rbac/role.yaml b/config/lcmi/rbac/role.yaml new file mode 100644 index 0000000..490ed9b --- /dev/null +++ b/config/lcmi/rbac/role.yaml @@ -0,0 +1,88 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: manager-role +rules: +- apiGroups: + - ironcore.dev + resources: + - oobs + verbs: + - get + - list + - watch +- apiGroups: + - ironcore.dev + resources: + - oobs/status + verbs: + - get + - list + - watch +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machines + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machines/finalizers + verbs: + - update +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machines/status + verbs: + - get + - patch + - update +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machinetypes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machinetypes/finalizers + verbs: + - update +- apiGroups: + - lifecycle.ironcore.dev + resources: + - machinetypes/status + verbs: + - get + - patch + - update +- apiGroups: + - onmetal.de + resources: + - oobs + verbs: + - get + - list + - watch +- apiGroups: + - onmetal.de + resources: + - oobs/status + verbs: + - get diff --git a/config/lcmi/rbac/role_binding.yaml b/config/lcmi/rbac/role_binding.yaml new file mode 100644 index 0000000..0a654db --- /dev/null +++ b/config/lcmi/rbac/role_binding.yaml @@ -0,0 +1,19 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/name: clusterrolebinding + app.kubernetes.io/instance: manager-rolebinding + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: manager-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: manager-role +subjects: +- kind: ServiceAccount + name: service-sa + namespace: system diff --git a/config/lcmi/rbac/service_account.yaml b/config/lcmi/rbac/service_account.yaml new file mode 100644 index 0000000..3dba3a5 --- /dev/null +++ b/config/lcmi/rbac/service_account.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/name: serviceaccount + app.kubernetes.io/instance: controller-manager-sa + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: lifecycle-service + app.kubernetes.io/part-of: lifecycle-service + app.kubernetes.io/managed-by: kustomize + name: service-sa + namespace: system diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5c5f0b8..d897eb3 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ resources: - manager.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ironcore-dev/lifecycle-controller-manager + newTag: v0.0.1-dev-202403061527 diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index f4d948d..490ed9b 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -4,6 +4,22 @@ kind: ClusterRole metadata: name: manager-role rules: +- apiGroups: + - ironcore.dev + resources: + - oobs + verbs: + - get + - list + - watch +- apiGroups: + - ironcore.dev + resources: + - oobs/status + verbs: + - get + - list + - watch - apiGroups: - lifecycle.ironcore.dev resources: diff --git a/go.mod b/go.mod index 950af7b..e5b189a 100644 --- a/go.mod +++ b/go.mod @@ -5,49 +5,51 @@ go 1.22 toolchain go1.22.0 require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 - github.com/bufbuild/protovalidate-go v0.5.1 + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 + connectrpc.com/connect v1.15.0 + connectrpc.com/grpchealth v1.3.0 + connectrpc.com/grpcreflect v1.2.0 + connectrpc.com/validate v0.1.0 github.com/go-logr/logr v1.4.1 github.com/gogo/protobuf v1.3.2 github.com/google/uuid v1.6.0 - github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 - github.com/jellydator/ttlcache/v3 v3.1.1 - github.com/onmetal/oob-operator v0.4.0 - github.com/onsi/ginkgo/v2 v2.15.0 + github.com/ironcore-dev/oob v0.5.1 + github.com/jellydator/ttlcache/v3 v3.2.0 + github.com/onsi/ginkgo/v2 v2.16.0 github.com/onsi/gomega v1.31.1 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - golang.org/x/crypto v0.19.0 - golang.org/x/mod v0.15.0 - google.golang.org/grpc v1.61.0 - google.golang.org/protobuf v1.32.0 - k8s.io/api v0.29.1 - k8s.io/apimachinery v0.29.1 - k8s.io/client-go v0.29.1 - k8s.io/kube-openapi v0.0.0-20240209001042-7a0d5b415232 - k8s.io/utils v0.0.0-20240102154912-e7106e64919e - sigs.k8s.io/controller-runtime v0.17.1 + golang.org/x/crypto v0.21.0 + golang.org/x/mod v0.16.0 + golang.org/x/net v0.22.0 + google.golang.org/protobuf v1.33.0 + k8s.io/api v0.29.2 + k8s.io/apimachinery v0.29.2 + k8s.io/client-go v0.29.2 + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 + sigs.k8s.io/controller-runtime v0.17.2 sigs.k8s.io/structured-merge-diff/v4 v4.4.1 ) require ( github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bufbuild/protovalidate-go v0.6.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.11.2 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.3 // indirect github.com/evanphx/json-patch v5.9.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/zapr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/jsonreference v0.20.4 // indirect - github.com/go-openapi/swag v0.22.9 // indirect + github.com/go-openapi/jsonpointer v0.20.3 // indirect + github.com/go-openapi/jsonreference v0.20.5 // indirect + github.com/go-openapi/swag v0.22.10 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/cel-go v0.18.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/cel-go v0.20.0 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect @@ -60,32 +62,33 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.46.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect + github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.18.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.29.1 // indirect - k8s.io/component-base v0.29.1 // indirect + k8s.io/apiextensions-apiserver v0.29.2 // indirect + k8s.io/component-base v0.29.2 // indirect k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index c128841..a0d2e91 100644 --- a/go.sum +++ b/go.sum @@ -1,23 +1,31 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 h1:0nWhrRcnkgw1kwJ7xibIO8bqfOA7pBzBjGCDBxIHch8= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1/go.mod h1:Tgn5bgL220vkFOI0KPStlcClPeOJzAv4uT+V8JXGUnw= +connectrpc.com/connect v1.15.0 h1:lFdeCbZrVVDydAqwr4xGV2y+ULn+0Z73s5JBj2LikWo= +connectrpc.com/connect v1.15.0/go.mod h1:bQmjpDY8xItMnttnurVgOkHUBMRT9cpsNi2O4AjKhmA= +connectrpc.com/grpchealth v1.3.0 h1:FA3OIwAvuMokQIXQrY5LbIy8IenftksTP/lG4PbYN+E= +connectrpc.com/grpchealth v1.3.0/go.mod h1:3vpqmX25/ir0gVgW6RdnCPPZRcR6HvqtXX5RNPmDXHM= +connectrpc.com/grpcreflect v1.2.0 h1:Q6og1S7HinmtbEuBvARLNwYmTbhEGRpHDhqrPNlmK+U= +connectrpc.com/grpcreflect v1.2.0/go.mod h1:nwSOKmE8nU5u/CidgHtPYk1PFI3U9ignz7iDMxOYkSY= +connectrpc.com/validate v0.1.0 h1:r55jirxMK7HO/xZwVHj3w2XkVFarsUM77ZDy367NtH4= +connectrpc.com/validate v0.1.0/go.mod h1:GU47c9/x/gd+u9wRSPkrQOP46gx2rMN+Wo37EHgI3Ow= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bufbuild/protovalidate-go v0.5.1 h1:pUUNnrxkUpt2yEX0gMiPTibTTFpGmzQkYxYLbL3lDVg= -github.com/bufbuild/protovalidate-go v0.5.1/go.mod h1:3XAwFeJ2x9sXyPLgkxufH9sts1tQRk8fdt1AW93NiUU= +github.com/bufbuild/protovalidate-go v0.6.0 h1:Jgs1kFuZ2LHvvdj8SpCLA1W/+pXS8QSM3F/E2l3InPY= +github.com/bufbuild/protovalidate-go v0.6.0/go.mod h1:1LamgoYHZ2NdIQH0XGczGTc6Z8YrTHjcJVmiBaar4t4= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.11.2 h1:1onLa9DcsMYO9P+CXaL0dStDqQ2EHHXLiz+BtnqkLAU= -github.com/emicklei/go-restful/v3 v3.11.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.11.3 h1:yagOQz/38xJmcNeZJtrUcKjkHRltIaIFXKWeG1SkWGE= +github.com/emicklei/go-restful/v3 v3.11.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= @@ -30,12 +38,12 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= -github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= -github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= -github.com/go-openapi/swag v0.22.9 h1:XX2DssF+mQKM2DHsbgZK74y/zj4mo9I99+89xUmuZCE= -github.com/go-openapi/swag v0.22.9/go.mod h1:3/OXnFfnMAwBD099SwYRk7GD3xOrr1iL7d/XNLXVVwE= +github.com/go-openapi/jsonpointer v0.20.3 h1:jykzYWS/kyGtsHfRt6aV8JTB9pcQAXPIA7qlZ5aRlyk= +github.com/go-openapi/jsonpointer v0.20.3/go.mod h1:c7l0rjoouAuIxCm8v/JWKRgMjDG/+/7UBWsXMrv6PsM= +github.com/go-openapi/jsonreference v0.20.5 h1:hutI+cQI+HbSQaIGSfsBsYI0pHk+CATf8Fk5gCSj0yI= +github.com/go-openapi/jsonreference v0.20.5/go.mod h1:thAqAp31UABtI+FQGKAQfmv7DbFpKNUlva2UPCxKu2Y= +github.com/go-openapi/swag v0.22.10 h1:4y86NVn7Z2yYd6pfS4Z+Nyh3aAUL3Nul+LMbhFKy0gA= +github.com/go-openapi/swag v0.22.10/go.mod h1:Cnn8BYtRlx6BNE3DPN86f/xkapGIcLWzh3CLEb4C1jI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -44,10 +52,10 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/cel-go v0.18.2 h1:L0B6sNBSVmt0OyECi8v6VOS74KOc9W/tLiWKfZABvf4= -github.com/google/cel-go v0.18.2/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/cel-go v0.20.0 h1:h4n6DOCppEMpWERzllyNkntl7JrDyxoE543KWS6BLpc= +github.com/google/cel-go v0.20.0/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -61,15 +69,15 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 h1:HcUWd006luQPljE73d5sk+/VgYPGUReEVz2y1/qylwY= -github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jellydator/ttlcache/v3 v3.1.1 h1:RCgYJqo3jgvhl+fEWvjNW8thxGWsgxi+TPhRir1Y9y8= -github.com/jellydator/ttlcache/v3 v3.1.1/go.mod h1:hi7MGFdMAwZna5n2tuvh63DvFLzVKySzCVW6+0gA2n4= +github.com/ironcore-dev/oob v0.5.1 h1:9Rz9A/Wn5bpPSY/Q48i9ELTvHh1VkHOZX2ugEI6Js9g= +github.com/ironcore-dev/oob v0.5.1/go.mod h1:vdY4CT5hKd88r9QNX8TeAqa/ICnMnYd2C2NynRQs9DI= +github.com/jellydator/ttlcache/v3 v3.2.0 h1:6lqVJ8X3ZaUwvzENqPAobDsXNExfUJd61u++uW8a3LE= +github.com/jellydator/ttlcache/v3 v3.2.0/go.mod h1:hi7MGFdMAwZna5n2tuvh63DvFLzVKySzCVW6+0gA2n4= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -89,29 +97,28 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onmetal/oob-operator v0.4.0 h1:PBssckQjKPAsgh5pjNzS9Un1cKH3KhMmmKhwb00UjFs= -github.com/onmetal/oob-operator v0.4.0/go.mod h1:izNEozbvt8MYyC8VMZN0fvj+6SZEpIPiU1qz8sJ12OE= github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= +github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= -github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= -github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -126,8 +133,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -135,31 +142,31 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -174,12 +181,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -193,8 +200,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -203,16 +210,14 @@ gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe h1:bQnxqljG/wqi4NTXu2+DJ3n7APcEA882QZ1JvhQAq9o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= -google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8 h1:8eadJkXbwDEMNwcB5O0s5Y5eCfyuCLdvaiOIaGTrWmQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240304212257-790db918fca8/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -224,24 +229,24 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.29.1 h1:DAjwWX/9YT7NQD4INu49ROJuZAAAP/Ijki48GUPzxqw= -k8s.io/api v0.29.1/go.mod h1:7Kl10vBRUXhnQQI8YR/R327zXC8eJ7887/+Ybta+RoQ= -k8s.io/apiextensions-apiserver v0.29.1 h1:S9xOtyk9M3Sk1tIpQMu9wXHm5O2MX6Y1kIpPMimZBZw= -k8s.io/apiextensions-apiserver v0.29.1/go.mod h1:zZECpujY5yTW58co8V2EQR4BD6A9pktVgHhvc0uLfeU= -k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= -k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= -k8s.io/client-go v0.29.1 h1:19B/+2NGEwnFLzt0uB5kNJnfTsbV8w6TgQRz9l7ti7A= -k8s.io/client-go v0.29.1/go.mod h1:TDG/psL9hdet0TI9mGyHJSgRkW3H9JZk2dNEUS7bRks= -k8s.io/component-base v0.29.1 h1:MUimqJPCRnnHsskTTjKD+IC1EHBbRCVyi37IoFBrkYw= -k8s.io/component-base v0.29.1/go.mod h1:fP9GFjxYrLERq1GcWWZAE3bqbNcDKDytn2srWuHTtKc= +k8s.io/api v0.29.2 h1:hBC7B9+MU+ptchxEqTNW2DkUosJpp1P+Wn6YncZ474A= +k8s.io/api v0.29.2/go.mod h1:sdIaaKuU7P44aoyyLlikSLayT6Vb7bvJNCX105xZXY0= +k8s.io/apiextensions-apiserver v0.29.2 h1:UK3xB5lOWSnhaCk0RFZ0LUacPZz9RY4wi/yt2Iu+btg= +k8s.io/apiextensions-apiserver v0.29.2/go.mod h1:aLfYjpA5p3OwtqNXQFkhJ56TB+spV8Gc4wfMhUA3/b8= +k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= +k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg= +k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA= +k8s.io/component-base v0.29.2 h1:lpiLyuvPA9yV1aQwGLENYyK7n/8t6l3nn3zAtFTJYe8= +k8s.io/component-base v0.29.2/go.mod h1:BfB3SLrefbZXiBfbM+2H1dlat21Uewg/5qtKOl8degM= k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240209001042-7a0d5b415232 h1:MMq4iF9pHuAz/9dLnHwBQKEoeigXClzs3MFh/seyqtA= -k8s.io/kube-openapi v0.0.0-20240209001042-7a0d5b415232/go.mod h1:Pa1PvrP7ACSkuX6I7KYomY6cmMA0Tx86waBhDUgoKPw= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.17.1 h1:V1dQELMGVk46YVXXQUbTFujU7u4DQj6YUj9Rb6cuzz8= -sigs.k8s.io/controller-runtime v0.17.1/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s= +sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeGOUvw0= +sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/hack/setup-git-redirect.sh b/hack/setup-git-redirect.sh deleted file mode 100755 index e46075c..0000000 --- a/hack/setup-git-redirect.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [[ -f "$GITHUB_PAT_PATH" ]]; then - echo "Sourcing Github pat from path" - GITHUB_PAT="$(cat "$GITHUB_PAT_PATH")" -fi - -if [[ "$GITHUB_PAT" != "" ]]; then - echo "Rewriting to use Github pat" - git config --global url."https://${GITHUB_PAT}:x-oauth-basic@github.com/".insteadOf "https://github.com/" -else - echo "No Github pat given, rewriting to use plain ssh auth" - git config --global url."git@github.com:".insteadOf "https://github.com" -fi diff --git a/integrationtests/controller/suite_test.go b/integrationtests/controller/suite_test.go index 18e9d2e..4f1e888 100644 --- a/integrationtests/controller/suite_test.go +++ b/integrationtests/controller/suite_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - oobv1alpha1 "github.com/onmetal/oob-operator/api/v1alpha1" + oobv1alpha1 "github.com/ironcore-dev/oob/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -100,9 +100,9 @@ var _ = BeforeSuite(func() { ScanPeriod: scanPeriod, }).SetupWithManager(k8sManager)).To(Succeed()) Expect((&controllers.MachineTypeReconciler{ - Client: k8sClient, - Scheme: scheme, - Broker: nil, // todo: setup broker client + Client: k8sClient, + Scheme: scheme, + MachineTypeServiceClient: nil, // todo: setup broker client }).SetupWithManager(k8sManager)).To(Succeed()) Expect((&controllers.MachineReconciler{ Client: k8sClient, diff --git a/internal/controllers/common.go b/internal/controllers/common.go index 9edbaf1..b899d49 100644 --- a/internal/controllers/common.go +++ b/internal/controllers/common.go @@ -6,9 +6,6 @@ package controllers import ( "time" - "k8s.io/utils/ptr" - "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" ) @@ -45,25 +42,12 @@ func (r RequestResult) IsFailure() bool { return r == RequestResultFailure } -var patchOpts = &client.SubResourcePatchOptions{ - PatchOptions: client.PatchOptions{ - Force: ptr.To(true), - FieldManager: "lifecycle-manager", - }, -} - var LCIMScanResultToString = map[commonv1alpha1.ScanResult]v1alpha1.ScanResult{ commonv1alpha1.ScanResult_SCAN_RESULT_UNSPECIFIED: "", commonv1alpha1.ScanResult_SCAN_RESULT_SUCCESS: v1alpha1.ScanSuccess, commonv1alpha1.ScanResult_SCAN_RESULT_FAILURE: v1alpha1.ScanFailure, } -// var LCIMInstallResultToString = map[commonv1alpha1.InstallResult]string{ -// commonv1alpha1.InstallResult_INSTALL_RESULT_UNSPECIFIED: "", -// commonv1alpha1.InstallResult_INSTALL_RESULT_SCHEDULED: InstallScheduled, -// commonv1alpha1.InstallResult_INSTALL_RESULT_FAILURE: InstallFailed, -// } - var LCIMRequestResultToString = map[commonv1alpha1.RequestResult]RequestResult{ commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED: "", commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED: RequestResultScheduled, diff --git a/internal/controllers/machine_controller.go b/internal/controllers/machine_controller.go index f7e573e..928f144 100644 --- a/internal/controllers/machine_controller.go +++ b/internal/controllers/machine_controller.go @@ -8,8 +8,11 @@ import ( "reflect" "slices" + "connectrpc.com/connect" "github.com/go-logr/logr" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1/machinev1alpha1connect" corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -29,7 +32,7 @@ import ( // MachineReconciler reconciles a Machine object. type MachineReconciler struct { client.Client - machinev1alpha1.MachineServiceClient + machinev1alpha1connect.MachineServiceClient Namespace string @@ -67,7 +70,10 @@ func (r *MachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct log.V(1).Info("reconciliation interrupted by an error") return result, err } - if err = r.Status().Patch(ctx, obj, client.Apply, patchOpts); err != nil { + if err = r.Status().Update(ctx, obj); err != nil { + if apierrors.IsConflict(err) { + return ctrl.Result{RequeueAfter: requeuePeriod}, nil + } log.Error(err, "failed to update object status") return ctrl.Result{}, err } @@ -87,12 +93,16 @@ func (r *MachineReconciler) reconcileRequired( return ctrl.Result{}, nil } -func (r *MachineReconciler) reconcileScan(ctx context.Context, obj *lifecyclev1alpha1.Machine) (ctrl.Result, error) { +func (r *MachineReconciler) reconcileScan( + ctx context.Context, + obj *lifecyclev1alpha1.Machine, +) (ctrl.Result, error) { log := logr.FromContextOrDiscard(ctx) - scanResponse, err := r.ScanMachine(ctx, &machinev1alpha1.ScanMachineRequest{ + resp, err := r.ScanMachine(ctx, connect.NewRequest(&machinev1alpha1.ScanMachineRequest{ Name: obj.Name, Namespace: obj.Namespace, - }) + })) + scanResponse := resp.Msg if err != nil { log.Error(err, "failed to send scan request") return ctrl.Result{}, err @@ -108,7 +118,10 @@ func (r *MachineReconciler) reconcileScan(ctx context.Context, obj *lifecyclev1a return r.reconcileInstall(ctx, obj) } -func (r *MachineReconciler) reconcileInstall(ctx context.Context, obj *lifecyclev1alpha1.Machine) (ctrl.Result, error) { +func (r *MachineReconciler) reconcileInstall( + ctx context.Context, + obj *lifecyclev1alpha1.Machine, +) (ctrl.Result, error) { log := logr.FromContextOrDiscard(ctx) packagesToInstall, err := r.packagesToInstall(ctx, obj) if err != nil { @@ -118,10 +131,11 @@ func (r *MachineReconciler) reconcileInstall(ctx context.Context, obj *lifecycle log.V(1).Info("install packages versions match desired state") return ctrl.Result{}, nil } - installResponse, err := r.Install(ctx, &machinev1alpha1.InstallRequest{ + resp, err := r.Install(ctx, connect.NewRequest(&machinev1alpha1.InstallRequest{ Name: obj.Name, Namespace: obj.Namespace, - }) + })) + installResponse := resp.Msg if err != nil { log.Error(err, "failed to send install request") return ctrl.Result{}, err diff --git a/internal/controllers/machine_controller_test.go b/internal/controllers/machine_controller_test.go index 6304646..6d48155 100644 --- a/internal/controllers/machine_controller_test.go +++ b/internal/controllers/machine_controller_test.go @@ -5,8 +5,10 @@ package controllers import ( "context" - "time" + "github.com/ironcore-dev/lifecycle-manager/util/convertutil" + "github.com/ironcore-dev/lifecycle-manager/util/testutil/fake" + "github.com/ironcore-dev/lifecycle-manager/util/testutil/mock" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -16,7 +18,6 @@ import ( lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/lcmi/fake" "github.com/ironcore-dev/lifecycle-manager/util/apiutil" "github.com/ironcore-dev/lifecycle-manager/util/testutil" "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" @@ -39,9 +40,9 @@ var _ = Describe("Machine controller", func() { Context("When Machine object is being deleted", func() { It("Should interrupt reconciliation and return empty result with no error", func() { s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineObject("sample", "default", - testutil.MachineWithDeletionTimestamp(), - testutil.MachineWithFinalizer(), + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineObject("sample", "default", + mock.MachineWithDeletionTimestamp(), + mock.MachineWithFinalizer(), ))) machineRec := NewMachineReconciler(c, s) req := ctrl.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "sample"}} @@ -56,13 +57,13 @@ var _ = Describe("Machine controller", func() { now := metav1.Now() machineKey := types.NamespacedName{Namespace: "default", Name: "sample"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineObject("sample", "default", - testutil.MachineWithMachineTypeRef("sample"), + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineObject("sample", "default", + mock.MachineWithMachineTypeRef("sample"), ))) machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{ uuidutil.UUIDFromObjectKey(machineKey): { - LastScanTime: &now, + LastScanTime: convertutil.TimeToTimestampPtr(now), LastScanResult: commonv1alpha1.ScanResult_SCAN_RESULT_SUCCESS, InstalledPackages: nil, Message: "", @@ -80,7 +81,7 @@ var _ = Describe("Machine controller", func() { It("Should update Machine object's status with corresponding message", func() { machineKey := types.NamespacedName{Namespace: "default", Name: "sample"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineObject("sample", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineObject("sample", "default"))) machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{}) machineRec.MachineServiceClient = brokerClient @@ -103,7 +104,7 @@ var _ = Describe("Machine controller", func() { It("Should interrupt reconciliation and return empty result with error", func() { machineKey := types.NamespacedName{Namespace: "default", Name: "failed-scan"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineObject("failed-scan", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineObject("failed-scan", "default"))) machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{}) machineRec.MachineServiceClient = brokerClient @@ -116,14 +117,14 @@ var _ = Describe("Machine controller", func() { Context("When installed packages match desired state", func() { It("Should update Machine object's status with scan timestamp and result", func() { - now := time.Unix(time.Now().Unix(), 0) + now := metav1.Now() expectedPackages := []*commonv1alpha1.PackageVersion{{Name: "bios", Version: "1.0.0"}} - machine := testutil.NewMachineObject("sample", "default", - testutil.MachineWithMachineTypeRef("sample"), - testutil.MachineWithLabels(map[string]string{"env": "test"}), - testutil.MachineStatusWithInstalledPackages(apiutil.PackageVersionsToKubeAPI(expectedPackages))) - machineType := testutil.NewMachineTypeObject("sample", "default", - testutil.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ + machine := mock.NewMachineObject("sample", "default", + mock.MachineWithMachineTypeRef("sample"), + mock.MachineWithLabels(map[string]string{"env": "test"}), + mock.MachineStatusWithInstalledPackages(apiutil.PackageVersionsToKubeAPI(expectedPackages))) + machineType := mock.NewMachineTypeObject("sample", "default", + mock.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ MachineSelector: metav1.LabelSelector{MatchLabels: map[string]string{"env": "test"}}, Packages: apiutil.PackageVersionsToKubeAPI(expectedPackages)})) @@ -135,7 +136,7 @@ var _ = Describe("Machine controller", func() { machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{ uuidutil.UUIDFromObjectKey(machineKey): { - LastScanTime: &metav1.Time{Time: now}, + LastScanTime: convertutil.TimeToTimestampPtr(now), LastScanResult: 1, InstalledPackages: expectedPackages, }}) @@ -154,13 +155,13 @@ var _ = Describe("Machine controller", func() { Context("When packages installation scheduled", func() { It("Should update Machine object's status with corresponding message", func() { - now := time.Unix(time.Now().Unix(), 0) + now := metav1.Now() desiredPackages := []lifecyclev1alpha1.PackageVersion{{Name: "bios", Version: "1.0.0"}} - machine := testutil.NewMachineObject("sample", "default", - testutil.MachineWithMachineTypeRef("sample"), - testutil.MachineWithLabels(map[string]string{"env": "test"})) - machineType := testutil.NewMachineTypeObject("sample", "default", - testutil.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ + machine := mock.NewMachineObject("sample", "default", + mock.MachineWithMachineTypeRef("sample"), + mock.MachineWithLabels(map[string]string{"env": "test"})) + machineType := mock.NewMachineTypeObject("sample", "default", + mock.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ MachineSelector: metav1.LabelSelector{MatchLabels: map[string]string{"env": "test"}}, Packages: desiredPackages})) @@ -172,7 +173,7 @@ var _ = Describe("Machine controller", func() { machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{ uuidutil.UUIDFromObjectKey(machineKey): { - LastScanTime: &metav1.Time{Time: now}, + LastScanTime: convertutil.TimeToTimestampPtr(now), LastScanResult: 1, }}) machineRec.MachineServiceClient = brokerClient @@ -190,13 +191,13 @@ var _ = Describe("Machine controller", func() { Context("When failed to send install request", func() { It("Should interrupt reconciliation and return empty result with error", func() { - now := time.Unix(time.Now().Unix(), 0) + now := metav1.Now() desiredPackages := []lifecyclev1alpha1.PackageVersion{{Name: "bios", Version: "1.0.0"}} - machine := testutil.NewMachineObject("failed-install", "default", - testutil.MachineWithMachineTypeRef("sample"), - testutil.MachineWithLabels(map[string]string{"env": "test"})) - machineType := testutil.NewMachineTypeObject("sample", "default", - testutil.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ + machine := mock.NewMachineObject("failed-install", "default", + mock.MachineWithMachineTypeRef("sample"), + mock.MachineWithLabels(map[string]string{"env": "test"})) + machineType := mock.NewMachineTypeObject("sample", "default", + mock.MachineTypeWithGroup(lifecyclev1alpha1.MachineGroup{ MachineSelector: metav1.LabelSelector{MatchLabels: map[string]string{"env": "test"}}, Packages: desiredPackages})) @@ -208,7 +209,7 @@ var _ = Describe("Machine controller", func() { machineRec := NewMachineReconciler(c, s) brokerClient := fake.NewMachineClient(map[string]*machinev1alpha1.MachineStatus{ uuidutil.UUIDFromObjectKey(machineKey): { - LastScanTime: &metav1.Time{Time: now}, + LastScanTime: convertutil.TimeToTimestampPtr(now), LastScanResult: 1, }}) machineRec.MachineServiceClient = brokerClient diff --git a/internal/controllers/machinetype_controller.go b/internal/controllers/machinetype_controller.go index a91fdf5..36dff44 100644 --- a/internal/controllers/machinetype_controller.go +++ b/internal/controllers/machinetype_controller.go @@ -6,7 +6,9 @@ package controllers import ( "context" + "connectrpc.com/connect" "github.com/go-logr/logr" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -22,7 +24,7 @@ import ( // MachineTypeReconciler reconciles a MachineType object. type MachineTypeReconciler struct { client.Client - Broker machinetypev1alpha1.MachineTypeServiceClient + machinetypev1alpha1connect.MachineTypeServiceClient Log logr.Logger Scheme *runtime.Scheme @@ -31,6 +33,8 @@ type MachineTypeReconciler struct { // +kubebuilder:rbac:groups=lifecycle.ironcore.dev,resources=machinetypes,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=lifecycle.ironcore.dev,resources=machinetypes/status,verbs=get;update;patch // +kubebuilder:rbac:groups=lifecycle.ironcore.dev,resources=machinetypes/finalizers,verbs=update +// +kubebuilder:rbac:groups=ironcore.dev,resources=oobs,verbs=get;list;watch +// +kubebuilder:rbac:groups=ironcore.dev,resources=oobs/status,verbs=get;list;watch func (r *MachineTypeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { var ( @@ -58,7 +62,7 @@ func (r *MachineTypeReconciler) Reconcile(ctx context.Context, req ctrl.Request) log.V(1).Info("reconciliation interrupted by an error") return result, err } - if err = r.Status().Patch(ctx, obj, client.Apply, patchOpts); err != nil { + if err = r.Status().Update(ctx, obj); err != nil { if apierrors.IsConflict(err) { return ctrl.Result{RequeueAfter: requeuePeriod}, nil } @@ -66,7 +70,7 @@ func (r *MachineTypeReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, err } log.V(1).Info("reconciliation finished") - return result, err + return result, nil } func (r *MachineTypeReconciler) reconcileRequired( @@ -86,16 +90,20 @@ func (r *MachineTypeReconciler) reconcile( obj *lifecyclev1alpha1.MachineType, ) (ctrl.Result, error) { log := logr.FromContextOrDiscard(ctx) - resp, err := r.Broker.Scan(ctx, &machinetypev1alpha1.ScanRequest{Name: obj.Name, Namespace: obj.Namespace}) + resp, err := r.Scan(ctx, connect.NewRequest(&machinetypev1alpha1.ScanRequest{ + Name: obj.Name, + Namespace: obj.Namespace, + })) + scanResponse := resp.Msg if err != nil { log.Error(err, "failed to send scan request") return ctrl.Result{}, err } - if LCIMRequestResultToString[resp.Result].IsScheduled() { + if LCIMRequestResultToString[scanResponse.Result].IsScheduled() { obj.Status.Message = StatusMessageScanRequestSubmitted return ctrl.Result{}, nil } - if LCIMRequestResultToString[resp.Result].IsFailure() { + if LCIMRequestResultToString[scanResponse.Result].IsFailure() { obj.Status.Message = StatusMessageScanRequestFailed return ctrl.Result{}, nil } diff --git a/internal/controllers/machinetype_controller_test.go b/internal/controllers/machinetype_controller_test.go index c47eaf4..9446007 100644 --- a/internal/controllers/machinetype_controller_test.go +++ b/internal/controllers/machinetype_controller_test.go @@ -5,8 +5,10 @@ package controllers import ( "context" - "time" + "github.com/ironcore-dev/lifecycle-manager/util/convertutil" + "github.com/ironcore-dev/lifecycle-manager/util/testutil/fake" + "github.com/ironcore-dev/lifecycle-manager/util/testutil/mock" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -18,7 +20,6 @@ import ( lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/lcmi/fake" ) var _ = Describe("MachineType controller", func() { @@ -37,9 +38,9 @@ var _ = Describe("MachineType controller", func() { Context("When MachineType object is being deleted", func() { It("Should interrupt reconciliation and return empty result with no error", func() { s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineTypeObject("sample", "default", - testutil.MachineTypeWithDeletionTimestamp(), - testutil.MachineTypeWithFinalizer(), + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineTypeObject("sample", "default", + mock.MachineTypeWithDeletionTimestamp(), + mock.MachineTypeWithFinalizer(), ))) machinetypeRec := NewMachineTypeReconciler(c, s) req := ctrl.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "sample"}} @@ -53,15 +54,15 @@ var _ = Describe("MachineType controller", func() { It("Should update MachineType object's status with corresponding message", func() { machinetypeKey := types.NamespacedName{Namespace: "default", Name: "sample"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineTypeObject("sample", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineTypeObject("sample", "default"))) machinetypeRec := NewMachineTypeReconciler(c, s) brokerClient := fake.NewMachineTypeClient(map[string]*machinetypev1alpha1.MachineTypeStatus{}) - machinetypeRec.Broker = brokerClient + machinetypeRec.MachineTypeServiceClient = brokerClient req := ctrl.Request{NamespacedName: machinetypeKey} res, err := machinetypeRec.Reconcile(context.Background(), req) Expect(err).NotTo(HaveOccurred()) Expect(res).To(Equal(ctrl.Result{})) - broker, _ := machinetypeRec.Broker.(*fake.MachineTypeClient) + broker, _ := machinetypeRec.MachineTypeServiceClient.(*fake.MachineTypeClient) entry := broker.ReadCache(uuidutil.UUIDFromObjectKey(machinetypeKey)) Expect(entry).NotTo(BeNil()) reconciledMachineType := &lifecyclev1alpha1.MachineType{} @@ -75,10 +76,10 @@ var _ = Describe("MachineType controller", func() { It("Should interrupt reconciliation and return empty result with error", func() { machinetypeKey := types.NamespacedName{Namespace: "default", Name: "failed-scan"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineTypeObject("failed-scan", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineTypeObject("failed-scan", "default"))) machinetypeRec := NewMachineTypeReconciler(c, s) brokerClient := fake.NewMachineTypeClient(map[string]*machinetypev1alpha1.MachineTypeStatus{}) - machinetypeRec.Broker = brokerClient + machinetypeRec.MachineTypeServiceClient = brokerClient req := ctrl.Request{NamespacedName: machinetypeKey} res, err := machinetypeRec.Reconcile(context.Background(), req) Expect(err).To(HaveOccurred()) @@ -88,26 +89,26 @@ var _ = Describe("MachineType controller", func() { Context("When scan response received", func() { It("Should update MachineType object's status with scan timestamp and result", func() { - now := time.Unix(time.Now().Unix(), 0) + now := metav1.Now() machinetypeKey := types.NamespacedName{Namespace: "default", Name: "sample"} s := testutil.SetupScheme(testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewMachineTypeObject("sample", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewMachineTypeObject("sample", "default"))) machinetypeRec := NewMachineTypeReconciler(c, s) brokerClient := fake.NewMachineTypeClient(map[string]*machinetypev1alpha1.MachineTypeStatus{ uuidutil.UUIDFromObjectKey(machinetypeKey): { - LastScanTime: &metav1.Time{Time: now}, + LastScanTime: convertutil.TimeToTimestampPtr(now), LastScanResult: 1, AvailablePackages: []*machinetypev1alpha1.AvailablePackageVersions{ {Name: "raid", Versions: []string{"2.9.0", "3.0.0", "3.2.1"}}, }, }, }) - machinetypeRec.Broker = brokerClient + machinetypeRec.MachineTypeServiceClient = brokerClient req := ctrl.Request{NamespacedName: machinetypeKey} res, err := machinetypeRec.Reconcile(context.Background(), req) Expect(err).NotTo(HaveOccurred()) Expect(res).To(Equal(ctrl.Result{})) - broker, _ := machinetypeRec.Broker.(*fake.MachineTypeClient) + broker, _ := machinetypeRec.MachineTypeServiceClient.(*fake.MachineTypeClient) entry := broker.ReadCache(uuidutil.UUIDFromObjectKey(machinetypeKey)) Expect(entry).NotTo(BeNil()) reconciledMachineType := &lifecyclev1alpha1.MachineType{} diff --git a/internal/controllers/onboarding_controller.go b/internal/controllers/onboarding_controller.go index e816ba1..b20880f 100644 --- a/internal/controllers/onboarding_controller.go +++ b/internal/controllers/onboarding_controller.go @@ -9,7 +9,7 @@ import ( "time" "github.com/go-logr/logr" - oobv1alpha1 "github.com/onmetal/oob-operator/api/v1alpha1" + oobv1alpha1 "github.com/ironcore-dev/oob/api/v1alpha1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/internal/controllers/onboarding_controller_test.go b/internal/controllers/onboarding_controller_test.go index 05f3905..bc4d669 100644 --- a/internal/controllers/onboarding_controller_test.go +++ b/internal/controllers/onboarding_controller_test.go @@ -6,7 +6,8 @@ package controllers import ( "context" - oobv1alpha1 "github.com/onmetal/oob-operator/api/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/util/testutil/mock" + oobv1alpha1 "github.com/ironcore-dev/oob/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -34,7 +35,7 @@ var _ = Describe("Onboarding controller", func() { Context("When OOB object's status is empty", func() { It("Should requeue OOB object's reconciliation", func() { s := testutil.SetupScheme(testutil.WithGroupVersion(oobv1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewOOBObject("sample", "default"))) + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewOOBObject("sample", "default"))) onboardingRec := NewOnboardingReconciler(c, s) req := ctrl.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "sample"}} res, err := onboardingRec.Reconcile(context.Background(), req) @@ -46,9 +47,9 @@ var _ = Describe("Onboarding controller", func() { Context("When OOB object is being deleted", func() { It("Should interrupt reconciliation and return empty result with no error", func() { s := testutil.SetupScheme(testutil.WithGroupVersion(oobv1alpha1.AddToScheme)) - c := testutil.SetupClient(s, testutil.WithRuntimeObject(testutil.NewOOBObject("sample", "default", - testutil.OOBWithDeletionTimestamp(), - testutil.OOBWithFinalizer(), + c := testutil.SetupClient(s, testutil.WithRuntimeObject(mock.NewOOBObject("sample", "default", + mock.OOBWithDeletionTimestamp(), + mock.OOBWithFinalizer(), ))) onboardingRec := NewOnboardingReconciler(c, s) req := ctrl.Request{NamespacedName: types.NamespacedName{Namespace: "default", Name: "sample"}} @@ -66,7 +67,7 @@ var _ = Describe("Onboarding controller", func() { testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme), ) c := testutil.SetupClient(s, testutil.WithRuntimeObject( - testutil.NewOOBObject("sample", "default", testutil.OOBWithStatus()))) + mock.NewOOBObject("sample", "default", mock.OOBWithStatus()))) onboardingRec := NewOnboardingReconciler(c, s) onboardedMachineType := &lifecyclev1alpha1.MachineType{} err := onboardingRec.Get(context.Background(), expectedMachineTypeKey, onboardedMachineType) @@ -89,7 +90,7 @@ var _ = Describe("Onboarding controller", func() { testutil.WithGroupVersion(lifecyclev1alpha1.AddToScheme), ) c := testutil.SetupClient(s, testutil.WithRuntimeObject( - testutil.NewOOBObject("sample", "default", testutil.OOBWithStatus()))) + mock.NewOOBObject("sample", "default", mock.OOBWithStatus()))) onboardingRec := NewOnboardingReconciler(c, s) onboardedMachine := &lifecyclev1alpha1.Machine{} err := onboardingRec.Get(context.Background(), expectedMachineKey, onboardedMachine) diff --git a/lcmi/api/common/v1alpha1/api.pb.go b/lcmi/api/common/v1alpha1/api.pb.go index 35a33fa..c22ad47 100644 --- a/lcmi/api/common/v1alpha1/api.pb.go +++ b/lcmi/api/common/v1alpha1/api.pb.go @@ -13,6 +13,7 @@ import ( _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -178,6 +179,93 @@ func (x *PackageVersion) GetVersion() string { return "" } +type Condition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` + Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` + ObservedGeneration int64 `protobuf:"varint,5,opt,name=observed_generation,json=observedGeneration,proto3" json:"observed_generation,omitempty"` + LastTransitionTime *v1.Timestamp `protobuf:"bytes,6,opt,name=last_transition_time,json=lastTransitionTime,proto3" json:"last_transition_time,omitempty"` +} + +func (x *Condition) Reset() { + *x = Condition{} + if protoimpl.UnsafeEnabled { + mi := &file_common_v1alpha1_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Condition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Condition) ProtoMessage() {} + +func (x *Condition) ProtoReflect() protoreflect.Message { + mi := &file_common_v1alpha1_api_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Condition.ProtoReflect.Descriptor instead. +func (*Condition) Descriptor() ([]byte, []int) { + return file_common_v1alpha1_api_proto_rawDescGZIP(), []int{1} +} + +func (x *Condition) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Condition) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *Condition) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +func (x *Condition) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *Condition) GetObservedGeneration() int64 { + if x != nil { + return x.ObservedGeneration + } + return 0 +} + +func (x *Condition) GetLastTransitionTime() *v1.Timestamp { + if x != nil { + return x.LastTransitionTime + } + return nil +} + var File_common_v1alpha1_api_proto protoreflect.FileDescriptor var file_common_v1alpha1_api_proto_rawDesc = []byte{ @@ -185,49 +273,69 @@ var file_common_v1alpha1_api_proto_rawDesc = []byte{ 0x31, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x01, 0x0a, 0x0e, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0xa1, 0x01, 0xba, 0x48, 0x9d, - 0x01, 0x1a, 0x48, 0x0a, 0x14, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x1a, 0x30, 0x21, 0x68, 0x61, 0x73, 0x28, - 0x74, 0x68, 0x69, 0x73, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x3f, 0x20, 0x27, 0x6e, 0x61, - 0x6d, 0x65, 0x20, 0x69, 0x73, 0x20, 0x6d, 0x61, 0x6e, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x20, - 0x66, 0x69, 0x65, 0x6c, 0x64, 0x27, 0x20, 0x3a, 0x20, 0x27, 0x27, 0x1a, 0x51, 0x0a, 0x17, 0x70, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x36, 0x21, 0x68, 0x61, 0x73, 0x28, 0x74, 0x68, 0x69, - 0x73, 0x2e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x29, 0x20, 0x3f, 0x20, 0x27, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x6d, 0x61, 0x6e, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x79, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x27, 0x20, 0x3a, 0x20, 0x27, 0x27, 0x2a, 0x85, - 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x12, 0x1e, 0x0a, 0x1a, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, - 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x1c, 0x0a, 0x18, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, - 0x4c, 0x54, 0x5f, 0x53, 0x43, 0x48, 0x45, 0x44, 0x55, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x1a, - 0x0a, 0x16, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, - 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x45, - 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x46, 0x41, 0x49, - 0x4c, 0x55, 0x52, 0x45, 0x10, 0x03, 0x2a, 0x5b, 0x0a, 0x0a, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x43, 0x41, 0x4e, 0x5f, 0x52, 0x45, 0x53, - 0x55, 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, - 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x43, 0x41, 0x4e, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, - 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x43, - 0x41, 0x4e, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, - 0x45, 0x10, 0x02, 0x42, 0xcf, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x51, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x72, 0x6f, 0x6e, 0x63, 0x6f, 0x72, 0x65, 0x2d, 0x64, 0x65, 0x76, - 0x2f, 0x6c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x2f, 0x6c, 0x63, 0x6d, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, - 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5c, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x10, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x34, 0x6b, 0x38, 0x73, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2f, 0x70, + 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x2f, 0x76, 0x31, 0x2f, + 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xe2, 0x01, 0x0a, 0x0e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x3a, 0xa1, 0x01, 0xba, 0x48, 0x9d, 0x01, 0x1a, 0x48, 0x0a, 0x14, 0x70, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x1a, + 0x30, 0x21, 0x68, 0x61, 0x73, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x29, + 0x20, 0x3f, 0x20, 0x27, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x69, 0x73, 0x20, 0x6d, 0x61, 0x6e, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x27, 0x20, 0x3a, 0x20, 0x27, + 0x27, 0x1a, 0x51, 0x0a, 0x17, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x36, 0x21, 0x68, + 0x61, 0x73, 0x28, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x29, + 0x20, 0x3f, 0x20, 0x27, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x6d, + 0x61, 0x6e, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x27, 0x20, + 0x3a, 0x20, 0x27, 0x27, 0x22, 0xfd, 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x2f, 0x0a, 0x13, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x67, 0x65, 0x6e, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, 0x6f, + 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x61, 0x0a, 0x14, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2f, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, + 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x12, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x54, 0x69, 0x6d, 0x65, 0x2a, 0x85, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1e, 0x0a, 0x1a, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, + 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1c, 0x0a, 0x18, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, + 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x43, 0x48, 0x45, 0x44, 0x55, 0x4c, + 0x45, 0x44, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, + 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, + 0x12, 0x1a, 0x0a, 0x16, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, 0x45, 0x53, 0x55, + 0x4c, 0x54, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x03, 0x2a, 0x5b, 0x0a, 0x0a, + 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x43, + 0x41, 0x4e, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x43, 0x41, 0x4e, 0x5f, + 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, + 0x12, 0x17, 0x0a, 0x13, 0x53, 0x43, 0x41, 0x4e, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, + 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x02, 0x42, 0xcf, 0x01, 0x0a, 0x13, 0x63, 0x6f, + 0x6d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x51, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x72, 0x6f, 0x6e, 0x63, 0x6f, + 0x72, 0x65, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, + 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x6c, 0x63, 0x6d, 0x69, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -243,18 +351,21 @@ func file_common_v1alpha1_api_proto_rawDescGZIP() []byte { } var file_common_v1alpha1_api_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_common_v1alpha1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_common_v1alpha1_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_common_v1alpha1_api_proto_goTypes = []interface{}{ (RequestResult)(0), // 0: common.v1alpha1.RequestResult (ScanResult)(0), // 1: common.v1alpha1.ScanResult (*PackageVersion)(nil), // 2: common.v1alpha1.PackageVersion + (*Condition)(nil), // 3: common.v1alpha1.Condition + (*v1.Timestamp)(nil), // 4: k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp } var file_common_v1alpha1_api_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 4, // 0: common.v1alpha1.Condition.last_transition_time:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_common_v1alpha1_api_proto_init() } @@ -275,6 +386,18 @@ func file_common_v1alpha1_api_proto_init() { return nil } } + file_common_v1alpha1_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Condition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -282,7 +405,7 @@ func file_common_v1alpha1_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_common_v1alpha1_api_proto_rawDesc, NumEnums: 2, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/lcmi/api/machine/v1alpha1/api.pb.go b/lcmi/api/machine/v1alpha1/api.pb.go index 53d3ba4..2065bb8 100644 --- a/lcmi/api/machine/v1alpha1/api.pb.go +++ b/lcmi/api/machine/v1alpha1/api.pb.go @@ -100,11 +100,11 @@ type MachineStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LastScanTime *v11.Time `protobuf:"bytes,1,opt,name=last_scan_time,json=lastScanTime,proto3" json:"last_scan_time,omitempty"` + LastScanTime *v11.Timestamp `protobuf:"bytes,1,opt,name=last_scan_time,json=lastScanTime,proto3" json:"last_scan_time,omitempty"` LastScanResult v1alpha1.ScanResult `protobuf:"varint,2,opt,name=last_scan_result,json=lastScanResult,proto3,enum=common.v1alpha1.ScanResult" json:"last_scan_result,omitempty"` InstalledPackages []*v1alpha1.PackageVersion `protobuf:"bytes,3,rep,name=installed_packages,json=installedPackages,proto3" json:"installed_packages,omitempty"` Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` - Conditions []*v11.Condition `protobuf:"bytes,5,rep,name=conditions,proto3" json:"conditions,omitempty"` + Conditions []*v1alpha1.Condition `protobuf:"bytes,5,rep,name=conditions,proto3" json:"conditions,omitempty"` } func (x *MachineStatus) Reset() { @@ -139,7 +139,7 @@ func (*MachineStatus) Descriptor() ([]byte, []int) { return file_machine_v1alpha1_api_proto_rawDescGZIP(), []int{1} } -func (x *MachineStatus) GetLastScanTime() *v11.Time { +func (x *MachineStatus) GetLastScanTime() *v11.Timestamp { if x != nil { return x.LastScanTime } @@ -167,7 +167,7 @@ func (x *MachineStatus) GetMessage() string { return "" } -func (x *MachineStatus) GetConditions() []*v11.Condition { +func (x *MachineStatus) GetConditions() []*v1alpha1.Condition { if x != nil { return x.Conditions } @@ -1048,28 +1048,27 @@ var file_machine_v1alpha1_api_proto_rawDesc = []byte{ 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xe3, 0x02, 0x0a, 0x0d, 0x4d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x0e, 0x6c, 0x61, 0x73, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xd3, 0x02, 0x0a, 0x0d, 0x4d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x55, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, + 0x0b, 0x32, 0x2f, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, - 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x0c, 0x6c, - 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x6c, - 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x5f, - 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4f, 0x0a, 0x0a, - 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2f, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, - 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x45, 0x0a, 0x10, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, 0x5f, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, + 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, + 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x12, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x50, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x12, 0x3a, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x95, 0x02, 0x0a, 0x07, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x4b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x6b, @@ -1278,9 +1277,9 @@ var file_machine_v1alpha1_api_proto_goTypes = []interface{}{ (*v1.LocalObjectReference)(nil), // 17: k8s.io.api.core.v1.LocalObjectReference (*v11.Duration)(nil), // 18: k8s.io.apimachinery.pkg.apis.meta.v1.Duration (*v1alpha1.PackageVersion)(nil), // 19: common.v1alpha1.PackageVersion - (*v11.Time)(nil), // 20: k8s.io.apimachinery.pkg.apis.meta.v1.Time + (*v11.Timestamp)(nil), // 20: k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp (v1alpha1.ScanResult)(0), // 21: common.v1alpha1.ScanResult - (*v11.Condition)(nil), // 22: k8s.io.apimachinery.pkg.apis.meta.v1.Condition + (*v1alpha1.Condition)(nil), // 22: common.v1alpha1.Condition (*v11.TypeMeta)(nil), // 23: k8s.io.apimachinery.pkg.apis.meta.v1.TypeMeta (*v11.ObjectMeta)(nil), // 24: k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta (*v11.LabelSelector)(nil), // 25: k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector @@ -1291,10 +1290,10 @@ var file_machine_v1alpha1_api_proto_depIdxs = []int32{ 17, // 1: machine.v1alpha1.MachineSpec.oob_machine_ref:type_name -> k8s.io.api.core.v1.LocalObjectReference 18, // 2: machine.v1alpha1.MachineSpec.scan_period:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Duration 19, // 3: machine.v1alpha1.MachineSpec.packages:type_name -> common.v1alpha1.PackageVersion - 20, // 4: machine.v1alpha1.MachineStatus.last_scan_time:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Time + 20, // 4: machine.v1alpha1.MachineStatus.last_scan_time:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp 21, // 5: machine.v1alpha1.MachineStatus.last_scan_result:type_name -> common.v1alpha1.ScanResult 19, // 6: machine.v1alpha1.MachineStatus.installed_packages:type_name -> common.v1alpha1.PackageVersion - 22, // 7: machine.v1alpha1.MachineStatus.conditions:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Condition + 22, // 7: machine.v1alpha1.MachineStatus.conditions:type_name -> common.v1alpha1.Condition 23, // 8: machine.v1alpha1.Machine.type_meta:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.TypeMeta 24, // 9: machine.v1alpha1.Machine.object_meta:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta 0, // 10: machine.v1alpha1.Machine.spec:type_name -> machine.v1alpha1.MachineSpec diff --git a/lcmi/api/machine/v1alpha1/api_grpc.pb.go b/lcmi/api/machine/v1alpha1/api_grpc.pb.go deleted file mode 100644 index f4c62d0..0000000 --- a/lcmi/api/machine/v1alpha1/api_grpc.pb.go +++ /dev/null @@ -1,332 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: machine/v1alpha1/api.proto - -package machinev1alpha1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - MachineService_ScanMachine_FullMethodName = "/machine.v1alpha1.MachineService/ScanMachine" - MachineService_Install_FullMethodName = "/machine.v1alpha1.MachineService/Install" - MachineService_UpdateMachineStatus_FullMethodName = "/machine.v1alpha1.MachineService/UpdateMachineStatus" - MachineService_ListMachines_FullMethodName = "/machine.v1alpha1.MachineService/ListMachines" - MachineService_AddPackageVersion_FullMethodName = "/machine.v1alpha1.MachineService/AddPackageVersion" - MachineService_SetPackageVersion_FullMethodName = "/machine.v1alpha1.MachineService/SetPackageVersion" - MachineService_RemovePackageVersion_FullMethodName = "/machine.v1alpha1.MachineService/RemovePackageVersion" -) - -// MachineServiceClient is the client API for MachineService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type MachineServiceClient interface { - ScanMachine(ctx context.Context, in *ScanMachineRequest, opts ...grpc.CallOption) (*ScanMachineResponse, error) - Install(ctx context.Context, in *InstallRequest, opts ...grpc.CallOption) (*InstallResponse, error) - UpdateMachineStatus(ctx context.Context, in *UpdateMachineStatusRequest, opts ...grpc.CallOption) (*UpdateMachineStatusResponse, error) - ListMachines(ctx context.Context, in *ListMachinesRequest, opts ...grpc.CallOption) (*ListMachinesResponse, error) - AddPackageVersion(ctx context.Context, in *AddPackageVersionRequest, opts ...grpc.CallOption) (*AddPackageVersionResponse, error) - SetPackageVersion(ctx context.Context, in *SetPackageVersionRequest, opts ...grpc.CallOption) (*SetPackageVersionResponse, error) - RemovePackageVersion(ctx context.Context, in *RemovePackageVersionRequest, opts ...grpc.CallOption) (*RemovePackageVersionResponse, error) -} - -type machineServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewMachineServiceClient(cc grpc.ClientConnInterface) MachineServiceClient { - return &machineServiceClient{cc} -} - -func (c *machineServiceClient) ScanMachine(ctx context.Context, in *ScanMachineRequest, opts ...grpc.CallOption) (*ScanMachineResponse, error) { - out := new(ScanMachineResponse) - err := c.cc.Invoke(ctx, MachineService_ScanMachine_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) Install(ctx context.Context, in *InstallRequest, opts ...grpc.CallOption) (*InstallResponse, error) { - out := new(InstallResponse) - err := c.cc.Invoke(ctx, MachineService_Install_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) UpdateMachineStatus(ctx context.Context, in *UpdateMachineStatusRequest, opts ...grpc.CallOption) (*UpdateMachineStatusResponse, error) { - out := new(UpdateMachineStatusResponse) - err := c.cc.Invoke(ctx, MachineService_UpdateMachineStatus_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) ListMachines(ctx context.Context, in *ListMachinesRequest, opts ...grpc.CallOption) (*ListMachinesResponse, error) { - out := new(ListMachinesResponse) - err := c.cc.Invoke(ctx, MachineService_ListMachines_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) AddPackageVersion(ctx context.Context, in *AddPackageVersionRequest, opts ...grpc.CallOption) (*AddPackageVersionResponse, error) { - out := new(AddPackageVersionResponse) - err := c.cc.Invoke(ctx, MachineService_AddPackageVersion_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) SetPackageVersion(ctx context.Context, in *SetPackageVersionRequest, opts ...grpc.CallOption) (*SetPackageVersionResponse, error) { - out := new(SetPackageVersionResponse) - err := c.cc.Invoke(ctx, MachineService_SetPackageVersion_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineServiceClient) RemovePackageVersion(ctx context.Context, in *RemovePackageVersionRequest, opts ...grpc.CallOption) (*RemovePackageVersionResponse, error) { - out := new(RemovePackageVersionResponse) - err := c.cc.Invoke(ctx, MachineService_RemovePackageVersion_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MachineServiceServer is the server API for MachineService service. -// All implementations must embed UnimplementedMachineServiceServer -// for forward compatibility -type MachineServiceServer interface { - ScanMachine(context.Context, *ScanMachineRequest) (*ScanMachineResponse, error) - Install(context.Context, *InstallRequest) (*InstallResponse, error) - UpdateMachineStatus(context.Context, *UpdateMachineStatusRequest) (*UpdateMachineStatusResponse, error) - ListMachines(context.Context, *ListMachinesRequest) (*ListMachinesResponse, error) - AddPackageVersion(context.Context, *AddPackageVersionRequest) (*AddPackageVersionResponse, error) - SetPackageVersion(context.Context, *SetPackageVersionRequest) (*SetPackageVersionResponse, error) - RemovePackageVersion(context.Context, *RemovePackageVersionRequest) (*RemovePackageVersionResponse, error) - mustEmbedUnimplementedMachineServiceServer() -} - -// UnimplementedMachineServiceServer must be embedded to have forward compatible implementations. -type UnimplementedMachineServiceServer struct { -} - -func (UnimplementedMachineServiceServer) ScanMachine(context.Context, *ScanMachineRequest) (*ScanMachineResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ScanMachine not implemented") -} -func (UnimplementedMachineServiceServer) Install(context.Context, *InstallRequest) (*InstallResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Install not implemented") -} -func (UnimplementedMachineServiceServer) UpdateMachineStatus(context.Context, *UpdateMachineStatusRequest) (*UpdateMachineStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateMachineStatus not implemented") -} -func (UnimplementedMachineServiceServer) ListMachines(context.Context, *ListMachinesRequest) (*ListMachinesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListMachines not implemented") -} -func (UnimplementedMachineServiceServer) AddPackageVersion(context.Context, *AddPackageVersionRequest) (*AddPackageVersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddPackageVersion not implemented") -} -func (UnimplementedMachineServiceServer) SetPackageVersion(context.Context, *SetPackageVersionRequest) (*SetPackageVersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetPackageVersion not implemented") -} -func (UnimplementedMachineServiceServer) RemovePackageVersion(context.Context, *RemovePackageVersionRequest) (*RemovePackageVersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemovePackageVersion not implemented") -} -func (UnimplementedMachineServiceServer) mustEmbedUnimplementedMachineServiceServer() {} - -// UnsafeMachineServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MachineServiceServer will -// result in compilation errors. -type UnsafeMachineServiceServer interface { - mustEmbedUnimplementedMachineServiceServer() -} - -func RegisterMachineServiceServer(s grpc.ServiceRegistrar, srv MachineServiceServer) { - s.RegisterService(&MachineService_ServiceDesc, srv) -} - -func _MachineService_ScanMachine_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ScanMachineRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).ScanMachine(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_ScanMachine_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).ScanMachine(ctx, req.(*ScanMachineRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_Install_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InstallRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).Install(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_Install_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).Install(ctx, req.(*InstallRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_UpdateMachineStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateMachineStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).UpdateMachineStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_UpdateMachineStatus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).UpdateMachineStatus(ctx, req.(*UpdateMachineStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_ListMachines_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListMachinesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).ListMachines(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_ListMachines_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).ListMachines(ctx, req.(*ListMachinesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_AddPackageVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddPackageVersionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).AddPackageVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_AddPackageVersion_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).AddPackageVersion(ctx, req.(*AddPackageVersionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_SetPackageVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetPackageVersionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).SetPackageVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_SetPackageVersion_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).SetPackageVersion(ctx, req.(*SetPackageVersionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineService_RemovePackageVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemovePackageVersionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineServiceServer).RemovePackageVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineService_RemovePackageVersion_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineServiceServer).RemovePackageVersion(ctx, req.(*RemovePackageVersionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// MachineService_ServiceDesc is the grpc.ServiceDesc for MachineService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var MachineService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "machine.v1alpha1.MachineService", - HandlerType: (*MachineServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ScanMachine", - Handler: _MachineService_ScanMachine_Handler, - }, - { - MethodName: "Install", - Handler: _MachineService_Install_Handler, - }, - { - MethodName: "UpdateMachineStatus", - Handler: _MachineService_UpdateMachineStatus_Handler, - }, - { - MethodName: "ListMachines", - Handler: _MachineService_ListMachines_Handler, - }, - { - MethodName: "AddPackageVersion", - Handler: _MachineService_AddPackageVersion_Handler, - }, - { - MethodName: "SetPackageVersion", - Handler: _MachineService_SetPackageVersion_Handler, - }, - { - MethodName: "RemovePackageVersion", - Handler: _MachineService_RemovePackageVersion_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "machine/v1alpha1/api.proto", -} diff --git a/lcmi/api/machine/v1alpha1/machinev1alpha1connect/api.connect.go b/lcmi/api/machine/v1alpha1/machinev1alpha1connect/api.connect.go new file mode 100644 index 0000000..a0f4ec6 --- /dev/null +++ b/lcmi/api/machine/v1alpha1/machinev1alpha1connect/api.connect.go @@ -0,0 +1,293 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: machine/v1alpha1/api.proto + +package machinev1alpha1connect + +import ( + context "context" + errors "errors" + http "net/http" + strings "strings" + + connect "connectrpc.com/connect" + v1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // MachineServiceName is the fully-qualified name of the MachineService service. + MachineServiceName = "machine.v1alpha1.MachineService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // MachineServiceScanMachineProcedure is the fully-qualified name of the MachineService's + // ScanMachine RPC. + MachineServiceScanMachineProcedure = "/machine.v1alpha1.MachineService/ScanMachine" + // MachineServiceInstallProcedure is the fully-qualified name of the MachineService's Install RPC. + MachineServiceInstallProcedure = "/machine.v1alpha1.MachineService/Install" + // MachineServiceUpdateMachineStatusProcedure is the fully-qualified name of the MachineService's + // UpdateMachineStatus RPC. + MachineServiceUpdateMachineStatusProcedure = "/machine.v1alpha1.MachineService/UpdateMachineStatus" + // MachineServiceListMachinesProcedure is the fully-qualified name of the MachineService's + // ListMachines RPC. + MachineServiceListMachinesProcedure = "/machine.v1alpha1.MachineService/ListMachines" + // MachineServiceAddPackageVersionProcedure is the fully-qualified name of the MachineService's + // AddPackageVersion RPC. + MachineServiceAddPackageVersionProcedure = "/machine.v1alpha1.MachineService/AddPackageVersion" + // MachineServiceSetPackageVersionProcedure is the fully-qualified name of the MachineService's + // SetPackageVersion RPC. + MachineServiceSetPackageVersionProcedure = "/machine.v1alpha1.MachineService/SetPackageVersion" + // MachineServiceRemovePackageVersionProcedure is the fully-qualified name of the MachineService's + // RemovePackageVersion RPC. + MachineServiceRemovePackageVersionProcedure = "/machine.v1alpha1.MachineService/RemovePackageVersion" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + machineServiceServiceDescriptor = v1alpha1.File_machine_v1alpha1_api_proto.Services().ByName("MachineService") + machineServiceScanMachineMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("ScanMachine") + machineServiceInstallMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("Install") + machineServiceUpdateMachineStatusMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("UpdateMachineStatus") + machineServiceListMachinesMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("ListMachines") + machineServiceAddPackageVersionMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("AddPackageVersion") + machineServiceSetPackageVersionMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("SetPackageVersion") + machineServiceRemovePackageVersionMethodDescriptor = machineServiceServiceDescriptor.Methods().ByName("RemovePackageVersion") +) + +// MachineServiceClient is a client for the machine.v1alpha1.MachineService service. +type MachineServiceClient interface { + ScanMachine(context.Context, *connect.Request[v1alpha1.ScanMachineRequest]) (*connect.Response[v1alpha1.ScanMachineResponse], error) + Install(context.Context, *connect.Request[v1alpha1.InstallRequest]) (*connect.Response[v1alpha1.InstallResponse], error) + UpdateMachineStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineStatusResponse], error) + ListMachines(context.Context, *connect.Request[v1alpha1.ListMachinesRequest]) (*connect.Response[v1alpha1.ListMachinesResponse], error) + AddPackageVersion(context.Context, *connect.Request[v1alpha1.AddPackageVersionRequest]) (*connect.Response[v1alpha1.AddPackageVersionResponse], error) + SetPackageVersion(context.Context, *connect.Request[v1alpha1.SetPackageVersionRequest]) (*connect.Response[v1alpha1.SetPackageVersionResponse], error) + RemovePackageVersion(context.Context, *connect.Request[v1alpha1.RemovePackageVersionRequest]) (*connect.Response[v1alpha1.RemovePackageVersionResponse], error) +} + +// NewMachineServiceClient constructs a client for the machine.v1alpha1.MachineService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewMachineServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MachineServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &machineServiceClient{ + scanMachine: connect.NewClient[v1alpha1.ScanMachineRequest, v1alpha1.ScanMachineResponse]( + httpClient, + baseURL+MachineServiceScanMachineProcedure, + connect.WithSchema(machineServiceScanMachineMethodDescriptor), + connect.WithClientOptions(opts...), + ), + install: connect.NewClient[v1alpha1.InstallRequest, v1alpha1.InstallResponse]( + httpClient, + baseURL+MachineServiceInstallProcedure, + connect.WithSchema(machineServiceInstallMethodDescriptor), + connect.WithClientOptions(opts...), + ), + updateMachineStatus: connect.NewClient[v1alpha1.UpdateMachineStatusRequest, v1alpha1.UpdateMachineStatusResponse]( + httpClient, + baseURL+MachineServiceUpdateMachineStatusProcedure, + connect.WithSchema(machineServiceUpdateMachineStatusMethodDescriptor), + connect.WithClientOptions(opts...), + ), + listMachines: connect.NewClient[v1alpha1.ListMachinesRequest, v1alpha1.ListMachinesResponse]( + httpClient, + baseURL+MachineServiceListMachinesProcedure, + connect.WithSchema(machineServiceListMachinesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + addPackageVersion: connect.NewClient[v1alpha1.AddPackageVersionRequest, v1alpha1.AddPackageVersionResponse]( + httpClient, + baseURL+MachineServiceAddPackageVersionProcedure, + connect.WithSchema(machineServiceAddPackageVersionMethodDescriptor), + connect.WithClientOptions(opts...), + ), + setPackageVersion: connect.NewClient[v1alpha1.SetPackageVersionRequest, v1alpha1.SetPackageVersionResponse]( + httpClient, + baseURL+MachineServiceSetPackageVersionProcedure, + connect.WithSchema(machineServiceSetPackageVersionMethodDescriptor), + connect.WithClientOptions(opts...), + ), + removePackageVersion: connect.NewClient[v1alpha1.RemovePackageVersionRequest, v1alpha1.RemovePackageVersionResponse]( + httpClient, + baseURL+MachineServiceRemovePackageVersionProcedure, + connect.WithSchema(machineServiceRemovePackageVersionMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// machineServiceClient implements MachineServiceClient. +type machineServiceClient struct { + scanMachine *connect.Client[v1alpha1.ScanMachineRequest, v1alpha1.ScanMachineResponse] + install *connect.Client[v1alpha1.InstallRequest, v1alpha1.InstallResponse] + updateMachineStatus *connect.Client[v1alpha1.UpdateMachineStatusRequest, v1alpha1.UpdateMachineStatusResponse] + listMachines *connect.Client[v1alpha1.ListMachinesRequest, v1alpha1.ListMachinesResponse] + addPackageVersion *connect.Client[v1alpha1.AddPackageVersionRequest, v1alpha1.AddPackageVersionResponse] + setPackageVersion *connect.Client[v1alpha1.SetPackageVersionRequest, v1alpha1.SetPackageVersionResponse] + removePackageVersion *connect.Client[v1alpha1.RemovePackageVersionRequest, v1alpha1.RemovePackageVersionResponse] +} + +// ScanMachine calls machine.v1alpha1.MachineService.ScanMachine. +func (c *machineServiceClient) ScanMachine(ctx context.Context, req *connect.Request[v1alpha1.ScanMachineRequest]) (*connect.Response[v1alpha1.ScanMachineResponse], error) { + return c.scanMachine.CallUnary(ctx, req) +} + +// Install calls machine.v1alpha1.MachineService.Install. +func (c *machineServiceClient) Install(ctx context.Context, req *connect.Request[v1alpha1.InstallRequest]) (*connect.Response[v1alpha1.InstallResponse], error) { + return c.install.CallUnary(ctx, req) +} + +// UpdateMachineStatus calls machine.v1alpha1.MachineService.UpdateMachineStatus. +func (c *machineServiceClient) UpdateMachineStatus(ctx context.Context, req *connect.Request[v1alpha1.UpdateMachineStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineStatusResponse], error) { + return c.updateMachineStatus.CallUnary(ctx, req) +} + +// ListMachines calls machine.v1alpha1.MachineService.ListMachines. +func (c *machineServiceClient) ListMachines(ctx context.Context, req *connect.Request[v1alpha1.ListMachinesRequest]) (*connect.Response[v1alpha1.ListMachinesResponse], error) { + return c.listMachines.CallUnary(ctx, req) +} + +// AddPackageVersion calls machine.v1alpha1.MachineService.AddPackageVersion. +func (c *machineServiceClient) AddPackageVersion(ctx context.Context, req *connect.Request[v1alpha1.AddPackageVersionRequest]) (*connect.Response[v1alpha1.AddPackageVersionResponse], error) { + return c.addPackageVersion.CallUnary(ctx, req) +} + +// SetPackageVersion calls machine.v1alpha1.MachineService.SetPackageVersion. +func (c *machineServiceClient) SetPackageVersion(ctx context.Context, req *connect.Request[v1alpha1.SetPackageVersionRequest]) (*connect.Response[v1alpha1.SetPackageVersionResponse], error) { + return c.setPackageVersion.CallUnary(ctx, req) +} + +// RemovePackageVersion calls machine.v1alpha1.MachineService.RemovePackageVersion. +func (c *machineServiceClient) RemovePackageVersion(ctx context.Context, req *connect.Request[v1alpha1.RemovePackageVersionRequest]) (*connect.Response[v1alpha1.RemovePackageVersionResponse], error) { + return c.removePackageVersion.CallUnary(ctx, req) +} + +// MachineServiceHandler is an implementation of the machine.v1alpha1.MachineService service. +type MachineServiceHandler interface { + ScanMachine(context.Context, *connect.Request[v1alpha1.ScanMachineRequest]) (*connect.Response[v1alpha1.ScanMachineResponse], error) + Install(context.Context, *connect.Request[v1alpha1.InstallRequest]) (*connect.Response[v1alpha1.InstallResponse], error) + UpdateMachineStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineStatusResponse], error) + ListMachines(context.Context, *connect.Request[v1alpha1.ListMachinesRequest]) (*connect.Response[v1alpha1.ListMachinesResponse], error) + AddPackageVersion(context.Context, *connect.Request[v1alpha1.AddPackageVersionRequest]) (*connect.Response[v1alpha1.AddPackageVersionResponse], error) + SetPackageVersion(context.Context, *connect.Request[v1alpha1.SetPackageVersionRequest]) (*connect.Response[v1alpha1.SetPackageVersionResponse], error) + RemovePackageVersion(context.Context, *connect.Request[v1alpha1.RemovePackageVersionRequest]) (*connect.Response[v1alpha1.RemovePackageVersionResponse], error) +} + +// NewMachineServiceHandler builds an HTTP handler from the service implementation. It returns the +// path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewMachineServiceHandler(svc MachineServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + machineServiceScanMachineHandler := connect.NewUnaryHandler( + MachineServiceScanMachineProcedure, + svc.ScanMachine, + connect.WithSchema(machineServiceScanMachineMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceInstallHandler := connect.NewUnaryHandler( + MachineServiceInstallProcedure, + svc.Install, + connect.WithSchema(machineServiceInstallMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceUpdateMachineStatusHandler := connect.NewUnaryHandler( + MachineServiceUpdateMachineStatusProcedure, + svc.UpdateMachineStatus, + connect.WithSchema(machineServiceUpdateMachineStatusMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceListMachinesHandler := connect.NewUnaryHandler( + MachineServiceListMachinesProcedure, + svc.ListMachines, + connect.WithSchema(machineServiceListMachinesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceAddPackageVersionHandler := connect.NewUnaryHandler( + MachineServiceAddPackageVersionProcedure, + svc.AddPackageVersion, + connect.WithSchema(machineServiceAddPackageVersionMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceSetPackageVersionHandler := connect.NewUnaryHandler( + MachineServiceSetPackageVersionProcedure, + svc.SetPackageVersion, + connect.WithSchema(machineServiceSetPackageVersionMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineServiceRemovePackageVersionHandler := connect.NewUnaryHandler( + MachineServiceRemovePackageVersionProcedure, + svc.RemovePackageVersion, + connect.WithSchema(machineServiceRemovePackageVersionMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/machine.v1alpha1.MachineService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case MachineServiceScanMachineProcedure: + machineServiceScanMachineHandler.ServeHTTP(w, r) + case MachineServiceInstallProcedure: + machineServiceInstallHandler.ServeHTTP(w, r) + case MachineServiceUpdateMachineStatusProcedure: + machineServiceUpdateMachineStatusHandler.ServeHTTP(w, r) + case MachineServiceListMachinesProcedure: + machineServiceListMachinesHandler.ServeHTTP(w, r) + case MachineServiceAddPackageVersionProcedure: + machineServiceAddPackageVersionHandler.ServeHTTP(w, r) + case MachineServiceSetPackageVersionProcedure: + machineServiceSetPackageVersionHandler.ServeHTTP(w, r) + case MachineServiceRemovePackageVersionProcedure: + machineServiceRemovePackageVersionHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedMachineServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedMachineServiceHandler struct{} + +func (UnimplementedMachineServiceHandler) ScanMachine(context.Context, *connect.Request[v1alpha1.ScanMachineRequest]) (*connect.Response[v1alpha1.ScanMachineResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.ScanMachine is not implemented")) +} + +func (UnimplementedMachineServiceHandler) Install(context.Context, *connect.Request[v1alpha1.InstallRequest]) (*connect.Response[v1alpha1.InstallResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.Install is not implemented")) +} + +func (UnimplementedMachineServiceHandler) UpdateMachineStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineStatusResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.UpdateMachineStatus is not implemented")) +} + +func (UnimplementedMachineServiceHandler) ListMachines(context.Context, *connect.Request[v1alpha1.ListMachinesRequest]) (*connect.Response[v1alpha1.ListMachinesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.ListMachines is not implemented")) +} + +func (UnimplementedMachineServiceHandler) AddPackageVersion(context.Context, *connect.Request[v1alpha1.AddPackageVersionRequest]) (*connect.Response[v1alpha1.AddPackageVersionResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.AddPackageVersion is not implemented")) +} + +func (UnimplementedMachineServiceHandler) SetPackageVersion(context.Context, *connect.Request[v1alpha1.SetPackageVersionRequest]) (*connect.Response[v1alpha1.SetPackageVersionResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.SetPackageVersion is not implemented")) +} + +func (UnimplementedMachineServiceHandler) RemovePackageVersion(context.Context, *connect.Request[v1alpha1.RemovePackageVersionRequest]) (*connect.Response[v1alpha1.RemovePackageVersionResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machine.v1alpha1.MachineService.RemovePackageVersion is not implemented")) +} diff --git a/lcmi/api/machinetype/v1alpha1/api.pb.go b/lcmi/api/machinetype/v1alpha1/api.pb.go index 6b7fd01..97172bd 100644 --- a/lcmi/api/machinetype/v1alpha1/api.pb.go +++ b/lcmi/api/machinetype/v1alpha1/api.pb.go @@ -28,9 +28,9 @@ type MachineGroup struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - MachineSelector *v1.LabelSelector `protobuf:"bytes,2,opt,name=machine_selector,json=machineSelector,proto3" json:"machine_selector,omitempty"` - Packages *v1alpha1.PackageVersion `protobuf:"bytes,3,opt,name=packages,proto3" json:"packages,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + MachineSelector *v1.LabelSelector `protobuf:"bytes,2,opt,name=machine_selector,json=machineSelector,proto3" json:"machine_selector,omitempty"` + Packages []*v1alpha1.PackageVersion `protobuf:"bytes,3,rep,name=packages,proto3" json:"packages,omitempty"` } func (x *MachineGroup) Reset() { @@ -79,7 +79,7 @@ func (x *MachineGroup) GetMachineSelector() *v1.LabelSelector { return nil } -func (x *MachineGroup) GetPackages() *v1alpha1.PackageVersion { +func (x *MachineGroup) GetPackages() []*v1alpha1.PackageVersion { if x != nil { return x.Packages } @@ -217,7 +217,7 @@ type MachineTypeStatus struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - LastScanTime *v1.Time `protobuf:"bytes,1,opt,name=last_scan_time,json=lastScanTime,proto3" json:"last_scan_time,omitempty"` + LastScanTime *v1.Timestamp `protobuf:"bytes,1,opt,name=last_scan_time,json=lastScanTime,proto3" json:"last_scan_time,omitempty"` LastScanResult v1alpha1.ScanResult `protobuf:"varint,2,opt,name=last_scan_result,json=lastScanResult,proto3,enum=common.v1alpha1.ScanResult" json:"last_scan_result,omitempty"` AvailablePackages []*AvailablePackageVersions `protobuf:"bytes,3,rep,name=available_packages,json=availablePackages,proto3" json:"available_packages,omitempty"` Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` @@ -255,7 +255,7 @@ func (*MachineTypeStatus) Descriptor() ([]byte, []int) { return file_machinetype_v1alpha1_api_proto_rawDescGZIP(), []int{3} } -func (x *MachineTypeStatus) GetLastScanTime() *v1.Time { +func (x *MachineTypeStatus) GetLastScanTime() *v1.Timestamp { if x != nil { return x.LastScanTime } @@ -932,7 +932,7 @@ var file_machinetype_v1alpha1_api_proto_rawDesc = []byte{ 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x0f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x3b, 0x0a, 0x08, - 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x22, 0xe5, 0x01, 0x0a, 0x0f, 0x4d, 0x61, @@ -954,168 +954,169 @@ var file_machinetype_v1alpha1_api_proto_rawDesc = []byte{ 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xa5, 0x02, + 0x03, 0x28, 0x09, 0x52, 0x08, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xaa, 0x02, 0x0a, 0x11, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x38, + 0x74, 0x75, 0x73, 0x12, 0x55, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, - 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, - 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x63, - 0x61, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x1b, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0e, 0x6c, 0x61, - 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x5d, 0x0a, 0x12, - 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, + 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x6c, 0x61, + 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x73, 0x63, 0x61, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x5d, 0x0a, 0x12, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x70, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, + 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x11, 0x61, + 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, + 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa9, 0x02, 0x0a, 0x0b, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4b, 0x0a, 0x09, 0x74, 0x79, + 0x70, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, + 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, + 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x74, + 0x79, 0x70, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x51, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x6b, + 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, + 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x0a, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x04, 0x73, 0x70, + 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, - 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x11, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, - 0x62, 0x6c, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xa9, 0x02, 0x0a, 0x0b, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6d, 0x65, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, + 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x70, 0x65, 0x63, 0x52, + 0x04, 0x73, 0x70, 0x65, 0x63, 0x12, 0x3f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, + 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x93, 0x01, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x12, 0x5a, 0x0a, 0x0e, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x54, 0x79, 0x70, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4d, 0x65, - 0x74, 0x61, 0x12, 0x51, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6d, 0x65, 0x74, - 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, - 0x2e, 0x61, 0x70, 0x69, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, - 0x67, 0x2e, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, - 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, - 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, - 0x12, 0x3f, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, - 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x93, 0x01, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x0e, 0x6c, - 0x61, 0x62, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x6b, 0x38, 0x73, 0x2e, 0x69, 0x6f, 0x2e, 0x61, 0x70, 0x69, - 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x6b, 0x67, 0x2e, 0x61, 0x70, - 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, - 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x0d, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x53, - 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x62, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0d, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0c, 0x6d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x3f, 0x0a, 0x0b, 0x53, - 0x63, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x46, 0x0a, 0x0c, - 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x06, - 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x22, 0x93, 0x01, 0x0a, 0x1e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x71, 0x0a, 0x1f, 0x55, 0x70, + 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x0d, 0x6c, + 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x62, 0x0a, 0x18, + 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0d, 0x6d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x21, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x0c, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, + 0x22, 0x3f, 0x0a, 0x0b, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x22, 0x46, 0x0a, 0x0c, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x93, 0x01, 0x0a, 0x1e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, - 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x93, 0x01, - 0x0a, 0x16, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, - 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0d, 0x6d, 0x61, - 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0c, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x22, 0x69, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x6c, - 0x0a, 0x19, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x6c, 0x0a, 0x1a, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, 0xd2, 0x04, 0x0a, 0x12, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x73, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x2d, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, - 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, - 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x04, 0x53, 0x63, 0x61, 0x6e, 0x12, 0x21, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x3f, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x22, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x88, 0x01, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x34, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, - 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x6d, 0x61, 0x63, 0x68, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, + 0x71, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x22, 0x93, 0x01, 0x0a, 0x16, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, + 0x47, 0x0a, 0x0d, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0c, 0x6d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x22, 0x69, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x22, 0x6c, 0x0a, 0x19, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4e, 0x61, 0x6d, + 0x65, 0x22, 0x6c, 0x0a, 0x1a, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x32, + 0xd2, 0x04, 0x0a, 0x12, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x73, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x2d, 0x2e, 0x6d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, - 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x70, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2c, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, - 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, - 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, - 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4d, 0x61, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x04, 0x53, + 0x63, 0x61, 0x6e, 0x12, 0x21, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, + 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x53, 0x63, + 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x88, 0x01, 0x0a, + 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, + 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x70, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2c, 0x2e, 0x6d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x2e, 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, + 0x41, 0x64, 0x64, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x12, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, + 0x2f, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x30, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x79, 0x0a, 0x12, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, - 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2f, 0x2e, 0x6d, 0x61, 0x63, + 0x73, 0x65, 0x22, 0x00, 0x42, 0xf2, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6d, 0x61, - 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0xf2, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, - 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x08, 0x41, 0x70, - 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x72, 0x6f, 0x6e, 0x63, 0x6f, 0x72, 0x65, 0x2d, 0x64, 0x65, - 0x76, 0x2f, 0x6c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2f, 0x6c, 0x63, 0x6d, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, - 0x31, 0x3b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, 0xaa, 0x02, 0x14, 0x4d, 0x61, - 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0xca, 0x02, 0x14, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, - 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x20, 0x4d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x4d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x42, 0x08, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x5b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x72, 0x6f, 0x6e, 0x63, 0x6f, + 0x72, 0x65, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, + 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x6c, 0x63, 0x6d, 0x69, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, + 0x70, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, + 0xaa, 0x02, 0x14, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x56, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x14, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x74, 0x79, 0x70, 0x65, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, + 0x20, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x5c, 0x56, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x15, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x74, 0x79, 0x70, 0x65, 0x3a, + 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -1150,7 +1151,7 @@ var file_machinetype_v1alpha1_api_proto_goTypes = []interface{}{ (*v1.LabelSelector)(nil), // 15: k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector (*v1alpha1.PackageVersion)(nil), // 16: common.v1alpha1.PackageVersion (*v1.Duration)(nil), // 17: k8s.io.apimachinery.pkg.apis.meta.v1.Duration - (*v1.Time)(nil), // 18: k8s.io.apimachinery.pkg.apis.meta.v1.Time + (*v1.Timestamp)(nil), // 18: k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp (v1alpha1.ScanResult)(0), // 19: common.v1alpha1.ScanResult (*v1.TypeMeta)(nil), // 20: k8s.io.apimachinery.pkg.apis.meta.v1.TypeMeta (*v1.ObjectMeta)(nil), // 21: k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta @@ -1161,7 +1162,7 @@ var file_machinetype_v1alpha1_api_proto_depIdxs = []int32{ 16, // 1: machinetype.v1alpha1.MachineGroup.packages:type_name -> common.v1alpha1.PackageVersion 17, // 2: machinetype.v1alpha1.MachineTypeSpec.scan_period:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Duration 0, // 3: machinetype.v1alpha1.MachineTypeSpec.machine_groups:type_name -> machinetype.v1alpha1.MachineGroup - 18, // 4: machinetype.v1alpha1.MachineTypeStatus.last_scan_time:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Time + 18, // 4: machinetype.v1alpha1.MachineTypeStatus.last_scan_time:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp 19, // 5: machinetype.v1alpha1.MachineTypeStatus.last_scan_result:type_name -> common.v1alpha1.ScanResult 2, // 6: machinetype.v1alpha1.MachineTypeStatus.available_packages:type_name -> machinetype.v1alpha1.AvailablePackageVersions 20, // 7: machinetype.v1alpha1.MachineType.type_meta:type_name -> k8s.io.apimachinery.pkg.apis.meta.v1.TypeMeta diff --git a/lcmi/api/machinetype/v1alpha1/api_grpc.pb.go b/lcmi/api/machinetype/v1alpha1/api_grpc.pb.go deleted file mode 100644 index 9f481a5..0000000 --- a/lcmi/api/machinetype/v1alpha1/api_grpc.pb.go +++ /dev/null @@ -1,258 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: machinetype/v1alpha1/api.proto - -package machinetypev1alpha1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - MachineTypeService_ListMachineTypes_FullMethodName = "/machinetype.v1alpha1.MachineTypeService/ListMachineTypes" - MachineTypeService_Scan_FullMethodName = "/machinetype.v1alpha1.MachineTypeService/Scan" - MachineTypeService_UpdateMachineTypeStatus_FullMethodName = "/machinetype.v1alpha1.MachineTypeService/UpdateMachineTypeStatus" - MachineTypeService_AddMachineGroup_FullMethodName = "/machinetype.v1alpha1.MachineTypeService/AddMachineGroup" - MachineTypeService_RemoveMachineGroup_FullMethodName = "/machinetype.v1alpha1.MachineTypeService/RemoveMachineGroup" -) - -// MachineTypeServiceClient is the client API for MachineTypeService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type MachineTypeServiceClient interface { - ListMachineTypes(ctx context.Context, in *ListMachineTypesRequest, opts ...grpc.CallOption) (*ListMachineTypesResponse, error) - Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) - UpdateMachineTypeStatus(ctx context.Context, in *UpdateMachineTypeStatusRequest, opts ...grpc.CallOption) (*UpdateMachineTypeStatusResponse, error) - AddMachineGroup(ctx context.Context, in *AddMachineGroupRequest, opts ...grpc.CallOption) (*AddMachineGroupResponse, error) - RemoveMachineGroup(ctx context.Context, in *RemoveMachineGroupRequest, opts ...grpc.CallOption) (*RemoveMachineGroupResponse, error) -} - -type machineTypeServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewMachineTypeServiceClient(cc grpc.ClientConnInterface) MachineTypeServiceClient { - return &machineTypeServiceClient{cc} -} - -func (c *machineTypeServiceClient) ListMachineTypes(ctx context.Context, in *ListMachineTypesRequest, opts ...grpc.CallOption) (*ListMachineTypesResponse, error) { - out := new(ListMachineTypesResponse) - err := c.cc.Invoke(ctx, MachineTypeService_ListMachineTypes_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineTypeServiceClient) Scan(ctx context.Context, in *ScanRequest, opts ...grpc.CallOption) (*ScanResponse, error) { - out := new(ScanResponse) - err := c.cc.Invoke(ctx, MachineTypeService_Scan_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineTypeServiceClient) UpdateMachineTypeStatus(ctx context.Context, in *UpdateMachineTypeStatusRequest, opts ...grpc.CallOption) (*UpdateMachineTypeStatusResponse, error) { - out := new(UpdateMachineTypeStatusResponse) - err := c.cc.Invoke(ctx, MachineTypeService_UpdateMachineTypeStatus_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineTypeServiceClient) AddMachineGroup(ctx context.Context, in *AddMachineGroupRequest, opts ...grpc.CallOption) (*AddMachineGroupResponse, error) { - out := new(AddMachineGroupResponse) - err := c.cc.Invoke(ctx, MachineTypeService_AddMachineGroup_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *machineTypeServiceClient) RemoveMachineGroup(ctx context.Context, in *RemoveMachineGroupRequest, opts ...grpc.CallOption) (*RemoveMachineGroupResponse, error) { - out := new(RemoveMachineGroupResponse) - err := c.cc.Invoke(ctx, MachineTypeService_RemoveMachineGroup_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MachineTypeServiceServer is the server API for MachineTypeService service. -// All implementations must embed UnimplementedMachineTypeServiceServer -// for forward compatibility -type MachineTypeServiceServer interface { - ListMachineTypes(context.Context, *ListMachineTypesRequest) (*ListMachineTypesResponse, error) - Scan(context.Context, *ScanRequest) (*ScanResponse, error) - UpdateMachineTypeStatus(context.Context, *UpdateMachineTypeStatusRequest) (*UpdateMachineTypeStatusResponse, error) - AddMachineGroup(context.Context, *AddMachineGroupRequest) (*AddMachineGroupResponse, error) - RemoveMachineGroup(context.Context, *RemoveMachineGroupRequest) (*RemoveMachineGroupResponse, error) - mustEmbedUnimplementedMachineTypeServiceServer() -} - -// UnimplementedMachineTypeServiceServer must be embedded to have forward compatible implementations. -type UnimplementedMachineTypeServiceServer struct { -} - -func (UnimplementedMachineTypeServiceServer) ListMachineTypes(context.Context, *ListMachineTypesRequest) (*ListMachineTypesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListMachineTypes not implemented") -} -func (UnimplementedMachineTypeServiceServer) Scan(context.Context, *ScanRequest) (*ScanResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Scan not implemented") -} -func (UnimplementedMachineTypeServiceServer) UpdateMachineTypeStatus(context.Context, *UpdateMachineTypeStatusRequest) (*UpdateMachineTypeStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateMachineTypeStatus not implemented") -} -func (UnimplementedMachineTypeServiceServer) AddMachineGroup(context.Context, *AddMachineGroupRequest) (*AddMachineGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddMachineGroup not implemented") -} -func (UnimplementedMachineTypeServiceServer) RemoveMachineGroup(context.Context, *RemoveMachineGroupRequest) (*RemoveMachineGroupResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveMachineGroup not implemented") -} -func (UnimplementedMachineTypeServiceServer) mustEmbedUnimplementedMachineTypeServiceServer() {} - -// UnsafeMachineTypeServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MachineTypeServiceServer will -// result in compilation errors. -type UnsafeMachineTypeServiceServer interface { - mustEmbedUnimplementedMachineTypeServiceServer() -} - -func RegisterMachineTypeServiceServer(s grpc.ServiceRegistrar, srv MachineTypeServiceServer) { - s.RegisterService(&MachineTypeService_ServiceDesc, srv) -} - -func _MachineTypeService_ListMachineTypes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListMachineTypesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineTypeServiceServer).ListMachineTypes(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineTypeService_ListMachineTypes_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineTypeServiceServer).ListMachineTypes(ctx, req.(*ListMachineTypesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineTypeService_Scan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ScanRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineTypeServiceServer).Scan(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineTypeService_Scan_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineTypeServiceServer).Scan(ctx, req.(*ScanRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineTypeService_UpdateMachineTypeStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateMachineTypeStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineTypeServiceServer).UpdateMachineTypeStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineTypeService_UpdateMachineTypeStatus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineTypeServiceServer).UpdateMachineTypeStatus(ctx, req.(*UpdateMachineTypeStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineTypeService_AddMachineGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddMachineGroupRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineTypeServiceServer).AddMachineGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineTypeService_AddMachineGroup_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineTypeServiceServer).AddMachineGroup(ctx, req.(*AddMachineGroupRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MachineTypeService_RemoveMachineGroup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemoveMachineGroupRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MachineTypeServiceServer).RemoveMachineGroup(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MachineTypeService_RemoveMachineGroup_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MachineTypeServiceServer).RemoveMachineGroup(ctx, req.(*RemoveMachineGroupRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// MachineTypeService_ServiceDesc is the grpc.ServiceDesc for MachineTypeService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var MachineTypeService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "machinetype.v1alpha1.MachineTypeService", - HandlerType: (*MachineTypeServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListMachineTypes", - Handler: _MachineTypeService_ListMachineTypes_Handler, - }, - { - MethodName: "Scan", - Handler: _MachineTypeService_Scan_Handler, - }, - { - MethodName: "UpdateMachineTypeStatus", - Handler: _MachineTypeService_UpdateMachineTypeStatus_Handler, - }, - { - MethodName: "AddMachineGroup", - Handler: _MachineTypeService_AddMachineGroup_Handler, - }, - { - MethodName: "RemoveMachineGroup", - Handler: _MachineTypeService_RemoveMachineGroup_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "machinetype/v1alpha1/api.proto", -} diff --git a/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect/api.connect.go b/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect/api.connect.go new file mode 100644 index 0000000..e429c76 --- /dev/null +++ b/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect/api.connect.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: machinetype/v1alpha1/api.proto + +package machinetypev1alpha1connect + +import ( + context "context" + errors "errors" + http "net/http" + strings "strings" + + connect "connectrpc.com/connect" + v1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // MachineTypeServiceName is the fully-qualified name of the MachineTypeService service. + MachineTypeServiceName = "machinetype.v1alpha1.MachineTypeService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // MachineTypeServiceListMachineTypesProcedure is the fully-qualified name of the + // MachineTypeService's ListMachineTypes RPC. + MachineTypeServiceListMachineTypesProcedure = "/machinetype.v1alpha1.MachineTypeService/ListMachineTypes" + // MachineTypeServiceScanProcedure is the fully-qualified name of the MachineTypeService's Scan RPC. + MachineTypeServiceScanProcedure = "/machinetype.v1alpha1.MachineTypeService/Scan" + // MachineTypeServiceUpdateMachineTypeStatusProcedure is the fully-qualified name of the + // MachineTypeService's UpdateMachineTypeStatus RPC. + MachineTypeServiceUpdateMachineTypeStatusProcedure = "/machinetype.v1alpha1.MachineTypeService/UpdateMachineTypeStatus" + // MachineTypeServiceAddMachineGroupProcedure is the fully-qualified name of the + // MachineTypeService's AddMachineGroup RPC. + MachineTypeServiceAddMachineGroupProcedure = "/machinetype.v1alpha1.MachineTypeService/AddMachineGroup" + // MachineTypeServiceRemoveMachineGroupProcedure is the fully-qualified name of the + // MachineTypeService's RemoveMachineGroup RPC. + MachineTypeServiceRemoveMachineGroupProcedure = "/machinetype.v1alpha1.MachineTypeService/RemoveMachineGroup" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + machineTypeServiceServiceDescriptor = v1alpha1.File_machinetype_v1alpha1_api_proto.Services().ByName("MachineTypeService") + machineTypeServiceListMachineTypesMethodDescriptor = machineTypeServiceServiceDescriptor.Methods().ByName("ListMachineTypes") + machineTypeServiceScanMethodDescriptor = machineTypeServiceServiceDescriptor.Methods().ByName("Scan") + machineTypeServiceUpdateMachineTypeStatusMethodDescriptor = machineTypeServiceServiceDescriptor.Methods().ByName("UpdateMachineTypeStatus") + machineTypeServiceAddMachineGroupMethodDescriptor = machineTypeServiceServiceDescriptor.Methods().ByName("AddMachineGroup") + machineTypeServiceRemoveMachineGroupMethodDescriptor = machineTypeServiceServiceDescriptor.Methods().ByName("RemoveMachineGroup") +) + +// MachineTypeServiceClient is a client for the machinetype.v1alpha1.MachineTypeService service. +type MachineTypeServiceClient interface { + ListMachineTypes(context.Context, *connect.Request[v1alpha1.ListMachineTypesRequest]) (*connect.Response[v1alpha1.ListMachineTypesResponse], error) + Scan(context.Context, *connect.Request[v1alpha1.ScanRequest]) (*connect.Response[v1alpha1.ScanResponse], error) + UpdateMachineTypeStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineTypeStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineTypeStatusResponse], error) + AddMachineGroup(context.Context, *connect.Request[v1alpha1.AddMachineGroupRequest]) (*connect.Response[v1alpha1.AddMachineGroupResponse], error) + RemoveMachineGroup(context.Context, *connect.Request[v1alpha1.RemoveMachineGroupRequest]) (*connect.Response[v1alpha1.RemoveMachineGroupResponse], error) +} + +// NewMachineTypeServiceClient constructs a client for the machinetype.v1alpha1.MachineTypeService +// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for +// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply +// the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewMachineTypeServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MachineTypeServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &machineTypeServiceClient{ + listMachineTypes: connect.NewClient[v1alpha1.ListMachineTypesRequest, v1alpha1.ListMachineTypesResponse]( + httpClient, + baseURL+MachineTypeServiceListMachineTypesProcedure, + connect.WithSchema(machineTypeServiceListMachineTypesMethodDescriptor), + connect.WithClientOptions(opts...), + ), + scan: connect.NewClient[v1alpha1.ScanRequest, v1alpha1.ScanResponse]( + httpClient, + baseURL+MachineTypeServiceScanProcedure, + connect.WithSchema(machineTypeServiceScanMethodDescriptor), + connect.WithClientOptions(opts...), + ), + updateMachineTypeStatus: connect.NewClient[v1alpha1.UpdateMachineTypeStatusRequest, v1alpha1.UpdateMachineTypeStatusResponse]( + httpClient, + baseURL+MachineTypeServiceUpdateMachineTypeStatusProcedure, + connect.WithSchema(machineTypeServiceUpdateMachineTypeStatusMethodDescriptor), + connect.WithClientOptions(opts...), + ), + addMachineGroup: connect.NewClient[v1alpha1.AddMachineGroupRequest, v1alpha1.AddMachineGroupResponse]( + httpClient, + baseURL+MachineTypeServiceAddMachineGroupProcedure, + connect.WithSchema(machineTypeServiceAddMachineGroupMethodDescriptor), + connect.WithClientOptions(opts...), + ), + removeMachineGroup: connect.NewClient[v1alpha1.RemoveMachineGroupRequest, v1alpha1.RemoveMachineGroupResponse]( + httpClient, + baseURL+MachineTypeServiceRemoveMachineGroupProcedure, + connect.WithSchema(machineTypeServiceRemoveMachineGroupMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// machineTypeServiceClient implements MachineTypeServiceClient. +type machineTypeServiceClient struct { + listMachineTypes *connect.Client[v1alpha1.ListMachineTypesRequest, v1alpha1.ListMachineTypesResponse] + scan *connect.Client[v1alpha1.ScanRequest, v1alpha1.ScanResponse] + updateMachineTypeStatus *connect.Client[v1alpha1.UpdateMachineTypeStatusRequest, v1alpha1.UpdateMachineTypeStatusResponse] + addMachineGroup *connect.Client[v1alpha1.AddMachineGroupRequest, v1alpha1.AddMachineGroupResponse] + removeMachineGroup *connect.Client[v1alpha1.RemoveMachineGroupRequest, v1alpha1.RemoveMachineGroupResponse] +} + +// ListMachineTypes calls machinetype.v1alpha1.MachineTypeService.ListMachineTypes. +func (c *machineTypeServiceClient) ListMachineTypes(ctx context.Context, req *connect.Request[v1alpha1.ListMachineTypesRequest]) (*connect.Response[v1alpha1.ListMachineTypesResponse], error) { + return c.listMachineTypes.CallUnary(ctx, req) +} + +// Scan calls machinetype.v1alpha1.MachineTypeService.Scan. +func (c *machineTypeServiceClient) Scan(ctx context.Context, req *connect.Request[v1alpha1.ScanRequest]) (*connect.Response[v1alpha1.ScanResponse], error) { + return c.scan.CallUnary(ctx, req) +} + +// UpdateMachineTypeStatus calls machinetype.v1alpha1.MachineTypeService.UpdateMachineTypeStatus. +func (c *machineTypeServiceClient) UpdateMachineTypeStatus(ctx context.Context, req *connect.Request[v1alpha1.UpdateMachineTypeStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineTypeStatusResponse], error) { + return c.updateMachineTypeStatus.CallUnary(ctx, req) +} + +// AddMachineGroup calls machinetype.v1alpha1.MachineTypeService.AddMachineGroup. +func (c *machineTypeServiceClient) AddMachineGroup(ctx context.Context, req *connect.Request[v1alpha1.AddMachineGroupRequest]) (*connect.Response[v1alpha1.AddMachineGroupResponse], error) { + return c.addMachineGroup.CallUnary(ctx, req) +} + +// RemoveMachineGroup calls machinetype.v1alpha1.MachineTypeService.RemoveMachineGroup. +func (c *machineTypeServiceClient) RemoveMachineGroup(ctx context.Context, req *connect.Request[v1alpha1.RemoveMachineGroupRequest]) (*connect.Response[v1alpha1.RemoveMachineGroupResponse], error) { + return c.removeMachineGroup.CallUnary(ctx, req) +} + +// MachineTypeServiceHandler is an implementation of the machinetype.v1alpha1.MachineTypeService +// service. +type MachineTypeServiceHandler interface { + ListMachineTypes(context.Context, *connect.Request[v1alpha1.ListMachineTypesRequest]) (*connect.Response[v1alpha1.ListMachineTypesResponse], error) + Scan(context.Context, *connect.Request[v1alpha1.ScanRequest]) (*connect.Response[v1alpha1.ScanResponse], error) + UpdateMachineTypeStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineTypeStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineTypeStatusResponse], error) + AddMachineGroup(context.Context, *connect.Request[v1alpha1.AddMachineGroupRequest]) (*connect.Response[v1alpha1.AddMachineGroupResponse], error) + RemoveMachineGroup(context.Context, *connect.Request[v1alpha1.RemoveMachineGroupRequest]) (*connect.Response[v1alpha1.RemoveMachineGroupResponse], error) +} + +// NewMachineTypeServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewMachineTypeServiceHandler(svc MachineTypeServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + machineTypeServiceListMachineTypesHandler := connect.NewUnaryHandler( + MachineTypeServiceListMachineTypesProcedure, + svc.ListMachineTypes, + connect.WithSchema(machineTypeServiceListMachineTypesMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineTypeServiceScanHandler := connect.NewUnaryHandler( + MachineTypeServiceScanProcedure, + svc.Scan, + connect.WithSchema(machineTypeServiceScanMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineTypeServiceUpdateMachineTypeStatusHandler := connect.NewUnaryHandler( + MachineTypeServiceUpdateMachineTypeStatusProcedure, + svc.UpdateMachineTypeStatus, + connect.WithSchema(machineTypeServiceUpdateMachineTypeStatusMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineTypeServiceAddMachineGroupHandler := connect.NewUnaryHandler( + MachineTypeServiceAddMachineGroupProcedure, + svc.AddMachineGroup, + connect.WithSchema(machineTypeServiceAddMachineGroupMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + machineTypeServiceRemoveMachineGroupHandler := connect.NewUnaryHandler( + MachineTypeServiceRemoveMachineGroupProcedure, + svc.RemoveMachineGroup, + connect.WithSchema(machineTypeServiceRemoveMachineGroupMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/machinetype.v1alpha1.MachineTypeService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case MachineTypeServiceListMachineTypesProcedure: + machineTypeServiceListMachineTypesHandler.ServeHTTP(w, r) + case MachineTypeServiceScanProcedure: + machineTypeServiceScanHandler.ServeHTTP(w, r) + case MachineTypeServiceUpdateMachineTypeStatusProcedure: + machineTypeServiceUpdateMachineTypeStatusHandler.ServeHTTP(w, r) + case MachineTypeServiceAddMachineGroupProcedure: + machineTypeServiceAddMachineGroupHandler.ServeHTTP(w, r) + case MachineTypeServiceRemoveMachineGroupProcedure: + machineTypeServiceRemoveMachineGroupHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedMachineTypeServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedMachineTypeServiceHandler struct{} + +func (UnimplementedMachineTypeServiceHandler) ListMachineTypes(context.Context, *connect.Request[v1alpha1.ListMachineTypesRequest]) (*connect.Response[v1alpha1.ListMachineTypesResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machinetype.v1alpha1.MachineTypeService.ListMachineTypes is not implemented")) +} + +func (UnimplementedMachineTypeServiceHandler) Scan(context.Context, *connect.Request[v1alpha1.ScanRequest]) (*connect.Response[v1alpha1.ScanResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machinetype.v1alpha1.MachineTypeService.Scan is not implemented")) +} + +func (UnimplementedMachineTypeServiceHandler) UpdateMachineTypeStatus(context.Context, *connect.Request[v1alpha1.UpdateMachineTypeStatusRequest]) (*connect.Response[v1alpha1.UpdateMachineTypeStatusResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machinetype.v1alpha1.MachineTypeService.UpdateMachineTypeStatus is not implemented")) +} + +func (UnimplementedMachineTypeServiceHandler) AddMachineGroup(context.Context, *connect.Request[v1alpha1.AddMachineGroupRequest]) (*connect.Response[v1alpha1.AddMachineGroupResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machinetype.v1alpha1.MachineTypeService.AddMachineGroup is not implemented")) +} + +func (UnimplementedMachineTypeServiceHandler) RemoveMachineGroup(context.Context, *connect.Request[v1alpha1.RemoveMachineGroupRequest]) (*connect.Response[v1alpha1.RemoveMachineGroupResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("machinetype.v1alpha1.MachineTypeService.RemoveMachineGroup is not implemented")) +} diff --git a/lcmi/api/storage/v1alpha1/api_grpc.pb.go b/lcmi/api/storage/v1alpha1/api_grpc.pb.go deleted file mode 100644 index bb8c42b..0000000 --- a/lcmi/api/storage/v1alpha1/api_grpc.pb.go +++ /dev/null @@ -1,284 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: storage/v1alpha1/api.proto - -package commonv1alpha1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - FirmwareStorageService_InitUpload_FullMethodName = "/common.v1alpha1.FirmwareStorageService/InitUpload" - FirmwareStorageService_Upload_FullMethodName = "/common.v1alpha1.FirmwareStorageService/Upload" - FirmwareStorageService_InitDownload_FullMethodName = "/common.v1alpha1.FirmwareStorageService/InitDownload" - FirmwareStorageService_Download_FullMethodName = "/common.v1alpha1.FirmwareStorageService/Download" -) - -// FirmwareStorageServiceClient is the client API for FirmwareStorageService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type FirmwareStorageServiceClient interface { - InitUpload(ctx context.Context, in *InitUploadRequest, opts ...grpc.CallOption) (*InitUploadResponse, error) - Upload(ctx context.Context, opts ...grpc.CallOption) (FirmwareStorageService_UploadClient, error) - InitDownload(ctx context.Context, in *InitDownloadRequest, opts ...grpc.CallOption) (*InitDownloadResponse, error) - Download(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (FirmwareStorageService_DownloadClient, error) -} - -type firmwareStorageServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewFirmwareStorageServiceClient(cc grpc.ClientConnInterface) FirmwareStorageServiceClient { - return &firmwareStorageServiceClient{cc} -} - -func (c *firmwareStorageServiceClient) InitUpload(ctx context.Context, in *InitUploadRequest, opts ...grpc.CallOption) (*InitUploadResponse, error) { - out := new(InitUploadResponse) - err := c.cc.Invoke(ctx, FirmwareStorageService_InitUpload_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *firmwareStorageServiceClient) Upload(ctx context.Context, opts ...grpc.CallOption) (FirmwareStorageService_UploadClient, error) { - stream, err := c.cc.NewStream(ctx, &FirmwareStorageService_ServiceDesc.Streams[0], FirmwareStorageService_Upload_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := &firmwareStorageServiceUploadClient{stream} - return x, nil -} - -type FirmwareStorageService_UploadClient interface { - Send(*UploadRequest) error - CloseAndRecv() (*UploadResponse, error) - grpc.ClientStream -} - -type firmwareStorageServiceUploadClient struct { - grpc.ClientStream -} - -func (x *firmwareStorageServiceUploadClient) Send(m *UploadRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *firmwareStorageServiceUploadClient) CloseAndRecv() (*UploadResponse, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(UploadResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *firmwareStorageServiceClient) InitDownload(ctx context.Context, in *InitDownloadRequest, opts ...grpc.CallOption) (*InitDownloadResponse, error) { - out := new(InitDownloadResponse) - err := c.cc.Invoke(ctx, FirmwareStorageService_InitDownload_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *firmwareStorageServiceClient) Download(ctx context.Context, in *DownloadRequest, opts ...grpc.CallOption) (FirmwareStorageService_DownloadClient, error) { - stream, err := c.cc.NewStream(ctx, &FirmwareStorageService_ServiceDesc.Streams[1], FirmwareStorageService_Download_FullMethodName, opts...) - if err != nil { - return nil, err - } - x := &firmwareStorageServiceDownloadClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type FirmwareStorageService_DownloadClient interface { - Recv() (*DownloadResponse, error) - grpc.ClientStream -} - -type firmwareStorageServiceDownloadClient struct { - grpc.ClientStream -} - -func (x *firmwareStorageServiceDownloadClient) Recv() (*DownloadResponse, error) { - m := new(DownloadResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// FirmwareStorageServiceServer is the server API for FirmwareStorageService service. -// All implementations must embed UnimplementedFirmwareStorageServiceServer -// for forward compatibility -type FirmwareStorageServiceServer interface { - InitUpload(context.Context, *InitUploadRequest) (*InitUploadResponse, error) - Upload(FirmwareStorageService_UploadServer) error - InitDownload(context.Context, *InitDownloadRequest) (*InitDownloadResponse, error) - Download(*DownloadRequest, FirmwareStorageService_DownloadServer) error - mustEmbedUnimplementedFirmwareStorageServiceServer() -} - -// UnimplementedFirmwareStorageServiceServer must be embedded to have forward compatible implementations. -type UnimplementedFirmwareStorageServiceServer struct { -} - -func (UnimplementedFirmwareStorageServiceServer) InitUpload(context.Context, *InitUploadRequest) (*InitUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method InitUpload not implemented") -} -func (UnimplementedFirmwareStorageServiceServer) Upload(FirmwareStorageService_UploadServer) error { - return status.Errorf(codes.Unimplemented, "method Upload not implemented") -} -func (UnimplementedFirmwareStorageServiceServer) InitDownload(context.Context, *InitDownloadRequest) (*InitDownloadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method InitDownload not implemented") -} -func (UnimplementedFirmwareStorageServiceServer) Download(*DownloadRequest, FirmwareStorageService_DownloadServer) error { - return status.Errorf(codes.Unimplemented, "method Download not implemented") -} -func (UnimplementedFirmwareStorageServiceServer) mustEmbedUnimplementedFirmwareStorageServiceServer() { -} - -// UnsafeFirmwareStorageServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to FirmwareStorageServiceServer will -// result in compilation errors. -type UnsafeFirmwareStorageServiceServer interface { - mustEmbedUnimplementedFirmwareStorageServiceServer() -} - -func RegisterFirmwareStorageServiceServer(s grpc.ServiceRegistrar, srv FirmwareStorageServiceServer) { - s.RegisterService(&FirmwareStorageService_ServiceDesc, srv) -} - -func _FirmwareStorageService_InitUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InitUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(FirmwareStorageServiceServer).InitUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: FirmwareStorageService_InitUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FirmwareStorageServiceServer).InitUpload(ctx, req.(*InitUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _FirmwareStorageService_Upload_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(FirmwareStorageServiceServer).Upload(&firmwareStorageServiceUploadServer{stream}) -} - -type FirmwareStorageService_UploadServer interface { - SendAndClose(*UploadResponse) error - Recv() (*UploadRequest, error) - grpc.ServerStream -} - -type firmwareStorageServiceUploadServer struct { - grpc.ServerStream -} - -func (x *firmwareStorageServiceUploadServer) SendAndClose(m *UploadResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *firmwareStorageServiceUploadServer) Recv() (*UploadRequest, error) { - m := new(UploadRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _FirmwareStorageService_InitDownload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InitDownloadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(FirmwareStorageServiceServer).InitDownload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: FirmwareStorageService_InitDownload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FirmwareStorageServiceServer).InitDownload(ctx, req.(*InitDownloadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _FirmwareStorageService_Download_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(DownloadRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(FirmwareStorageServiceServer).Download(m, &firmwareStorageServiceDownloadServer{stream}) -} - -type FirmwareStorageService_DownloadServer interface { - Send(*DownloadResponse) error - grpc.ServerStream -} - -type firmwareStorageServiceDownloadServer struct { - grpc.ServerStream -} - -func (x *firmwareStorageServiceDownloadServer) Send(m *DownloadResponse) error { - return x.ServerStream.SendMsg(m) -} - -// FirmwareStorageService_ServiceDesc is the grpc.ServiceDesc for FirmwareStorageService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var FirmwareStorageService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "common.v1alpha1.FirmwareStorageService", - HandlerType: (*FirmwareStorageServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "InitUpload", - Handler: _FirmwareStorageService_InitUpload_Handler, - }, - { - MethodName: "InitDownload", - Handler: _FirmwareStorageService_InitDownload_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Upload", - Handler: _FirmwareStorageService_Upload_Handler, - ClientStreams: true, - }, - { - StreamName: "Download", - Handler: _FirmwareStorageService_Download_Handler, - ServerStreams: true, - }, - }, - Metadata: "storage/v1alpha1/api.proto", -} diff --git a/lcmi/api/storage/v1alpha1/commonv1alpha1connect/api.connect.go b/lcmi/api/storage/v1alpha1/commonv1alpha1connect/api.connect.go new file mode 100644 index 0000000..4b2cf58 --- /dev/null +++ b/lcmi/api/storage/v1alpha1/commonv1alpha1connect/api.connect.go @@ -0,0 +1,205 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: storage/v1alpha1/api.proto + +package commonv1alpha1connect + +import ( + context "context" + errors "errors" + http "net/http" + strings "strings" + + connect "connectrpc.com/connect" + v1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/storage/v1alpha1" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // FirmwareStorageServiceName is the fully-qualified name of the FirmwareStorageService service. + FirmwareStorageServiceName = "common.v1alpha1.FirmwareStorageService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // FirmwareStorageServiceInitUploadProcedure is the fully-qualified name of the + // FirmwareStorageService's InitUpload RPC. + FirmwareStorageServiceInitUploadProcedure = "/common.v1alpha1.FirmwareStorageService/InitUpload" + // FirmwareStorageServiceUploadProcedure is the fully-qualified name of the FirmwareStorageService's + // Upload RPC. + FirmwareStorageServiceUploadProcedure = "/common.v1alpha1.FirmwareStorageService/Upload" + // FirmwareStorageServiceInitDownloadProcedure is the fully-qualified name of the + // FirmwareStorageService's InitDownload RPC. + FirmwareStorageServiceInitDownloadProcedure = "/common.v1alpha1.FirmwareStorageService/InitDownload" + // FirmwareStorageServiceDownloadProcedure is the fully-qualified name of the + // FirmwareStorageService's Download RPC. + FirmwareStorageServiceDownloadProcedure = "/common.v1alpha1.FirmwareStorageService/Download" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + firmwareStorageServiceServiceDescriptor = v1alpha1.File_storage_v1alpha1_api_proto.Services().ByName("FirmwareStorageService") + firmwareStorageServiceInitUploadMethodDescriptor = firmwareStorageServiceServiceDescriptor.Methods().ByName("InitUpload") + firmwareStorageServiceUploadMethodDescriptor = firmwareStorageServiceServiceDescriptor.Methods().ByName("Upload") + firmwareStorageServiceInitDownloadMethodDescriptor = firmwareStorageServiceServiceDescriptor.Methods().ByName("InitDownload") + firmwareStorageServiceDownloadMethodDescriptor = firmwareStorageServiceServiceDescriptor.Methods().ByName("Download") +) + +// FirmwareStorageServiceClient is a client for the common.v1alpha1.FirmwareStorageService service. +type FirmwareStorageServiceClient interface { + InitUpload(context.Context, *connect.Request[v1alpha1.InitUploadRequest]) (*connect.Response[v1alpha1.InitUploadResponse], error) + Upload(context.Context) *connect.ClientStreamForClient[v1alpha1.UploadRequest, v1alpha1.UploadResponse] + InitDownload(context.Context, *connect.Request[v1alpha1.InitDownloadRequest]) (*connect.Response[v1alpha1.InitDownloadResponse], error) + Download(context.Context, *connect.Request[v1alpha1.DownloadRequest]) (*connect.ServerStreamForClient[v1alpha1.DownloadResponse], error) +} + +// NewFirmwareStorageServiceClient constructs a client for the +// common.v1alpha1.FirmwareStorageService service. By default, it uses the Connect protocol with the +// binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the +// gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewFirmwareStorageServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) FirmwareStorageServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &firmwareStorageServiceClient{ + initUpload: connect.NewClient[v1alpha1.InitUploadRequest, v1alpha1.InitUploadResponse]( + httpClient, + baseURL+FirmwareStorageServiceInitUploadProcedure, + connect.WithSchema(firmwareStorageServiceInitUploadMethodDescriptor), + connect.WithClientOptions(opts...), + ), + upload: connect.NewClient[v1alpha1.UploadRequest, v1alpha1.UploadResponse]( + httpClient, + baseURL+FirmwareStorageServiceUploadProcedure, + connect.WithSchema(firmwareStorageServiceUploadMethodDescriptor), + connect.WithClientOptions(opts...), + ), + initDownload: connect.NewClient[v1alpha1.InitDownloadRequest, v1alpha1.InitDownloadResponse]( + httpClient, + baseURL+FirmwareStorageServiceInitDownloadProcedure, + connect.WithSchema(firmwareStorageServiceInitDownloadMethodDescriptor), + connect.WithClientOptions(opts...), + ), + download: connect.NewClient[v1alpha1.DownloadRequest, v1alpha1.DownloadResponse]( + httpClient, + baseURL+FirmwareStorageServiceDownloadProcedure, + connect.WithSchema(firmwareStorageServiceDownloadMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// firmwareStorageServiceClient implements FirmwareStorageServiceClient. +type firmwareStorageServiceClient struct { + initUpload *connect.Client[v1alpha1.InitUploadRequest, v1alpha1.InitUploadResponse] + upload *connect.Client[v1alpha1.UploadRequest, v1alpha1.UploadResponse] + initDownload *connect.Client[v1alpha1.InitDownloadRequest, v1alpha1.InitDownloadResponse] + download *connect.Client[v1alpha1.DownloadRequest, v1alpha1.DownloadResponse] +} + +// InitUpload calls common.v1alpha1.FirmwareStorageService.InitUpload. +func (c *firmwareStorageServiceClient) InitUpload(ctx context.Context, req *connect.Request[v1alpha1.InitUploadRequest]) (*connect.Response[v1alpha1.InitUploadResponse], error) { + return c.initUpload.CallUnary(ctx, req) +} + +// Upload calls common.v1alpha1.FirmwareStorageService.Upload. +func (c *firmwareStorageServiceClient) Upload(ctx context.Context) *connect.ClientStreamForClient[v1alpha1.UploadRequest, v1alpha1.UploadResponse] { + return c.upload.CallClientStream(ctx) +} + +// InitDownload calls common.v1alpha1.FirmwareStorageService.InitDownload. +func (c *firmwareStorageServiceClient) InitDownload(ctx context.Context, req *connect.Request[v1alpha1.InitDownloadRequest]) (*connect.Response[v1alpha1.InitDownloadResponse], error) { + return c.initDownload.CallUnary(ctx, req) +} + +// Download calls common.v1alpha1.FirmwareStorageService.Download. +func (c *firmwareStorageServiceClient) Download(ctx context.Context, req *connect.Request[v1alpha1.DownloadRequest]) (*connect.ServerStreamForClient[v1alpha1.DownloadResponse], error) { + return c.download.CallServerStream(ctx, req) +} + +// FirmwareStorageServiceHandler is an implementation of the common.v1alpha1.FirmwareStorageService +// service. +type FirmwareStorageServiceHandler interface { + InitUpload(context.Context, *connect.Request[v1alpha1.InitUploadRequest]) (*connect.Response[v1alpha1.InitUploadResponse], error) + Upload(context.Context, *connect.ClientStream[v1alpha1.UploadRequest]) (*connect.Response[v1alpha1.UploadResponse], error) + InitDownload(context.Context, *connect.Request[v1alpha1.InitDownloadRequest]) (*connect.Response[v1alpha1.InitDownloadResponse], error) + Download(context.Context, *connect.Request[v1alpha1.DownloadRequest], *connect.ServerStream[v1alpha1.DownloadResponse]) error +} + +// NewFirmwareStorageServiceHandler builds an HTTP handler from the service implementation. It +// returns the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewFirmwareStorageServiceHandler(svc FirmwareStorageServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + firmwareStorageServiceInitUploadHandler := connect.NewUnaryHandler( + FirmwareStorageServiceInitUploadProcedure, + svc.InitUpload, + connect.WithSchema(firmwareStorageServiceInitUploadMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + firmwareStorageServiceUploadHandler := connect.NewClientStreamHandler( + FirmwareStorageServiceUploadProcedure, + svc.Upload, + connect.WithSchema(firmwareStorageServiceUploadMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + firmwareStorageServiceInitDownloadHandler := connect.NewUnaryHandler( + FirmwareStorageServiceInitDownloadProcedure, + svc.InitDownload, + connect.WithSchema(firmwareStorageServiceInitDownloadMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + firmwareStorageServiceDownloadHandler := connect.NewServerStreamHandler( + FirmwareStorageServiceDownloadProcedure, + svc.Download, + connect.WithSchema(firmwareStorageServiceDownloadMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/common.v1alpha1.FirmwareStorageService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case FirmwareStorageServiceInitUploadProcedure: + firmwareStorageServiceInitUploadHandler.ServeHTTP(w, r) + case FirmwareStorageServiceUploadProcedure: + firmwareStorageServiceUploadHandler.ServeHTTP(w, r) + case FirmwareStorageServiceInitDownloadProcedure: + firmwareStorageServiceInitDownloadHandler.ServeHTTP(w, r) + case FirmwareStorageServiceDownloadProcedure: + firmwareStorageServiceDownloadHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedFirmwareStorageServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedFirmwareStorageServiceHandler struct{} + +func (UnimplementedFirmwareStorageServiceHandler) InitUpload(context.Context, *connect.Request[v1alpha1.InitUploadRequest]) (*connect.Response[v1alpha1.InitUploadResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("common.v1alpha1.FirmwareStorageService.InitUpload is not implemented")) +} + +func (UnimplementedFirmwareStorageServiceHandler) Upload(context.Context, *connect.ClientStream[v1alpha1.UploadRequest]) (*connect.Response[v1alpha1.UploadResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("common.v1alpha1.FirmwareStorageService.Upload is not implemented")) +} + +func (UnimplementedFirmwareStorageServiceHandler) InitDownload(context.Context, *connect.Request[v1alpha1.InitDownloadRequest]) (*connect.Response[v1alpha1.InitDownloadResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("common.v1alpha1.FirmwareStorageService.InitDownload is not implemented")) +} + +func (UnimplementedFirmwareStorageServiceHandler) Download(context.Context, *connect.Request[v1alpha1.DownloadRequest], *connect.ServerStream[v1alpha1.DownloadResponse]) error { + return connect.NewError(connect.CodeUnimplemented, errors.New("common.v1alpha1.FirmwareStorageService.Download is not implemented")) +} diff --git a/lcmi/fake/machine_client.go b/lcmi/fake/machine_client.go deleted file mode 100644 index 86ed49e..0000000 --- a/lcmi/fake/machine_client.go +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package fake - -import ( - "context" - - "github.com/pkg/errors" - "google.golang.org/grpc" - "k8s.io/apimachinery/pkg/types" - - commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" - machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" -) - -type MachineClient struct { - cache map[string]*machinev1alpha1.MachineStatus -} - -func NewMachineClient(cache map[string]*machinev1alpha1.MachineStatus) *MachineClient { - return &MachineClient{cache: cache} -} - -func (m *MachineClient) WriteCache(id string, item *machinev1alpha1.MachineStatus) { - m.cache[id] = item -} - -func (m *MachineClient) ReadCache(id string) *machinev1alpha1.MachineStatus { - return m.cache[id] -} - -func (m *MachineClient) ListMachines( - _ context.Context, - _ *machinev1alpha1.ListMachinesRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.ListMachinesResponse, error) { - return nil, nil -} - -func (m *MachineClient) ScanMachine( - _ context.Context, - in *machinev1alpha1.ScanMachineRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.ScanMachineResponse, error) { - if in.Name == "failed-scan" { - return nil, errors.New("fake error") - } - key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} - uid := uuidutil.UUIDFromObjectKey(key) - _, ok := m.cache[uid] - if ok { - return &machinev1alpha1.ScanMachineResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil - } - m.cache[uid] = &machinev1alpha1.MachineStatus{} - return &machinev1alpha1.ScanMachineResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED, - }, nil -} - -func (m *MachineClient) Install( - _ context.Context, - in *machinev1alpha1.InstallRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.InstallResponse, error) { - if in.Name == "failed-install" { - return nil, errors.New("fake error") - } - if in.Name == "fake-failure" { - return &machinev1alpha1.InstallResponse{Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE}, nil - } - key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} - uid := uuidutil.UUIDFromObjectKey(key) - _, ok := m.cache[uid] - if ok { - return &machinev1alpha1.InstallResponse{Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED}, nil - } - m.cache[uid] = &machinev1alpha1.MachineStatus{} - return &machinev1alpha1.InstallResponse{Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED}, nil -} - -func (m *MachineClient) UpdateMachineStatus( - _ context.Context, - _ *machinev1alpha1.UpdateMachineStatusRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.UpdateMachineStatusResponse, error) { - return nil, nil -} - -func (m *MachineClient) AddPackageVersion( - _ context.Context, - _ *machinev1alpha1.AddPackageVersionRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.AddPackageVersionResponse, error) { - return nil, nil -} - -func (m *MachineClient) SetPackageVersion( - _ context.Context, - _ *machinev1alpha1.SetPackageVersionRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.SetPackageVersionResponse, error) { - return nil, nil -} - -func (m *MachineClient) RemovePackageVersion( - _ context.Context, - _ *machinev1alpha1.RemovePackageVersionRequest, - _ ...grpc.CallOption, -) (*machinev1alpha1.RemovePackageVersionResponse, error) { - return nil, nil -} diff --git a/lcmi/fake/machinetype_client.go b/lcmi/fake/machinetype_client.go deleted file mode 100644 index e5fd31c..0000000 --- a/lcmi/fake/machinetype_client.go +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package fake - -import ( - "context" - - "github.com/pkg/errors" - "google.golang.org/grpc" - "k8s.io/apimachinery/pkg/types" - - commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" - machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" -) - -type MachineTypeClient struct { - cache map[string]*machinetypev1alpha1.MachineTypeStatus -} - -func NewMachineTypeClient(cache map[string]*machinetypev1alpha1.MachineTypeStatus) *MachineTypeClient { - return &MachineTypeClient{cache: cache} -} - -func (m *MachineTypeClient) WriteCache(id string, item *machinetypev1alpha1.MachineTypeStatus) { - m.cache[id] = item -} - -func (m *MachineTypeClient) ReadCache(id string) *machinetypev1alpha1.MachineTypeStatus { - return m.cache[id] -} - -func (m *MachineTypeClient) ListMachineTypes( - _ context.Context, - _ *machinetypev1alpha1.ListMachineTypesRequest, - _ ...grpc.CallOption, -) (*machinetypev1alpha1.ListMachineTypesResponse, error) { - return nil, nil -} - -func (m *MachineTypeClient) Scan( - _ context.Context, - in *machinetypev1alpha1.ScanRequest, - _ ...grpc.CallOption, -) (*machinetypev1alpha1.ScanResponse, error) { - if in.Name == "failed-scan" { - return nil, errors.New("fake error") - } - key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} - uid := uuidutil.UUIDFromObjectKey(key) - _, ok := m.cache[uid] - if ok { - return &machinetypev1alpha1.ScanResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil - } - m.cache[uid] = &machinetypev1alpha1.MachineTypeStatus{} - return &machinetypev1alpha1.ScanResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED, - }, nil -} - -func (m *MachineTypeClient) UpdateMachineTypeStatus( - _ context.Context, - _ *machinetypev1alpha1.UpdateMachineTypeStatusRequest, - _ ...grpc.CallOption, -) (*machinetypev1alpha1.UpdateMachineTypeStatusResponse, error) { - return nil, nil -} - -func (m *MachineTypeClient) AddMachineGroup( - _ context.Context, - _ *machinetypev1alpha1.AddMachineGroupRequest, - _ ...grpc.CallOption, -) (*machinetypev1alpha1.AddMachineGroupResponse, error) { - return nil, nil -} - -func (m *MachineTypeClient) RemoveMachineGroup( - _ context.Context, - _ *machinetypev1alpha1.RemoveMachineGroupRequest, - _ ...grpc.CallOption, -) (*machinetypev1alpha1.RemoveMachineGroupResponse, error) { - return nil, nil -} diff --git a/lcmi/server/interceptors.go b/lcmi/server/interceptors.go deleted file mode 100644 index 4a4b5c8..0000000 --- a/lcmi/server/interceptors.go +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package server - -import ( - "context" - "log/slog" - - protov "github.com/bufbuild/protovalidate-go" - "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" - "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/protovalidate" - "google.golang.org/grpc" -) - -func UnaryServerValidatorInterceptor(val *protov.Validator) grpc.UnaryServerInterceptor { - return protovalidate.UnaryServerInterceptor(val) -} - -func UnaryServerLoggerInterceptor(log *slog.Logger, opts ...logging.Option) grpc.UnaryServerInterceptor { - l := interceptLogger(log) - return logging.UnaryServerInterceptor(l, opts...) -} - -func StreamServerValidatorInterceptor(val *protov.Validator) grpc.StreamServerInterceptor { - return protovalidate.StreamServerInterceptor(val) -} - -func StreamServerLoggingInterceptor(log *slog.Logger, opts ...logging.Option) grpc.StreamServerInterceptor { - l := interceptLogger(log) - return logging.StreamServerInterceptor(l, opts...) -} - -func interceptLogger(l *slog.Logger) logging.Logger { - return logging.LoggerFunc(func(_ context.Context, level logging.Level, msg string, fields ...any) { - switch level { - case logging.LevelDebug: - l.Debug(msg, fields...) - case logging.LevelInfo: - l.Info(msg, fields...) - case logging.LevelWarn: - l.Warn(msg, fields...) - case logging.LevelError: - l.Error(msg, fields...) - } - }) -} diff --git a/lcmi/server/machine/service.go b/lcmi/server/machine/service.go deleted file mode 100644 index 89dbc7f..0000000 --- a/lcmi/server/machine/service.go +++ /dev/null @@ -1,382 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package machine - -import ( - "context" - "reflect" - "slices" - "time" - - "github.com/go-logr/logr" - "github.com/jellydator/ttlcache/v3" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/rest" - - lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/clientgo/applyconfiguration/lifecycle/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/clientgo/lifecycle" - commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" - machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/util/apiutil" - "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" -) - -type Operation string - -type Scheduler interface { - ScanScheduled(key types.NamespacedName) bool - InstallScheduled(key types.NamespacedName) bool - ScheduleScan(key types.NamespacedName, spec lifecyclev1alpha1.MachineSpec, next time.Duration) - ScheduleInstall(key types.NamespacedName, spec lifecyclev1alpha1.MachineSpec) - DropJobFromCache(key types.NamespacedName) -} - -const ( - AddPackageFailureReason = "package already in the list" - SetPackageFailureReason = "package is not in the list" - - Scan Operation = "scan" - Install Operation = "install" -) - -type GrpcService struct { - machinev1alpha1.UnimplementedMachineServiceServer - cl *lifecycle.Clientset - scheduler Scheduler - cache *ttlcache.Cache[string, *machinev1alpha1.MachineStatus] - horizon time.Duration - scanPeriod time.Duration - namespace string -} - -type ServiceOption func(service *GrpcService) - -func NewGrpcService(cfg *rest.Config, opts ...ServiceOption) *GrpcService { - cl := lifecycle.NewForConfigOrDie(cfg) - svc := &GrpcService{ - cl: cl, - } - for _, opt := range opts { - opt(svc) - } - return svc -} - -func WithNamespace(namespace string) ServiceOption { - return func(svc *GrpcService) { - svc.namespace = namespace - } -} - -func WithHorizon(horizon time.Duration) ServiceOption { - return func(svc *GrpcService) { - svc.horizon = horizon - } -} - -func WithScanPeriod(period time.Duration) ServiceOption { - return func(svc *GrpcService) { - svc.scanPeriod = period - } -} - -func WithCache(cache *ttlcache.Cache[string, *machinev1alpha1.MachineStatus]) ServiceOption { - return func(svc *GrpcService) { - svc.cache = cache - } -} - -// ListMachines returns the list of Machine objects. -func (s *GrpcService) ListMachines( - ctx context.Context, - req *machinev1alpha1.ListMachinesRequest, -) (*machinev1alpha1.ListMachinesResponse, error) { - log := logr.FromContextOrDiscard(ctx) - namespace := req.GetNamespace() - if namespace == "" { - namespace = s.namespace - } - - opts := metav1.ListOptions{} - reqSelector := req.GetLabelSelector() - if reqSelector != nil { - opts.LabelSelector = labels.Set(reqSelector.MatchLabels).String() - } - machines, err := s.cl.LifecycleV1alpha1().Machines(namespace).List(ctx, opts) - if err != nil { - log.Error(err, "failed to list machines") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - resp := &machinev1alpha1.ListMachinesResponse{Machines: make([]*machinev1alpha1.Machine, len(machines.Items))} - for i, item := range machines.Items { - m := item.DeepCopy() - resp.Machines[i] = apiutil.MachineToGrpcAPI(m) - } - return resp, nil -} - -// ScanMachine runs scan job for target Machine. First it checks whether Machine -// state is in service's cache. If cache entry is found, it checks whether last -// scan timestamp is within defined horizon. If not, scan job will be spawned. -// Otherwise, cached state will be returned in response. -func (s *GrpcService) ScanMachine( - ctx context.Context, - req *machinev1alpha1.ScanMachineRequest, -) (*machinev1alpha1.ScanMachineResponse, error) { - resp := &machinev1alpha1.ScanMachineResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, - } - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - - key := types.NamespacedName{Name: req.Name, Namespace: namespace} - cacheItem := s.cache.Get(uuidutil.UUIDFromObjectKey(key)) - - switch { - case cacheItem == nil: - fallthrough - case time.Since(cacheItem.Value().LastScanTime.Time) > s.horizon: - fallthrough - case !installedPackagesEqual(machine.Status, cacheItem.Value()): - log.V(1).Info("scan scheduled") - resp.Result = s.scheduleOperation(Scan, key, machine.Spec) - default: - resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS - } - - return resp, nil -} - -// Install schedules package installation for target Machine. -func (s *GrpcService) Install( - ctx context.Context, - req *machinev1alpha1.InstallRequest, -) (*machinev1alpha1.InstallResponse, error) { - resp := &machinev1alpha1.InstallResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, - } - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - key := types.NamespacedName{Name: req.Name, Namespace: namespace} - s.scheduleOperation(Install, key, machine.Spec) - resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED - log.V(1).Info("packages installation scheduled") - return resp, nil -} - -// UpdateMachineStatus request initialized by the spawned Job and should update -// the status of processed Machine. If request succeed, Job exits with exit code 0, -// otherwise, Job will stop with non-zero exit code. -func (s *GrpcService) UpdateMachineStatus( - ctx context.Context, - req *machinev1alpha1.UpdateMachineStatusRequest, -) (*machinev1alpha1.UpdateMachineStatusResponse, error) { - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - machineApply := v1alpha1.Machine(machine.Name, machine.Namespace). - WithStatus(apiutil.MachineStatusToApplyConfiguration(req.Status)) - if _, err = s.cl.LifecycleV1alpha1().Machines(namespace).ApplyStatus(ctx, machineApply, metav1.ApplyOptions{ - FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", - Force: true, - }); err != nil { - log.Error(err, "failed to update machine status") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - key := types.NamespacedName{Name: req.Name, Namespace: namespace} - s.cache.Set(uuidutil.UUIDFromObjectKey(key), req.Status, ttlcache.DefaultTTL) - s.scheduler.DropJobFromCache(key) - return &machinev1alpha1.UpdateMachineStatusResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil -} - -func (s *GrpcService) AddPackageVersion( - ctx context.Context, - req *machinev1alpha1.AddPackageVersionRequest, -) (*machinev1alpha1.AddPackageVersionResponse, error) { - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) - if packageIndex(req.Package.Name, pkg) == -1 { - return &machinev1alpha1.AddPackageVersionResponse{ - Reason: AddPackageFailureReason, - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, - }, nil - } - pkg = slices.Grow(pkg, 1) - pkg = append(pkg, req.Package) - machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( - v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) - if _, err = s.cl.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ - FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", - Force: true, - }); err != nil { - log.Error(err, "failed to update machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - return &machinev1alpha1.AddPackageVersionResponse{ - Reason: "", - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil -} - -func (s *GrpcService) SetPackageVersion( - ctx context.Context, - req *machinev1alpha1.SetPackageVersionRequest, -) (*machinev1alpha1.SetPackageVersionResponse, error) { - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) - idx := packageIndex(req.Package.Name, pkg) - if idx < 0 { - return &machinev1alpha1.SetPackageVersionResponse{ - Reason: SetPackageFailureReason, - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, - }, nil - } - pkg[idx] = req.Package - machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( - v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) - if _, err = s.cl.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ - FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", - Force: true, - }); err != nil { - log.Error(err, "failed to update machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - return &machinev1alpha1.SetPackageVersionResponse{ - Reason: "", - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil -} - -func (s *GrpcService) RemovePackageVersion( - ctx context.Context, - req *machinev1alpha1.RemovePackageVersionRequest, -) (*machinev1alpha1.RemovePackageVersionResponse, error) { - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - machine, err := s.cl.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) - idx := packageIndex(req.PackageName, pkg) - if idx < 0 { - return &machinev1alpha1.RemovePackageVersionResponse{ - Reason: "", - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil - } - pkg = removePackage(pkg, idx) - machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( - v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) - if _, err = s.cl.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ - FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", - Force: true, - }); err != nil { - log.Error(err, "failed to update machine") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - return &machinev1alpha1.RemovePackageVersionResponse{ - Reason: "", - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil -} - -func installedPackagesEqual( - src lifecyclev1alpha1.MachineStatus, - tgt *machinev1alpha1.MachineStatus, -) bool { - conv := apiutil.MachineStatusToKubeAPI(tgt) - return reflect.DeepEqual(src, conv) -} - -func packageIndex(pkg string, dst []*commonv1alpha1.PackageVersion) int { - return slices.IndexFunc(dst, func(pv *commonv1alpha1.PackageVersion) bool { - return pkg == pv.Name - }) -} - -func removePackage(src []*commonv1alpha1.PackageVersion, index int) []*commonv1alpha1.PackageVersion { - result := make([]*commonv1alpha1.PackageVersion, 0, len(src)-1) - if len(src) == 1 { - return result - } - result = append(result, src[:index]...) - if len(src) == 2 && index == 1 { - return result - } - result = append(result, src[index+1:]...) - return result -} - -func (s *GrpcService) scheduleOperation( - op Operation, - key types.NamespacedName, - spec lifecyclev1alpha1.MachineSpec, -) commonv1alpha1.RequestResult { - switch op { - case Scan: - if !s.scheduler.ScanScheduled(key) { - s.scheduler.ScheduleScan(key, spec, s.scanPeriod) - } - case Install: - if !s.scheduler.InstallScheduled(key) { - s.scheduler.ScheduleInstall(key, spec) - } - } - return commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED -} diff --git a/lcmi/server/machinetype/service.go b/lcmi/server/machinetype/service.go deleted file mode 100644 index 18903b4..0000000 --- a/lcmi/server/machinetype/service.go +++ /dev/null @@ -1,187 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package machinetype - -import ( - "context" - "time" - - "github.com/go-logr/logr" - "github.com/ironcore-dev/lifecycle-manager/clientgo/applyconfiguration/lifecycle/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/clientgo/lifecycle" - commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" - machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/util/apiutil" - "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" - "github.com/jellydator/ttlcache/v3" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/types" - "k8s.io/client-go/rest" -) - -type Scheduler interface { - ScanScheduled(key types.NamespacedName) bool - ScheduleScan(key types.NamespacedName, next time.Duration) - DropJobFromCache(key types.NamespacedName) -} - -type GrpcService struct { - machinetypev1alpha1.UnimplementedMachineTypeServiceServer - cl *lifecycle.Clientset - scheduler Scheduler - cache *ttlcache.Cache[string, *machinetypev1alpha1.MachineTypeStatus] - horizon time.Duration - scanPeriod time.Duration - namespace string -} - -type ServiceOption func(service *GrpcService) - -func NewGrpcService(cfg *rest.Config, opts ...ServiceOption) *GrpcService { - cl := lifecycle.NewForConfigOrDie(cfg) - svc := &GrpcService{ - cl: cl, - } - for _, opt := range opts { - opt(svc) - } - return svc -} - -func WithNamespace(namespace string) ServiceOption { - return func(svc *GrpcService) { - svc.namespace = namespace - } -} - -func WithHorizon(horizon time.Duration) ServiceOption { - return func(svc *GrpcService) { - svc.horizon = horizon - } -} - -func WithScanPeriod(period time.Duration) ServiceOption { - return func(svc *GrpcService) { - svc.scanPeriod = period - } -} - -func WithCache(cache *ttlcache.Cache[string, *machinetypev1alpha1.MachineTypeStatus]) ServiceOption { - return func(svc *GrpcService) { - svc.cache = cache - } -} - -func (s *GrpcService) ListMachineTypes( - ctx context.Context, - req *machinetypev1alpha1.ListMachineTypesRequest, -) (*machinetypev1alpha1.ListMachineTypesResponse, error) { - log := logr.FromContextOrDiscard(ctx) - namespace := req.GetNamespace() - if namespace == "" { - namespace = s.namespace - } - - opts := metav1.ListOptions{} - reqSelector := req.GetLabelSelector() - if reqSelector != nil { - opts.LabelSelector = labels.Set(reqSelector.MatchLabels).String() - } - machinetypes, err := s.cl.LifecycleV1alpha1().MachineTypes(namespace).List(ctx, opts) - if err != nil { - log.Error(err, "failed to list machine types") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - resp := &machinetypev1alpha1.ListMachineTypesResponse{MachineTypes: make([]*machinetypev1alpha1.MachineType, - len(machinetypes.Items))} - for i, item := range machinetypes.Items { - m := item.DeepCopy() - resp.MachineTypes[i] = apiutil.MachineTypeToGrpcAPI(m) - } - return nil, err -} - -func (s *GrpcService) Scan( - ctx context.Context, - req *machinetypev1alpha1.ScanRequest, -) (*machinetypev1alpha1.ScanResponse, error) { - resp := &machinetypev1alpha1.ScanResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, - } - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - - key := types.NamespacedName{Name: req.Name, Namespace: namespace} - cacheItem := s.cache.Get(uuidutil.UUIDFromObjectKey(key)) - - switch { - case cacheItem == nil: - fallthrough - case time.Since(cacheItem.Value().LastScanTime.Time) > s.horizon: - log.V(1).Info("scan scheduled") - if !s.scheduler.ScanScheduled(key) { - s.scheduler.ScheduleScan(key, s.scanPeriod) - } - resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED - default: - resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS - } - - return resp, nil -} - -func (s *GrpcService) UpdateMachineTypeStatus( - ctx context.Context, - req *machinetypev1alpha1.UpdateMachineTypeStatusRequest, -) (*machinetypev1alpha1.UpdateMachineTypeStatusResponse, error) { - namespace := req.Namespace - if namespace == "" { - namespace = s.namespace - } - log := logr.FromContextOrDiscard(ctx).WithValues("name", req.Name, "namespace", namespace) - machinetype, err := s.cl.LifecycleV1alpha1().MachineTypes(namespace).Get(ctx, req.Name, metav1.GetOptions{}) - if err != nil { - log.Error(err, "failed to get machine type") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - machinetypeApply := v1alpha1.MachineType(machinetype.Name, machinetype.Namespace). - WithStatus(apiutil.MachineTypeStatusToApplyConfiguration(req.Status)) - if _, err = s.cl.LifecycleV1alpha1().MachineTypes(namespace).ApplyStatus(ctx, machinetypeApply, metav1.ApplyOptions{ - FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", - Force: true, - }); err != nil { - log.Error(err, "failed to update machine type status") - return nil, status.Errorf(codes.Internal, "%s", err.Error()) - } - key := types.NamespacedName{Name: req.Name, Namespace: namespace} - s.cache.Set(uuidutil.UUIDFromObjectKey(key), req.Status, ttlcache.DefaultTTL) - s.scheduler.DropJobFromCache(key) - return &machinetypev1alpha1.UpdateMachineTypeStatusResponse{ - Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, - }, nil -} - -func (s *GrpcService) AddMachineGroup( - ctx context.Context, - req *machinetypev1alpha1.AddMachineGroupRequest, -) (*machinetypev1alpha1.AddMachineGroupResponse, error) { - // TODO implement me - err := status.Error(codes.Unimplemented, "AddMachineGroup() is not implemented yet") - return nil, err -} - -func (s *GrpcService) RemoveMachineGroup( - ctx context.Context, - req *machinetypev1alpha1.RemoveMachineGroupRequest, -) (*machinetypev1alpha1.RemoveMachineGroupResponse, error) { - // TODO implement me - err := status.Error(codes.Unimplemented, "RemoveMachineGroup() is not implemented yet") - return nil, err -} diff --git a/lcmi/server/server.go b/lcmi/server/server.go deleted file mode 100644 index 9ad6202..0000000 --- a/lcmi/server/server.go +++ /dev/null @@ -1,126 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package server - -import ( - "context" - "fmt" - "log/slog" - "net" - "time" - - protov "github.com/bufbuild/protovalidate-go" - "github.com/jellydator/ttlcache/v3" - "google.golang.org/grpc" - "k8s.io/client-go/rest" - - machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" - machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" - storagev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/storage/v1alpha1" - "github.com/ironcore-dev/lifecycle-manager/lcmi/server/machine" - "github.com/ironcore-dev/lifecycle-manager/lcmi/server/machinetype" - "github.com/ironcore-dev/lifecycle-manager/lcmi/server/storage" -) - -const cacheCapacity = 1024 - -type LifecycleGRPCServer struct { - log *slog.Logger - machineGrpcService *machine.GrpcService - machinetypeGrpcService *machinetype.GrpcService - storageGrpcService *storage.GrpcService - machineCache *ttlcache.Cache[string, *machinev1alpha1.MachineStatus] - machinetypeCache *ttlcache.Cache[string, *machinetypev1alpha1.MachineTypeStatus] - port int -} - -type Options struct { - Cfg *rest.Config - Log *slog.Logger - Port int - Namespace string - ScanPeriod time.Duration - Horizon time.Duration -} - -func NewLifecycleGRPCServer(opts Options) *LifecycleGRPCServer { - srv := &LifecycleGRPCServer{ - log: opts.Log, - port: opts.Port, - } - machineCache := ttlcache.New[string, *machinev1alpha1.MachineStatus]( - ttlcache.WithTTL[string, *machinev1alpha1.MachineStatus](opts.ScanPeriod), - ttlcache.WithDisableTouchOnHit[string, *machinev1alpha1.MachineStatus](), - ttlcache.WithCapacity[string, *machinev1alpha1.MachineStatus](cacheCapacity)) - machinetypeCache := ttlcache.New[string, *machinetypev1alpha1.MachineTypeStatus]( - ttlcache.WithTTL[string, *machinetypev1alpha1.MachineTypeStatus](opts.ScanPeriod), - ttlcache.WithDisableTouchOnHit[string, *machinetypev1alpha1.MachineTypeStatus](), - ttlcache.WithCapacity[string, *machinetypev1alpha1.MachineTypeStatus](cacheCapacity)) - machineGrpcService := machine.NewGrpcService(opts.Cfg, - machine.WithNamespace(opts.Namespace), - machine.WithHorizon(opts.Horizon), - machine.WithScanPeriod(opts.ScanPeriod), - machine.WithCache(machineCache)) - machinetypeGrpcService := machinetype.NewGrpcService(opts.Cfg, - machinetype.WithNamespace(opts.Namespace), - machinetype.WithHorizon(opts.Horizon), - machinetype.WithScanPeriod(opts.ScanPeriod), - machinetype.WithCache(machinetypeCache)) - storageGrpcService := storage.NewGrpcService() - srv.machineCache = machineCache - srv.machinetypeCache = machinetypeCache - srv.machineGrpcService = machineGrpcService - srv.machinetypeGrpcService = machinetypeGrpcService - srv.storageGrpcService = storageGrpcService - return srv -} - -func (s *LifecycleGRPCServer) Start(ctx context.Context) error { - listener, err := net.Listen("tcp", fmt.Sprintf(":%d", s.port)) - if err != nil { - s.log.Error("failed to bind port for listener", "error", err.Error()) - return err - } - - validator, err := protov.New(protov.WithFailFast(true)) - if err != nil { - s.log.Error("failed to create validator", "error", err.Error()) - return err - } - - srv := grpc.NewServer( - grpc.ChainUnaryInterceptor( - UnaryServerLoggerInterceptor(s.log), - UnaryServerValidatorInterceptor(validator), - ), - grpc.ChainStreamInterceptor( - StreamServerLoggingInterceptor(s.log), - StreamServerValidatorInterceptor(validator), - ), - ) - machinev1alpha1.RegisterMachineServiceServer(srv, s.machineGrpcService) - machinetypev1alpha1.RegisterMachineTypeServiceServer(srv, s.machinetypeGrpcService) - storagev1alpha1.RegisterFirmwareStorageServiceServer(srv, s.storageGrpcService) - - go func() { - defer func() { - s.machineCache.Stop() - s.machinetypeCache.Stop() - s.log.Debug("stopping server", "kind", "lifecycle-service") - srv.GracefulStop() - s.log.Info("server stopped") - }() - <-ctx.Done() - }() - - // todo: run scheduler for scan/install jobs - go s.machineCache.Start() - go s.machinetypeCache.Start() - - s.log.Debug("starting server", "kind", "lifecycle-service", "addr", listener.Addr().String()) - if err = srv.Serve(listener); err != nil { - s.log.Error("failed to serve", "error", err.Error()) - } - return nil -} diff --git a/lcmi/server/storage/service.go b/lcmi/server/storage/service.go deleted file mode 100644 index ed7917f..0000000 --- a/lcmi/server/storage/service.go +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors -// SPDX-License-Identifier: Apache-2.0 - -package storage - -import ( - "context" - - storagev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/storage/v1alpha1" -) - -type GrpcService struct { - storagev1alpha1.UnimplementedFirmwareStorageServiceServer -} - -func NewGrpcService() *GrpcService { - return &GrpcService{} -} - -func (g *GrpcService) InitUpload( - ctx context.Context, - req *storagev1alpha1.InitUploadRequest, -) (*storagev1alpha1.InitUploadResponse, error) { - // TODO implement me - panic("implement me") -} - -func (g *GrpcService) Upload(srv storagev1alpha1.FirmwareStorageService_UploadServer) error { - // TODO implement me - panic("implement me") -} - -func (g *GrpcService) InitDownload( - ctx context.Context, - req *storagev1alpha1.InitDownloadRequest, -) (*storagev1alpha1.InitDownloadResponse, error) { - // TODO implement me - panic("implement me") -} - -func (g *GrpcService) Download( - req *storagev1alpha1.DownloadRequest, - srv storagev1alpha1.FirmwareStorageService_DownloadServer, -) error { - // TODO implement me - panic("implement me") -} diff --git a/lcmi/svc/interceptor/logging.go b/lcmi/svc/interceptor/logging.go new file mode 100644 index 0000000..ca0116c --- /dev/null +++ b/lcmi/svc/interceptor/logging.go @@ -0,0 +1,143 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package interceptor + +import ( + "context" + "log/slog" + "net/http" + + "connectrpc.com/connect" + "github.com/go-logr/logr" +) + +type LogInterceptor struct { + logger *slog.Logger +} + +func NewLoggerInterceptor(log *slog.Logger) connect.Interceptor { + return &LogInterceptor{logger: log} +} + +func (l *LogInterceptor) WrapUnary(unaryFunc connect.UnaryFunc) connect.UnaryFunc { + return func(ctx context.Context, req connect.AnyRequest) (connect.AnyResponse, error) { + log := l.logger.With("peer", req.Peer(), "endpoint", req.Spec().Procedure) + reqCtx := logr.NewContextWithSlogLogger(ctx, log) + response, err := unaryFunc(reqCtx, req) + if err != nil { + log.Error("request failed", "error", err.Error()) + return response, err + } + log.Debug("request finished", "response", response.Any()) + return response, err + } +} + +func (l *LogInterceptor) WrapStreamingClient(clientFunc connect.StreamingClientFunc) connect.StreamingClientFunc { + return func(ctx context.Context, spec connect.Spec) connect.StreamingClientConn { + return &streamingClientInterceptor{ + StreamingClientConn: clientFunc(ctx, spec), + logger: l.logger, + } + } +} + +func (l *LogInterceptor) WrapStreamingHandler(handlerFunc connect.StreamingHandlerFunc) connect.StreamingHandlerFunc { + return func(ctx context.Context, conn connect.StreamingHandlerConn) error { + return handlerFunc(ctx, &streamingHandlerInterceptor{ + StreamingHandlerConn: conn, + logger: l.logger, + }) + } +} + +type streamingClientInterceptor struct { + connect.StreamingClientConn + logger *slog.Logger +} + +func (s *streamingClientInterceptor) Spec() connect.Spec { + // TODO implement me + panic("implement me") +} + +func (s *streamingClientInterceptor) Peer() connect.Peer { + // TODO implement me + panic("implement me") +} + +// func (s *streamingClientInterceptor) Send(a any) error { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) RequestHeader() http.Header { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) CloseRequest() error { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) Receive(a any) error { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) ResponseHeader() http.Header { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) ResponseTrailer() http.Header { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingClientInterceptor) CloseResponse() error { +// // TODO implement me +// panic("implement me") +// } + +type streamingHandlerInterceptor struct { + connect.StreamingHandlerConn + logger *slog.Logger +} + +// func (s *streamingHandlerInterceptor) Spec() connect.Spec { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingHandlerInterceptor) Peer() connect.Peer { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingHandlerInterceptor) Receive(a any) error { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingHandlerInterceptor) RequestHeader() http.Header { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingHandlerInterceptor) Send(a any) error { +// // TODO implement me +// panic("implement me") +// } +// +// func (s *streamingHandlerInterceptor) ResponseHeader() http.Header { +// // TODO implement me +// panic("implement me") +// } + +func (s *streamingHandlerInterceptor) ResponseTrailer() http.Header { + // TODO implement me + panic("implement me") +} diff --git a/lcmi/svc/machine/v1alpha1/service.go b/lcmi/svc/machine/v1alpha1/service.go new file mode 100644 index 0000000..1fa3179 --- /dev/null +++ b/lcmi/svc/machine/v1alpha1/service.go @@ -0,0 +1,374 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + "context" + "reflect" + "slices" + "time" + + "connectrpc.com/connect" + "github.com/go-logr/logr" + lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/clientgo/applyconfiguration/lifecycle/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/clientgo/lifecycle" + commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" + machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1/machinev1alpha1connect" + "github.com/ironcore-dev/lifecycle-manager/util/apiutil" + "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" + "github.com/jellydator/ttlcache/v3" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/rest" +) + +const ( + AddPackageFailureReason = "package already in the list" + SetPackageFailureReason = "package is not in the list" +) + +type MachineService struct { + machinev1alpha1connect.UnimplementedMachineServiceHandler + c *lifecycle.Clientset + cache *ttlcache.Cache[string, *machinev1alpha1.MachineStatus] + horizon time.Duration + period time.Duration + namespace string +} + +type Option func(service *MachineService) + +func NewService(cfg *rest.Config, opts ...Option) *MachineService { + c := lifecycle.NewForConfigOrDie(cfg) + svc := &MachineService{c: c} + for _, opt := range opts { + opt(svc) + } + return svc +} + +func WithNamespace(namespace string) Option { + return func(svc *MachineService) { + svc.namespace = namespace + } +} + +func WithHorizon(horizon time.Duration) Option { + return func(svc *MachineService) { + svc.horizon = horizon + } +} + +func WithScanPeriod(period time.Duration) Option { + return func(svc *MachineService) { + svc.period = period + } +} + +func WithCache(cache *ttlcache.Cache[string, *machinev1alpha1.MachineStatus]) Option { + return func(svc *MachineService) { + svc.cache = cache + } +} + +// ScanMachine runs scan job for target Machine. First it checks whether Machine +// state is in service's cache. If cache entry is found, it checks whether last +// scan timestamp is within defined horizon. If not, scan job will be spawned. +// Otherwise, cached state will be returned in response. +func (s *MachineService) ScanMachine( + ctx context.Context, + c *connect.Request[machinev1alpha1.ScanMachineRequest], +) (*connect.Response[machinev1alpha1.ScanMachineResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + resp := &machinev1alpha1.ScanMachineResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, + } + + machine, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + + key := types.NamespacedName{Name: req.Name, Namespace: namespace} + cacheItem := s.cache.Get(uuidutil.UUIDFromObjectKey(key)) + + switch { + case cacheItem == nil: + fallthrough + case time.Since(time.Unix( + cacheItem.Value().LastScanTime.Seconds, int64(cacheItem.Value().LastScanTime.Nanos))) > s.horizon: + fallthrough + case !installedPackagesEqual(machine.Status, cacheItem.Value()): + // todo: result should be returned by the call to scheduler, like + // resp.Result = s.scheduleJob() + resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED + default: + resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS + } + return connect.NewResponse(resp), nil +} + +// Install schedules package installation for target Machine. +func (s *MachineService) Install( + ctx context.Context, + c *connect.Request[machinev1alpha1.InstallRequest], +) (*connect.Response[machinev1alpha1.InstallResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.Namespace + if namespace == "" { + namespace = s.namespace + } + resp := &machinev1alpha1.InstallResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, + } + + _, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + // todo: result should be returned by the call to scheduler, like + // resp.Result = s.scheduleJob() + resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED + return connect.NewResponse(resp), nil +} + +// UpdateMachineStatus request initialized by the spawned Job and should update +// the status of processed Machine. If request succeed, Job exits with exit code 0, +// otherwise, Job will stop with non-zero exit code. +func (s *MachineService) UpdateMachineStatus( + ctx context.Context, + c *connect.Request[machinev1alpha1.UpdateMachineStatusRequest], +) (*connect.Response[machinev1alpha1.UpdateMachineStatusResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.Namespace + if namespace == "" { + namespace = s.namespace + } + + machine, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + machineApply := v1alpha1.Machine(machine.Name, machine.Namespace). + WithStatus(apiutil.MachineStatusToApplyConfiguration(req.Status)) + if _, err = s.c.LifecycleV1alpha1().Machines(namespace).ApplyStatus(ctx, machineApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + key := types.NamespacedName{Name: req.Name, Namespace: namespace} + s.cache.Set(uuidutil.UUIDFromObjectKey(key), req.Status, ttlcache.DefaultTTL) + return connect.NewResponse(&machinev1alpha1.UpdateMachineStatusResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +// ListMachines returns the list of Machine objects. +func (s *MachineService) ListMachines( + ctx context.Context, + c *connect.Request[machinev1alpha1.ListMachinesRequest], +) (*connect.Response[machinev1alpha1.ListMachinesResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + opts := metav1.ListOptions{} + reqSelector := req.GetLabelSelector() + if reqSelector != nil { + opts.LabelSelector = labels.Set(reqSelector.MatchLabels).String() + } + machines, err := s.c.LifecycleV1alpha1().Machines(namespace).List(ctx, opts) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + resp := &machinev1alpha1.ListMachinesResponse{Machines: make([]*machinev1alpha1.Machine, len(machines.Items))} + for i, item := range machines.Items { + m := item.DeepCopy() + resp.Machines[i] = apiutil.MachineToGrpcAPI(m) + } + return connect.NewResponse(resp), nil +} + +func (s *MachineService) AddPackageVersion( + ctx context.Context, + c *connect.Request[machinev1alpha1.AddPackageVersionRequest], +) (*connect.Response[machinev1alpha1.AddPackageVersionResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machine, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) + if packageIndex(req.Package.Name, pkg) > -1 { + return connect.NewResponse(&machinev1alpha1.AddPackageVersionResponse{ + Reason: AddPackageFailureReason, + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, + }), nil + } + pkg = slices.Grow(pkg, 1) + pkg = append(pkg, req.Package) + machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( + v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) + if _, err = s.c.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + return connect.NewResponse(&machinev1alpha1.AddPackageVersionResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func (s *MachineService) SetPackageVersion( + ctx context.Context, + c *connect.Request[machinev1alpha1.SetPackageVersionRequest], +) (*connect.Response[machinev1alpha1.SetPackageVersionResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machine, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) + var idx int + if idx = packageIndex(req.Package.Name, pkg); idx == -1 { + return connect.NewResponse(&machinev1alpha1.SetPackageVersionResponse{ + Reason: SetPackageFailureReason, + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, + }), nil + } + pkg[idx] = req.Package + machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( + v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) + if _, err = s.c.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + return connect.NewResponse(&machinev1alpha1.SetPackageVersionResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func (s *MachineService) RemovePackageVersion( + ctx context.Context, + c *connect.Request[machinev1alpha1.RemovePackageVersionRequest], +) (*connect.Response[machinev1alpha1.RemovePackageVersionResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machine, err := s.c.LifecycleV1alpha1().Machines(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + pkg := apiutil.PackageVersionsToGrpcAPI(machine.Spec.Packages) + var idx int + if idx = packageIndex(req.PackageName, pkg); idx == -1 { + return connect.NewResponse(&machinev1alpha1.RemovePackageVersionResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil + } + pkg = removePackage(pkg, idx) + machineApply := v1alpha1.Machine(machine.Name, machine.Namespace).WithSpec( + v1alpha1.MachineSpec().WithPackages(apiutil.PackageVersionsToApplyConfiguration(pkg)...)) + if _, err = s.c.LifecycleV1alpha1().Machines(namespace).Apply(ctx, machineApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + return connect.NewResponse(&machinev1alpha1.RemovePackageVersionResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func installedPackagesEqual( + src lifecyclev1alpha1.MachineStatus, + tgt *machinev1alpha1.MachineStatus, +) bool { + conv := apiutil.MachineStatusToKubeAPI(tgt) + return reflect.DeepEqual(src, conv) +} + +func packageIndex(pkg string, dst []*commonv1alpha1.PackageVersion) int { + return slices.IndexFunc(dst, func(pv *commonv1alpha1.PackageVersion) bool { + return pkg == pv.Name + }) +} + +func removePackage(src []*commonv1alpha1.PackageVersion, index int) []*commonv1alpha1.PackageVersion { + result := make([]*commonv1alpha1.PackageVersion, 0, len(src)-1) + if len(src) == 1 { + return result + } + result = append(result, src[:index]...) + if len(src) == 2 && index == 1 { + return result + } + result = append(result, src[index+1:]...) + return result +} diff --git a/lcmi/svc/machinetype/v1alpha1/service.go b/lcmi/svc/machinetype/v1alpha1/service.go new file mode 100644 index 0000000..d93222c --- /dev/null +++ b/lcmi/svc/machinetype/v1alpha1/service.go @@ -0,0 +1,272 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package v1alpha1 + +import ( + "context" + "slices" + "time" + + "connectrpc.com/connect" + "github.com/go-logr/logr" + "github.com/ironcore-dev/lifecycle-manager/clientgo/applyconfiguration/lifecycle/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/clientgo/lifecycle" + commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" + machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect" + "github.com/ironcore-dev/lifecycle-manager/util/apiutil" + "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" + "github.com/jellydator/ttlcache/v3" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/rest" +) + +const ( + AddMachineGroupFailureReason = "machine group already in the list" +) + +type MachineTypeService struct { + machinetypev1alpha1connect.UnimplementedMachineTypeServiceHandler + c *lifecycle.Clientset + cache *ttlcache.Cache[string, *machinetypev1alpha1.MachineTypeStatus] + horizon time.Duration + period time.Duration + namespace string +} + +type Option func(service *MachineTypeService) + +func NewService(cfg *rest.Config, opts ...Option) *MachineTypeService { + c := lifecycle.NewForConfigOrDie(cfg) + svc := &MachineTypeService{c: c} + for _, opt := range opts { + opt(svc) + } + return svc +} + +func WithNamespace(namespace string) Option { + return func(svc *MachineTypeService) { + svc.namespace = namespace + } +} + +func WithHorizon(horizon time.Duration) Option { + return func(svc *MachineTypeService) { + svc.horizon = horizon + } +} + +func WithScanPeriod(period time.Duration) Option { + return func(svc *MachineTypeService) { + svc.period = period + } +} + +func WithCache(cache *ttlcache.Cache[string, *machinetypev1alpha1.MachineTypeStatus]) Option { + return func(svc *MachineTypeService) { + svc.cache = cache + } +} + +func (s *MachineTypeService) ListMachineTypes( + ctx context.Context, + c *connect.Request[machinetypev1alpha1.ListMachineTypesRequest], +) (*connect.Response[machinetypev1alpha1.ListMachineTypesResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + opts := metav1.ListOptions{} + reqSelector := req.GetLabelSelector() + if reqSelector != nil { + opts.LabelSelector = labels.Set(reqSelector.MatchLabels).String() + } + machinetypes, err := s.c.LifecycleV1alpha1().MachineTypes(namespace).List(ctx, opts) + if err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + resp := &machinetypev1alpha1.ListMachineTypesResponse{ + MachineTypes: make([]*machinetypev1alpha1.MachineType, len(machinetypes.Items))} + for i, item := range machinetypes.Items { + m := item.DeepCopy() + resp.MachineTypes[i] = apiutil.MachineTypeToGrpcAPI(m) + } + return connect.NewResponse(resp), nil +} + +func (s *MachineTypeService) Scan( + ctx context.Context, + c *connect.Request[machinetypev1alpha1.ScanRequest], +) (*connect.Response[machinetypev1alpha1.ScanResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + resp := &machinetypev1alpha1.ScanResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, + } + + key := types.NamespacedName{Name: req.Name, Namespace: namespace} + cacheItem := s.cache.Get(uuidutil.UUIDFromObjectKey(key)) + switch { + case cacheItem == nil: + fallthrough + case time.Since(time.Unix( + cacheItem.Value().LastScanTime.Seconds, int64(cacheItem.Value().LastScanTime.Nanos))) > s.horizon: + // todo: result should be returned by the call to scheduler, like + // resp.Result = s.scheduleJob() + resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED + default: + resp.Result = commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS + } + return connect.NewResponse(resp), nil +} + +func (s *MachineTypeService) UpdateMachineTypeStatus( + ctx context.Context, + c *connect.Request[machinetypev1alpha1.UpdateMachineTypeStatusRequest], +) (*connect.Response[machinetypev1alpha1.UpdateMachineTypeStatusResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machinetype, err := s.c.LifecycleV1alpha1().MachineTypes(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + machinetypeApply := v1alpha1.MachineType(machinetype.Name, machinetype.Namespace). + WithStatus(apiutil.MachineTypeStatusToApplyConfiguration(req.Status)) + if _, err = s.c.LifecycleV1alpha1().MachineTypes(namespace).ApplyStatus(ctx, machinetypeApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + key := types.NamespacedName{Name: req.Name, Namespace: namespace} + s.cache.Set(uuidutil.UUIDFromObjectKey(key), req.Status, ttlcache.DefaultTTL) + return connect.NewResponse(&machinetypev1alpha1.UpdateMachineTypeStatusResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func (s *MachineTypeService) AddMachineGroup( + ctx context.Context, + c *connect.Request[machinetypev1alpha1.AddMachineGroupRequest], +) (*connect.Response[machinetypev1alpha1.AddMachineGroupResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machinetype, err := s.c.LifecycleV1alpha1().MachineTypes(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + machineGroups := apiutil.MachineGroupsToGrpcAPI(machinetype.Spec.MachineGroups) + if machineGroupIndex(req.MachineGroup.Name, machineGroups) > -1 { + return connect.NewResponse(&machinetypev1alpha1.AddMachineGroupResponse{ + Reason: AddMachineGroupFailureReason, + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, + }), nil + } + machineGroups = slices.Grow(machineGroups, 1) + machineGroups = append(machineGroups, req.MachineGroup) + machinetypeApply := v1alpha1.MachineType(machinetype.Name, machinetype.Namespace).WithSpec( + v1alpha1.MachineTypeSpec().WithMachineGroups(apiutil.MachineGroupsToApplyConfiguration(machineGroups)...)) + if _, err = s.c.LifecycleV1alpha1().MachineTypes(namespace).Apply(ctx, machinetypeApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + return connect.NewResponse(&machinetypev1alpha1.AddMachineGroupResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func (s *MachineTypeService) RemoveMachineGroup( + ctx context.Context, + c *connect.Request[machinetypev1alpha1.RemoveMachineGroupRequest], +) (*connect.Response[machinetypev1alpha1.RemoveMachineGroupResponse], error) { + log := logr.FromContextAsSlogLogger(ctx) + log.Info("request", "request_body", c.Any()) + req := c.Msg + namespace := req.GetNamespace() + if namespace == "" { + namespace = s.namespace + } + + machinetype, err := s.c.LifecycleV1alpha1().MachineTypes(namespace).Get(ctx, req.Name, metav1.GetOptions{}) + if err != nil { + errCode := connect.CodeInternal + if apierrors.IsNotFound(err) { + errCode = connect.CodeNotFound + } + return nil, connect.NewError(errCode, err) + } + machineGroups := apiutil.MachineGroupsToGrpcAPI(machinetype.Spec.MachineGroups) + var idx int + if idx = machineGroupIndex(req.GroupName, machineGroups); idx == -1 { + return connect.NewResponse(&machinetypev1alpha1.RemoveMachineGroupResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil + } + machineGroups = removeMachineGroup(machineGroups, idx) + machinetypeApply := v1alpha1.MachineType(machinetype.Name, machinetype.Namespace).WithSpec( + v1alpha1.MachineTypeSpec().WithMachineGroups(apiutil.MachineGroupsToApplyConfiguration(machineGroups)...)) + if _, err = s.c.LifecycleV1alpha1().MachineTypes(namespace).Apply(ctx, machinetypeApply, metav1.ApplyOptions{ + FieldManager: "lifecycle.ironcore.dev/lifecycle-manager", + Force: true, + }); err != nil { + return nil, connect.NewError(connect.CodeInternal, err) + } + return connect.NewResponse(&machinetypev1alpha1.RemoveMachineGroupResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil +} + +func machineGroupIndex(name string, dst []*machinetypev1alpha1.MachineGroup) int { + return slices.IndexFunc(dst, func(g *machinetypev1alpha1.MachineGroup) bool { + return name == g.Name + }) +} + +func removeMachineGroup(src []*machinetypev1alpha1.MachineGroup, index int) []*machinetypev1alpha1.MachineGroup { + result := make([]*machinetypev1alpha1.MachineGroup, 0, len(src)-1) + if len(src) == 1 { + return result + } + result = append(result, src[:index]...) + if len(src) == 2 && index == 1 { + return result + } + result = append(result, src[index+1:]...) + return result +} diff --git a/lcmi/svc/reflect.go b/lcmi/svc/reflect.go new file mode 100644 index 0000000..7a2698a --- /dev/null +++ b/lcmi/svc/reflect.go @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package svc + +var Names = []string{ + "machine.v1alpha1.MachineService.ScanMachine", + "machine.v1alpha1.MachineService.Install", + "machine.v1alpha1.MachineService.ListMachines", + "machine.v1alpha1.MachineService.UpdateMachineStatus", + "machine.v1alpha1.MachineService.AddPackageVersion", + "machine.v1alpha1.MachineService.SetPackageVersion", + "machine.v1alpha1.MachineService.RemovePackageVersion", + "machinetype.v1alpha1.MachineTypeService.Scan", + "machinetype.v1alpha1.MachineTypeService.ListMachineTypes", + "machinetype.v1alpha1.MachineTypeService.UpdateMachineTypeStatus", + "machinetype.v1alpha1.MachineTypeService.AddMachineGroup", + "machinetype.v1alpha1.MachineTypeService.RemoveMachineGroup", +} diff --git a/lcmi/svc/server.go b/lcmi/svc/server.go new file mode 100644 index 0000000..bccc02d --- /dev/null +++ b/lcmi/svc/server.go @@ -0,0 +1,127 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package svc + +import ( + "context" + "fmt" + "log/slog" + "net/http" + "os" + "time" + + "connectrpc.com/connect" + "connectrpc.com/grpchealth" + "connectrpc.com/grpcreflect" + "connectrpc.com/validate" + machineapiv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1/machinev1alpha1connect" + machinetypeapiv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1/machinetypev1alpha1connect" + "github.com/ironcore-dev/lifecycle-manager/lcmi/svc/interceptor" + machinesvcv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/svc/machine/v1alpha1" + machinetypesvcv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/svc/machinetype/v1alpha1" + "github.com/jellydator/ttlcache/v3" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" + "k8s.io/client-go/rest" +) + +const cacheCapacity = 1024 + +type GrpcServer struct { + log *slog.Logger + host string + port int + machineService *machinesvcv1alpha1.MachineService + machineCache *ttlcache.Cache[string, *machineapiv1alpha1.MachineStatus] + machinetypeCache *ttlcache.Cache[string, *machinetypeapiv1alpha1.MachineTypeStatus] + machineTypeService *machinetypesvcv1alpha1.MachineTypeService +} + +type Options struct { + Cfg *rest.Config + Log *slog.Logger + Host string + Port int + Namespace string + ScanPeriod time.Duration + Horizon time.Duration +} + +func NewGrpcServer(opts Options) *GrpcServer { + srv := &GrpcServer{ + log: opts.Log, + host: opts.Host, + port: opts.Port, + } + machineCache := ttlcache.New[string, *machineapiv1alpha1.MachineStatus]( + ttlcache.WithTTL[string, *machineapiv1alpha1.MachineStatus](opts.ScanPeriod), + ttlcache.WithDisableTouchOnHit[string, *machineapiv1alpha1.MachineStatus](), + ttlcache.WithCapacity[string, *machineapiv1alpha1.MachineStatus](cacheCapacity)) + machinetypeCache := ttlcache.New[string, *machinetypeapiv1alpha1.MachineTypeStatus]( + ttlcache.WithTTL[string, *machinetypeapiv1alpha1.MachineTypeStatus](opts.ScanPeriod), + ttlcache.WithDisableTouchOnHit[string, *machinetypeapiv1alpha1.MachineTypeStatus](), + ttlcache.WithCapacity[string, *machinetypeapiv1alpha1.MachineTypeStatus](cacheCapacity)) + machineService := machinesvcv1alpha1.NewService(opts.Cfg, + machinesvcv1alpha1.WithNamespace(opts.Namespace), + machinesvcv1alpha1.WithHorizon(opts.Horizon), + machinesvcv1alpha1.WithScanPeriod(opts.ScanPeriod), + machinesvcv1alpha1.WithCache(machineCache)) + machinetypeService := machinetypesvcv1alpha1.NewService(opts.Cfg, + machinetypesvcv1alpha1.WithNamespace(opts.Namespace), + machinetypesvcv1alpha1.WithHorizon(opts.Horizon), + machinetypesvcv1alpha1.WithScanPeriod(opts.ScanPeriod), + machinetypesvcv1alpha1.WithCache(machinetypeCache)) + srv.machineCache = machineCache + srv.machinetypeCache = machinetypeCache + srv.machineService = machineService + srv.machineTypeService = machinetypeService + return srv +} + +func (s *GrpcServer) Start(ctx context.Context) error { + mux := http.NewServeMux() + reflector := grpcreflect.NewStaticReflector(Names...) + checker := grpchealth.NewStaticChecker(Names...) + + validator, err := validate.NewInterceptor() + if err != nil { + s.log.Error("failed to create validator", "error", err.Error()) + return err + } + logger := interceptor.NewLoggerInterceptor(s.log) + + // enable services + mux.Handle(machinev1alpha1connect.NewMachineServiceHandler(s.machineService, + connect.WithInterceptors(logger, validator))) + mux.Handle(machinetypev1alpha1connect.NewMachineTypeServiceHandler(s.machineTypeService, + connect.WithInterceptors(logger, validator))) + + // enable health checks + mux.Handle(grpchealth.NewHandler(checker)) + + // enable reflection for gRPC server + mux.Handle(grpcreflect.NewHandlerV1(reflector)) + mux.Handle(grpcreflect.NewHandlerV1Alpha(reflector)) + + srv := &http2.Server{} + + go func() { + defer func() { + s.log.Debug("stopping server", "kind", "lifecycle-service") + s.machineCache.Stop() + s.machinetypeCache.Stop() + s.log.Info("server stopped") + os.Exit(0) + }() + <-ctx.Done() + }() + + go s.machineCache.Start() + go s.machinetypeCache.Start() + + s.log.Info("start serving", "addr", fmt.Sprintf("%s:%d", s.host, s.port)) + return http.ListenAndServe(fmt.Sprintf("%s:%d", s.host, s.port), h2c.NewHandler(mux, srv)) +} diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index dc5a063..6ffdb08 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -11,7 +11,7 @@ plugins: out: ../lcmi/api opt: - paths=source_relative - - plugin: buf.build/grpc/go:v1.3.0 + - plugin: buf.build/connectrpc/go:v1.15.0 out: ../lcmi/api opt: - paths=source_relative \ No newline at end of file diff --git a/proto/commonapi/buf.lock b/proto/commonapi/buf.lock index 3ce75d9..4e2c971 100644 --- a/proto/commonapi/buf.lock +++ b/proto/commonapi/buf.lock @@ -4,5 +4,10 @@ deps: - remote: buf.build owner: bufbuild repository: protovalidate - commit: e097f827e65240ac9fd4b1158849a8fc - digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad + commit: f05a6f4403ce4327bae4f50f281c3ed0 + digest: shake256:668a0661b8df44d41839194896329330965fc215f3d2f88057fd60eeb759c2daf6cc6edfdd13b2a653d49fe2896ebedcb1a33c4c5b2dd10919f03ffb7fc52ae6 + - remote: buf.build + owner: k8s + repository: api + commit: 8f68e41b943c4de8a5e9c9a921c889a7 + digest: shake256:38ab77d24cf737d1204719a0ffc654056c29499f26b1546cc5af9ddb34e33799930d79d1f5a4a04b0f5c149097eabbeed37a5d2abf9552169a7d52011f6a8d6f diff --git a/proto/commonapi/buf.yaml b/proto/commonapi/buf.yaml index d661493..b601607 100644 --- a/proto/commonapi/buf.yaml +++ b/proto/commonapi/buf.yaml @@ -6,4 +6,5 @@ lint: use: - DEFAULT deps: + - buf.build/k8s/api - buf.build/bufbuild/protovalidate diff --git a/proto/commonapi/common/v1alpha1/api.proto b/proto/commonapi/common/v1alpha1/api.proto index 35d9401..ddbe71e 100644 --- a/proto/commonapi/common/v1alpha1/api.proto +++ b/proto/commonapi/common/v1alpha1/api.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package common.v1alpha1; import "buf/validate/validate.proto"; +import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; option go_package = "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1"; @@ -30,4 +31,13 @@ message PackageVersion { }; string name = 1; string version = 2; +} + +message Condition { + string type = 1; + string status = 2; + string reason = 3; + string message = 4; + int64 observed_generation = 5; + k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp last_transition_time = 6; } \ No newline at end of file diff --git a/proto/machineapi/machine/v1alpha1/api.proto b/proto/machineapi/machine/v1alpha1/api.proto index 7136c30..019d2a6 100644 --- a/proto/machineapi/machine/v1alpha1/api.proto +++ b/proto/machineapi/machine/v1alpha1/api.proto @@ -16,11 +16,11 @@ message MachineSpec { } message MachineStatus { - k8s.io.apimachinery.pkg.apis.meta.v1.Time last_scan_time = 1; + k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp last_scan_time = 1; common.v1alpha1.ScanResult last_scan_result = 2; repeated common.v1alpha1.PackageVersion installed_packages = 3; string message = 4; - repeated k8s.io.apimachinery.pkg.apis.meta.v1.Condition conditions = 5; + repeated common.v1alpha1.Condition conditions = 5; } message Machine { diff --git a/proto/machinetypeapi/machinetype/v1alpha1/api.proto b/proto/machinetypeapi/machinetype/v1alpha1/api.proto index d60b540..8c76d1a 100644 --- a/proto/machinetypeapi/machinetype/v1alpha1/api.proto +++ b/proto/machinetypeapi/machinetype/v1alpha1/api.proto @@ -10,7 +10,7 @@ option go_package = "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinet message MachineGroup { string name = 1; k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector machine_selector = 2; - common.v1alpha1.PackageVersion packages = 3; + repeated common.v1alpha1.PackageVersion packages = 3; } message MachineTypeSpec { @@ -26,7 +26,7 @@ message AvailablePackageVersions { } message MachineTypeStatus { - k8s.io.apimachinery.pkg.apis.meta.v1.Time last_scan_time = 1; + k8s.io.apimachinery.pkg.apis.meta.v1.Timestamp last_scan_time = 1; common.v1alpha1.ScanResult last_scan_result = 2; repeated AvailablePackageVersions available_packages = 3; string message = 4; diff --git a/util/apiutil/grpcapi.go b/util/apiutil/grpcapi.go index c55498e..9e470d2 100644 --- a/util/apiutil/grpcapi.go +++ b/util/apiutil/grpcapi.go @@ -4,6 +4,8 @@ package apiutil import ( + "time" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" @@ -14,6 +16,12 @@ import ( machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" ) +var LCIMScanResultToString = map[commonv1alpha1.ScanResult]lifecyclev1alpha1.ScanResult{ + commonv1alpha1.ScanResult_SCAN_RESULT_UNSPECIFIED: lifecyclev1alpha1.Unspecified, + commonv1alpha1.ScanResult_SCAN_RESULT_SUCCESS: lifecyclev1alpha1.ScanSuccess, + commonv1alpha1.ScanResult_SCAN_RESULT_FAILURE: lifecyclev1alpha1.ScanFailure, +} + func MachineToKubeAPI(src *machinev1alpha1.Machine) *lifecyclev1alpha1.Machine { return nil } @@ -23,7 +31,7 @@ func MachineStatusToKubeAPI(src *machinev1alpha1.MachineStatus) lifecyclev1alpha return lifecyclev1alpha1.MachineStatus{} } status := lifecyclev1alpha1.MachineStatus{ - LastScanTime: *src.LastScanTime, + LastScanTime: metav1.Time{Time: time.Unix(src.LastScanTime.Seconds, int64(src.LastScanTime.Nanos))}, LastScanResult: lifecyclev1alpha1.ScanResult(src.LastScanResult), InstalledPackages: PackageVersionsToKubeAPI(src.InstalledPackages), Message: src.Message, @@ -34,16 +42,20 @@ func MachineStatusToKubeAPI(src *machinev1alpha1.MachineStatus) lifecyclev1alpha func MachineStatusToApplyConfiguration( src *machinev1alpha1.MachineStatus, ) *lifecycleapplyv1alpha1.MachineStatusApplyConfiguration { - return lifecycleapplyv1alpha1.MachineStatus(). + apply := lifecycleapplyv1alpha1.MachineStatus(). WithMessage(src.Message). WithConditions(ConditionsToApplyConfiguration(src.Conditions)...). WithInstalledPackages(PackageVersionsToApplyConfiguration(src.InstalledPackages)...). - WithLastScanResult(lifecyclev1alpha1.ScanResult(src.LastScanResult)). - WithLastScanTime(*src.LastScanTime) + WithLastScanResult(LCIMScanResultToString[src.LastScanResult]) + if src.LastScanTime != nil { + apply = apply.WithLastScanTime(metav1.Time{ + Time: time.Unix(src.LastScanTime.Seconds, int64(src.LastScanTime.Nanos))}) + } + return apply } func ConditionsToApplyConfiguration( - src []*metav1.Condition, + src []*commonv1alpha1.Condition, ) []*v1.ConditionApplyConfiguration { result := make([]*v1.ConditionApplyConfiguration, len(src)) for i, item := range src { @@ -52,8 +64,9 @@ func ConditionsToApplyConfiguration( WithReason(item.Reason). WithType(item.Type). WithObservedGeneration(item.ObservedGeneration). - WithLastTransitionTime(item.LastTransitionTime). - WithStatus(item.Status) + WithLastTransitionTime(metav1.Time{ + Time: time.Unix(item.LastTransitionTime.Seconds, int64(item.LastTransitionTime.Nanos))}). + WithStatus(metav1.ConditionStatus(item.Status)) } return result } @@ -94,7 +107,7 @@ func MachineTypeStatusToKubeAPI(src *machinetypev1alpha1.MachineTypeStatus) life return lifecyclev1alpha1.MachineTypeStatus{} } status := lifecyclev1alpha1.MachineTypeStatus{ - LastScanTime: *src.LastScanTime, + LastScanTime: metav1.Time{Time: time.Unix(src.LastScanTime.Seconds, int64(src.LastScanTime.Nanos))}, LastScanResult: lifecyclev1alpha1.ScanResult(src.LastScanResult), AvailablePackages: AvailablePackageVersionsToKubeAPI(src.AvailablePackages), Message: src.Message, @@ -105,11 +118,15 @@ func MachineTypeStatusToKubeAPI(src *machinetypev1alpha1.MachineTypeStatus) life func MachineTypeStatusToApplyConfiguration( src *machinetypev1alpha1.MachineTypeStatus, ) *lifecycleapplyv1alpha1.MachineTypeStatusApplyConfiguration { - return lifecycleapplyv1alpha1.MachineTypeStatus(). + apply := lifecycleapplyv1alpha1.MachineTypeStatus(). WithMessage(src.Message). WithAvailablePackages(AvailablePackagesToApplyConfiguration(src.AvailablePackages)...). - WithLastScanResult(lifecyclev1alpha1.ScanResult(src.LastScanResult)). - WithLastScanTime(*src.LastScanTime) + WithLastScanResult(lifecyclev1alpha1.ScanResult(src.LastScanResult)) + if src.LastScanTime != nil { + apply = apply.WithLastScanTime(metav1.Time{ + Time: time.Unix(src.LastScanTime.Seconds, int64(src.LastScanTime.Nanos))}) + } + return apply } func AvailablePackagesToApplyConfiguration( @@ -140,3 +157,37 @@ func AvailablePackageVersionsToKubeAPI( } return result } + +func MachineGroupsToApplyConfiguration( + src []*machinetypev1alpha1.MachineGroup, +) []*lifecycleapplyv1alpha1.MachineGroupApplyConfiguration { + result := make([]*lifecycleapplyv1alpha1.MachineGroupApplyConfiguration, len(src)) + for i, item := range src { + result[i] = lifecycleapplyv1alpha1.MachineGroup(). + WithName(item.Name). + WithPackages(PackageVersionsToApplyConfiguration(item.Packages)...). + WithMachineSelector(LabelSelectorToApplyConfiguration(item.MachineSelector)) + } + return result +} + +func LabelSelectorToApplyConfiguration( + src *metav1.LabelSelector, +) *v1.LabelSelectorApplyConfiguration { + return v1.LabelSelector(). + WithMatchLabels(src.MatchLabels). + WithMatchExpressions(MatchExpressionToApplyConfiguration(src.MatchExpressions)...) +} + +func MatchExpressionToApplyConfiguration( + src []metav1.LabelSelectorRequirement, +) []*v1.LabelSelectorRequirementApplyConfiguration { + result := make([]*v1.LabelSelectorRequirementApplyConfiguration, len(src)) + for i, item := range src { + result[i] = v1.LabelSelectorRequirement(). + WithKey(item.Key). + WithOperator(item.Operator). + WithValues(item.Values...) + } + return result +} diff --git a/util/apiutil/kubeapi.go b/util/apiutil/kubeapi.go index 65d9a34..353a6c9 100644 --- a/util/apiutil/kubeapi.go +++ b/util/apiutil/kubeapi.go @@ -4,18 +4,51 @@ package apiutil import ( + "slices" + lifecyclev1alpha1 "github.com/ironcore-dev/lifecycle-manager/api/lifecycle/v1alpha1" commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" machinev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" machinetypev1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +var ScanResultToInt = map[lifecyclev1alpha1.ScanResult]commonv1alpha1.ScanResult{ + lifecyclev1alpha1.Unspecified: commonv1alpha1.ScanResult_SCAN_RESULT_UNSPECIFIED, + lifecyclev1alpha1.ScanSuccess: commonv1alpha1.ScanResult_SCAN_RESULT_SUCCESS, + lifecyclev1alpha1.ScanFailure: commonv1alpha1.ScanResult_SCAN_RESULT_FAILURE, +} + func MachineToGrpcAPI(src *lifecyclev1alpha1.Machine) *machinev1alpha1.Machine { - return nil + m := &machinev1alpha1.Machine{ + TypeMeta: &src.TypeMeta, + ObjectMeta: &src.ObjectMeta, + Spec: MachineSpecToGrpcAPI(src.Spec), + Status: MachineStatusToGrpcAPI(src.Status), + } + return m +} + +func MachineSpecToGrpcAPI(src lifecyclev1alpha1.MachineSpec) *machinev1alpha1.MachineSpec { + s := &machinev1alpha1.MachineSpec{ + MachineTypeRef: &corev1.LocalObjectReference{Name: src.MachineTypeRef.Name}, + OobMachineRef: &corev1.LocalObjectReference{Name: src.OOBMachineRef.Name}, + ScanPeriod: &src.ScanPeriod, + Packages: PackageVersionsToGrpcAPI(src.Packages), + } + return s } func MachineStatusToGrpcAPI(src lifecyclev1alpha1.MachineStatus) *machinev1alpha1.MachineStatus { - return nil + s := &machinev1alpha1.MachineStatus{ + LastScanTime: &metav1.Timestamp{Seconds: src.LastScanTime.Unix()}, + LastScanResult: ScanResultToInt[src.LastScanResult], + InstalledPackages: PackageVersionsToGrpcAPI(src.InstalledPackages), + Message: src.Message, + Conditions: ConditionsToGrpcAPI(src.Conditions), + } + return s } func PackageVersionsToGrpcAPI(src []lifecyclev1alpha1.PackageVersion) []*commonv1alpha1.PackageVersion { @@ -30,10 +63,75 @@ func PackageVersionsToGrpcAPI(src []lifecyclev1alpha1.PackageVersion) []*commonv return result } +func ConditionsToGrpcAPI(src []metav1.Condition) []*commonv1alpha1.Condition { + result := make([]*commonv1alpha1.Condition, len(src)) + for i, item := range src { + el := &commonv1alpha1.Condition{ + Type: item.Type, + Status: string(item.Status), + ObservedGeneration: item.ObservedGeneration, + LastTransitionTime: &metav1.Timestamp{Seconds: item.LastTransitionTime.Unix()}, + Reason: item.Reason, + Message: item.Message, + } + result[i] = el + } + return result +} + func MachineTypeToGrpcAPI(src *lifecyclev1alpha1.MachineType) *machinetypev1alpha1.MachineType { - return nil + m := &machinetypev1alpha1.MachineType{ + TypeMeta: &src.TypeMeta, + ObjectMeta: &src.ObjectMeta, + Spec: MachineTypeSpecToGrpcAPI(src.Spec), + Status: MachineTypeStatusToGrpcAPI(src.Status), + } + return m +} + +func MachineTypeSpecToGrpcAPI(src lifecyclev1alpha1.MachineTypeSpec) *machinetypev1alpha1.MachineTypeSpec { + s := &machinetypev1alpha1.MachineTypeSpec{ + Manufacturer: src.Manufacturer, + Type: src.Type, + ScanPeriod: &src.ScanPeriod, + MachineGroups: MachineGroupsToGrpcAPI(src.MachineGroups), + } + return s +} + +func MachineGroupsToGrpcAPI(src []lifecyclev1alpha1.MachineGroup) []*machinetypev1alpha1.MachineGroup { + result := make([]*machinetypev1alpha1.MachineGroup, len(src)) + for i, item := range src { + el := &machinetypev1alpha1.MachineGroup{ + Name: item.Name, + MachineSelector: item.MachineSelector.DeepCopy(), + Packages: PackageVersionsToGrpcAPI(item.Packages), + } + result[i] = el + } + return result } func MachineTypeStatusToGrpcAPI(src lifecyclev1alpha1.MachineTypeStatus) *machinetypev1alpha1.MachineTypeStatus { - return nil + s := &machinetypev1alpha1.MachineTypeStatus{ + LastScanTime: &metav1.Timestamp{Seconds: src.LastScanTime.Unix()}, + LastScanResult: ScanResultToInt[src.LastScanResult], + AvailablePackages: AvailablePackagesToGrpcAPI(src.AvailablePackages), + Message: src.Message, + } + return s +} + +func AvailablePackagesToGrpcAPI( + src []lifecyclev1alpha1.AvailablePackageVersions, +) []*machinetypev1alpha1.AvailablePackageVersions { + result := make([]*machinetypev1alpha1.AvailablePackageVersions, len(src)) + for i, item := range src { + el := &machinetypev1alpha1.AvailablePackageVersions{ + Name: item.Name, + Versions: slices.Clone(item.Versions), + } + result[i] = el + } + return result } diff --git a/util/convertutil/common.go b/util/convertutil/common.go new file mode 100644 index 0000000..697053f --- /dev/null +++ b/util/convertutil/common.go @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package convertutil + +import ( + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func TimeToTimestamp(in metav1.Time) metav1.Timestamp { + return metav1.Timestamp{Seconds: in.Unix()} +} + +func TimeToTimestampPtr(in metav1.Time) *metav1.Timestamp { + return &metav1.Timestamp{Seconds: in.Unix()} +} + +func TimestampToTime(in metav1.Timestamp) metav1.Time { + return metav1.Time{Time: time.Unix(in.Seconds, int64(in.Nanos))} +} + +func TimestampToTimePtr(in metav1.Timestamp) *metav1.Time { + return &metav1.Time{Time: time.Unix(in.Seconds, int64(in.Nanos))} +} diff --git a/util/testutil/fake/machine_client.go b/util/testutil/fake/machine_client.go new file mode 100644 index 0000000..c073323 --- /dev/null +++ b/util/testutil/fake/machine_client.go @@ -0,0 +1,115 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package fake + +import ( + "context" + + "connectrpc.com/connect" + commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" + machineapiv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machine/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/types" +) + +type MachineClient struct { + cache map[string]*machineapiv1alpha1.MachineStatus +} + +func NewMachineClient(cache map[string]*machineapiv1alpha1.MachineStatus) *MachineClient { + return &MachineClient{cache: cache} +} + +func (c *MachineClient) WriteCache(id string, item *machineapiv1alpha1.MachineStatus) { + c.cache[id] = item +} + +func (c *MachineClient) ReadCache(id string) *machineapiv1alpha1.MachineStatus { + return c.cache[id] +} + +func (c *MachineClient) ScanMachine( + _ context.Context, + req *connect.Request[machineapiv1alpha1.ScanMachineRequest], +) (*connect.Response[machineapiv1alpha1.ScanMachineResponse], error) { + in := req.Msg + if in.Name == "failed-scan" { + return nil, errors.New("fake error") + } + key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} + uid := uuidutil.UUIDFromObjectKey(key) + _, ok := c.cache[uid] + if ok { + return connect.NewResponse(&machineapiv1alpha1.ScanMachineResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil + } + c.cache[uid] = &machineapiv1alpha1.MachineStatus{} + return connect.NewResponse(&machineapiv1alpha1.ScanMachineResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED, + }), nil +} + +func (c *MachineClient) Install( + _ context.Context, + req *connect.Request[machineapiv1alpha1.InstallRequest], +) (*connect.Response[machineapiv1alpha1.InstallResponse], error) { + in := req.Msg + if in.Name == "failed-install" { + return nil, connect.NewError(connect.CodeInternal, errors.New("fake error")) + } + if in.Name == "fake-failure" { + return connect.NewResponse(&machineapiv1alpha1.InstallResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_FAILURE, + }), nil + } + key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} + uid := uuidutil.UUIDFromObjectKey(key) + _, ok := c.cache[uid] + if ok { + return connect.NewResponse(&machineapiv1alpha1.InstallResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED, + }), nil + } + c.cache[uid] = &machineapiv1alpha1.MachineStatus{} + return connect.NewResponse(&machineapiv1alpha1.InstallResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_UNSPECIFIED, + }), nil +} + +func (c *MachineClient) UpdateMachineStatus( + _ context.Context, + _ *connect.Request[machineapiv1alpha1.UpdateMachineStatusRequest], +) (*connect.Response[machineapiv1alpha1.UpdateMachineStatusResponse], error) { + return nil, nil +} + +func (c *MachineClient) ListMachines( + _ context.Context, + _ *connect.Request[machineapiv1alpha1.ListMachinesRequest], +) (*connect.Response[machineapiv1alpha1.ListMachinesResponse], error) { + return nil, nil +} + +func (c *MachineClient) AddPackageVersion( + _ context.Context, + _ *connect.Request[machineapiv1alpha1.AddPackageVersionRequest], +) (*connect.Response[machineapiv1alpha1.AddPackageVersionResponse], error) { + return nil, nil +} + +func (c *MachineClient) SetPackageVersion( + _ context.Context, + _ *connect.Request[machineapiv1alpha1.SetPackageVersionRequest], +) (*connect.Response[machineapiv1alpha1.SetPackageVersionResponse], error) { + return nil, nil +} + +func (c *MachineClient) RemovePackageVersion( + _ context.Context, + _ *connect.Request[machineapiv1alpha1.RemovePackageVersionRequest], +) (*connect.Response[machineapiv1alpha1.RemovePackageVersionResponse], error) { + return nil, nil +} diff --git a/util/testutil/fake/machinetype_client.go b/util/testutil/fake/machinetype_client.go new file mode 100644 index 0000000..a3ff1c6 --- /dev/null +++ b/util/testutil/fake/machinetype_client.go @@ -0,0 +1,81 @@ +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + +package fake + +import ( + "context" + + "connectrpc.com/connect" + commonv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/common/v1alpha1" + machinetypeapiv1alpha1 "github.com/ironcore-dev/lifecycle-manager/lcmi/api/machinetype/v1alpha1" + "github.com/ironcore-dev/lifecycle-manager/util/uuidutil" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/types" +) + +type MachineTypeClient struct { + cache map[string]*machinetypeapiv1alpha1.MachineTypeStatus +} + +func NewMachineTypeClient(cache map[string]*machinetypeapiv1alpha1.MachineTypeStatus) *MachineTypeClient { + return &MachineTypeClient{cache: cache} +} + +func (c *MachineTypeClient) WriteCache(id string, item *machinetypeapiv1alpha1.MachineTypeStatus) { + c.cache[id] = item +} + +func (c *MachineTypeClient) ReadCache(id string) *machinetypeapiv1alpha1.MachineTypeStatus { + return c.cache[id] +} + +func (c *MachineTypeClient) ListMachineTypes( + _ context.Context, + _ *connect.Request[machinetypeapiv1alpha1.ListMachineTypesRequest], +) (*connect.Response[machinetypeapiv1alpha1.ListMachineTypesResponse], error) { + return nil, nil +} + +func (c *MachineTypeClient) Scan( + ctx context.Context, + req *connect.Request[machinetypeapiv1alpha1.ScanRequest], +) (*connect.Response[machinetypeapiv1alpha1.ScanResponse], error) { + in := req.Msg + if in.Name == "failed-scan" { + return nil, connect.NewError(connect.CodeInternal, errors.New("fake error")) + } + key := types.NamespacedName{Name: in.Name, Namespace: in.Namespace} + uid := uuidutil.UUIDFromObjectKey(key) + _, ok := c.cache[uid] + if ok { + return connect.NewResponse(&machinetypeapiv1alpha1.ScanResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SUCCESS, + }), nil + } + c.cache[uid] = &machinetypeapiv1alpha1.MachineTypeStatus{} + return connect.NewResponse(&machinetypeapiv1alpha1.ScanResponse{ + Result: commonv1alpha1.RequestResult_REQUEST_RESULT_SCHEDULED, + }), nil +} + +func (c *MachineTypeClient) UpdateMachineTypeStatus( + _ context.Context, + _ *connect.Request[machinetypeapiv1alpha1.UpdateMachineTypeStatusRequest], +) (*connect.Response[machinetypeapiv1alpha1.UpdateMachineTypeStatusResponse], error) { + return nil, nil +} + +func (c *MachineTypeClient) AddMachineGroup( + _ context.Context, + _ *connect.Request[machinetypeapiv1alpha1.AddMachineGroupRequest], +) (*connect.Response[machinetypeapiv1alpha1.AddMachineGroupResponse], error) { + return nil, nil +} + +func (c *MachineTypeClient) RemoveMachineGroup( + _ context.Context, + _ *connect.Request[machinetypeapiv1alpha1.RemoveMachineGroupRequest], +) (*connect.Response[machinetypeapiv1alpha1.RemoveMachineGroupResponse], error) { + return nil, nil +} diff --git a/util/testutil/mock_machine.go b/util/testutil/mock/mock_machine.go similarity index 94% rename from util/testutil/mock_machine.go rename to util/testutil/mock/mock_machine.go index 8111b70..a981331 100644 --- a/util/testutil/mock_machine.go +++ b/util/testutil/mock/mock_machine.go @@ -1,7 +1,7 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors // SPDX-License-Identifier: Apache-2.0 -package testutil +package mock import ( "time" diff --git a/util/testutil/mock_machinetype.go b/util/testutil/mock/mock_machinetype.go similarity index 93% rename from util/testutil/mock_machinetype.go rename to util/testutil/mock/mock_machinetype.go index e86ad25..f03e14b 100644 --- a/util/testutil/mock_machinetype.go +++ b/util/testutil/mock/mock_machinetype.go @@ -1,7 +1,7 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors // SPDX-License-Identifier: Apache-2.0 -package testutil +package mock import ( "time" diff --git a/util/testutil/mock_oob.go b/util/testutil/mock/mock_oob.go similarity index 86% rename from util/testutil/mock_oob.go rename to util/testutil/mock/mock_oob.go index c20ba7f..50ef5b7 100644 --- a/util/testutil/mock_oob.go +++ b/util/testutil/mock/mock_oob.go @@ -1,12 +1,12 @@ -// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors // SPDX-License-Identifier: Apache-2.0 -package testutil +package mock import ( "time" - oobv1alpha1 "github.com/onmetal/oob-operator/api/v1alpha1" + oobv1alpha1 "github.com/ironcore-dev/oob/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" )