Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- deprecated `marketplace` when console version is greater than or equal 14.0.0

### Added

- new command: `catalog`

## [v0.17.3] - 2025-03-20

### Changed
Expand Down
137 changes: 137 additions & 0 deletions docs/30_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,10 @@ Available flags for the command:

## marketplace

:::warning
This command and its subcommands are deprecated from Mia-Platform Console v14.0.0. Please use [catalog](#catalog) command instead.
:::

View and manage Marketplace items

All the subcommands inherit the following flags:
Expand Down Expand Up @@ -1140,3 +1144,136 @@ The flag `--item-id` or `-i` accepts the `itemId` of the Item.
```bash
miactl marketplace list-versions -i some-item
```

## catalog

:::info
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.
:::

View and manage Catalog items

All the subcommands inherit the following flags:

```sh
--auth-name string the name of the miactl auth to use
--certificate-authority string path to a cert file for the certificate authority for the selected endpoint
--company-id string the ID of the Company
-c, --config string path to the config file default to $HOME/miactl/config
--context string the name of the miactl context to use
--endpoint string the address and port of the Mia-Platform Console server
--insecure-skip-tls-verify if true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
-v --verbose increase the verbosity of the cli output
```

### list

List Catalog items

#### Synopsis

List the Catalog items that the current user can access.

#### Usage

```sh
miactl catalog list --company-id company-id [FLAGS]...
```

#### Flags

- `--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.

### get

Get a Catalog item

#### Synopsis

Get a single Catalog item

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.

```bash
miactl catalog get { --item-id item-id --version version } ...
```

### delete

Delete a Catalog item

#### Synopsis

Delete a single Catalog item

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.

```bash
miactl catalog delete { --item-id item-id --version version } ...
```

### apply

Create or update Catalog items

#### Synopsis

Create or update one or more Catalog items.

The flag -f accepts either files or directories. In case of directories, it explores them recursively.

Supported formats are JSON (.json files) and YAML (.yaml or .yml files).

The file can contain an image object with the following format:

```json
"image": {
"localPath": "./someImage.png"
}
```

The localPath can be absolute or relative to the file location.
The image will be uploaded along with the Marketplace item.
Before being applied, the "image" key will be replaced with the "imageUrl" referring to the uploaded image.
You can retrieve the updated item with the "get" command.

You can also specify the "supportedByImage" in a similar way.

Be aware that the presence of both "image" and "imageUrl" and/or of both "supportedByImage" and "supportedByImageUrl" is ambiguous and raises an error.

```bash
miactl catalog apply { -f file-path }... } [flags]
```

#### Examples

```bash

# Apply the configuration of the file myFantasticGoTemplate.json located in the current directory to the Catalog
miactl catalog apply -f myFantasticGoTemplate.json

# Apply the configurations in myFantasticGoTemplate.json and myFantasticNodeTemplate.yml to the Catalog, with relative paths
miactl catalog apply -f ./path/to/myFantasticGoTemplate.json -f ./path/to/myFantasticNodeTemplate.yml

# Apply all the valid configuration files in the directory myFantasticGoTemplates to the Catalog
miactl catalog apply -f myFantasticGoTemplates
```

#### Options

```bash
-f, --file stringArray paths to JSON/YAML files or folder of files containing a Marketplace item definition
-h, --help help for apply
```

### list-versions

List all the available versions of a specific Catalog item.

#### Synopsis

The flag `--item-id` or `-i` accepts the `itemId` of the Item.

```bash
miactl catalog list-versions -i some-item
```
45 changes: 45 additions & 0 deletions internal/cmd/catalog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright Mia srl
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"github.com/mia-platform/miactl/internal/clioptions"
"github.com/mia-platform/miactl/internal/cmd/catalog"
catalog_apply "github.com/mia-platform/miactl/internal/cmd/catalog/apply"
"github.com/spf13/cobra"
)

func CatalogCmd(options *clioptions.CLIOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "catalog",
Short: "View and manage Catalog items. This command is available from Mia-Platform Console v14.0.0.",
}

// add cmd flags
flags := cmd.PersistentFlags()
options.AddConnectionFlags(flags)
options.AddCompanyFlags(flags)
options.AddContextFlags(flags)

// add sub commands
cmd.AddCommand(catalog.ListCmd(options))
cmd.AddCommand(catalog.GetCmd(options))
cmd.AddCommand(catalog.DeleteCmd(options))
cmd.AddCommand(catalog_apply.ApplyCmd(options))
cmd.AddCommand(catalog.ListVersionCmd(options))

return cmd
}
Loading