From c5024aaac889838baf8b55b6cc36d5a9866dffde Mon Sep 17 00:00:00 2001 From: Audrey Kadjar Date: Tue, 17 May 2022 11:41:26 +0200 Subject: [PATCH 01/49] Bump version to 0.45.0-alpha --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a8ab6c9666..7197fa4efa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.44.0 +0.45.0-alpha From 4e33f4909722b6484cb910832b2c7a6416779d88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 15:23:40 +0200 Subject: [PATCH 02/49] Bump @types/react-redux from 7.1.23 to 7.1.24 (#3062) Bumps [@types/react-redux](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-redux) from 7.1.23 to 7.1.24. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-redux) --- updated-dependencies: - dependency-name: "@types/react-redux" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 62bc1bcead..628eb57b86 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@types/node": "17.0.26", "@types/react": "17.0.43", "@types/react-dom": "17.0.14", - "@types/react-redux": "7.1.23", + "@types/react-redux": "7.1.24", "@types/react-router-dom": "^5.3.3", "@types/react-window-infinite-loader": "^1.0.6", "@types/resize-observer-browser": "^0.1.7", diff --git a/yarn.lock b/yarn.lock index c63da279a0..d479d364d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1328,9 +1328,9 @@ dependencies: "@types/react" "*" -"@types/react-redux@7.1.23": - version "7.1.23" - resolved "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.23.tgz" +"@types/react-redux@7.1.24": + version "7.1.24" + resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.24.tgz#6caaff1603aba17b27d20f8ad073e4c077e975c0" dependencies: "@types/hoist-non-react-statics" "^3.3.0" "@types/react" "*" From 3f2f7c1e29e5f7fd47a29f35dde6d5acbb631f8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 May 2022 20:00:09 +0200 Subject: [PATCH 03/49] Bump core-js from 3.22.0 to 3.22.5 (#3151) Bumps [core-js](https://github.com/zloirock/core-js) from 3.22.0 to 3.22.5. - [Release notes](https://github.com/zloirock/core-js/releases) - [Changelog](https://github.com/zloirock/core-js/blob/master/CHANGELOG.md) - [Commits](https://github.com/zloirock/core-js/compare/v3.22.0...v3.22.5) --- updated-dependencies: - dependency-name: core-js dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 628eb57b86..687ba35718 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@stomp/stompjs": "^6.1.2", "audio-recorder-polyfill": "^0.4.1", "camelcase-keys": "^7.0.2", - "core-js": "3.22.0", + "core-js": "3.22.5", "emoji-mart": "3.0.1", "form-data": "^4.0.0", "i18next": "^21.6.16", diff --git a/yarn.lock b/yarn.lock index d479d364d0..18b7169fc2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2229,9 +2229,9 @@ core-js-compat@^3.20.2, core-js-compat@^3.21.0: browserslist "^4.19.1" semver "7.0.0" -core-js@3.22.0: - version "3.22.0" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.0.tgz#b52007870c5e091517352e833b77f0b2d2b259f3" +core-js@3.22.5: + version "3.22.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.5.tgz#a5f5a58e663d5c0ebb4e680cd7be37536fb2a9cf" core-util-is@1.0.2: version "1.0.2" From 08d87ec18a2b119c2a64c5d4e4e5dde3a6cf307d Mon Sep 17 00:00:00 2001 From: Juan Sebastian Pena Rodriguez Date: Fri, 20 May 2022 10:02:56 +0200 Subject: [PATCH 04/49] [#3130] Feature/endpoint for retrieving the current configuration (#3177) --- cli/pkg/cmd/config/BUILD | 2 + cli/pkg/cmd/config/config.go | 27 +++++++ infrastructure/controller/pkg/endpoints/BUILD | 2 + .../controller/pkg/endpoints/cluster_get.go | 75 +++++++++++++++++++ .../controller/pkg/endpoints/server.go | 8 +- lib/go/kubectl/configmaps/BUILD | 16 ++++ lib/go/kubectl/configmaps/get.go | 54 +++++++++++++ 7 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 infrastructure/controller/pkg/endpoints/cluster_get.go create mode 100644 lib/go/kubectl/configmaps/BUILD create mode 100644 lib/go/kubectl/configmaps/get.go diff --git a/cli/pkg/cmd/config/BUILD b/cli/pkg/cmd/config/BUILD index dc31f67e11..ae583a0fa0 100644 --- a/cli/pkg/cmd/config/BUILD +++ b/cli/pkg/cmd/config/BUILD @@ -10,8 +10,10 @@ go_library( "//cli/pkg/console", "//cli/pkg/kube", "//cli/pkg/workspace", + "//lib/go/kubectl/configmaps", "@com_github_spf13_cobra//:cobra", "@com_github_spf13_viper//:viper", + "@in_gopkg_yaml_v2//:yaml_v2", "@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library", ], ) diff --git a/cli/pkg/cmd/config/config.go b/cli/pkg/cmd/config/config.go index 80e31b66b1..99abe17b95 100644 --- a/cli/pkg/cmd/config/config.go +++ b/cli/pkg/cmd/config/config.go @@ -8,8 +8,10 @@ import ( "fmt" "os" + "github.com/airyhq/airy/lib/go/kubectl/configmaps" "github.com/spf13/cobra" "github.com/spf13/viper" + "gopkg.in/yaml.v2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -20,6 +22,31 @@ var ConfigCmd = &cobra.Command{ Use: "config", TraverseChildren: true, Short: "Manages an Airy Core instance via airy.yaml", + Run: getConfig, +} + +func getConfig(cmd *cobra.Command, args []string) { + namespace := viper.GetString("namespace") + kubeCtx := kube.Load() + clientSet, err := kubeCtx.GetClientSet() + if err != nil { + fmt.Printf(err.Error()) + console.Exit("could not find an installation of Airy Core. Get started here https://airy.co/docs/core/getting-started/installation/introduction") + } + + identity := func(d map[string]string) map[string]string { return d } + + components, err := configmaps.GetComponentsConfigMaps(context.Background(), namespace, clientSet, identity) + if err != nil { + console.Exit(err.Error()) + } + + blob, err := yaml.Marshal(map[string]interface{}{"components": components}) + if err != nil { + console.Exit("could not marshal components list %s", err) + } + + fmt.Println(string(blob)) } func applyConfig(cmd *cobra.Command, args []string) { diff --git a/infrastructure/controller/pkg/endpoints/BUILD b/infrastructure/controller/pkg/endpoints/BUILD index 4570a935f9..0e71b68ce4 100644 --- a/infrastructure/controller/pkg/endpoints/BUILD +++ b/infrastructure/controller/pkg/endpoints/BUILD @@ -5,12 +5,14 @@ go_library( name = "endpoints", srcs = [ "auth.go", + "cluster_get.go", "server.go", "services.go", ], importpath = "github.com/airyhq/airy/infrastructure/controller/pkg/endpoints", visibility = ["//visibility:public"], deps = [ + "//lib/go/kubectl/configmaps", "@com_github_golang_jwt_jwt//:jwt", "@com_github_gorilla_mux//:mux", "@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library", diff --git a/infrastructure/controller/pkg/endpoints/cluster_get.go b/infrastructure/controller/pkg/endpoints/cluster_get.go new file mode 100644 index 0000000000..a53a40a767 --- /dev/null +++ b/infrastructure/controller/pkg/endpoints/cluster_get.go @@ -0,0 +1,75 @@ +package endpoints + +import ( + "encoding/json" + "log" + "net/http" + "regexp" + "strings" + + "github.com/airyhq/airy/lib/go/kubectl/configmaps" + "k8s.io/client-go/kubernetes" +) + +type ClusterGet struct { + clientSet *kubernetes.Clientset + namespace string +} + +func (s *ClusterGet) ServeHTTP(w http.ResponseWriter, r *http.Request) { + components, err := configmaps.GetComponentsConfigMaps(r.Context(), s.namespace, s.clientSet, maskSecrets) + if err != nil { + log.Printf(err.Error()) + w.WriteHeader(http.StatusInternalServerError) + return + } + + blob, err := json.Marshal(map[string]interface{}{"components": components}) + if err != nil { + log.Printf("Unable to marshal config Error: %s\n", err) + w.WriteHeader(http.StatusInternalServerError) + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + w.Write(blob) +} + +func getComponentFromLabel(l string) (string, string, bool) { + c := strings.Split(l, "-") + if len(c) != 2 { + return "", "", false + } + + return c[0], c[1], true +} + +var secretMatcher = regexp.MustCompile(`(?i)secret|key|token`) + +func maskSecrets(data map[string]string) map[string]string { + mask := func(s string) string { + if len(s) < 2 { + return "..." + } + + if len(s) > 8 { + return s[:4] + "..." + } + + return s[:1] + "..." + } + out := make(map[string]string, len(data)) + + for k, v := range data { + if k == "saFile" { + out[k] = "" + } else if secretMatcher.MatchString(k) { + out[k] = mask(v) + } else { + out[k] = v + } + } + + return out +} diff --git a/infrastructure/controller/pkg/endpoints/server.go b/infrastructure/controller/pkg/endpoints/server.go index 7c38e053e2..48aa949214 100644 --- a/infrastructure/controller/pkg/endpoints/server.go +++ b/infrastructure/controller/pkg/endpoints/server.go @@ -1,12 +1,13 @@ package endpoints import ( - "github.com/gorilla/mux" - "k8s.io/klog" "log" "net/http" "os" + "github.com/gorilla/mux" + "k8s.io/klog" + "k8s.io/client-go/kubernetes" ) @@ -38,5 +39,8 @@ func Serve(clientSet *kubernetes.Clientset, namespace string) { s := &Services{clientSet: clientSet, namespace: namespace} r.Handle("/services", s) + cg := &ClusterGet{clientSet: clientSet, namespace: namespace} + r.Handle("/components.get", cg).Methods("GET") + log.Fatal(http.ListenAndServe(":8080", r)) } diff --git a/lib/go/kubectl/configmaps/BUILD b/lib/go/kubectl/configmaps/BUILD new file mode 100644 index 0000000000..41e5cb6a86 --- /dev/null +++ b/lib/go/kubectl/configmaps/BUILD @@ -0,0 +1,16 @@ +load("@com_github_airyhq_bazel_tools//lint:buildifier.bzl", "check_pkg") +load("@io_bazel_rules_go//go:def.bzl", "go_library") +# gazelle:prefix github.com/airyhq/airy/lib/go/kubectl/configmaps + +go_library( + name = "configmaps", + srcs = ["get.go"], + importpath = "github.com/airyhq/airy/lib/go/kubectl/configmaps", + visibility = ["//visibility:public"], + deps = [ + "@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library", + "@io_k8s_client_go//kubernetes:go_default_library", + ], +) + +check_pkg(name = "buildifier") diff --git a/lib/go/kubectl/configmaps/get.go b/lib/go/kubectl/configmaps/get.go new file mode 100644 index 0000000000..27dccfb788 --- /dev/null +++ b/lib/go/kubectl/configmaps/get.go @@ -0,0 +1,54 @@ +package configmaps + +import ( + "context" + "fmt" + "strings" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" +) + +func GetComponentsConfigMaps( + ctx context.Context, + namespace string, + clientSet *kubernetes.Clientset, + valueTransformer func(map[string]string) map[string]string, +) (map[string]map[string]interface{}, error) { + configmapList, err := clientSet.CoreV1().ConfigMaps(namespace).List(ctx, v1.ListOptions{LabelSelector: "core.airy.co/component"}) + if err != nil { + return nil, fmt.Errorf("Unable to list config maps. Error: %s\n", err) + } + + components := make(map[string]map[string]interface{}) + for _, configmap := range configmapList.Items { + label, ok := configmap.Labels["core.airy.co/component"] + if !ok { + continue + } + + componentsGroup, componentName, ok := getComponentFromLabel(label) + if !ok { + continue + } + + componentsGroupContent, ok := components[componentsGroup] + if !ok { + componentsGroupContent = make(map[string]interface{}) + components[componentsGroup] = componentsGroupContent + } + + componentsGroupContent[componentName] = valueTransformer(configmap.Data) + } + + return components, nil +} + +func getComponentFromLabel(l string) (string, string, bool) { + c := strings.Split(l, "-") + if len(c) != 2 { + return "", "", false + } + + return c[0], c[1], true +} From 7df91c520eff6237a39402d56a4d52f056c8b2cf Mon Sep 17 00:00:00 2001 From: Thorsten Date: Fri, 20 May 2022 13:35:25 +0200 Subject: [PATCH 05/49] [#3066] New design sidebar inbox (#3182) --- .../src/components/Sidebar/index.module.scss | 37 +++++++++++++++---- .../inbox/src/components/Sidebar/index.tsx | 4 +- .../pages/Inbox/Messenger/index.module.scss | 2 +- .../inbox/src/pages/Tags/index.module.scss | 4 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/frontend/inbox/src/components/Sidebar/index.module.scss b/frontend/inbox/src/components/Sidebar/index.module.scss index f8bc6c9fa9..47d8b8c1c4 100644 --- a/frontend/inbox/src/components/Sidebar/index.module.scss +++ b/frontend/inbox/src/components/Sidebar/index.module.scss @@ -5,12 +5,15 @@ .wrapper { display: flex; flex-direction: column; + align-items: center; border-top-right-radius: 8px; overflow-y: hidden; margin-top: 88px; - width: 80px; - height: auto; + width: 175px; + height: 100%; background-color: var(--color-background-white); + color: var(--color-text-contrast); + position: fixed; } .linkSection { @@ -20,23 +23,27 @@ .align { display: flex; justify-content: center; - margin-top: 24px; - margin-bottom: 32px; + margin-top: 11px; + width: 164px; + height: 42px; + border-radius: 10px; } .link { display: flex; - flex-direction: column; - justify-content: center; + flex-direction: row; + justify-content: flex-start; align-items: center; transition: 0.5s; text-decoration: none; font-weight: 400; + width: 100%; color: var(--color-text-gray); + margin-left: 8px; span { @include font-s; - margin: 0; + margin-left: 11px; padding: 0; text-align: center; } @@ -45,6 +52,7 @@ } &:hover { + color: var(--color-airy-blue); svg path { fill: var(--color-airy-blue); } @@ -60,8 +68,23 @@ .link.active { color: var(--color-airy-blue); + padding-left: 10px; svg path { fill: var(--color-airy-blue); } } + +.align.active { + background-color: var(--color-blue-white); +} + +.version { + position: absolute; + left: 8px; + bottom: 96px; + font-size: 10px; + line-height: 10px; + font-family: 'Lato', sans-serif; + color: var(--color-text-gray); +} diff --git a/frontend/inbox/src/components/Sidebar/index.tsx b/frontend/inbox/src/components/Sidebar/index.tsx index cc95b13eda..7d7e48860b 100644 --- a/frontend/inbox/src/components/Sidebar/index.tsx +++ b/frontend/inbox/src/components/Sidebar/index.tsx @@ -16,13 +16,13 @@ export const Sidebar = () => { return (