-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: implement addon init command #4162
Conversation
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Codecov Report
@@ Coverage Diff @@
## master #4162 +/- ##
==========================================
+ Coverage 60.36% 60.39% +0.03%
==========================================
Files 330 335 +5
Lines 31799 32540 +741
==========================================
+ Hits 19195 19654 +459
- Misses 10093 10330 +237
- Partials 2511 2556 +45
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can support a flag -p
allow user to define the target path, default is ./
Yes, manually specifying path is supported. Just kubevela/references/cli/addon.go Line 379 in 7bd5e06
|
Is better, and this is helm style. |
Well, it is good to follow existing user habits. Will develop a |
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM. Good job! Please fix the comments.
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
vela addon init mongodb -p ./some/repo --helm-repo-url=https://marketplace.azurecr.io/helm/v1/repo --chart=mongodb --version=12.1.16 | ||
|
||
If you don't want the Helm component, just omit the three Chart-related parameters. We will create an empty scaffold for you. | ||
vela addon init mongodb`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty scaffold should also create other addon dir for convenience, it's even better if we could put some meanful files as example in it.
https://kubevela.io/docs/platform-engineers/addon/intro#build-an-addon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there will be a minimal example in it (required files of an addon and other directories).
File Structure and Contents (Basic)
$ vela addon init mongo-sample
Scaffold created in directory mongo-sample. What to do next:
- Check out our guide on how to build your own addon: https://kubevela.io/docs/platform-engineers/addon/intro
- Review and edit what we have generated in mongo-sample
- To enable the addon, run: vela addon enable mongo-sample
$ tree mongo-sample
mongo-sample
├── definitions
├── metadata.yaml
├── readme.md
├── resources
├── schemas
└── template.yaml
3 directories, 3 files
$ cat mongo-sample/metadata.yaml
description: An addon for KubeVela.
icon: ""
invisible: false
name: mongo-sample
version: 1.0.0
$ cat mongo-sample/readme.md
# mongo-sample
Also check how to build your own addon: https://kubevela.net/docs/platform-engineers/addon/intro
## Directory Structure
- `template.yaml`: contains the basic app, you can add some component and workflow to meet your requirements. Other files in `resources/` and `definitions/` will be rendered as Components and appended in `spec.components`
- `metadata.yaml`: contains addon metadata information.
- `definitions/`: contains the X-Definition yaml/cue files. These file will be rendered as KubeVela Component in `template.yaml`
- `resources/`:
- `parameter.cue` to expose parameters. It will be converted to JSON schema and rendered in UI forms.
- All other files will be rendered as KubeVela Components. It can be one of the two types:
- YAML file that contains only one resource. This will be rendered as a `raw` component
- CUE template file that can read user input as `parameter.XXX` as defined `parameter.cue`.
Basically the CUE template file will be combined with `parameter.cue` to render a resource.
**You can specify the type and trait in this format**
$ cat mongo-sample/template.yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
creationTimestamp: null
name: mongo-sample
namespace: vela-system
spec:
components: null
status: {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great pr!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job!
Description of your changes
As described in #4116 (comment), this pr adds a
vela addon init
command.helm
component inside, will be created.helm
component, a basic addon scaffold is generated instead.This pr does not close that issue, since more features are needed.
Command Help Text
Examples:
Normal creation
Only when
./<addon-name>
(or user-specified path with-p
) does not exist, or is an empty directory, will this command succeed. Otherwise, to prevent overwrites, this command will fail.File Structure and Contents (Helm Component)
File Structure and Contents (Basic)
Directory already exists in local filesystem
File with the same name already exists or other reasons
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Relevant unit tests have been added. Also manually tested several conditions described above.
Special notes for your reviewer