Skip to content

Commit

Permalink
Allow adding an optional description for app repositories #759 (#2787)
Browse files Browse the repository at this point in the history
* #759

Allow adding an optional description for app repositories

* updates based on Michael Nelson's feedback

* missed a test
  • Loading branch information
gfichtenholt committed May 14, 2021
1 parent 2af2f43 commit 0760319
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 13 deletions.
17 changes: 16 additions & 1 deletion cmd/apprepository-controller/hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@
# 2. Run the this script from the apprepository-controller directory: ./hack/update-codegen.sh
# 3. Move the newly generated files over the old ones:
# mv github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/apis/apprepository/v1alpha1/zz_generated.deepcopy.go ./pkg/apis/apprepository/v1alpha1/zz_generated.deepcopy.go
# rm pkg/client -rf && mv github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/client ./pkg
# rm -rf pkg/client && mv github.com/kubeapps/kubeapps/cmd/apprepository-controller/pkg/client ./pkg
#
# What are the situations when one needs to run update-codegen.sh manually after modifying
# types.go in apprepository-controller?
# Generally if the generated client will change. This can happen for multiple reasons. If you
# change to the `AppRepository.Spec` struct the updated struct is imported by the client (so
# regeneration not needed necessarily) but if your change has a complex type (structs and
# pointers to structs) the generated client will need to be updated as it includes a deep copy
# function. Another cause of your generated client changing is if you update the version of the
# client.go library that your project uses.
# Note that the generated client is generally stored in the repo so that other (external) projects
# can import your client directly. You can see examples of generated clients in the sample-controller
# for the the K8s org at:
# https://github.com/kubernetes/sample-controller/blob/master/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go
# or any other controllers in the k8s project
#
set -o errexit
set -o nounset
set -o pipefail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type AppRepositorySpec struct {
TLSInsecureSkipVerify bool `json:"tlsInsecureSkipVerify,omitempty"`
// FilterRule allows to filter packages based on a JQuery
FilterRule FilterRuleSpec `json:"filterRule,omitempty"`
// (optional) description
Description string `json:"description,omitempty"`
}

// AppRepositoryAuth is the auth for an AppRepository resource
Expand Down
4 changes: 4 additions & 0 deletions dashboard/public/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,8 @@ components:
type: string
type:
type: string
description:
type: string
repoURL:
type: string
authHeader:
Expand Down Expand Up @@ -2093,6 +2095,8 @@ components:
type: string
tlsInsecureSkipVerify:
type: boolean
description:
type: string
# cmd/apprepository-controller/pkg/apis/apprepository/v1alpha1/types.go
AppRepositoryStatus:
type: object
Expand Down
97 changes: 97 additions & 0 deletions dashboard/src/actions/repos.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
[],
[],
false,
Expand All @@ -385,6 +386,7 @@ describe("installRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"Bearer: abc",
"",
"",
Expand All @@ -403,6 +405,7 @@ describe("installRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"Bearer: abc",
"",
"",
Expand All @@ -425,6 +428,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
[],
["apache", "jenkins"],
false,
Expand All @@ -440,6 +444,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
{},
[],
["apache", "jenkins"],
Expand All @@ -459,6 +464,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
[],
[],
true,
Expand All @@ -474,6 +480,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
{},
[],
[],
Expand All @@ -496,6 +503,7 @@ describe("installRepo", () => {
"helm",
"",
"",
"",
"This is a cert!",
"",
[],
Expand All @@ -514,6 +522,7 @@ describe("installRepo", () => {
"helm",
"",
"",
"",
"This is a cert!",
{},
[],
Expand All @@ -539,6 +548,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
safeYAMLTemplate,
[],
[],
Expand All @@ -556,6 +566,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
{
spec: { containers: [{ env: [{ name: "FOO", value: "BAR" }] }] },
},
Expand All @@ -580,6 +591,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
unsafeYAMLTemplate,
[],
[],
Expand All @@ -604,6 +616,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
{},
[],
[],
Expand Down Expand Up @@ -672,6 +685,7 @@ describe("installRepo", () => {
"",
"",
"",
"",
["repo-1"],
[],
false,
Expand All @@ -688,13 +702,50 @@ describe("installRepo", () => {
"",
"",
"",
"",
{},
["repo-1"],
[],
false,
undefined,
);
});

it("calls AppRepository create with description", async () => {
await store.dispatch(
repoActions.installRepo(
"my-repo",
"my-namespace",
"http://foo.bar",
"oci",
"This is a weird description 123!@#$%^&&*()_+-=<>?/.,;:'\"",
"",
"",
"",
"",
[],
["apache", "jenkins"],
false,
undefined,
),
);
expect(AppRepository.create).toHaveBeenCalledWith(
"default",
"my-repo",
"my-namespace",
"http://foo.bar",
"oci",
"This is a weird description 123!@#$%^&&*()_+-=<>?/.,;:'\"",
"",
"",
"",
{},
[],
["apache", "jenkins"],
false,
undefined,
);
});
});

describe("updateRepo", () => {
Expand Down Expand Up @@ -728,6 +779,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"foo",
"",
"bar",
Expand All @@ -745,6 +797,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"foo",
"",
"bar",
Expand Down Expand Up @@ -786,6 +839,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"foo",
"",
"bar",
Expand All @@ -803,6 +857,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"foo",
"",
"bar",
Expand Down Expand Up @@ -834,6 +889,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"helm",
"",
"foo",
"",
"bar",
Expand Down Expand Up @@ -861,6 +917,46 @@ describe("updateRepo", () => {
"",
"",
"",
"",
[],
["apache", "jenkins"],
false,
undefined,
),
);
expect(AppRepository.update).toHaveBeenCalledWith(
"default",
"my-repo",
"my-namespace",
"http://foo.bar",
"oci",
"",
"",
"",
"",
{},
[],
["apache", "jenkins"],
false,
undefined,
);
});

it("updates a repo with description", async () => {
AppRepository.update = jest.fn().mockReturnValue({
appRepository: {},
});
await store.dispatch(
repoActions.updateRepo(
"my-repo",
"my-namespace",
"http://foo.bar",
"oci",
"updated description",
"",
"",
"",
"",
[],
["apache", "jenkins"],
false,
Expand All @@ -873,6 +969,7 @@ describe("updateRepo", () => {
"my-namespace",
"http://foo.bar",
"oci",
"updated description",
"",
"",
"",
Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/actions/repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const installRepo = (
namespace: string,
repoURL: string,
type: string,
description: string,
authHeader: string,
authRegCreds: string,
customCA: string,
Expand All @@ -239,6 +240,7 @@ export const installRepo = (
namespace,
repoURL,
type,
description,
authHeader,
authRegCreds,
customCA,
Expand All @@ -263,6 +265,7 @@ export const updateRepo = (
namespace: string,
repoURL: string,
type: string,
description: string,
authHeader: string,
authRegCreds: string,
customCA: string,
Expand All @@ -285,6 +288,7 @@ export const updateRepo = (
namespace,
repoURL,
type,
description,
authHeader,
authRegCreds,
customCA,
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/components/Config/AppRepoList/AppRepoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function AppRepoAddButton({
name: string,
url: string,
type: string,
description: string,
authHeader: string,
authRegCreds: string,
customCA: string,
Expand All @@ -55,6 +56,7 @@ export function AppRepoAddButton({
namespace,
url,
type,
description,
authHeader,
authRegCreds,
customCA,
Expand All @@ -72,6 +74,7 @@ export function AppRepoAddButton({
namespace,
url,
type,
description,
authHeader,
authRegCreds,
customCA,
Expand Down

0 comments on commit 0760319

Please sign in to comment.