0.2.3 • Published 2 days ago

@veecode-platform/plugin-database-explorer v0.2.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 days ago

Database Explorer Plugin

The Database plugin has two approaches:

  • A list of the Databases available in your catalog

  • The Database overview with all its data and relationships within the catalog.

⚠️ It is important to note that the Database is a Kind customized by the VeeCode Platform and therefore it requires the installation of the veecode-platform-common plugin in order to work.

To install the veecode-platform-common plugin click here.

Okay, given that you already have a properly configured environment, let's start our installation.

Get Started

cd packages/app
yarn add @veecode-platform/plugin-database-explorer

Now, in the file packages > app > src > App.tsx:

...
+ import { DatabaseExplorerPage } from '@veecode-platform/plugin-database-explorer';

...

const routes = (
<FlatRoutes>
+ <Route path="/database-explorer" element={<DatabaseExplorerPage/>}/>
</FlatRoutes>
)
...

To add a menu to your sidebar, just follow these steps: packages > app > src > components > Root > Root.tsx

In the example, we've added an external icon, using the lib react-icons.

cd packages/app
yarn add react-icons
...
+ import { ImDatabase } from "react-icons/im";

...

export const Root = ({ children }: PropsWithChildren<{}>) => (
  <SidebarPage>
    <Sidebar>
      <SidebarLogo />
      <SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
        <SidebarSearchModal />
      </SidebarGroup>
      <SidebarDivider />
      <SidebarGroup label="Menu" icon={<MenuIcon />}>
        <SidebarItem icon={HomeIcon} to="catalog" text="Home" />
        <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
        <SidebarItem icon={ExtensionIcon} to="cluster-explorer" text="Cluster" />
        <SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
+        <SidebarItem icon={ImDatabase} to="database-explorer" text="Databases" />
        <SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
        <SidebarDivider />
        <SidebarScrollWrapper>
          <SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
        </SidebarScrollWrapper>
      </SidebarGroup>
      <SidebarSpace />
      <SidebarDivider />
      <SidebarGroup
        label="Settings"
        icon={<UserSettingsSignInAvatar />}
        to="/settings"
      >
        <SidebarSettings />
      </SidebarGroup>
    </Sidebar>
    {children}
  </SidebarPage>
);

Or you can create a "Resources" menu and add "Databases" as a submenu:

...

+ import BusinessIcon from '@material-ui/icons/Business';
+ import { ImDatabase } from "react-icons/im";

...

export const Root = ({ children }: PropsWithChildren<{}>) => (
  <SidebarPage>
    <Sidebar>
      <SidebarLogo />
      <SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
        <SidebarSearchModal />
      </SidebarGroup>
      <SidebarDivider />
      <SidebarGroup label="Menu" icon={<MenuIcon />}>
        <SidebarItem icon={HomeIcon} to="catalog" text="Home" />
        <SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
        <SidebarItem icon={ExtensionIcon} to="cluster-explorer" text="Cluster" />
        <SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
+          <SidebarItem icon={BusinessIcon} text="Resources">
+            <SidebarSubmenu title="">
+              <SidebarDivider />
+              <SidebarSubmenuItem
+                title="Databases"
+                to="database-explorer"
+                icon={ImDatabase}
+              />
+
+            </SidebarSubmenu>
+          </SidebarItem>
        <SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
        <SidebarDivider />
        <SidebarScrollWrapper>
          <SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
        </SidebarScrollWrapper>
      </SidebarGroup>
      <SidebarSpace />
      <SidebarDivider />
      <SidebarGroup
        label="Settings"
        icon={<UserSettingsSignInAvatar />}
        to="/settings"
      >
        <SidebarSettings />
      </SidebarGroup>
    </Sidebar>
    {children}
  </SidebarPage>
);

And that's the view:

By clicking on the icon in the side menu:

  • Database Listing:

Database

  • Database Overview:

image2

It's worth noting that each Database is a yaml file belonging to the application catalog. In other words, you need to configure the catalog discovery in your App-config.yaml:

1- First of all, we need to allow the new Kind in the app-config.yaml:

catalog:
  rules:
    - allow: [Component, API, Location, Cluster, Template, Database]
  providers: 
    github:
      providerId: # the provider ID can be any camelCase string
        organization: ${ GITHUB_ORGANIZATION }
        catalogPath: /catalog-info.yaml # string
        filters:
          branch: ${ GITHUB_CATALOG_BRANCH } # string
          repository: devportal-catalog # Regex
          validateLocationsExist: true
        schedule:        
          frequency: 
            minutes: ${GITHUB_CATALOG_PROVIDER_REFRESH_FREQUENCY}
          timeout: 
            minutes: ${GITHUB_CATALOG_PROVIDER_TIMEOUT}

Registering components manually:

image3

Playing the url of where the yaml of the Database is:

Captura de tela de 2024-01-04 11-45-57

This file should have the following structure:

apiVersion: veecode.backstage.io/v1alpha1 #or backstage.io/v1alpha1
kind: Database
metadata:
  name: "name_database"
  environment:
    type: "No-Sql"
    dns: xxxxxxx
spec:
  type: service
  lifecycle: development
  owner: "group:default/infra"

The file can have any name, as long as it follows this structure. Below the metadata key, we have the environment key and in this example we have some properties, but they are not mandatory, you can add the properties you think are necessary, we have developed the overview of this kind dynamically, so that it serves the information according to the properties that this key has.

The metadata.name key cannot contain spaces, separate words using "-", "_" or using camelCase.

How to reuse the resources of the Database entity

In the context we envisioned for the project, the Database is used to reuse information that will be useful when creating new entities for our catalog.

We have developed customizable components to provide the scaffolder with the possibility of parsing information from the environment key of our Kind.

This is our ResourcePicker, ➡️ here's how to install it.

With it we can approach the reuse of this information when creating entities via a template.

Example:

    - title: Database Settings
      properties:
        dataBaseResource:
          title: Select the Database from our catalog
          type: object
          ui:field: ResourcePicker
          ui:options:
            catalogFilter:
              kind: [Database]

In this case, we will list all our entities in the catalog that have the Database kind, and under the hood we will scan the metadata.enviromnet key of the chosen entity, and thus parse the information as values to serve the skeleton of our template.

example:

...
  steps:
    - id: template
      name: Fetch Skeleton + Template
      action: fetch:template
      input:
        url: ./skeleton      
        values:
          dns: ${{ parameters.dataBaseResource.dns }}

...

ℹ️ Remember to validate that the selected entity has this property, otherwise the values will be empty.

0.2.1

2 days ago

0.2.3

2 days ago

0.2.2

2 days ago

0.1.89

4 days ago

0.1.85

8 days ago

0.1.86

8 days ago

0.1.87

8 days ago

0.1.88

8 days ago

0.1.80

10 days ago

0.1.81

10 days ago

0.1.82

10 days ago

0.1.83

10 days ago

0.1.84

9 days ago

0.1.78

10 days ago

0.1.79

10 days ago

0.1.76

11 days ago

0.1.77

11 days ago

0.1.74

15 days ago

0.1.75

14 days ago

0.1.73

17 days ago

0.1.71

18 days ago

0.1.72

18 days ago

0.1.70

21 days ago

0.1.68

21 days ago

0.1.69

21 days ago

0.1.67

21 days ago

0.1.65

30 days ago

0.1.66

30 days ago

0.1.64

1 month ago

0.1.63

1 month ago

0.1.61

1 month ago

0.1.62

1 month ago

0.1.58

1 month ago

0.1.59

1 month ago

0.1.60

1 month ago

0.1.57

2 months ago

0.1.54

2 months ago

0.1.55

2 months ago

0.1.56

2 months ago

0.1.52

2 months ago

0.1.53

2 months ago

0.1.51

2 months ago

0.1.50

2 months ago

0.1.49

2 months ago

0.1.44

2 months ago

0.1.45

2 months ago

0.1.46

2 months ago

0.1.47

2 months ago

0.1.48

2 months ago

0.1.42

2 months ago

0.1.43

2 months ago

0.1.41

3 months ago

0.1.40

3 months ago

0.1.38

3 months ago

0.1.39

3 months ago

0.1.36

3 months ago

0.1.31

3 months ago

0.1.32

3 months ago

0.1.30

4 months ago

0.1.28

4 months ago

0.1.29

4 months ago

0.1.27

4 months ago

0.1.25

4 months ago

0.1.26

4 months ago

0.1.24

4 months ago

0.1.20

4 months ago

0.1.21

4 months ago

0.1.22

4 months ago

0.1.23

4 months ago

0.1.19

4 months ago

0.1.16

4 months ago

0.1.17

4 months ago

0.1.18

4 months ago

0.1.10

4 months ago

0.1.11

4 months ago

0.1.12

4 months ago

0.1.13

4 months ago

0.1.14

4 months ago

0.1.15

4 months ago

0.1.8

4 months ago

0.1.9

4 months ago

0.1.7

5 months ago

0.1.6

5 months ago

0.1.4

5 months ago

0.1.5

5 months ago

0.1.3

5 months ago

0.1.2

5 months ago

0.1.1

5 months ago