install actual version of go-license-detector
add swagger check to build-proto.sh
MODIFY
Jenkinsfile
Jenkinsfile
@@ -153,11 +153,11 @@ pipeline {
curl -s -L https://github.com/mitchellh/golicense/releases/latest/download/golicense_0.2.0_linux_x86_64.tar.gz \
| sudo tar -C /usr/local/bin --wildcards -zxvpf -
- # curl -s -L https://github.com/src-d/go-license-detector/releases/latest/download/license-detector.linux_amd64.gz \
- # | gunzip | sudo tee /usr/local/bin/license-detector > /dev/null
- curl -s -L https://github.com/src-d/go-license-detector/releases/download/v3.0.2/license-detector.linux_amd64.gz \
- | gunzip | sudo tee /usr/local/bin/license-detector > /dev/null
+ sudo curl -s -L https://github.com/go-swagger/go-swagger/releases/download/v0.24.0/swagger_linux_amd64 -o /usr/local/bin/swagger
+ curl -s -L https://github.com/go-enry/go-license-detector/releases/download/v4.0.0/license-detector-v4.0.0-linux-amd64.tar.gz \
+ | sudo tar -C /usr/local/bin --wildcards -zxvpf -
sudo chmod +x /usr/local/bin/license-detector
+ sudo chmod +x /usr/local/bin/swagger
'''
withCredentials([file(credentialsId: 'cloud-secret-file', variable: 'CLOUD_SECRET_FILE')]) {
sh '''
@@ -179,13 +179,13 @@ pipeline {
docker_tag_file='./results/docker/TAG'
mkdir -p $(dirname ${docker_tag_file})
echo ${DOCKER_TAG} > "${docker_tag_file}"
-
sg docker -c "
docker login -u '${USER}' -p '${PASS}'
export IMAGE=\$DOCKER_TAG
./e2e-tests/build
docker logout
"
+ sudo rm -rf ./build
'''
}
stash includes: 'results/docker/TAG', name: 'IMAGE'
@@ -221,7 +221,9 @@ pipeline {
-v $WORKSPACE/src/github.com/percona/percona-xtradb-cluster-operator:/go/src/github.com/percona/percona-xtradb-cluster-operator \
-w /go/src/github.com/percona/percona-xtradb-cluster-operator \
-e GO111MODULE=on \
- golang:1.14 sh -c 'cd /go/src/github.com/percona/percona-xtradb-cluster-operator && build/build-proto.sh && cd - && go build -v -mod=vendor -o percona-xtradb-cluster-operator github.com/percona/percona-xtradb-cluster-operator/cmd/manager'
+ golang:1.14 sh -c 'go install github.com/go-swagger/go-swagger/cmd/swagger \
+ && swagger generate client -f vendor/github.com/Percona-Lab/percona-version-service/api/version.swagger.yaml -c versionserviceclient -m versionserviceclient/models \
+ && go build -v -mod=vendor -o percona-xtradb-cluster-operator github.com/percona/percona-xtradb-cluster-operator/cmd/manager'
"
'''

MODIFY
build/build-proto.sh
build/build-proto.sh
set -o errexit
set -o xtrace
-proto_compiler=protoc
-
-go get \
- github.com/golang/protobuf/protoc-gen-go \
- github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
- github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
- github.com/rakyll/statik
-
+if ! swagger version &>/dev/null; then
go install github.com/go-swagger/go-swagger/cmd/swagger
-
-rm -rf versionserviceclient
-
-if ! protoc --version &>/dev/null; then
- apt-get update && apt-get install unzip
-
- curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.12.1/protoc-3.12.1-linux-x86_64.zip
-
- unzip protoc-3.12.1-linux-x86_64.zip -d $HOME/.local
-
- proto_compiler=$HOME/.local/bin/protoc
fi
-rm -rf build/third_party
-
-mkdir -p openapi
-mkdir -p build/third_party/openapi_proto
-
-git clone https://github.com/googleapis/googleapis build/third_party/googleapis
-git clone -b v2 https://github.com/grpc-ecosystem/grpc-gateway build/third_party/openapi
-
-cd build/third_party/googleapis && git checkout 76905ffe7e3b0605f64ef889fb88913634f9f836 && cd ../../..
-cd build/third_party/openapi && git checkout fcec199c8378122670cbf93a72d7363e9bd460fe && mv protoc-gen-openapiv2 ../openapi_proto/ && cd ../../..
-
-$proto_compiler -I build/third_party/googleapis -I build/third_party/openapi_proto -I vendor/github.com/Percona-Lab/percona-version-service/api --openapiv2_out=./openapi vendor/github.com/Percona-Lab/percona-version-service/api/version.proto
-
-swagger generate client -f openapi/version.swagger.json -c versionserviceclient -m versionserviceclient/models
+rm -rf versionserviceclient
-rm -rf openapi
-rm -rf build/third_party
+swagger generate client -f vendor/github.com/Percona-Lab/percona-version-service/api/version.swagger.yaml -c versionserviceclient -m versionserviceclient/models

MODIFY
e2e-tests/license/compare/license-detector
e2e-tests/license/compare/license-detector
Apache-2.0
ECL-2.0
+SHL-0.51
+SHL-0.5

MODIFY
go.mod
go.mod
@@ -3,7 +3,7 @@ module github.com/percona/percona-xtradb-cluster-operator
go 1.13
require (
- github.com/Percona-Lab/percona-version-service/api v0.0.0-20200702140248-ad469044aacf
+ github.com/Percona-Lab/percona-version-service/api v0.0.0-20200707073643-e3dd469db8be
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-openapi/errors v0.19.6
github.com/go-openapi/runtime v0.19.16

MODIFY
go.sum
go.sum
@@ -61,8 +61,8 @@ github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMo
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.6/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
-github.com/Percona-Lab/percona-version-service/api v0.0.0-20200702140248-ad469044aacf h1:GeAiiL7NlH1q/j3emyXKYeRWCqv0ML7jJ1AZsMv0mmY=
-github.com/Percona-Lab/percona-version-service/api v0.0.0-20200702140248-ad469044aacf/go.mod h1:QDbZ+DHh0CkTHN6LRkMQd1pEl3b30EaNZ9FA97Mb3TA=
+github.com/Percona-Lab/percona-version-service/api v0.0.0-20200707073643-e3dd469db8be h1:TL1Q7CRBmK3vUC9Z6EMdcra6wHmL0fkcMjDgs3ypEyI=
+github.com/Percona-Lab/percona-version-service/api v0.0.0-20200707073643-e3dd469db8be/go.mod h1:QDbZ+DHh0CkTHN6LRkMQd1pEl3b30EaNZ9FA97Mb3TA=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=

MODIFY
pkg/controller/pxc/vs.go
pkg/controller/pxc/vs.go
@@ -2,6 +2,7 @@ package pxc
import (
"fmt"
+ "net/http"
"net/url"
"time"
@@ -10,9 +11,9 @@ import (
"github.com/percona/percona-xtradb-cluster-operator/versionserviceclient/version_service"
)
-const productName = "pxc"
+const productName = "pxc-operator"
-func (vs VersionServiceClient) GetExactVersion(desiredVersion, currentVersion string, versionMeta currVersionMeta) (DepVersion, error) {
+func (vs VersionServiceClient) GetExactVersion(vm versionMeta) (DepVersion, error) {
requestURL, err := url.Parse(vs.URL)
if err != nil {
return DepVersion{}, err
@@ -24,12 +25,21 @@ func (vs VersionServiceClient) GetExactVersion(desiredVersion, currentVersion st
Schemes: []string{requestURL.Scheme},
})
- params := version_service.NewVersionServiceApplyParamsWithTimeout(10 * time.Second).WithProduct(productName).
- WithOperatorVersion(vs.OpVersion).WithApply(desiredVersion).WithDatabaseVersion(&currentVersion).
- WithKubeVersion(&versionMeta.KubeVersion).WithPlatform(&versionMeta.Platform).WithCustomResourceOid(&versionMeta.CRUID).
- WithPmmVersion(&versionMeta.PMMVersion).WithBackupVersion(&versionMeta.BackupVersion)
+ applyParams := &version_service.VersionServiceApplyParams{
+ Apply: vm.Apply,
+ BackupVersion: &vm.BackupVersion,
+ CustomResourceOid: &vm.CRUID,
+ DatabaseVersion: &vm.PXCVersion,
+ KubeVersion: &vm.KubeVersion,
+ OperatorVersion: vs.OpVersion,
+ Platform: &vm.Platform,
+ PmmVersion: &vm.PMMVersion,
+ Product: productName,
+ HTTPClient: &http.Client{Timeout: 10 * time.Second},
+ }
+ applyParams = applyParams.WithTimeout(10 * time.Second)
- resp, err := srvCl.VersionService.VersionServiceApply(params)
+ resp, err := srvCl.VersionService.VersionServiceApply(applyParams)
if err != nil {
return DepVersion{}, err
@@ -101,7 +111,7 @@ type DepVersion struct {
}
type VersionService interface {
- GetExactVersion(vm versionMeta) (DepVersion, error)
+ GetExactVersion(versionMeta versionMeta) (DepVersion, error)
}
type VersionServiceClient struct {
@@ -109,7 +119,9 @@ type VersionServiceClient struct {
OpVersion string
}
-type currVersionMeta struct {
+type versionMeta struct {
+ Apply string
+ PXCVersion string
KubeVersion string
Platform string
PMMVersion string

MODIFY
vendor/github.com/Percona-Lab/percona-version-service/api/version.proto
vendor/github.com/Percona-Lab/percona-version-service/api/version.proto
@@ -2,30 +2,33 @@ syntax="proto3";
package version;
-import "google/api/annotations.proto";
-import "protoc-gen-openapiv2/options/annotations.proto";
-
-// Defines the import path that should be used to import the generated package,
-// and the package name.
-option go_package = "github.com/Percona-Lab/percona-version-service/proto;version";
-
// These annotations are used when generating the OpenAPI file.
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
- version: "1.0";
- };
+ version: "1.0"
+ }
external_docs: {
- url: "https://github.com/Percona-Lab/percona-version-service";
- description: "gRPC-gateway boilerplate repository";
+ url: "https://github.com/Percona-Lab/percona-version-service"
+ description: "This service provides version information and image paths for supporting the use of Percona Kubernetes Operators in a variety of scenarios while enabling specific version deployments and automated upgrades."
}
- schemes: [HTTP, HTTPS];
+ schemes: [
+ HTTP,
+ HTTPS
+ ]
};
+// Defines the import path that should be used to import the generated package,
+// and the package name.
+option go_package = "github.com/Percona-Lab/percona-version-service/version";
+
+import "google/api/annotations.proto";
+import "protoc-gen-openapiv2/options/annotations.proto";
+// VersionService provides public API methods for version service usage.
service VersionService {
+ // Apply provides information about specific product version and its dependencies.
rpc Apply(ApplyRequest) returns (VersionResponse) {
option (google.api.http) = {
- // Route to this method from GET requests to /versions/v1/{product}/{operatorVersion}/{apply}
- get: "/api/versions/v1/{product}/{operator_version}/{apply}"
+ get: "/versions/v1/{product}/{operator_version}/{apply}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Specific version"
@@ -44,16 +47,27 @@ message ApplyRequest {
string pmm_version = 7;
string backup_version = 8;
string namespace_oid = 9;
- string customResource_oid = 10;
+ string custom_resource_oid = 10;
+}
+
+// Status describes the current version status.
+enum Status {
+ status_invalid = 0;
+ recommended = 1;
+ available = 2;
+ required = 3;
+ disabled = 4;
}
+// Version represents product version information.
message Version {
string image_path = 1;
string image_hash = 2;
- string status = 3;
+ Status status = 3;
bool critical = 4;
}
+// VersionMatrix represents set of possible product versions.
message VersionMatrix {
map<string, Version> mongod = 1;
map<string, Version> pxc = 2;
@@ -64,9 +78,10 @@ message VersionMatrix {
map<string, Version> operator = 7;
}
+// OperatorVersion represents operator version.
message OperatorVersion {
- string operator = 1;
- string database = 2;
+ string product = 1;
+ string operator = 2;
VersionMatrix matrix = 3;
}

ADD
vendor/github.com/Percona-Lab/percona-version-service/api/version.swagger.yaml
+swagger: "2.0"
+info:
+ title: api/version.proto
+ version: "1.0"
+schemes:
+ - http
+ - https
+consumes:
+ - application/json
+produces:
+ - application/json
+paths:
+ /versions/v1/{product}/{operatorVersion}/{apply}:
+ get:
+ summary: Specific version
+ description: Return specific product version
+ operationId: VersionService_Apply
+ responses:
+ "200":
+ description: A successful response.
+ schema:
+ $ref: '#/definitions/versionVersionResponse'
+ default:
+ description: An unexpected error response
+ schema:
+ $ref: '#/definitions/googlerpcStatus'
+ parameters:
+ - name: product
+ in: path
+ required: true
+ type: string
+ - name: operatorVersion
+ in: path
+ required: true
+ type: string
+ - name: apply
+ in: path
+ required: true
+ type: string
+ - name: databaseVersion
+ in: query
+ required: false
+ type: string
+ - name: kubeVersion
+ in: query
+ required: false
+ type: string
+ - name: platform
+ in: query
+ required: false
+ type: string
+ - name: pmmVersion
+ in: query
+ required: false
+ type: string
+ - name: backupVersion
+ in: query
+ required: false
+ type: string
+ - name: namespaceOid
+ in: query
+ required: false
+ type: string
+ - name: customResourceOid
+ in: query
+ required: false
+ type: string
+ tags:
+ - VersionService
+definitions:
+ googlerpcStatus:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ message:
+ type: string
+ details:
+ type: array
+ items:
+ $ref: '#/definitions/protobufAny'
+ protobufAny:
+ type: object
+ properties:
+ typeUrl:
+ type: string
+ description: |-
+ A URL/resource name that uniquely identifies the type of the serialized
+ protocol buffer message. This string must contain at least
+ one "/" character. The last segment of the URL's path must represent
+ the fully qualified name of the type (as in
+ `path/google.protobuf.Duration`). The name should be in a canonical form
+ (e.g., leading "." is not accepted).
+
+ In practice, teams usually precompile into the binary all types that they
+ expect it to use in the context of Any. However, for URLs which use the
+ scheme `http`, `https`, or no scheme, one can optionally set up a type
+ server that maps type URLs to message definitions as follows:
+
+ * If no scheme is provided, `https` is assumed.
+ * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+ value in binary format, or produce an error.
+ * Applications are allowed to cache lookup results based on the
+ URL, or have them precompiled into a binary to avoid any
+ lookup. Therefore, binary compatibility needs to be preserved
+ on changes to types. (Use versioned type names to manage
+ breaking changes.)
+
+ Note: this functionality is not currently available in the official
+ protobuf release, and it is not used for type URLs beginning with
+ type.googleapis.com.
+
+ Schemes other than `http`, `https` (or the empty scheme) might be
+ used with implementation specific semantics.
+ value:
+ type: string
+ format: byte
+ description: Must be a valid serialized protocol buffer of the above specified type.
+ description: |-
+ `Any` contains an arbitrary serialized protocol buffer message along with a
+ URL that describes the type of the serialized message.
+
+ Protobuf library provides support to pack/unpack Any values in the form
+ of utility functions or additional generated methods of the Any type.
+
+ Example 1: Pack and unpack a message in C++.
+
+ Foo foo = ...;
+ Any any;
+ any.PackFrom(foo);
+ ...
+ if (any.UnpackTo(&foo)) {
+ ...
+ }
+
+ Example 2: Pack and unpack a message in Java.
+
+ Foo foo = ...;
+ Any any = Any.pack(foo);
+ ...
+ if (any.is(Foo.class)) {
+ foo = any.unpack(Foo.class);
+ }
+
+ Example 3: Pack and unpack a message in Python.
+
+ foo = Foo(...)
+ any = Any()
+ any.Pack(foo)
+ ...
+ if any.Is(Foo.DESCRIPTOR):
+ any.Unpack(foo)
+ ...
+
+ Example 4: Pack and unpack a message in Go
+
+ foo := &pb.Foo{...}
+ any, err := ptypes.MarshalAny(foo)
+ ...
+ foo := &pb.Foo{}
+ if err := ptypes.UnmarshalAny(any, foo); err != nil {
+ ...
+ }
+
+ The pack methods provided by protobuf library will by default use
+ 'type.googleapis.com/full.type.name' as the type URL and the unpack
+ methods only use the fully qualified type name after the last '/'
+ in the type URL, for example "foo.bar.com/x/y.z" will yield type
+ name "y.z".
+
+
+ JSON
+ ====
+ The JSON representation of an `Any` value uses the regular
+ representation of the deserialized, embedded message, with an
+ additional field `@type` which contains the type URL. Example:
+
+ package google.profile;
+ message Person {
+ string first_name = 1;
+ string last_name = 2;
+ }
+
+ {
+ "@type": "type.googleapis.com/google.profile.Person",
+ "firstName": <string>,
+ "lastName": <string>
+ }
+
+ If the embedded message type is well-known and has a custom JSON
+ representation, that representation will be embedded adding a field
+ `value` which holds the custom JSON in addition to the `@type`
+ field. Example (for message [google.protobuf.Duration][]):
+
+ {
+ "@type": "type.googleapis.com/google.protobuf.Duration",
+ "value": "1.212s"
+ }
+ versionOperatorVersion:
+ type: object
+ properties:
+ product:
+ type: string
+ operator:
+ type: string
+ matrix:
+ $ref: '#/definitions/versionVersionMatrix'
+ description: OperatorVersion represents operator version.
+ versionStatus:
+ type: string
+ enum:
+ - status_invalid
+ - recommended
+ - available
+ - required
+ - disabled
+ default: status_invalid
+ description: Status describes the current version status.
+ versionVersion:
+ type: object
+ properties:
+ imagePath:
+ type: string
+ imageHash:
+ type: string
+ status:
+ $ref: '#/definitions/versionStatus'
+ critical:
+ type: boolean
+ format: boolean
+ description: Version represents product version information.
+ versionVersionMatrix:
+ type: object
+ properties:
+ mongod:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ pxc:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ pmm:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ proxysql:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ haproxy:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ backup:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ operator:
+ type: object
+ additionalProperties:
+ $ref: '#/definitions/versionVersion'
+ description: VersionMatrix represents set of possible product versions.
+ versionVersionResponse:
+ type: object
+ properties:
+ versions:
+ type: array
+ items:
+ $ref: '#/definitions/versionOperatorVersion'
+externalDocs:
+ description: This service provides version information and image paths for supporting the use of Percona Kubernetes Operators in a variety of scenarios while enabling specific version deployments and automated upgrades.
+ url: https://github.com/Percona-Lab/percona-version-service

MODIFY
vendor/modules.txt
vendor/modules.txt
# cloud.google.com/go v0.49.0
cloud.google.com/go/compute/metadata
-# github.com/Percona-Lab/percona-version-service/api v0.0.0-20200702140248-ad469044aacf
+# github.com/Percona-Lab/percona-version-service/api v0.0.0-20200707073643-e3dd469db8be
github.com/Percona-Lab/percona-version-service/api
# github.com/PuerkitoBio/purell v1.1.1
github.com/PuerkitoBio/purell

install actual version of go-license-detector
add swagger check to build-proto.sh