gitpod-io / gitpod

The developer platform for on-demand cloud development environments to create software faster and more securely.
https://www.gitpod.io
GNU Affero General Public License v3.0
12.71k stars 1.21k forks source link

Generated file is not assign to current file #10203

Open mustard-mh opened 2 years ago

mustard-mh commented 2 years ago

Tech Debt

In this PR https://github.com/gitpod-io/gitpod/pull/9797, we edited gitpod-config-types.go which have content below in its header

// Code generated by schema-generate. DO NOT EDIT.

⁉️ So the question is, should we continue to use this JSON schema generator?

If so, we need to

If not, we need to

Diff

Click to show diff ```diff From a7ba4588f2ec0ab2fc6f678b60dfa236121827af Mon Sep 17 00:00:00 2001 From: mustard Date: Tue, 24 May 2022 05:44:33 +0000 Subject: [PATCH] after gen scirpt --- .../gitpod-protocol/go/gitpod-config-types.go | 670 ++++++++++++++++-- 1 file changed, 602 insertions(+), 68 deletions(-) diff --git a/components/gitpod-protocol/go/gitpod-config-types.go b/components/gitpod-protocol/go/gitpod-config-types.go index f9cd78253cdb..e1227c8a9e7d 100644 --- a/components/gitpod-protocol/go/gitpod-config-types.go +++ b/components/gitpod-protocol/go/gitpod-config-types.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Gitpod GmbH. All rights reserved. +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. // Licensed under the GNU Affero General Public License (AGPL). // See License-AGPL.txt in the project root for license information. @@ -10,10 +10,19 @@ import ( "bytes" "encoding/json" "errors" - - "golang.org/x/xerrors" + "fmt" ) +// AdditionalRepositoriesItems +type AdditionalRepositoriesItems struct { + + // Path to where the repository should be checked out relative to `/workspace`. Defaults to the simple repository name. + CheckoutLocation string `yaml:"checkoutLocation,omitempty"` + + // The url of the git repository to clone. Supports any context URLs. + Url string `yaml:"url"` +} + // Env Environment variables to set. type Env struct { } @@ -28,21 +37,30 @@ type Github struct { // GitpodConfig type GitpodConfig struct { - // Path to where the repository should be checked out. + // List of additional repositories that are part of this project. + AdditionalRepositories []*AdditionalRepositoriesItems `yaml:"additionalRepositories,omitempty"` + + // Path to where the repository should be checked out relative to `/workspace`. Defaults to the simple repository name. CheckoutLocation string `yaml:"checkoutLocation,omitempty"` + // Experimental network configuration in workspaces (deprecated). Enabled by default + ExperimentalNetwork bool `yaml:"experimentalNetwork,omitempty"` + // Git config values should be provided in pairs. E.g. `core.autocrlf: input`. See https://git-scm.com/docs/git-config#_values. GitConfig map[string]string `yaml:"gitConfig,omitempty"` // Configures Gitpod's GitHub app Github *Github `yaml:"github,omitempty"` - // Controls what ide should be used for a workspace. - Ide interface{} `yaml:"ide,omitempty"` - // The Docker image to run your workspace in. Image interface{} `yaml:"image,omitempty"` + // Configure JetBrains integration + Jetbrains *Jetbrains `yaml:"jetbrains,omitempty"` + + // The main repository, containing the dev environment configuration. + MainConfiguration string `yaml:"mainConfiguration,omitempty"` + // List of exposed ports. Ports []*PortsItems `yaml:"ports,omitempty"` @@ -52,13 +70,20 @@ type GitpodConfig struct { // Configure VS Code integration Vscode *Vscode `yaml:"vscode,omitempty"` - // Configure JetBrains integration - JetBrains *JetBrains `yaml:"jetbrains,omitempty"` - - // Path to where the IDE's workspace should be opened. + // Path to where the IDE's workspace should be opened. Supports vscode's `*.code-workspace` files. WorkspaceLocation string `yaml:"workspaceLocation,omitempty"` } +// Goland Configure GoLand integration +type Goland struct { + + // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. + Plugins []string `yaml:"plugins,omitempty"` + + // Enable warming up of GoLand in prebuilds. + Prebuilds *Prebuilds `yaml:"prebuilds,omitempty"` +} + // Image_object The Docker image to run your workspace in. type Image_object struct { @@ -69,10 +94,52 @@ type Image_object struct { File string `yaml:"file"` } +// Intellij Configure IntelliJ integration +type Intellij struct { + + // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. + Plugins []string `yaml:"plugins,omitempty"` + + // Enable warming up of IntelliJ in prebuilds. + Prebuilds *Prebuilds `yaml:"prebuilds,omitempty"` +} + +// Jetbrains Configure JetBrains integration +type Jetbrains struct { + + // Configure GoLand integration + Goland *Goland `yaml:"goland,omitempty"` + + // Configure IntelliJ integration + Intellij *Intellij `yaml:"intellij,omitempty"` + + // Configure PhpStorm integration + Phpstorm *Phpstorm `yaml:"phpstorm,omitempty"` + + // List of plugins which should be installed for all JetBrains product for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. + Plugins []string `yaml:"plugins,omitempty"` + + // Configure PyCharm integration + Pycharm *Pycharm `yaml:"pycharm,omitempty"` +} + +// Phpstorm Configure PhpStorm integration +type Phpstorm struct { + + // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. + Plugins []string `yaml:"plugins,omitempty"` + + // Enable warming up of PhpStorm in prebuilds. + Prebuilds *Prebuilds `yaml:"prebuilds,omitempty"` +} + // PortsItems type PortsItems struct { - // Port name (deprecated). + // A description to identify what is this port used for. + Description string `yaml:"description,omitempty"` + + // Port name. Name string `yaml:"name,omitempty"` // What to do when a service on this port was detected. 'notify' (default) will show a notification asking the user what to do. 'open-browser' will open a new browser tab. 'open-preview' will open in the preview on the right of the IDE. 'ignore' will do nothing. @@ -84,16 +151,26 @@ type PortsItems struct { // The protocol to be used. (deprecated) Protocol string `yaml:"protocol,omitempty"` - // Whether the port visibility should be private or public. 'public' (default) will allow everyone with the port URL to access the port. 'private' will only allow users with workspace access to access the port. + // Whether the port visibility should be private or public. 'private' (default) will only allow users with workspace access to access the port. 'public' will allow everyone with the port URL to access the port. Visibility string `yaml:"visibility,omitempty"` } +// Prebuilds Enable warming up of PhpStorm in prebuilds. +type Prebuilds struct { + + // Whether only stable, latest or both versions should be warmed up. Default is stable only. + Version string `yaml:"version,omitempty"` +} + // Prebuilds_object Set to true to enable workspace prebuilds, false to disable them. Defaults to true. type Prebuilds_object struct { // Add a Review in Gitpod badge to pull requests. Defaults to true. AddBadge bool `yaml:"addBadge,omitempty"` + // Add a commit check to pull requests. Set to 'fail-on-error' if you want broken prebuilds to block merging. Defaults to true. + AddCheck interface{} `yaml:"addCheck,omitempty"` + // Add a label to a PR when it's prebuilt. Set to true to use the default label (prebuilt-in-gitpod) or set to a string to use a different label name. This is a beta feature and may be unreliable. Defaults to false. AddLabel interface{} `yaml:"addLabel,omitempty"` @@ -110,32 +187,42 @@ type Prebuilds_object struct { PullRequestsFromForks bool `yaml:"pullRequestsFromForks,omitempty"` } +// Pycharm Configure PyCharm integration +type Pycharm struct { + + // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. + Plugins []string `yaml:"plugins,omitempty"` + + // Enable warming up of PyCharm in prebuilds. + Prebuilds *Prebuilds `yaml:"prebuilds,omitempty"` +} + // TasksItems type TasksItems struct { // A shell command to run before `init` and the main `command`. This command is executed on every start and is expected to terminate. If it fails, the following commands will not be executed. - Before string `yaml:"before,omitempty" json:"before,omitempty"` + Before string `yaml:"before,omitempty"` // The main shell command to run after `before` and `init`. This command is executed last on every start and doesn't have to terminate. - Command string `yaml:"command,omitempty" json:"command,omitempty"` + Command string `yaml:"command,omitempty"` // Environment variables to set. - Env *Env `yaml:"env,omitempty" json:"env,omitempty"` + Env *Env `yaml:"env,omitempty"` // A shell command to run between `before` and the main `command`. This command is executed only on after initializing a workspace with a fresh clone, but not on restarts and snapshots. This command is expected to terminate. If it fails, the `command` property will not be executed. - Init string `yaml:"init,omitempty" json:"init,omitempty"` + Init string `yaml:"init,omitempty"` // Name of the task. Shown on the tab of the opened terminal. - Name string `yaml:"name,omitempty" json:"name,omitempty"` + Name string `yaml:"name,omitempty"` // The panel/area where to open the terminal. Default is 'bottom' panel. - OpenIn string `yaml:"openIn,omitempty" json:"openIn,omitempty"` + OpenIn string `yaml:"openIn,omitempty"` // The opening mode. Default is 'tab-after'. - OpenMode string `yaml:"openMode,omitempty" json:"openMode,omitempty"` + OpenMode string `yaml:"openMode,omitempty"` // A shell command to run after `before`. This command is executed only on during workspace prebuilds. This command is expected to terminate. If it fails, the workspace build fails. - Prebuild string `yaml:"prebuild,omitempty" json:"prebuild,omitempty"` + Prebuild string `yaml:"prebuild,omitempty"` } // Vscode Configure VS Code integration @@ -145,40 +232,67 @@ type Vscode struct { Extensions []string `yaml:"extensions,omitempty"` } -// Configure JetBrains integration -type JetBrains struct { - - // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. - Plugins []string `yaml:"plugins,omitempty"` - - // Configure IntelliJ integration - IntelliJ *JetBrainsProduct `yaml:"intellij,omitempty"` - - // Configure GoLand integration - GoLand *JetBrainsProduct `yaml:"goland,omitempty"` - - // Configure PyCharm integration - PyCharm *JetBrainsProduct `yaml:"pycharm,omitempty"` - - // Configure PhpStorm integration - PhpStorm *JetBrainsProduct `yaml:"phpstorm,omitempty"` -} - -// Configure JetBrains product -type JetBrainsProduct struct { - - // List of plugins which should be installed for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. - Plugins []string `yaml:"plugins,omitempty"` +func (strct *AdditionalRepositoriesItems) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "checkoutLocation" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"checkoutLocation\": ") + if tmp, err := json.Marshal(strct.CheckoutLocation); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // "Url" field is required + // only required object types supported for marshal checking (for now) + // Marshal the "url" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"url\": ") + if tmp, err := json.Marshal(strct.Url); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true - // Enable warming up of JetBrains product in prebuilds - Prebuilds *JetBrainsPrebuilds `yaml:"prebuilds,omitempty"` + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil } -// Enable warming up of JetBrains product in prebuilds -type JetBrainsPrebuilds struct { - - // Whether only stable, latest or both versions should be warmed up. - Version string `yaml:"version,omitempty"` +func (strct *AdditionalRepositoriesItems) UnmarshalJSON(b []byte) error { + urlReceived := false + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "checkoutLocation": + if err := json.Unmarshal([]byte(v), &strct.CheckoutLocation); err != nil { + return err + } + case "url": + if err := json.Unmarshal([]byte(v), &strct.Url); err != nil { + return err + } + urlReceived = true + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + // check if url (a required property) was received + if !urlReceived { + return errors.New("\"url\" is required but was not present") + } + return nil } func (strct *Github) MarshalJSON() ([]byte, error) { @@ -215,7 +329,7 @@ func (strct *Github) UnmarshalJSON(b []byte) error { return err } default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } return nil @@ -225,6 +339,17 @@ func (strct *GitpodConfig) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") comma := false + // Marshal the "additionalRepositories" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"additionalRepositories\": ") + if tmp, err := json.Marshal(strct.AdditionalRepositories); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true // Marshal the "checkoutLocation" field if comma { buf.WriteString(",") @@ -236,6 +361,17 @@ func (strct *GitpodConfig) MarshalJSON() ([]byte, error) { buf.Write(tmp) } comma = true + // Marshal the "experimentalNetwork" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"experimentalNetwork\": ") + if tmp, err := json.Marshal(strct.ExperimentalNetwork); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true // Marshal the "gitConfig" field if comma { buf.WriteString(",") @@ -258,23 +394,34 @@ func (strct *GitpodConfig) MarshalJSON() ([]byte, error) { buf.Write(tmp) } comma = true - // Marshal the "ide" field + // Marshal the "image" field if comma { buf.WriteString(",") } - buf.WriteString("\"ide\": ") - if tmp, err := json.Marshal(strct.Ide); err != nil { + buf.WriteString("\"image\": ") + if tmp, err := json.Marshal(strct.Image); err != nil { return nil, err } else { buf.Write(tmp) } comma = true - // Marshal the "image" field + // Marshal the "jetbrains" field if comma { buf.WriteString(",") } - buf.WriteString("\"image\": ") - if tmp, err := json.Marshal(strct.Image); err != nil { + buf.WriteString("\"jetbrains\": ") + if tmp, err := json.Marshal(strct.Jetbrains); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "mainConfiguration" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"mainConfiguration\": ") + if tmp, err := json.Marshal(strct.MainConfiguration); err != nil { return nil, err } else { buf.Write(tmp) @@ -338,10 +485,18 @@ func (strct *GitpodConfig) UnmarshalJSON(b []byte) error { // parse all the defined properties for k, v := range jsonMap { switch k { + case "additionalRepositories": + if err := json.Unmarshal([]byte(v), &strct.AdditionalRepositories); err != nil { + return err + } case "checkoutLocation": if err := json.Unmarshal([]byte(v), &strct.CheckoutLocation); err != nil { return err } + case "experimentalNetwork": + if err := json.Unmarshal([]byte(v), &strct.ExperimentalNetwork); err != nil { + return err + } case "gitConfig": if err := json.Unmarshal([]byte(v), &strct.GitConfig); err != nil { return err @@ -350,14 +505,18 @@ func (strct *GitpodConfig) UnmarshalJSON(b []byte) error { if err := json.Unmarshal([]byte(v), &strct.Github); err != nil { return err } - case "ide": - if err := json.Unmarshal([]byte(v), &strct.Ide); err != nil { - return err - } case "image": if err := json.Unmarshal([]byte(v), &strct.Image); err != nil { return err } + case "jetbrains": + if err := json.Unmarshal([]byte(v), &strct.Jetbrains); err != nil { + return err + } + case "mainConfiguration": + if err := json.Unmarshal([]byte(v), &strct.MainConfiguration); err != nil { + return err + } case "ports": if err := json.Unmarshal([]byte(v), &strct.Ports); err != nil { return err @@ -375,7 +534,62 @@ func (strct *GitpodConfig) UnmarshalJSON(b []byte) error { return err } default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + +func (strct *Goland) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "plugins" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"plugins\": ") + if tmp, err := json.Marshal(strct.Plugins); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "prebuilds" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"prebuilds\": ") + if tmp, err := json.Marshal(strct.Prebuilds); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Goland) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "plugins": + if err := json.Unmarshal([]byte(v), &strct.Plugins); err != nil { + return err + } + case "prebuilds": + if err := json.Unmarshal([]byte(v), &strct.Prebuilds); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } return nil @@ -434,7 +648,7 @@ func (strct *Image_object) UnmarshalJSON(b []byte) error { } fileReceived = true default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } // check if file (a required property) was received @@ -444,10 +658,231 @@ func (strct *Image_object) UnmarshalJSON(b []byte) error { return nil } +func (strct *Intellij) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "plugins" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"plugins\": ") + if tmp, err := json.Marshal(strct.Plugins); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "prebuilds" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"prebuilds\": ") + if tmp, err := json.Marshal(strct.Prebuilds); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Intellij) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "plugins": + if err := json.Unmarshal([]byte(v), &strct.Plugins); err != nil { + return err + } + case "prebuilds": + if err := json.Unmarshal([]byte(v), &strct.Prebuilds); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + +func (strct *Jetbrains) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "goland" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"goland\": ") + if tmp, err := json.Marshal(strct.Goland); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "intellij" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"intellij\": ") + if tmp, err := json.Marshal(strct.Intellij); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "phpstorm" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"phpstorm\": ") + if tmp, err := json.Marshal(strct.Phpstorm); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "plugins" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"plugins\": ") + if tmp, err := json.Marshal(strct.Plugins); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "pycharm" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"pycharm\": ") + if tmp, err := json.Marshal(strct.Pycharm); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Jetbrains) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "goland": + if err := json.Unmarshal([]byte(v), &strct.Goland); err != nil { + return err + } + case "intellij": + if err := json.Unmarshal([]byte(v), &strct.Intellij); err != nil { + return err + } + case "phpstorm": + if err := json.Unmarshal([]byte(v), &strct.Phpstorm); err != nil { + return err + } + case "plugins": + if err := json.Unmarshal([]byte(v), &strct.Plugins); err != nil { + return err + } + case "pycharm": + if err := json.Unmarshal([]byte(v), &strct.Pycharm); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + +func (strct *Phpstorm) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "plugins" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"plugins\": ") + if tmp, err := json.Marshal(strct.Plugins); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "prebuilds" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"prebuilds\": ") + if tmp, err := json.Marshal(strct.Prebuilds); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Phpstorm) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "plugins": + if err := json.Unmarshal([]byte(v), &strct.Plugins); err != nil { + return err + } + case "prebuilds": + if err := json.Unmarshal([]byte(v), &strct.Prebuilds); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + func (strct *PortsItems) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") comma := false + // Marshal the "description" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"description\": ") + if tmp, err := json.Marshal(strct.Description); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true // Marshal the "name" field if comma { buf.WriteString(",") @@ -520,6 +955,10 @@ func (strct *PortsItems) UnmarshalJSON(b []byte) error { // parse all the defined properties for k, v := range jsonMap { switch k { + case "description": + if err := json.Unmarshal([]byte(v), &strct.Description); err != nil { + return err + } case "name": if err := json.Unmarshal([]byte(v), &strct.Name); err != nil { return err @@ -542,7 +981,7 @@ func (strct *PortsItems) UnmarshalJSON(b []byte) error { return err } default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } // check if port (a required property) was received @@ -552,6 +991,101 @@ func (strct *PortsItems) UnmarshalJSON(b []byte) error { return nil } +func (strct *Prebuilds) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "version" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"version\": ") + if tmp, err := json.Marshal(strct.Version); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Prebuilds) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "version": + if err := json.Unmarshal([]byte(v), &strct.Version); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + +func (strct *Pycharm) MarshalJSON() ([]byte, error) { + buf := bytes.NewBuffer(make([]byte, 0)) + buf.WriteString("{") + comma := false + // Marshal the "plugins" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"plugins\": ") + if tmp, err := json.Marshal(strct.Plugins); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + // Marshal the "prebuilds" field + if comma { + buf.WriteString(",") + } + buf.WriteString("\"prebuilds\": ") + if tmp, err := json.Marshal(strct.Prebuilds); err != nil { + return nil, err + } else { + buf.Write(tmp) + } + comma = true + + buf.WriteString("}") + rv := buf.Bytes() + return rv, nil +} + +func (strct *Pycharm) UnmarshalJSON(b []byte) error { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(b, &jsonMap); err != nil { + return err + } + // parse all the defined properties + for k, v := range jsonMap { + switch k { + case "plugins": + if err := json.Unmarshal([]byte(v), &strct.Plugins); err != nil { + return err + } + case "prebuilds": + if err := json.Unmarshal([]byte(v), &strct.Prebuilds); err != nil { + return err + } + default: + return fmt.Errorf("additional property not allowed: \"" + k + "\"") + } + } + return nil +} + func (strct *TasksItems) MarshalJSON() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) buf.WriteString("{") @@ -691,7 +1225,7 @@ func (strct *TasksItems) UnmarshalJSON(b []byte) error { return err } default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } return nil @@ -731,7 +1265,7 @@ func (strct *Vscode) UnmarshalJSON(b []byte) error { return err } default: - return xerrors.Errorf("additional property not allowed: \"" + k + "\"") + return fmt.Errorf("additional property not allowed: \"" + k + "\"") } } return nil ```
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.