diff --git a/CHANGELOG.md b/CHANGELOG.md index 507bfbf..f4a700e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -## Updated +### Updated + +- Use name of application in Deployments instead of service account name. ([#142](https://github.com/coryodaniel/bonny/pull/142)) + +### Fixed -- Use name of application in Deployments instead of service account name. +- CRD manifest generation for `apiextensions.k8s.io/v1` ([#143](https://github.com/coryodaniel/bonny/pull/143), [#117](https://github.com/coryodaniel/bonny/issues/117), [#101](https://github.com/coryodaniel/bonny/pull/101)) ## [0.5.1] - 2022-05-25 diff --git a/config/config.exs b/config/config.exs index 2d02d9c..d6e9405 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/lib/bonny/crd.ex b/lib/bonny/crd.ex index 07cd181..445da07 100644 --- a/lib/bonny/crd.ex +++ b/lib/bonny/crd.ex @@ -169,11 +169,15 @@ defmodule Bonny.CRD do |> Map.put(:versions, [ %{ name: version, - scheme: %{ - openAPIV3Scheme: %{ - additionalPrinterColumns: additional_printer_columns_v1 + served: true, + storage: true, + schema: %{ + openAPIV3Schema: %{ + type: "object", + "x-kubernetes-preserve-unknown-fields": true } - } + }, + additionalPrinterColumns: additional_printer_columns_v1 } ]) end diff --git a/test/bonny/crd_test.exs b/test/bonny/crd_test.exs index 6222c98..8d2afaf 100644 --- a/test/bonny/crd_test.exs +++ b/test/bonny/crd_test.exs @@ -55,20 +55,24 @@ defmodule Bonny.CRDTest do versions: [ %{ name: "v1", - scheme: %{ - openAPIV3Scheme: %{ - 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" - } - ] + served: true, + storage: true, + schema: %{ + openAPIV3Schema: %{ + type: "object", + "x-kubernetes-preserve-unknown-fields": true } - } + }, + 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" + } + ] } ] } diff --git a/test/bonny/operator_test.exs b/test/bonny/operator_test.exs index f82c1c5..47b4530 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 + } + ] } } ]