From a9ec5d2c73e6b806d792e104fd2c713767e372df Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 18 Dec 2017 17:58:30 -0800 Subject: [PATCH 1/2] Complete site's build settings. The build settings is basically a repository into object underneath. This changes the definition to reuse the RepoInfo struct. `repo_branch` is used a read/write attribute to set the production branch for a site. Signed-off-by: David Calavera --- go/models/repo_info.go | 121 ++++++++++++++++++++++++++++++++++++++++ go/models/site.go | 70 +---------------------- go/models/site_setup.go | 6 +- swagger.yml | 25 ++++----- ui/swagger.json | 38 +++++-------- 5 files changed, 150 insertions(+), 110 deletions(-) create mode 100644 go/models/repo_info.go diff --git a/go/models/repo_info.go b/go/models/repo_info.go new file mode 100644 index 00000000..8b5f7504 --- /dev/null +++ b/go/models/repo_info.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// RepoInfo repo info +// swagger:model repoInfo + +type RepoInfo struct { + + // allowed branches + AllowedBranches []string `json:"allowed_branches"` + + // cmd + Cmd string `json:"cmd,omitempty"` + + // deploy key id + DeployKeyID string `json:"deploy_key_id,omitempty"` + + // dir + Dir string `json:"dir,omitempty"` + + // env + Env map[string]string `json:"env,omitempty"` + + // id + ID int64 `json:"id,omitempty"` + + // private logs + PrivateLogs bool `json:"private_logs,omitempty"` + + // provider + Provider string `json:"provider,omitempty"` + + // public repo + PublicRepo bool `json:"public_repo,omitempty"` + + // repo + Repo string `json:"repo,omitempty"` + + // repo branch + RepoBranch string `json:"repo_branch,omitempty"` + + // repo url + RepoURL string `json:"repo_url,omitempty"` +} + +/* polymorph repoInfo allowed_branches false */ + +/* polymorph repoInfo cmd false */ + +/* polymorph repoInfo deploy_key_id false */ + +/* polymorph repoInfo dir false */ + +/* polymorph repoInfo env false */ + +/* polymorph repoInfo id false */ + +/* polymorph repoInfo private_logs false */ + +/* polymorph repoInfo provider false */ + +/* polymorph repoInfo public_repo false */ + +/* polymorph repoInfo repo false */ + +/* polymorph repoInfo repo_branch false */ + +/* polymorph repoInfo repo_url false */ + +// Validate validates this repo info +func (m *RepoInfo) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAllowedBranches(formats); err != nil { + // prop + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RepoInfo) validateAllowedBranches(formats strfmt.Registry) error { + + if swag.IsZero(m.AllowedBranches) { // not required + return nil + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RepoInfo) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RepoInfo) UnmarshalBinary(b []byte) error { + var res RepoInfo + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/models/site.go b/go/models/site.go index 46ed1144..515e19df 100644 --- a/go/models/site.go +++ b/go/models/site.go @@ -27,7 +27,7 @@ type Site struct { AdminURL string `json:"admin_url,omitempty"` // build settings - BuildSettings *SiteBuildSettings `json:"build_settings,omitempty"` + BuildSettings *RepoInfo `json:"build_settings,omitempty"` // capabilities Capabilities map[string]interface{} `json:"capabilities,omitempty"` @@ -272,74 +272,6 @@ func (m *Site) UnmarshalBinary(b []byte) error { return nil } -// SiteBuildSettings site build settings -// swagger:model SiteBuildSettings - -type SiteBuildSettings struct { - - // allowed branches - AllowedBranches []string `json:"allowed_branches"` - - // branch - Branch string `json:"branch,omitempty"` - - // cmd - Cmd string `json:"cmd,omitempty"` - - // dir - Dir string `json:"dir,omitempty"` -} - -/* polymorph SiteBuildSettings allowed_branches false */ - -/* polymorph SiteBuildSettings branch false */ - -/* polymorph SiteBuildSettings cmd false */ - -/* polymorph SiteBuildSettings dir false */ - -// Validate validates this site build settings -func (m *SiteBuildSettings) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAllowedBranches(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SiteBuildSettings) validateAllowedBranches(formats strfmt.Registry) error { - - if swag.IsZero(m.AllowedBranches) { // not required - return nil - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SiteBuildSettings) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SiteBuildSettings) UnmarshalBinary(b []byte) error { - var res SiteBuildSettings - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} - // SiteProcessingSettings site processing settings // swagger:model SiteProcessingSettings diff --git a/go/models/site_setup.go b/go/models/site_setup.go index 19eb30ac..19514333 100644 --- a/go/models/site_setup.go +++ b/go/models/site_setup.go @@ -19,7 +19,7 @@ type SiteSetup struct { Site // repo - Repo *RepoSetup `json:"repo,omitempty"` + Repo *RepoInfo `json:"repo,omitempty"` } // UnmarshalJSON unmarshals this object from a JSON structure @@ -32,7 +32,7 @@ func (m *SiteSetup) UnmarshalJSON(raw []byte) error { m.Site = aO0 var data struct { - Repo *RepoSetup `json:"repo,omitempty"` + Repo *RepoInfo `json:"repo,omitempty"` } if err := swag.ReadJSON(raw, &data); err != nil { return err @@ -54,7 +54,7 @@ func (m SiteSetup) MarshalJSON() ([]byte, error) { _parts = append(_parts, aO0) var data struct { - Repo *RepoSetup `json:"repo,omitempty"` + Repo *RepoInfo `json:"repo,omitempty"` } data.Repo = m.Repo diff --git a/swagger.yml b/swagger.yml index 2ae88d6a..53d93c71 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1406,25 +1406,14 @@ definitions: pretty_urls: type: boolean build_settings: - type: object - properties: - branch: - type: string - dir: - type: string - cmd: - type: string - allowed_branches: - type: array - items: - type: string + $ref: "#/definitions/repoInfo" siteSetup: allOf: - $ref: "#/definitions/site" - properties: repo: - $ref: "#/definitions/repoSetup" - repoSetup: + $ref: "#/definitions/repoInfo" + repoInfo: type: object properties: id: @@ -1435,7 +1424,7 @@ definitions: type: string repo: type: string - branch: + repo_branch: type: string dir: type: string @@ -1449,6 +1438,12 @@ definitions: type: boolean private_logs: type: boolean + repo_url: + type: string + env: + type: object + additionalProperties: + type: string submission: type: object properties: diff --git a/ui/swagger.json b/ui/swagger.json index ab194f30..06414d9b 100644 --- a/ui/swagger.json +++ b/ui/swagger.json @@ -2752,7 +2752,7 @@ } } }, - "repoSetup": { + "repoInfo": { "type": "object", "properties": { "allowed_branches": { @@ -2761,9 +2761,6 @@ "type": "string" } }, - "branch": { - "type": "string" - }, "cmd": { "type": "string" }, @@ -2773,6 +2770,12 @@ "dir": { "type": "string" }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, "id": { "type": "integer" }, @@ -2787,6 +2790,12 @@ }, "repo": { "type": "string" + }, + "repo_branch": { + "type": "string" + }, + "repo_url": { + "type": "string" } } }, @@ -2803,24 +2812,7 @@ "type": "string" }, "build_settings": { - "type": "object", - "properties": { - "allowed_branches": { - "type": "array", - "items": { - "type": "string" - } - }, - "branch": { - "type": "string" - }, - "cmd": { - "type": "string" - }, - "dir": { - "type": "string" - } - } + "$ref": "#/definitions/repoInfo" }, "capabilities": { "type": "object", @@ -2939,7 +2931,7 @@ { "properties": { "repo": { - "$ref": "#/definitions/repoSetup" + "$ref": "#/definitions/repoInfo" } } } From f6fb5879e2d0616280a6eefdd758f639f0d4bbe6 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Mon, 18 Dec 2017 20:49:55 -0800 Subject: [PATCH 2/2] Remove unused models. Signed-off-by: David Calavera --- go/models/repo_setup.go | 111 -------------------------------- go/models/site_setup_all_of1.go | 73 --------------------- 2 files changed, 184 deletions(-) delete mode 100644 go/models/repo_setup.go delete mode 100644 go/models/site_setup_all_of1.go diff --git a/go/models/repo_setup.go b/go/models/repo_setup.go deleted file mode 100644 index dcfa6f76..00000000 --- a/go/models/repo_setup.go +++ /dev/null @@ -1,111 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// RepoSetup repo setup -// swagger:model repoSetup - -type RepoSetup struct { - - // allowed branches - AllowedBranches []string `json:"allowed_branches"` - - // branch - Branch string `json:"branch,omitempty"` - - // cmd - Cmd string `json:"cmd,omitempty"` - - // deploy key id - DeployKeyID string `json:"deploy_key_id,omitempty"` - - // dir - Dir string `json:"dir,omitempty"` - - // id - ID int64 `json:"id,omitempty"` - - // private logs - PrivateLogs bool `json:"private_logs,omitempty"` - - // provider - Provider string `json:"provider,omitempty"` - - // public repo - PublicRepo bool `json:"public_repo,omitempty"` - - // repo - Repo string `json:"repo,omitempty"` -} - -/* polymorph repoSetup allowed_branches false */ - -/* polymorph repoSetup branch false */ - -/* polymorph repoSetup cmd false */ - -/* polymorph repoSetup deploy_key_id false */ - -/* polymorph repoSetup dir false */ - -/* polymorph repoSetup id false */ - -/* polymorph repoSetup private_logs false */ - -/* polymorph repoSetup provider false */ - -/* polymorph repoSetup public_repo false */ - -/* polymorph repoSetup repo false */ - -// Validate validates this repo setup -func (m *RepoSetup) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAllowedBranches(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *RepoSetup) validateAllowedBranches(formats strfmt.Registry) error { - - if swag.IsZero(m.AllowedBranches) { // not required - return nil - } - - return nil -} - -// MarshalBinary interface implementation -func (m *RepoSetup) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *RepoSetup) UnmarshalBinary(b []byte) error { - var res RepoSetup - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/go/models/site_setup_all_of1.go b/go/models/site_setup_all_of1.go deleted file mode 100644 index 3177ff1b..00000000 --- a/go/models/site_setup_all_of1.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - strfmt "github.com/go-openapi/strfmt" - - "github.com/go-openapi/errors" - "github.com/go-openapi/swag" -) - -// SiteSetupAllOf1 site setup all of1 -// swagger:model siteSetupAllOf1 -type SiteSetupAllOf1 struct { - - // repo - Repo *RepoSetup `json:"repo,omitempty"` -} - -// Validate validates this site setup all of1 -func (m *SiteSetupAllOf1) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateRepo(formats); err != nil { - // prop - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SiteSetupAllOf1) validateRepo(formats strfmt.Registry) error { - - if swag.IsZero(m.Repo) { // not required - return nil - } - - if m.Repo != nil { - - if err := m.Repo.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("repo") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SiteSetupAllOf1) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SiteSetupAllOf1) UnmarshalBinary(b []byte) error { - var res SiteSetupAllOf1 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -}