"job_info.go",
"job_sort_by.go",
"job_status.go",
- "sort_order.go"]
+ "sort_order.go",
+ "version.go"]
}
--- /dev/null
+Release 0.1.0 - Fri Oct. 12 2018 - Paweł Wieczorek <p.wieczorek2@samsung.com>
+=============================================================================
+* Basic LAVA YAML job description support:
+ - Deploy (including partition mapping)
+ - Boot (with login and prompt variants)
+ - Test (run/push/pull actions)
+* Requesting DUT from Boruta based on "device_type" capability
+* Obtaining and storing job assets and artifacts locally
+* Sharing assets and artifacts with reverse SSHFS
+* Dryad requirements (under /usr/local/bin path):
+ - stm (for power controlling actions: -dut/-ts/-tick)
+ - fota (supporting mapping-based selective flashing)
+ - dut_boot.sh
+ - dut_login.sh
+ - dut_copyto.sh
+ - dut_copyfrom.sh
+ - dut_exec.sh
+* HTTP API v1:
+ - jobs: create new, cancel, list with filtering and sorting (paginated)
+ - artifacts: list with filtering and sorting (paginated)
revision = "de5bf2ad457846296e2031421a34e2568e304e35"
[[projects]]
- branch = "master"
- digest = "1:21e19132c685b8bad36ed74108e27f572a03e4d4a45ae11d592351de87808b49"
+ digest = "1:dddcbd3558fd08155e8a65399c5453777cdc726cce88ea746cee1902ec47819c"
name = "github.com/SamsungSLAV/boruta"
packages = [
".",
"http/client",
]
pruneopts = ""
- revision = "3dd45a88179118f23e5e097ceec5483c493748aa"
+ revision = "0303d3264d97bc7af3151f570dff6ddc7e1dd900"
+ version = "v0.1.0"
[[projects]]
digest = "1:d8a2bb36a048d1571bcc1aee208b61f39dc16c6c53823feffd37449dde162507"
]
[[constraint]]
+name = "github.com/SamsungSLAV/boruta"
+version = "v0.1.0"
+
+[[constraint]]
name = "github.com/golang/mock"
version = "v1.1.1"
flag "github.com/spf13/pflag"
"github.com/SamsungSLAV/boruta/http/client"
+ "github.com/SamsungSLAV/weles"
"github.com/SamsungSLAV/weles/artifacts"
"github.com/SamsungSLAV/weles/controller"
"github.com/SamsungSLAV/weles/manager"
artifactDownloadQueueCap int
activeWorkersCap int
notifierChannelCap int
+ version bool
)
// This file was generated by the swagger tool.
flag.IntVar(¬ifierChannelCap, "notifier-channel-cap", 100, "Notifier channel capacity.")
+ flag.BoolVar(&version, "version", false, "Print Weles server version and exit.")
+
//TODO: input validation
flag.Usage = func() {
// parse the CLI flags
flag.Parse()
+ if version {
+ fmt.Println("weles version", weles.SrvVersion)
+ os.Exit(0)
+ }
+
var yap parser.Parser
am, err := artifacts.NewArtifactManager(
artifactDBName,
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
+ "github.com/SamsungSLAV/weles"
"github.com/SamsungSLAV/weles/server/operations"
"github.com/SamsungSLAV/weles/server/operations/artifacts"
+ "github.com/SamsungSLAV/weles/server/operations/general"
"github.com/SamsungSLAV/weles/server/operations/jobs"
)
+const (
+ apiVersion = "v1"
+ apiState = weles.VersionStateDevel
+)
+
func configureFlags(api *operations.WelesAPI) {
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
}
api.ArtifactsArtifactListerHandler = artifacts.ArtifactListerHandlerFunc(a.ArtifactLister)
+ api.GeneralVersionHandler = general.VersionHandlerFunc(a.Version)
+
api.ServerShutdown = func() {}
return setupGlobalMiddleware(api.Serve(setupMiddlewares))
http
Host: localhost:8088
BasePath: /api/v1
- Version: 0.0.0
+ Version: v1
License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html
Contact: <tbd@tbd.com>
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
- "version": "0.0.0"
+ "version": "v1"
},
"host": "localhost:8088",
"basePath": "/api/v1",
}
}
}
+ },
+ "/version": {
+ "get": {
+ "description": "Version and state of API (e.g. v1 obsolete, v2 stable, v3 devel) and server version.",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "general"
+ ],
+ "summary": "Show current version of Weles internals",
+ "operationId": "Version",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Version"
+ },
+ "headers": {
+ "Weles-API-State": {
+ "type": "string",
+ "description": "State of Weles API."
+ },
+ "Weles-API-Version": {
+ "type": "string",
+ "description": "Version of Weles API."
+ },
+ "Weles-Server-Version": {
+ "type": "string",
+ "description": "Version of Weles server."
+ }
+ }
+ },
+ "500": {
+ "$ref": "#/responses/InternalServer"
+ }
+ }
+ }
}
},
"definitions": {
"Ascending",
"Descending"
]
+ },
+ "Version": {
+ "description": "defines version of Weles API (and its state) and server.\n",
+ "type": "object",
+ "properties": {
+ "API": {
+ "description": "Version of Weles API.",
+ "type": "string"
+ },
+ "Server": {
+ "description": "Version of Weles server.",
+ "type": "string"
+ },
+ "State": {
+ "description": "State of Weles API.",
+ "type": "string",
+ "enum": [
+ "devel",
+ "stable",
+ "deprecated"
+ ]
+ }
+ }
}
},
"responses": {
{
"description": "Info about all artifacts used by Weles jobs.",
"name": "artifacts"
+ },
+ {
+ "description": "Info about Weles (e.g. version)",
+ "name": "general"
}
],
"externalDocs": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
- "version": "0.0.0"
+ "version": "v1"
},
"host": "localhost:8088",
"basePath": "/api/v1",
}
}
}
+ },
+ "/version": {
+ "get": {
+ "description": "Version and state of API (e.g. v1 obsolete, v2 stable, v3 devel) and server version.",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "general"
+ ],
+ "summary": "Show current version of Weles internals",
+ "operationId": "Version",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/Version"
+ },
+ "headers": {
+ "Weles-API-State": {
+ "type": "string",
+ "description": "State of Weles API."
+ },
+ "Weles-API-Version": {
+ "type": "string",
+ "description": "Version of Weles API."
+ },
+ "Weles-Server-Version": {
+ "type": "string",
+ "description": "Version of Weles server."
+ }
+ }
+ },
+ "500": {
+ "description": "Internal Server error",
+ "schema": {
+ "$ref": "#/definitions/ErrResponse"
+ }
+ }
+ }
+ }
}
},
"definitions": {
"Ascending",
"Descending"
]
+ },
+ "Version": {
+ "description": "defines version of Weles API (and its state) and server.\n",
+ "type": "object",
+ "properties": {
+ "API": {
+ "description": "Version of Weles API.",
+ "type": "string"
+ },
+ "Server": {
+ "description": "Version of Weles server.",
+ "type": "string"
+ },
+ "State": {
+ "description": "State of Weles API.",
+ "type": "string",
+ "enum": [
+ "devel",
+ "stable",
+ "deprecated"
+ ]
+ }
+ }
}
},
"responses": {
{
"description": "Info about all artifacts used by Weles jobs.",
"name": "artifacts"
+ },
+ {
+ "description": "Info about Weles (e.g. version)",
+ "name": "general"
}
],
"externalDocs": {
--- /dev/null
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 general
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the generate command
+
+import (
+ "net/http"
+
+ middleware "github.com/go-openapi/runtime/middleware"
+)
+
+// VersionHandlerFunc turns a function with the right signature into a version handler
+type VersionHandlerFunc func(VersionParams) middleware.Responder
+
+// Handle executing the request and returning a response
+func (fn VersionHandlerFunc) Handle(params VersionParams) middleware.Responder {
+ return fn(params)
+}
+
+// VersionHandler interface for that can handle valid version params
+type VersionHandler interface {
+ Handle(VersionParams) middleware.Responder
+}
+
+// NewVersion creates a new http.Handler for the version operation
+func NewVersion(ctx *middleware.Context, handler VersionHandler) *Version {
+ return &Version{Context: ctx, Handler: handler}
+}
+
+/*Version swagger:route GET /version general version
+
+Show current version of Weles internals
+
+Version and state of API (e.g. v1 obsolete, v2 stable, v3 devel) and server version.
+
+*/
+type Version struct {
+ Context *middleware.Context
+ Handler VersionHandler
+}
+
+func (o *Version) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
+ route, rCtx, _ := o.Context.RouteInfo(r)
+ if rCtx != nil {
+ r = rCtx
+ }
+ var Params = NewVersionParams()
+
+ if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
+ o.Context.Respond(rw, r, route.Produces, route, err)
+ return
+ }
+
+ res := o.Handler.Handle(Params) // actually handle the request
+
+ o.Context.Respond(rw, r, route.Produces, route, res)
+
+}
--- /dev/null
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 general
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "net/http"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/runtime/middleware"
+)
+
+// NewVersionParams creates a new VersionParams object
+// no default values defined in spec.
+func NewVersionParams() VersionParams {
+
+ return VersionParams{}
+}
+
+// VersionParams contains all the bound params for the version operation
+// typically these are obtained from a http.Request
+//
+// swagger:parameters Version
+type VersionParams struct {
+
+ // HTTP Request Object
+ HTTPRequest *http.Request `json:"-"`
+}
+
+// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
+// for simple values it will use straight method calls.
+//
+// To ensure default values, the struct must have been initialized with NewVersionParams() beforehand.
+func (o *VersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
+ var res []error
+
+ o.HTTPRequest = r
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
--- /dev/null
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 general
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "net/http"
+
+ "github.com/go-openapi/runtime"
+
+ weles "github.com/SamsungSLAV/weles"
+)
+
+// VersionOKCode is the HTTP code returned for type VersionOK
+const VersionOKCode int = 200
+
+/*VersionOK OK
+
+swagger:response versionOK
+*/
+type VersionOK struct {
+ /*State of Weles API.
+
+ */
+ WelesAPIState string `json:"Weles-API-State"`
+ /*Version of Weles API.
+
+ */
+ WelesAPIVersion string `json:"Weles-API-Version"`
+ /*Version of Weles server.
+
+ */
+ WelesServerVersion string `json:"Weles-Server-Version"`
+
+ /*
+ In: Body
+ */
+ Payload *weles.Version `json:"body,omitempty"`
+}
+
+// NewVersionOK creates VersionOK with default headers values
+func NewVersionOK() *VersionOK {
+
+ return &VersionOK{}
+}
+
+// WithWelesAPIState adds the welesApiState to the version o k response
+func (o *VersionOK) WithWelesAPIState(welesAPIState string) *VersionOK {
+ o.WelesAPIState = welesAPIState
+ return o
+}
+
+// SetWelesAPIState sets the welesApiState to the version o k response
+func (o *VersionOK) SetWelesAPIState(welesAPIState string) {
+ o.WelesAPIState = welesAPIState
+}
+
+// WithWelesAPIVersion adds the welesApiVersion to the version o k response
+func (o *VersionOK) WithWelesAPIVersion(welesAPIVersion string) *VersionOK {
+ o.WelesAPIVersion = welesAPIVersion
+ return o
+}
+
+// SetWelesAPIVersion sets the welesApiVersion to the version o k response
+func (o *VersionOK) SetWelesAPIVersion(welesAPIVersion string) {
+ o.WelesAPIVersion = welesAPIVersion
+}
+
+// WithWelesServerVersion adds the welesServerVersion to the version o k response
+func (o *VersionOK) WithWelesServerVersion(welesServerVersion string) *VersionOK {
+ o.WelesServerVersion = welesServerVersion
+ return o
+}
+
+// SetWelesServerVersion sets the welesServerVersion to the version o k response
+func (o *VersionOK) SetWelesServerVersion(welesServerVersion string) {
+ o.WelesServerVersion = welesServerVersion
+}
+
+// WithPayload adds the payload to the version o k response
+func (o *VersionOK) WithPayload(payload *weles.Version) *VersionOK {
+ o.Payload = payload
+ return o
+}
+
+// SetPayload sets the payload to the version o k response
+func (o *VersionOK) SetPayload(payload *weles.Version) {
+ o.Payload = payload
+}
+
+// WriteResponse to the client
+func (o *VersionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
+
+ // response header Weles-API-State
+
+ welesAPIState := o.WelesAPIState
+ if welesAPIState != "" {
+ rw.Header().Set("Weles-API-State", welesAPIState)
+ }
+
+ // response header Weles-API-Version
+
+ welesAPIVersion := o.WelesAPIVersion
+ if welesAPIVersion != "" {
+ rw.Header().Set("Weles-API-Version", welesAPIVersion)
+ }
+
+ // response header Weles-Server-Version
+
+ welesServerVersion := o.WelesServerVersion
+ if welesServerVersion != "" {
+ rw.Header().Set("Weles-Server-Version", welesServerVersion)
+ }
+
+ rw.WriteHeader(200)
+ if o.Payload != nil {
+ payload := o.Payload
+ if err := producer.Produce(rw, payload); err != nil {
+ panic(err) // let the recovery middleware deal with this
+ }
+ }
+}
+
+// VersionInternalServerErrorCode is the HTTP code returned for type VersionInternalServerError
+const VersionInternalServerErrorCode int = 500
+
+/*VersionInternalServerError Internal Server error
+
+swagger:response versionInternalServerError
+*/
+type VersionInternalServerError struct {
+
+ /*
+ In: Body
+ */
+ Payload *weles.ErrResponse `json:"body,omitempty"`
+}
+
+// NewVersionInternalServerError creates VersionInternalServerError with default headers values
+func NewVersionInternalServerError() *VersionInternalServerError {
+
+ return &VersionInternalServerError{}
+}
+
+// WithPayload adds the payload to the version internal server error response
+func (o *VersionInternalServerError) WithPayload(payload *weles.ErrResponse) *VersionInternalServerError {
+ o.Payload = payload
+ return o
+}
+
+// SetPayload sets the payload to the version internal server error response
+func (o *VersionInternalServerError) SetPayload(payload *weles.ErrResponse) {
+ o.Payload = payload
+}
+
+// WriteResponse to the client
+func (o *VersionInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
+
+ rw.WriteHeader(500)
+ if o.Payload != nil {
+ payload := o.Payload
+ if err := producer.Produce(rw, payload); err != nil {
+ panic(err) // let the recovery middleware deal with this
+ }
+ }
+}
--- /dev/null
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 general
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the generate command
+
+import (
+ "errors"
+ "net/url"
+ golangswaggerpaths "path"
+)
+
+// VersionURL generates an URL for the version operation
+type VersionURL struct {
+ _basePath string
+}
+
+// WithBasePath sets the base path for this url builder, only required when it's different from the
+// base path specified in the swagger spec.
+// When the value of the base path is an empty string
+func (o *VersionURL) WithBasePath(bp string) *VersionURL {
+ o.SetBasePath(bp)
+ return o
+}
+
+// SetBasePath sets the base path for this url builder, only required when it's different from the
+// base path specified in the swagger spec.
+// When the value of the base path is an empty string
+func (o *VersionURL) SetBasePath(bp string) {
+ o._basePath = bp
+}
+
+// Build a url path and query string
+func (o *VersionURL) Build() (*url.URL, error) {
+ var result url.URL
+
+ var _path = "/version"
+
+ _basePath := o._basePath
+ if _basePath == "" {
+ _basePath = "/api/v1"
+ }
+ result.Path = golangswaggerpaths.Join(_basePath, _path)
+
+ return &result, nil
+}
+
+// Must is a helper function to panic when the url builder returns an error
+func (o *VersionURL) Must(u *url.URL, err error) *url.URL {
+ if err != nil {
+ panic(err)
+ }
+ if u == nil {
+ panic("url can't be nil")
+ }
+ return u
+}
+
+// String returns the string representation of the path with query string
+func (o *VersionURL) String() string {
+ return o.Must(o.Build()).String()
+}
+
+// BuildFull builds a full url with scheme, host, path and query string
+func (o *VersionURL) BuildFull(scheme, host string) (*url.URL, error) {
+ if scheme == "" {
+ return nil, errors.New("scheme is required for a full url on VersionURL")
+ }
+ if host == "" {
+ return nil, errors.New("host is required for a full url on VersionURL")
+ }
+
+ base, err := o.Build()
+ if err != nil {
+ return nil, err
+ }
+
+ base.Scheme = scheme
+ base.Host = host
+ return base, nil
+}
+
+// StringFull returns the string representation of a complete url
+func (o *VersionURL) StringFull(scheme, host string) string {
+ return o.Must(o.BuildFull(scheme, host)).String()
+}
"github.com/go-openapi/swag"
"github.com/SamsungSLAV/weles/server/operations/artifacts"
+ "github.com/SamsungSLAV/weles/server/operations/general"
"github.com/SamsungSLAV/weles/server/operations/jobs"
)
JobsJobListerHandler: jobs.JobListerHandlerFunc(func(params jobs.JobListerParams) middleware.Responder {
return middleware.NotImplemented("operation JobsJobLister has not yet been implemented")
}),
+ GeneralVersionHandler: general.VersionHandlerFunc(func(params general.VersionParams) middleware.Responder {
+ return middleware.NotImplemented("operation GeneralVersion has not yet been implemented")
+ }),
}
}
JobsJobCreatorHandler jobs.JobCreatorHandler
// JobsJobListerHandler sets the operation handler for the job lister operation
JobsJobListerHandler jobs.JobListerHandler
+ // GeneralVersionHandler sets the operation handler for the version operation
+ GeneralVersionHandler general.VersionHandler
// ServeError is called when an error is received, there is a default handler
// but you can set your own with this
unregistered = append(unregistered, "jobs.JobListerHandler")
}
+ if o.GeneralVersionHandler == nil {
+ unregistered = append(unregistered, "general.VersionHandler")
+ }
+
if len(unregistered) > 0 {
return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
}
}
o.handlers["POST"]["/jobs/list"] = jobs.NewJobLister(o.context, o.JobsJobListerHandler)
+ if o.handlers["GET"] == nil {
+ o.handlers["GET"] = make(map[string]http.Handler)
+ }
+ o.handlers["GET"]["/version"] = general.NewVersion(o.context, o.GeneralVersionHandler)
+
}
// Serve creates a http handler to serve the API over HTTP
--- /dev/null
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 server
+
+import (
+ "github.com/go-openapi/runtime/middleware"
+
+ "github.com/SamsungSLAV/weles"
+ "github.com/SamsungSLAV/weles/server/operations/general"
+)
+
+// Version is Weles version information API endpoint handler.
+func (a *APIDefaults) Version(params general.VersionParams) middleware.Responder {
+ var v = &weles.Version{
+ Server: weles.SrvVersion,
+ API: apiVersion,
+ State: apiState,
+ }
+
+ return general.NewVersionOK().WithPayload(v).
+ WithWelesAPIState(v.State).WithWelesAPIVersion(v.API).WithWelesServerVersion(v.Server)
+}
--- /dev/null
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 server_test
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "github.com/SamsungSLAV/weles"
+)
+
+var _ = Describe("VersionHandler", func() {
+ var (
+ testserver *httptest.Server
+ v1on010 = &weles.Version{
+ API: "v1",
+ State: "devel",
+ Server: "0.1.0",
+ }
+ )
+
+ BeforeEach(func() {
+ _, _, _, _, testserver = testServerSetup()
+ })
+
+ AfterEach(func() {
+ testserver.Close()
+ })
+
+ Describe("obtaining information on API and server version", func() {
+ getClientResp := func() (resp *http.Response) {
+ client := testserver.Client()
+
+ req, err := http.NewRequest(http.MethodGet, testserver.URL+"/api/v1/version", nil)
+ Expect(err).ToNot(HaveOccurred())
+
+ resp, err = client.Do(req)
+ Expect(err).ToNot(HaveOccurred())
+
+ return resp
+ }
+
+ Context("request to v0.1.0 API on v0.1.0 server", func() {
+ It("should respond with proper body and 200 Status Code", func() {
+ resp := getClientResp()
+ Expect(resp.StatusCode).To(Equal(200))
+ Expect(resp.Header).To(HaveKeyWithValue("Weles-Api-Version", []string{v1on010.API}))
+ Expect(resp.Header).To(HaveKeyWithValue("Weles-Api-State", []string{v1on010.State}))
+ Expect(resp.Header).To(HaveKeyWithValue("Weles-Server-Version", []string{v1on010.Server}))
+
+ respBody, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ToNot(HaveOccurred())
+ defer resp.Body.Close()
+
+ versionEncoded, err := json.Marshal(weles.Version{
+ API: v1on010.API,
+ State: v1on010.State,
+ Server: v1on010.Server,
+ })
+ Expect(err).ToNot(HaveOccurred())
+
+ Expect(string(respBody)).To(MatchJSON(string(versionEncoded)))
+ })
+ })
+ })
+})
description: >-
This is a Weles server. You can find out more about Weles at
[http://tbd.tbd](http://tbd.tbd).
- version: 0.0.0
+ version: v1
title: Weles
termsOfService: 'http://tbd.tbd/terms/'
contact:
description: Info and management of Weles jobs.
- name: artifacts
description: Info about all artifacts used by Weles jobs.
+ - name: general
+ description: Info about Weles (e.g. version)
schemes:
- http
paths:
$ref: '#/responses/NotFound'
'500':
$ref: '#/responses/InternalServer'
+ /version:
+ get:
+ tags:
+ - general
+ summary: Show current version of Weles internals
+ description: Version and state of API (e.g. v1 obsolete, v2 stable,
+ v3 devel) and server version.
+ operationId: Version
+ produces:
+ - application/json
+ responses:
+ '200':
+ description: OK
+ schema:
+ $ref: '#/definitions/Version'
+ headers:
+ Weles-Server-Version:
+ type: string
+ description: Version of Weles server.
+ Weles-API-Version:
+ type: string
+ description: Version of Weles API.
+ Weles-API-State:
+ type: string
+ description: State of Weles API.
+ '500':
+ $ref: '#/responses/InternalServer'
responses:
BadRequest:
description: Bad Request
$ref: '#/definitions/ArtifactSortBy'
SortOrder:
$ref: '#/definitions/SortOrder'
+ Version:
+ description: |
+ defines version of Weles API (and its state) and server.
+ type: object
+ properties:
+ Server:
+ description: Version of Weles server.
+ type: string
+ API:
+ description: Version of Weles API.
+ type: string
+ State:
+ description: State of Weles API.
+ type: string
+ enum:
+ - devel
+ - stable
+ - deprecated
externalDocs:
description: TBD
url: 'http://TBD.tbd'
--- /dev/null
+// Code generated by go-swagger; DO NOT EDIT.
+
+// Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved
+//
+// 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 weles
+
+// This file was generated by the swagger tool.
+// Editing this file might prove futile when you re-run the swagger generate command
+
+import (
+ "encoding/json"
+
+ strfmt "github.com/go-openapi/strfmt"
+
+ "github.com/go-openapi/errors"
+ "github.com/go-openapi/swag"
+ "github.com/go-openapi/validate"
+)
+
+// Version defines version of Weles API (and its state) and server.
+//
+// swagger:model Version
+type Version struct {
+
+ // Version of Weles API.
+ API string `json:"API,omitempty"`
+
+ // Version of Weles server.
+ Server string `json:"Server,omitempty"`
+
+ // State of Weles API.
+ // Enum: [devel stable deprecated]
+ State string `json:"State,omitempty"`
+}
+
+// Validate validates this version
+func (m *Version) Validate(formats strfmt.Registry) error {
+ var res []error
+
+ if err := m.validateState(formats); err != nil {
+ res = append(res, err)
+ }
+
+ if len(res) > 0 {
+ return errors.CompositeValidationError(res...)
+ }
+ return nil
+}
+
+var versionTypeStatePropEnum []interface{}
+
+func init() {
+ var res []string
+ if err := json.Unmarshal([]byte(`["devel","stable","deprecated"]`), &res); err != nil {
+ panic(err)
+ }
+ for _, v := range res {
+ versionTypeStatePropEnum = append(versionTypeStatePropEnum, v)
+ }
+}
+
+const (
+
+ // VersionStateDevel captures enum value "devel"
+ VersionStateDevel string = "devel"
+
+ // VersionStateStable captures enum value "stable"
+ VersionStateStable string = "stable"
+
+ // VersionStateDeprecated captures enum value "deprecated"
+ VersionStateDeprecated string = "deprecated"
+)
+
+// prop value enum
+func (m *Version) validateStateEnum(path, location string, value string) error {
+ if err := validate.Enum(path, location, value, versionTypeStatePropEnum); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (m *Version) validateState(formats strfmt.Registry) error {
+
+ if swag.IsZero(m.State) { // not required
+ return nil
+ }
+
+ // value enum
+ if err := m.validateStateEnum("State", "body", m.State); err != nil {
+ return err
+ }
+
+ return nil
+}
+
+// MarshalBinary interface implementation
+func (m *Version) MarshalBinary() ([]byte, error) {
+ if m == nil {
+ return nil, nil
+ }
+ return swag.WriteJSON(m)
+}
+
+// UnmarshalBinary interface implementation
+func (m *Version) UnmarshalBinary(b []byte) error {
+ var res Version
+ if err := swag.ReadJSON(b, &res); err != nil {
+ return err
+ }
+ *m = res
+ return nil
+}
// Package weles represents the base of the Weles system.
package weles
+
+// SrvVersion indicates version of Weles server.
+const SrvVersion string = "0.1.0"