Skip to content

Commit 466f051

Browse files
LiliumCandidumPaola Nicosia
andauthored
feat: new marketplace api support (#247)
Co-authored-by: Paola Nicosia <[email protected]>
1 parent e1b87bb commit 466f051

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4768
-376
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- deprecated `marketplace` when console version is greater than or equal 14.0.0
13+
14+
### Added
15+
16+
- new command: `catalog`
17+
1018
## [v0.17.3] - 2025-03-20
1119

1220
### Changed

docs/30_commands.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,10 @@ Available flags for the command:
10021002

10031003
## marketplace
10041004

1005+
:::warning
1006+
This command and its subcommands are deprecated from Mia-Platform Console v14.0.0. Please use [catalog](#catalog) command instead.
1007+
:::
1008+
10051009
View and manage Marketplace items
10061010

10071011
All the subcommands inherit the following flags:
@@ -1140,3 +1144,136 @@ The flag `--item-id` or `-i` accepts the `itemId` of the Item.
11401144
```bash
11411145
miactl marketplace list-versions -i some-item
11421146
```
1147+
1148+
## catalog
1149+
1150+
:::info
1151+
This command and its subcommands use APIs that are available from Mia-Plaftorm Console v14.0.0. If you are using a previous Console version, use [marketplace](#marketplace) command instead.
1152+
:::
1153+
1154+
View and manage Catalog items
1155+
1156+
All the subcommands inherit the following flags:
1157+
1158+
```sh
1159+
--auth-name string the name of the miactl auth to use
1160+
--certificate-authority string path to a cert file for the certificate authority for the selected endpoint
1161+
--company-id string the ID of the Company
1162+
-c, --config string path to the config file default to $HOME/miactl/config
1163+
--context string the name of the miactl context to use
1164+
--endpoint string the address and port of the Mia-Platform Console server
1165+
--insecure-skip-tls-verify if true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
1166+
-v --verbose increase the verbosity of the cli output
1167+
```
1168+
1169+
### list
1170+
1171+
List Catalog items
1172+
1173+
#### Synopsis
1174+
1175+
List the Catalog items that the current user can access.
1176+
1177+
#### Usage
1178+
1179+
```sh
1180+
miactl catalog list --company-id company-id [FLAGS]...
1181+
```
1182+
1183+
#### Flags
1184+
1185+
- `--public` - if this flag is set, the command fetches not only the items from the requested company, but also the public Catalog items from other companies.
1186+
1187+
### get
1188+
1189+
Get a Catalog item
1190+
1191+
#### Synopsis
1192+
1193+
Get a single Catalog item
1194+
1195+
You need to specify the companyId, itemId and version, via the respective flags (recommended). The company-id flag can be omitted if it is already set in the context.
1196+
1197+
```bash
1198+
miactl catalog get { --item-id item-id --version version } ...
1199+
```
1200+
1201+
### delete
1202+
1203+
Delete a Catalog item
1204+
1205+
#### Synopsis
1206+
1207+
Delete a single Catalog item
1208+
1209+
You need to specify the companyId, itemId and version, via the respective flags (recommended). The company-id flag can be omitted if it is already set in the context.
1210+
1211+
```bash
1212+
miactl catalog delete { --item-id item-id --version version } ...
1213+
```
1214+
1215+
### apply
1216+
1217+
Create or update Catalog items
1218+
1219+
#### Synopsis
1220+
1221+
Create or update one or more Catalog items.
1222+
1223+
The flag -f accepts either files or directories. In case of directories, it explores them recursively.
1224+
1225+
Supported formats are JSON (.json files) and YAML (.yaml or .yml files).
1226+
1227+
The file can contain an image object with the following format:
1228+
1229+
```json
1230+
"image": {
1231+
"localPath": "./someImage.png"
1232+
}
1233+
```
1234+
1235+
The localPath can be absolute or relative to the file location.
1236+
The image will be uploaded along with the Marketplace item.
1237+
Before being applied, the "image" key will be replaced with the "imageUrl" referring to the uploaded image.
1238+
You can retrieve the updated item with the "get" command.
1239+
1240+
You can also specify the "supportedByImage" in a similar way.
1241+
1242+
Be aware that the presence of both "image" and "imageUrl" and/or of both "supportedByImage" and "supportedByImageUrl" is ambiguous and raises an error.
1243+
1244+
```bash
1245+
miactl catalog apply { -f file-path }... } [flags]
1246+
```
1247+
1248+
#### Examples
1249+
1250+
```bash
1251+
1252+
# Apply the configuration of the file myFantasticGoTemplate.json located in the current directory to the Catalog
1253+
miactl catalog apply -f myFantasticGoTemplate.json
1254+
1255+
# Apply the configurations in myFantasticGoTemplate.json and myFantasticNodeTemplate.yml to the Catalog, with relative paths
1256+
miactl catalog apply -f ./path/to/myFantasticGoTemplate.json -f ./path/to/myFantasticNodeTemplate.yml
1257+
1258+
# Apply all the valid configuration files in the directory myFantasticGoTemplates to the Catalog
1259+
miactl catalog apply -f myFantasticGoTemplates
1260+
```
1261+
1262+
#### Options
1263+
1264+
```bash
1265+
-f, --file stringArray paths to JSON/YAML files or folder of files containing a Marketplace item definition
1266+
-h, --help help for apply
1267+
```
1268+
1269+
### list-versions
1270+
1271+
List all the available versions of a specific Catalog item.
1272+
1273+
#### Synopsis
1274+
1275+
The flag `--item-id` or `-i` accepts the `itemId` of the Item.
1276+
1277+
```bash
1278+
miactl catalog list-versions -i some-item
1279+
```

internal/cmd/catalog.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright Mia srl
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
package cmd
17+
18+
import (
19+
"github.com/mia-platform/miactl/internal/clioptions"
20+
"github.com/mia-platform/miactl/internal/cmd/catalog"
21+
catalog_apply "github.com/mia-platform/miactl/internal/cmd/catalog/apply"
22+
"github.com/spf13/cobra"
23+
)
24+
25+
func CatalogCmd(options *clioptions.CLIOptions) *cobra.Command {
26+
cmd := &cobra.Command{
27+
Use: "catalog",
28+
Short: "View and manage Catalog items. This command is available from Mia-Platform Console v14.0.0.",
29+
}
30+
31+
// add cmd flags
32+
flags := cmd.PersistentFlags()
33+
options.AddConnectionFlags(flags)
34+
options.AddCompanyFlags(flags)
35+
options.AddContextFlags(flags)
36+
37+
// add sub commands
38+
cmd.AddCommand(catalog.ListCmd(options))
39+
cmd.AddCommand(catalog.GetCmd(options))
40+
cmd.AddCommand(catalog.DeleteCmd(options))
41+
cmd.AddCommand(catalog_apply.ApplyCmd(options))
42+
cmd.AddCommand(catalog.ListVersionCmd(options))
43+
44+
return cmd
45+
}

0 commit comments

Comments
 (0)