diff --git a/config/config.exs b/config/config.exs index 2d02d9c1..d6e94057 100644 --- a/config/config.exs +++ b/config/config.exs @@ -9,10 +9,10 @@ if Mix.env() == :test do http_provider: K8s.Client.DynamicHTTPProvider config :bonny, - controllers: [Widget, Cog], + controllers: [Widget, Cog, Whizbang], group: "example.com", get_conn: {Bonny.K8sMock, :conn}, - api_version: "apiextensions.k8s.io/v1beta1" + api_version: "apiextensions.k8s.io/v1" end if Mix.env() == :dev do diff --git a/test/bonny/operator_test.exs b/test/bonny/operator_test.exs index f82c1c53..47b45307 100644 --- a/test/bonny/operator_test.exs +++ b/test/bonny/operator_test.exs @@ -18,6 +18,7 @@ defmodule Bonny.OperatorTest do }, %{apiGroups: ["example.com"], resources: ["widgets"], verbs: ["*"]}, %{apiGroups: ["example.com"], resources: ["cogs"], verbs: ["*"]}, + %{apiGroups: ["example.com"], resources: ["whizbangs"], verbs: ["*"]}, %{apiGroups: ["apps"], resources: ["deployments", "services"], verbs: ["*"]}, %{apiGroups: [""], resources: ["configmaps"], verbs: ["create", "read"]} ] @@ -37,6 +38,7 @@ defmodule Bonny.OperatorTest do }, %{apiGroups: ["example.com"], resources: ["widgets"], verbs: ["*"]}, %{apiGroups: ["example.com"], resources: ["cogs"], verbs: ["*"]}, + %{apiGroups: ["example.com"], resources: ["whizbangs"], verbs: ["*"]}, %{apiGroups: ["apps"], resources: ["deployments", "services"], verbs: ["*"]}, %{apiGroups: [""], resources: ["configmaps"], verbs: ["create", "read"]} ] @@ -61,36 +63,75 @@ defmodule Bonny.OperatorTest do expected = [ %{ - apiVersion: "apiextensions.k8s.io/v1beta1", + apiVersion: "apiextensions.k8s.io/v1", kind: "CustomResourceDefinition", metadata: %{labels: %{"k8s-app" => "bonny"}, name: "widgets.example.com"}, spec: %{ - additionalPrinterColumns: [ - %{JSONPath: ".spec.test", description: "test", name: "test", type: "string"}, - %{ - JSONPath: ".metadata.creationTimestamp", - description: - "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\n Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", - name: "Age", - type: "date" - } - ], group: "example.com", names: %{kind: "Widget", plural: "widgets", shortNames: nil, singular: "widget"}, scope: "Namespaced", - version: "v1" + versions: [ + %{ + additionalPrinterColumns: [ + %{description: "test", jsonPath: ".spec.test", name: "test", type: "string"}, + %{ + description: + "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\n Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata", + jsonPath: ".metadata.creationTimestamp", + name: "Age", + type: "date" + } + ], + name: "v1", + schema: %{ + openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true} + }, + served: true, + storage: true + } + ] } }, %{ - apiVersion: "apiextensions.k8s.io/v1beta1", + apiVersion: "apiextensions.k8s.io/v1", kind: "CustomResourceDefinition", metadata: %{labels: %{"k8s-app" => "bonny"}, name: "cogs.example.com"}, spec: %{ - additionalPrinterColumns: [], group: "example.com", names: %{kind: "Cog", plural: "cogs", shortNames: nil, singular: "cog"}, scope: "Namespaced", - version: "v1" + versions: [ + %{ + additionalPrinterColumns: [], + name: "v1", + schema: %{ + openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true} + }, + served: true, + storage: true + } + ] + } + }, + %{ + apiVersion: "apiextensions.k8s.io/v1", + kind: "CustomResourceDefinition", + metadata: %{labels: %{"k8s-app" => "bonny"}, name: "whizbangs.example.com"}, + spec: %{ + group: "example.com", + names: %{kind: "Whizbang", plural: "whizbangs", shortNames: nil, singular: "whizbang"}, + scope: "Namespaced", + versions: [ + %{ + additionalPrinterColumns: [], + name: "v1", + schema: %{ + openAPIV3Schema: %{type: "object", "x-kubernetes-preserve-unknown-fields": true} + }, + served: true, + storage: true + } + ] } } ]