Skip to content

Commit

Permalink
feat: support extension apply command after breaking change (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
MIA-Deltat1995 authored Sep 10, 2024
1 parent d58a374 commit 7e79367
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 122 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- update go version to 1.22.5
- `marketplace list-versions` command removed from alpha build

### BREAKING

- updated `extension apply` command to support new request body schema. The older version of miactl will not be compatible with the Console version upper or equal to 13.2.0.

## [v0.14.0] - 2024-07-25

### Added
Expand Down
76 changes: 37 additions & 39 deletions docs/30_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ miactl extensions list [flags]
Available flags for the command:

- `--company-id` to set the ID of the desired Company
- `--resolve-details` to evaluate all the extension details including `visibilities`, `menu`, `category` and `permissions`

### get

Expand Down Expand Up @@ -652,29 +653,26 @@ It accepts an Extension Manifest either in `yaml` or `json` format

```json
{
"name": "Extension 1",
"description": "My extension 1",
"entry": "https://example.com/",
"contexts": [
"project"
],
"routes": [
{
"id": "extension-1",
"parentId": "workloads",
"locationId": "runtime",
"renderType": "menu",
"labelIntl": {
"en": "SomeLabel",
"it": "SomeLabelInItalian"
},
"destinationPath": "/",
"order": 200.0,
"icon": {
"name": "PiHardDrives"
}
}
]
"name": "Extension 1",
"description": "My extension 1",
"entry": "https://example.com/",
"activationContexts": ["project"],
"destination": {
"id": "runtime",
"path": "/"
},
"iconName": "PiHardDrives",
"menu": {
"id": "extension-1",
"labelIntl": {
"en": "SomeLabel",
"it": "SomeLabelInItalian"
},
"order": 200.0,
},
"category": {
"id": "workloads",
}
}
```

Expand All @@ -684,23 +682,23 @@ It accepts an Extension Manifest either in `yaml` or `json` format
<summary>Example YAML Manifest</summary>

```yaml
name: "Extension 1"
description: "My extension 1"
entry: "https://example.com/"
contexts:
name: Extension 1
description: My extension 1
entry: https://example.com/
activationContexts:
- project
routes:
- id: "extension-1"
parentId: "workloads"
locationId: "runtime"
labelIntl:
en: "SomeLabel"
it: "SomeLabelInItalian"
destinationPath: "/"
renderType: "menu"
order: 200
icon:
name: "PiHardDrives"
destination:
id: runtime
path: "/"
iconName: PiHardDrives
menu:
id: extension-1
labelIntl:
en: SomeLabel
it: SomeLabelInItalian
order: 200
category:
id: workloads
```
</details>
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/extensions/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ If an extension-id is found an updated is performed, if not instead a new extens
extensionData.ExtensionID = o.EntityID
}

if extensionData.ExtensionType == "" {
extensionData.ExtensionType = IFrameExtensionType
if extensionData.Type == "" {
extensionData.Type = IFrameExtensionType
}

extensibilityClient := New(client)
Expand Down
37 changes: 19 additions & 18 deletions internal/cmd/extensions/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,27 @@ import (
)

func TestReadExtensionFromFile(t *testing.T) {
order := 200.0
var order extensibility.Order = 200.0
expectedRecord := &extensibility.Extension{
Name: "Extension 1",
Description: "My extension 1",
Entry: "https://example.com/",
Contexts: []string{"project"},
Routes: []*extensibility.ExtensionRoute{
{
ID: "extension-1",
ParentID: "workloads",
LocationID: "runtime",
LabelIntl: map[string]string{
"en": "SomeLabel",
"it": "SomeLabelInItalian",
},
DestinationPath: "/",
RenderType: "menu",
Order: &order,
Icon: &extensibility.Icon{Name: "PiHardDrives"},
Name: "Extension 1",
Description: "My extension 1",
Entry: "https://example.com/",
ActivationContexts: []extensibility.Context{"project"},
Destination: extensibility.DestinationArea{
ID: "runtime",
Path: "/",
},
IconName: "PiHardDrives",
Menu: extensibility.Menu{
ID: "extension-1",
LabelIntl: extensibility.IntlMessages{
extensibility.En: "SomeLabel",
extensibility.It: "SomeLabelInItalian",
},
Order: &order,
},
Category: &extensibility.Category{
ID: "workloads",
},
}

Expand Down
37 changes: 18 additions & 19 deletions internal/cmd/extensions/testdata/valid-extension.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
{
"name": "Extension 1",
"description": "My extension 1",
"entry": "https://example.com/",
"contexts": [
"description": "My extension 1",
"activationContexts": [
"project"
],
"routes": [
{
"id": "extension-1",
"parentId": "workloads",
"locationId": "runtime",
"renderType": "menu",
"labelIntl": {
"en": "SomeLabel",
"it": "SomeLabelInItalian"
},
"destinationPath": "/",
"order": 200.0,
"icon": {
"name": "PiHardDrives"
}
}
]
"iconName": "PiHardDrives",
"destination": {
"id": "runtime",
"path": "/"
},
"menu": {
"id": "extension-1",
"labelIntl": {
"en": "SomeLabel",
"it": "SomeLabelInItalian"
},
"order": 200.0
},
"category": {
"id": "workloads"
}
}
32 changes: 16 additions & 16 deletions internal/cmd/extensions/testdata/valid-extension.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: "Extension 1"
description: "My extension 1"
entry: "https://example.com/"
contexts:
name: Extension 1
entry: https://example.com/
description: My extension 1
activationContexts:
- project
routes:
- id: "extension-1"
parentId: "workloads"
locationId: "runtime"
labelIntl:
en: "SomeLabel"
it: "SomeLabelInItalian"
destinationPath: "/"
renderType: "menu"
order: 200
icon:
name: "PiHardDrives"
iconName: PiHardDrives
destination:
id: runtime
path: "/"
menu:
id: extension-1
labelIntl:
en: SomeLabel
it: SomeLabelInItalian
order: 200
category:
id: workloads
42 changes: 22 additions & 20 deletions internal/resources/extensibility/extensionInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type Order float64
type Context string

type DestinationArea struct {
ID string `json:"id" yaml:"id"`
ID string `yaml:"id" json:"id" `
Path string `yaml:"path" json:"path"`
}
type Languages string

Expand All @@ -33,32 +34,33 @@ const (
type IntlMessages map[Languages]string

type Visibility struct {
ContextType Context `json:"contextType" yaml:"contextType"`
ContextID string `json:"contextId" yaml:"contextId"`
ContextType Context `yaml:"contextType" json:"contextType"`
ContextID string `yaml:"contextId" json:"contextId"`
}

type Category struct {
ID string `json:"id" yaml:"id"`
LabelIntl IntlMessages `json:"labelIntl,omitempty" yaml:"labelIntl,omitempty"`
ID string `yaml:"id" json:"id" `
LabelIntl IntlMessages `yaml:"labelIntl,omitempty" json:"labelIntl,omitempty"`
Order *Order `yaml:"order,omitempty" json:"order,omitempty"`
}

type Menu struct {
ID string `json:"id" yaml:"id"`
LabelIntl IntlMessages `json:"labelIntl" yaml:"labelIntl"`
Order *Order `json:"order,omitempty" yaml:"order,omitempty"`
ID string `yaml:"id" json:"id"`
LabelIntl IntlMessages `yaml:"labelIntl" json:"labelIntl"`
Order *Order `yaml:"order,omitempty" json:"order,omitempty"`
}

type ExtensionInfo struct {
ExtensionID string `json:"extensionId" yaml:"extensionId"`
Name string `json:"name" yaml:"name"`
Entry string `json:"entry" yaml:"entry"`
Type string `json:"type" yaml:"type"`
Destination DestinationArea `json:"destination" yaml:"destination"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
IconName string `json:"iconName,omitempty" yaml:"iconName,omitempty"`
ActivationContexts []Context `json:"activationContexts" yaml:"activationContexts"`
Permissions []string `json:"permissions,omitempty" yaml:"permissions,omitempty"`
Visibilities []Visibility `json:"visibilities,omitempty" yaml:"visibilities,omitempty"`
Category *Category `json:"category,omitempty" yaml:"category,omitempty"`
Menu *Menu `json:"menu,omitempty" yaml:"menu"`
ExtensionID string `yaml:"extensionId" json:"extensionId"`
Name string `yaml:"name" json:"name"`
Entry string `yaml:"entry" json:"entry"`
Type string `yaml:"type" json:"type"`
Destination DestinationArea `yaml:"destination" json:"destination"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"`
ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"`
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
Visibilities []Visibility `yaml:"visibilities,omitempty" json:"visibilities,omitempty"`
Category *Category `yaml:"category,omitempty" json:"category,omitempty"`
Menu *Menu `yaml:"menu" json:"menu,omitempty"`
}
19 changes: 11 additions & 8 deletions internal/resources/extensibility/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
package extensibility

type Extension struct {
ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"`
ExtensionType string `yaml:"extensionType,omitempty" json:"extensionType,omitempty"`
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Entry string `yaml:"entry" json:"entry"`
Contexts []string `yaml:"contexts" json:"contexts"`
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
Routes []*ExtensionRoute `yaml:"routes,omitempty" json:"routes,omitempty"`
ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"`
Name string `yaml:"name" json:"name"`
Entry string `yaml:"entry" json:"entry"`
Type string `yaml:"type" json:"type"`
Destination DestinationArea `yaml:"destination" json:"destination"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"`
ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"`
Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"`
Category *Category `yaml:"category,omitempty" json:"category,omitempty"`
Menu Menu `yaml:"menu" json:"menu"`
}

type Icon struct {
Expand Down

0 comments on commit 7e79367

Please sign in to comment.