dapr / dapr/cli

Proposal: CRD generation + discovery

Open
#992 7 comments 4 reactions 0 assignees View on GitHub
area/cli discussion kind/feature P1 pinned
Dominant language
Go
Stars
353
Forks
221
Avg merge
3d 8h
Merged PRs (30d)
2

Description

## Describe the proposal

#### CRD Generation

Currently in order to create a Dapr component, subscription, configuration, middleware or resiliency policy you have to write a YAML manifest by looking at the docs or an example. I think we can make this easier for developers by providing a generator in the CLI.

You could create a Dapr CRD using a prompt based approach.

```
dapr generate component --interactive
...
> enter your component name:
...
> enter your component namespace:
...
```

Or you can provide flags and have it done in a single command using something like:

```
dapr generate component --set name=mypubsub --set namespace=default --set type=pubsub.redis --set version=v1 --set metadata.redisHost=localhost:6379 --set metadata.redisPassword=secretKeyRef:redispw
```

We could provide the same experience for subscriptions, configurations, middleware and resiliency policies.

I'd conside extending this further to provide Dapr CRD linting via:
```
dapr lint component mycomonent.yaml
```
This would check a provided component again a schema for the CRD and apply a set of rules based on "best practices" to identify potential problems such as not using secret references.

#### CRD Discovery
Currently the docs or code are the only place you can discovery what CRDs are available and what the structure looks like.

I propose a new command that will compliment the above CRD generation called:
```
dapr search components
```
This will return a list of the currently available components. It can be extended to provide filtering such as:
```
dapr search components --type state --status stable
```
Once you see a company you want to use, you can use either the CRD generation commands above or you could use an additional command:
```
dapr schema components --type state.redis --version v1
```
Which will return a suitable JSON schema for the object shape.

In order for the CLI to support these commands, we would likely have to hard code the data (schemas, CRD lists, etc.) into the CLI. Or we add a new GitHub repo which hosts the schemas which the CLI can query at runtime.

cc: @yaron2

## Release Note

RELEASE NOTE: **ADD** CRD generation, linting and discovery

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.