From 0dd49612323272a9eb3368b90b142d18311def1b Mon Sep 17 00:00:00 2001 From: Travis Raines <571832+rainest@users.noreply.github.com> Date: Mon, 24 Apr 2023 11:59:18 -0700 Subject: [PATCH] feat: add license file type --- CHANGELOG.md | 11 +++++++++++ file/kong_json_schema.json | 25 +++++++++++++++++++++++++ file/types.go | 20 ++++++++++++++++++++ file/zz_generated.deepcopy.go | 24 ++++++++++++++++++++++++ go.mod | 2 +- go.sum | 2 ++ 6 files changed, 83 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d7d7806..4056ac68b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Table of Contents +- [v1.20.0](#v1200) - [v1.19.1](#v1191) - [v1.19.0](#v1190) - [v1.18.1](#v1181) @@ -55,6 +56,15 @@ - [v0.2.0](#v020) - [v0.1.0](#v010) +## [v1.20.0] + +> Release date: 2023/04/24 + +### Add + +- Add the license type to the file package. + + ## [v1.19.1] > Release date: 2023/03/21 @@ -1192,6 +1202,7 @@ No breaking changes have been introduced in this release. Debut release of decK +[v1.20.0]: https://github.com/kong/deck/compare/v1.19.1...v1.20.0 [v1.19.1]: https://github.com/kong/deck/compare/v1.19.0...v1.19.1 [v1.19.0]: https://github.com/kong/deck/compare/v1.18.1...v1.19.0 [v1.18.1]: https://github.com/kong/deck/compare/v1.18.0...v1.18.1 diff --git a/file/kong_json_schema.json b/file/kong_json_schema.json index 05c669cd1..49c1655aa 100644 --- a/file/kong_json_schema.json +++ b/file/kong_json_schema.json @@ -55,6 +55,13 @@ }, "type": "array" }, + "licenses": { + "items": { + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/FLicense" + }, + "type": "array" + }, "plugins": { "items": { "$ref": "#/definitions/FPlugin" @@ -549,6 +556,24 @@ "additionalProperties": false, "type": "object" }, + "FLicense": { + "properties": { + "created_at": { + "type": "integer" + }, + "id": { + "type": "string" + }, + "payload": { + "type": "string" + }, + "updated_at": { + "type": "integer" + } + }, + "additionalProperties": false, + "type": "object" + }, "FPlugin": { "required": [ "name" diff --git a/file/types.go b/file/types.go index b173aa6ed..7c6aa44c5 100644 --- a/file/types.go +++ b/file/types.go @@ -680,6 +680,24 @@ func (c FVault) sortKey() string { return "" } +// FLicense exists as a file type _only_ +// This is a compatibility layer for KIC library usage. deck cannot interact with the license entity. +// Ref https://github.com/Kong/deck/pull/882 if we need to support this entity throughout deck. + +// FLicense represents a Kong License. +// +k8s:deepcopy-gen=true +type FLicense struct { + kong.License `yaml:",inline,omitempty"` +} + +// sortKey is used for sorting. +func (c FLicense) sortKey() string { + if c.ID != nil { + return *c.ID + } + return "" +} + //go:generate go run ./codegen/main.go // Content represents a serialized Kong state. @@ -707,4 +725,6 @@ type Content struct { ServicePackages []FServicePackage `json:"service_packages,omitempty" yaml:"service_packages,omitempty"` Vaults []FVault `json:"vaults,omitempty" yaml:"vaults,omitempty"` + + Licenses []FLicense `json:"licenses,omitempty" yaml:"licenses,omitempty"` } diff --git a/file/zz_generated.deepcopy.go b/file/zz_generated.deepcopy.go index 0a86655cb..718589385 100644 --- a/file/zz_generated.deepcopy.go +++ b/file/zz_generated.deepcopy.go @@ -127,6 +127,13 @@ func (in *Content) DeepCopyInto(out *Content) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.Licenses != nil { + in, out := &in.Licenses, &out.Licenses + *out = make([]FLicense, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -402,6 +409,23 @@ func (in *FDocument) DeepCopy() *FDocument { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FLicense) DeepCopyInto(out *FLicense) { + *out = *in + in.License.DeepCopyInto(&out.License) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FLicense. +func (in *FLicense) DeepCopy() *FLicense { + if in == nil { + return nil + } + out := new(FLicense) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FPlugin) DeepCopyInto(out *FPlugin) { *out = *in diff --git a/go.mod b/go.mod index 178ea2f63..8b96f0a9d 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.2 github.com/hexops/gotextdiff v1.0.3 github.com/imdario/mergo v0.3.15 - github.com/kong/go-kong v0.39.0 + github.com/kong/go-kong v0.40.0 github.com/mitchellh/go-homedir v1.1.0 github.com/shirou/gopsutil/v3 v3.23.3 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index f339bbdc1..e4562ce37 100644 --- a/go.sum +++ b/go.sum @@ -200,6 +200,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kong/go-kong v0.39.0 h1:fAtZXpM7RVYukBu7Mu6RvRpklZOfXBXUs06NlDY5yXg= github.com/kong/go-kong v0.39.0/go.mod h1:QHn1QBxwbtGBR+F2S5y49m/fEMmYeYAHeNCP+iGGBBk= +github.com/kong/go-kong v0.40.0 h1:6rd70L4GbPz90j3ey+wjHd4aC21uFgbqsoASJhbcbdU= +github.com/kong/go-kong v0.40.0/go.mod h1:t3siZEEGBB3FA5EQv9CL5EcaiogPTG0A175VQ6KvEHE= github.com/kong/semver/v4 v4.0.1 h1:DIcNR8W3gfx0KabFBADPalxxsp+q/5COwIFkkhrFQ2Y= github.com/kong/semver/v4 v4.0.1/go.mod h1:LImQ0oT15pJvSns/hs2laLca2zcYoHu5EsSNY0J6/QA= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=