11# CRD to Sample YAML - IntelliJ Plugin
22
3- IntelliJ IDEA plugin for generating sample YAML files from Kubernetes Custom Resource Definitions using the CTY tool.
4-
5- ## Features
6-
7- - ** CRD Detection** : Automatically detects CRD files in your project
8- - ** Sample Generation** : Generate complete, minimal, or commented sample YAML files
9- - ** Validation** : Validate sample YAML files against CRD schemas
10- - ** Context Menu Integration** : Right-click on CRD files to access all features
11- - ** Configurable** : Settings panel to configure CTY binary path and output options
3+ IntelliJ plugin for generating sample YAML files from Kubernetes Custom Resource Definitions.
124
135## Prerequisites
146
@@ -19,101 +11,36 @@ go install github.com/Skarlso/crd-to-sample-yaml@latest
1911
2012## Installation
2113
22- 1 . Build the plugin:
23- ``` bash
24- cd intellij-plugin
25- ./gradlew buildPlugin
26- ```
14+ Build the plugin and install the ZIP from ` build/distributions/ ` :
15+ ``` bash
16+ cd intellij-plugin
17+ ./gradlew buildPlugin
18+ ```
2719
28- 2 . Install the generated ` .zip ` file from ` build/distributions/ ` via:
29- - ** File → Settings → Plugins → Install Plugin from Disk**
20+ Install via File → Settings → Plugins → Install Plugin from Disk
3021
3122## Usage
3223
33- ### Generate Samples
34- 1 . Right-click on any CRD YAML file
35- 2 . Select ** CRD to Sample YAML** from the context menu
36- 3 . Choose your generation option:
37- - ** Generate Sample YAML** - Complete sample with all fields
38- - ** Generate Minimal Sample YAML** - Required fields only
39- - ** Generate Sample YAML with Comments** - Sample with field descriptions
40-
41- ### Validate Samples
42- 1 . Right-click on a CRD file
43- 2 . Select ** CRD to Sample YAML → Validate Sample Against CRD**
44- 3 . Choose the sample YAML file to validate
45-
46- ### Configure Settings
47- 1 . Go to ** File → Settings → Tools → CRD to Sample YAML**
48- 2 . Configure:
49- - ** CTY Binary Path** : Path to the cty executable (leave empty to use PATH)
50- - ** Output Location** : Where to save generated files
51- - ** Show Notifications** : Enable/disable success/error notifications
24+ Right-click on CRD YAML files to access the ` CRD to Sample YAML ` menu. Generate complete, minimal, or commented samples. Validate existing samples against CRD schemas.
25+
26+ Configure the CTY binary path and output location in File → Settings → Tools → CRD to Sample YAML.
5227
5328## Development
5429
55- ### Prerequisites
56- - IntelliJ IDEA 2023.2+
57- - Java 17+
58- - Gradle
30+ Requires IntelliJ IDEA 2023.2+, Java 17+, and Gradle.
5931
60- ### Setup
6132``` bash
6233git clone https://github.com/Skarlso/crd-to-sample-yaml.git
6334cd crd-to-sample-yaml/intellij-plugin
64- ./gradlew buildPlugin
65- ```
66-
67- ### Testing
68- ``` bash
69- ./gradlew test
70- ```
71-
72- ### Running in Development
73- ``` bash
74- ./gradlew runIde
75- ```
76-
77- ### Project Structure
78- ```
79- src/main/java/com/skarlso/crdtosampleyaml/
80- ├── actions/ # Context menu actions
81- │ ├── BaseAction.java
82- │ ├── GenerateSampleAction.java
83- │ ├── GenerateMinimalSampleAction.java
84- │ ├── GenerateSampleWithCommentsAction.java
85- │ └── ValidateSampleAction.java
86- ├── services/ # Core services
87- │ ├── CrdDetectorService.java
88- │ └── CtyService.java
89- └── settings/ # Plugin configuration
90- ├── CtySettings.java
91- └── CtyConfigurable.java
35+ ./gradlew buildPlugin # Build
36+ ./gradlew test # Test
37+ ./gradlew runIde # Run in development
9238```
9339
9440## Troubleshooting
9541
96- ### CTY Not Found
97- - Install CTY: ` go install github.com/Skarlso/crd-to-sample-yaml@latest `
98- - Or configure the full path in plugin settings
99-
100- ### No Context Menu Options
101- - Ensure you're right-clicking on a valid CRD YAML file
102- - CRD files must have ` kind: CustomResourceDefinition ` and ` apiVersion: apiextensions.k8s.io/v1 `
103-
104- ### Generation Fails
105- - Check that CTY is properly installed: ` cty version `
106- - Verify the CRD file is valid
107- - Check IntelliJ's Event Log for detailed error messages
108-
109- ## Building for Distribution
110-
111- ``` bash
112- ./gradlew buildPlugin
113- ```
114-
115- The plugin ZIP file will be created in ` build/distributions/ `
42+ Install CTY if missing: ` go install github.com/Skarlso/crd-to-sample-yaml@latest ` or configure the full path in settings.
11643
117- ## License
44+ Context menu only appears on valid CRD files with ` kind: CustomResourceDefinition ` and ` apiVersion: apiextensions.k8s.io/v1 ` .
11845
119- This plugin is part of the CRD to Sample YAML project and follows the same license terms .
46+ Check IntelliJ's Event Log for error details .
0 commit comments