Skip to content

Commit f7742a2

Browse files
authored
Merge pull request #14 from coder/coder-readme
add basic READMEs
2 parents 46bdea5 + ea0c89f commit f7742a2

File tree

7 files changed

+129
-85
lines changed

7 files changed

+129
-85
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# [Backstage](https://backstage.io)
1+
# Backstage Plugins
2+
3+
A collection of plugins that extend [Backstage](https://backstage.io) to help with developer onboarding, context switching, and automated IDE environments (remote or local).
4+
5+
- [backstage-plugin-coder](./plugins/backstage-plugin-coder/README.md): A plugin for integrating Coder workspaces with Backstage.
6+
- [backstage-plugin-devcontainers-backend](./plugins/backstage-plugin-devcontainers/README.md): A plugin for integrating VS Code Dev Containers extension with Backstage catalog items (no Coder deployment necessary).
7+
8+
Please use [GitHub issues](https://github.com/coder/backstage-plugins/issues) to report any issues or feature requests.
29

310
## Contributing
411

@@ -24,7 +31,7 @@ Backstage app.
2431
## Releasing
2532

2633
To draft a release for a plugin push a tag named `$name/v$version` without the
27-
`backstage-plugin-` prefix. For example:
34+
`backstage-plugin-` prefix. For example:
2835

2936
```sh
3037
git tag -a coder/v0.0.0 -m "coder v0.0.0"
Lines changed: 116 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,136 @@
1-
# coder-backstage
2-
3-
A basic plugin that adds the "Open in Coder" button to catalog items in backstage based on
4-
the catalog spec.
5-
6-
| Catalog item without Coder | Catalog item with Coder |
7-
| ---------------------------------------------------------------- | ---------------------------------------------------------- |
8-
| ![Screenshot without Coder](./docs/screenshot-without-coder.png) | ![Screenshot with Coder](./docs/screenshot-with-coder.png) |
9-
10-
This is a very basic MVP, but demonstrates the power of a Coder+Backstage integration. It allows Backstage users to quickly develop a service inside a CDE.
11-
12-
## How it works
13-
14-
All backstage catalog items are git repos with a [catalog-info.yaml](https://github.com/bcdr-demos/python-project/blob/main/catalog-info.yaml) file. To add Coder compatibility to a given template, we need to add a `coder` section to the catalog-info.yaml file.
15-
16-
Here's an example:
17-
18-
```yaml
19-
apiVersion: backstage.io/v1alpha1
20-
kind: Component
21-
metadata:
22-
name: python-project
23-
spec:
24-
type: other
25-
lifecycle: unknown
26-
owner: pm
27-
coder:
28-
template: 'devcontainers'
29-
createMode: 'auto'
30-
params:
31-
repo: 'custom'
32-
repo_url: 'https://github.com/bcdr-demos/python-project'
33-
region: 'us-pittsburgh'
34-
```
1+
# @coder/backstage-plugin-coder
2+
3+
Create and manage [Coder workspaces](https://coder.com/docs/v2/latest) from Backstage.
4+
5+
<!-- TOOD: Add Loom -->
6+
7+
## Screenshots
8+
9+
![Coder authentication](./screenshots/coder-auth.png)
3510

36-
## Adding the component
11+
![Workspace list page](./screenshots/catalog-item.png)
3712

38-
Since the Backstage UI is "DIY," you'll need to modify `EntityPage.tsx` in your Backstage deployment to import the components from this plugin.
13+
## Features
3914

40-
There are several ways to use the integration:
15+
- Users link their Coder accounts with Backstage via tokens
16+
- Associate Coder workspaces with catalog items in Backstage
17+
- Workspace list component for viewing and managing workspaces
18+
<!-- - Full Coder API access for custom plugins & integrations -->
4119

42-
### Example Card
20+
## Setup
4321

44-
The easiest way to consume this integration is by importing the `ExampleContributingCard` component
22+
This assumes you already have a [Coder](https://github.com/coder/coder) deployment running.
23+
Replace `https://coder.example.com` with your Coder deployment access URL. This also assumes
24+
you have a template that has a parameter for a git repository URL (e.g. `git_repo_url`) that auto-clones
25+
the repository or uses [envbuilder](https://coder.com/docs/v2/latest/templates/devcontainers) to build
26+
the devcontainer.
4527

46-
```tsx
47-
// EntityPage.tsx
48-
import { ExampleContributingCard } from '@internal/plugin-coder';
49-
50-
// ...
51-
const overviewContent = (
52-
<Grid container spacing={3} alignItems="stretch">
53-
{/* ... */}
54-
<Grid item md={6} xs={12}>
55-
<ExampleContributingCard coderAccessUrl="https://coder.example.com" />
56-
</Grid>
57-
{/* ... */}
58-
</Grid>
59-
);
60-
```
28+
1. If you have a standalone Backstage app (you didn't clone this repo), then do
29+
30+
```bash
31+
yarn --cwd packages/app add @coder/backstage-plugin-coder
32+
```
33+
34+
1. Add the proxy key to your `app-config.yaml`:
35+
36+
```yaml
37+
proxy:
38+
endpoints:
39+
'/coder':
40+
# Replace with your Coder deployment access URL and a trailing /
41+
target: 'https://coder.example.com/'
42+
changeOrigin: true
43+
allowedMethods: ['GET']
44+
allowedHeaders: ['Authorization', 'Coder-Session-Token']
45+
headers:
46+
X-Custom-Source: backstage
47+
```
48+
49+
1. Add the `CoderProvider` to the application:
50+
51+
```tsx
52+
// In packages/app/src/App.tsx
53+
import {
54+
type CoderAppConfig,
55+
CoderProvider,
56+
} from '@coder/backstage-plugin-coder';
6157
62-
### Button
58+
const appConfig: CoderAppConfig = {
59+
deployment: {
60+
accessUrl: 'https://coder.example.com',
61+
},
6362
64-
You can also just import the `OpenInCoderButton` component and use it in your own component.
63+
// Set the default template (and parameters) for
64+
// catalog items. This can be overridden in the
65+
// catalog-info.yaml for specific items.
66+
workspaces: {
67+
templateName: 'devcontainers',
68+
mode: 'manual',
69+
// This parameter is used to filter Coder workspaces
70+
// by a repo URL parameter.
71+
repoUrlParamKeys: ['custom_repo', 'repo_url'],
72+
params: {
73+
repo: 'custom',
74+
region: 'eu-helsinki',
75+
},
76+
},
77+
};
6578
66-
### URL
79+
// ...
6780
68-
For the most control, you can use the `useOpenInCoderLink` to get the Coder URL for a given catalog item.
81+
export default app.createRoot(
82+
<CoderProvider appConfig={appConfig}>
83+
<AlertDisplay />
84+
<OAuthRequestDialog />
85+
<AppRouter>
86+
<Root>{routes}</Root>
87+
</AppRouter>
88+
</CoderProvider>,
89+
);
90+
```
6991

70-
```ts
71-
// MyCustomComponent.tsx
72-
import { useOpenInCoderLink } from '@internal/plugin-coder';
92+
<!-- > Note: You can also wrap a single page or component with `CoderProvider` if you only need Coder in a specific part of your app. See our [API reference](#TODO) for more details. -->
7393

74-
export const MyCustomComponent = () => {
75-
const coderLink = useOpenInCoderLink(catalogItem);
76-
// some basic component that has error handling if coderLink is null
77-
if (coderLink) return <a href={coderLink}>Open in Coder</a>;
78-
return <p>Not configured for Coder</p>;
79-
};
94+
1. Add the `CoderWorkspacesCard` card to the entity page in your app:
95+
96+
```tsx
97+
// In packages/app/src/components/catalog/EntityPage.tsx
98+
import { CoderWorkspacesCard } from '@coder/backstage-plugin-coder';
99+
100+
// ...
101+
102+
<Grid item md={6} xs={12}>
103+
<CoderWorkspacesCard readEntityData />
104+
</Grid>;
105+
```
106+
107+
<!-- Individual components of the card can also be imported. See [the plugin documentation](./docs) for full configuration options and API reference. -->
108+
109+
<!-- ### API Access
110+
111+
The plugin provides a `CoderApi` instance for accessing the Coder API. This can be used in custom plugins and integrations. Here is an example component that lists all templates:
112+
113+
```tsx
114+
import { useCoder } from '@coder/backstage-plugin-coder';
115+
116+
// TODO. I believe Michael said this is possible today?
117+
// This can be a very basic component that requires auth
118+
// and lists all templates in a basic unstyled list
119+
// with a refresh button
80120
```
81121

82-
## Taking this further
122+
See to the [Coder REST API Reference](https://coder.com/docs/v2/latest/api) for more details -->
83123

84-
This is only the beginning. We can extend this integration further:
124+
## Roadmap
85125

86-
- [ ] Display Coder-compatible templates in the catalog
87-
- [ ] Developing a neutral Backstage plugin to detect `devcontainer.json` in repos and add a more advanced "contributing" card that links to VS Code Remote, Codespaces, and Coder
88-
- [ ] Allow developers to see their existing Coder workspaces and relate workspaces more directly to catalog items
89-
- [ ] Allow developers to create new workspaces from the catalog item page or a dedicated sidebar page
90-
- [ ] Build an IDE extension to allow people to see catalog items and start a new project, and open their CDE, without leaving their editor!
126+
This plugin is in active development. The following features are planned:
91127

92-
More ideas welcome!
128+
- [ ] Add support for only rendering component if `catalog-info.yaml` indicates the item is compatible with Coder
129+
- [ ] OAuth support (vs. token auth) for linking Coder accounts
130+
- [ ] "Open in Coder" button/card component for catalog items
131+
- [ ] Example creating workspaces with Backstage Scaffolder
132+
- [ ] Example dedicated "Coder" page in Backstage
93133

94134
## Contributing
95135

96-
Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn start` in the root directory, and then navigating to [/coder](http://localhost:3000/coder).
97-
98-
You can also serve the plugin in isolation by running `yarn start` in the plugin directory.
99-
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads.
100-
It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory.
136+
This plugin is part of the Backstage community. We welcome contributions!
Binary file not shown.
Binary file not shown.

plugins/backstage-plugin-coder/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@coder/backstage-plugin-coder",
33
"version": "0.0.0",
4-
"main": "src/index.ts",
5-
"types": "src/index.ts",
4+
"main": "dist/index.esm.js",
5+
"types": "dist/index.d.ts",
66
"license": "Apache-2.0",
77
"bugs": {
88
"url": "https://github.com/coder/backstage-plugins/issues"
@@ -57,5 +57,6 @@
5757
},
5858
"files": [
5959
"dist"
60-
]
60+
],
61+
"module": "./dist/index.esm.js"
6162
}
Loading
Loading

0 commit comments

Comments
 (0)