You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add support of metadata subcommand for provider services
This command will let Compose and external tooling know about which parameters should be passed to the Compose plugin
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
> __Note:__ `project-name` _should_ be used by the provider to tag resources
44
-
> set for project, so that later execution with `down` subcommand releases
45
+
> set for project, so that later execution with `down` subcommand releases
45
46
> all allocated resources set for the project.
46
47
47
48
## Communication with Compose
@@ -76,12 +77,12 @@ sequenceDiagram
76
77
77
78
## Connection to a service managed by a provider
78
79
79
-
A service in the Compose application can declare dependency on a service managed by an external provider:
80
+
A service in the Compose application can declare dependency on a service managed by an external provider:
80
81
81
82
```yaml
82
83
services:
83
84
app:
84
-
image: myapp
85
+
image: myapp
85
86
depends_on:
86
87
- database
87
88
@@ -104,8 +105,72 @@ into its runtime environment.
104
105
## Down lifecycle
105
106
106
107
`down`lifecycle is equivalent to `up` with the `<provider> compose --project-name <NAME> down <SERVICE>` command.
107
-
The provider is responsible for releasing all resources associated with the service.
108
+
The provider is responsible for releasing all resources associated with the service.
109
+
110
+
## Provide metadata about options
111
+
112
+
Compose extensions *MAY* optionally implement a `metadata` subcommand to provide information about the parameters accepted by the `up` and `down` commands.
113
+
114
+
The `metadata` subcommand takes no parameters and returns a JSON structure on the `stdout` channel that describes the parameters accepted by both the `up` and `down` commands, including whether each parameter is mandatory or optional.
115
+
116
+
```console
117
+
awesomecloud compose metadata
118
+
```
119
+
120
+
The expected JSON output format is:
121
+
```json
122
+
{
123
+
"description": "Manage services on AwesomeCloud",
124
+
"up": {
125
+
"parameters": [
126
+
{
127
+
"name": "type",
128
+
"description": "Database type (mysql, postgres, etc.)",
129
+
"required": true,
130
+
"type": "string"
131
+
},
132
+
{
133
+
"name": "size",
134
+
"description": "Database size in GB",
135
+
"required": false,
136
+
"type": "integer",
137
+
"default": "10"
138
+
},
139
+
{
140
+
"name": "name",
141
+
"description": "Name of the database to be created",
142
+
"required": true,
143
+
"type": "string"
144
+
}
145
+
]
146
+
},
147
+
"down": {
148
+
"parameters": [
149
+
{
150
+
"name": "name",
151
+
"description": "Name of the database to be removed",
152
+
"required": true,
153
+
"type": "string"
154
+
}
155
+
]
156
+
}
157
+
}
158
+
```
159
+
The top elements are:
160
+
- `description`: Human-readable description of the provider
161
+
- `up`: Object describing the parameters accepted by the `up` command
162
+
- `down`: Object describing the parameters accepted by the `down` command
163
+
164
+
And for each command parameter, you should include the following properties:
165
+
- `name`: The parameter name (without `--` prefix)
166
+
- `description`: Human-readable description of the parameter
167
+
- `required`: Boolean indicating if the parameter is mandatory
168
+
- `type`: Parameter type (`string`, `integer`, `boolean`, etc.)
169
+
- `default`: Default value (optional, only for non-required parameters)
170
+
- `enum`: List of possible values supported by the parameter separated by `,` (optional, only for parameters with a limited set of values)
171
+
172
+
This metadata allows Compose and other tools to understand the provider's interface and provide better user experience, such as validation, auto-completion, and documentation generation.
108
173
109
174
## Examples
110
175
111
-
See [example](examples/provider.go) for illustration on implementing this API in a command line
176
+
See [example](examples/provider.go) for illustration on implementing this API in a command line
0 commit comments