# Ozone Backstage Plugin

## ozone

Welcome to the ozone plugin!

### Setup

1. Generate the service account token

   Create a role for your service account with the following permissions

   * `Applications.List`
   * `Applications.Get`
   * `Pipelines.List`
   * `Pipelines.Get`
   * `Pipelines.Execute`
   * `Releases.List`
   * `Releases.Get`
   * `Releases.Execute`
   * `PipelineRun.List`
   * `PipelineRun.Get`
   * `ReleaseRun.List`
   * `ReleaseRun.Get`
   * `Registries.List`
   * `Registries.Get`
   * `Repositories.List`
   * `Repositories.Get`

<figure><img src="https://3829750647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAObcOkMb6sCSnSdcUOTm%2Fuploads%2FJ1QLUaVS7MF41Qq2rr1N%2FScreenshot%202023-06-12%20at%2012.32.33%20PM.png?alt=media&#x26;token=07a6b66c-1534-47d6-a862-2d5930445b9d" alt=""><figcaption><p><em>Create Role</em></p></figcaption></figure>

Create a Service Account token From the ozone website, click on the `Account Management` on the sidebar and navigate to the `Service Account token` tab, Click on the `Create Service Account` button and choose the above created role, this will create a token. ![Screenshot 2023-06-12 at 12 34 17 PM](https://github.com/OzoneCloud/ozone-backstage/assets/13351472/eb59dab3-64d4-4bfe-b11d-01dc444e7303)

<figure><img src="https://3829750647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAObcOkMb6sCSnSdcUOTm%2Fuploads%2FQDOerdbKs2DKRSmgCmaw%2FScreenshot%202023-06-12%20at%2012.34.17%20PM.png?alt=media&#x26;token=cd4aa351-2d4e-402d-bcb5-e89d97cb20db" alt=""><figcaption><p><em>Creating a Token</em></p></figcaption></figure>

Use the token generated in your backstage configuration ![Screenshot 2023-06-12 at 12 36 00 PM](https://github.com/OzoneCloud/ozone-backstage/assets/13351472/ae21d7dc-8296-42d1-9770-b8f43ba132ec)

<figure><img src="https://3829750647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAObcOkMb6sCSnSdcUOTm%2Fuploads%2FPLkrF0yCMgivmpUDWNv8%2FScreenshot%202023-06-12%20at%2012.34.52%20PM.png?alt=media&#x26;token=67d9aa55-6e3b-4151-9296-e7ddbaa51cd1" alt=""><figcaption><p><em>Generated Token</em></p></figcaption></figure>

2. Add the dependency for ozone plugin

```bash
# From your Backstage root directory
yarn add --cwd packages/app @ozonenpm/plugin-ozone
```

3. Add proxy config

use the following proxy format to expose your api token

```yaml
proxy:
  ### Example for how to add a proxy endpoint for the frontend.
  ### A typical reason to do this is to handle HTTPS and CORS for internal services.
  # '/test':
  #   target: 'https://example.com'
  #   changeOrigin: true
  '/ozone':
    target: '<ozone-api-url>'
    headers:
      'authorization': '<your auth-token>'
    allowedHeaders:
      - x-workspace-id
```

### Usage

#### PipelineRun List plugin

Add the `EntityOzonePipelineRunContent` extension to the entity page in your app:

```tsx
// In packages/app/src/components/catalog/EntityPage.tsx
import {EntityOzonePipelineRunContent} from '@ozonenpm/plugin-ozone';

// For example in the CI/CD section
const cicdContent = (
  <EntitySwitch>
    <EntitySwitch.Case if={isozonePluginAvailable}>
      <EntityOzonePipelineRunContent />
    </EntitySwitch.Case>
```

**Screenshots**

<figure><img src="https://3829750647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAObcOkMb6sCSnSdcUOTm%2Fuploads%2FBLOFdP74nJTnwFffZNOE%2F244346245-0b0ec612-e16c-4580-a854-ed2e43c952ab.png?alt=media&#x26;token=87a1624c-c832-458f-bb57-0718a6c97be5" alt=""><figcaption><p><em>Pipeline runs list view</em></p></figcaption></figure>

<figure><img src="https://3829750647-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAObcOkMb6sCSnSdcUOTm%2Fuploads%2F2b3LQ1np0VtrLTmljoxu%2F244346630-75027c18-1335-43a1-951c-0bf383ebeedb.png?alt=media&#x26;token=c5fbeb82-c0df-4dda-b3ee-3112e9654503" alt=""><figcaption><p><em>Detailed pipeline run view</em></p></figcaption></figure>

#### Ozone Resource Plugin

Ozone plugin outside the catalog

* This will be dependent on the workspace selection
* This component will have Tabs of `Microservice`, `Repository`, `Registry`, `pipelines`
* On click of tabs will route to the lists accordingly

#### Screenshots

![Screenshot from 2023-04-19 17-06-07](https://user-images.githubusercontent.com/122984557/233064075-8cd11436-9ceb-48aa-b5d7-db80fae66133.png)

![Screenshot from 2023-04-19 17-06-11](https://user-images.githubusercontent.com/122984557/233064295-f0863ab7-27c5-40b7-96d4-3ee30d0d0942.png)

![Screenshot from 2023-04-19 17-06-14](https://user-images.githubusercontent.com/122984557/233064456-c43a5f95-5b21-4a19-9046-958ef6e2588e.png)

### Features

* Lists all the Builds,microservices,registry,repository for particular workspace
* Dive into one build to see the tasks and steps
* logs
