Initial QSfera import
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.x
|
||||
- 1.4
|
||||
- 1.5
|
||||
- 1.6
|
||||
- 1.7
|
||||
- 1.8
|
||||
- 1.9
|
||||
- '1.10'
|
||||
- tip
|
||||
- master
|
||||
|
||||
go_import_path: stash.kopano.io/kgol/rndm
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- go: tip master
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 'golang:1.13'
|
||||
}
|
||||
}
|
||||
environment {
|
||||
GOBIN = '/tmp/go-bin'
|
||||
GOCACHE = '/tmp/go-build'
|
||||
}
|
||||
stages {
|
||||
stage('Bootstrap') {
|
||||
steps {
|
||||
echo 'Bootstrapping..'
|
||||
sh 'go version'
|
||||
sh 'go get -v golang.org/x/lint/golint'
|
||||
sh 'go get -v github.com/tebeka/go2xunit'
|
||||
sh 'go get -v github.com/axw/gocov/...'
|
||||
sh 'go get -v github.com/AlekSi/gocov-xml'
|
||||
sh 'go mod vendor'
|
||||
}
|
||||
}
|
||||
stage('Lint') {
|
||||
steps {
|
||||
echo 'Linting..'
|
||||
sh 'PATH=$PATH:$GOBIN golint | tee golint.txt || true'
|
||||
sh 'go vet | tee govet.txt || true'
|
||||
recordIssues qualityGates: [[threshold: 100, type: 'TOTAL', unstable: true]], tools: [goVet(pattern: 'govet.txt'), goLint(pattern: 'golint.txt')]
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
echo 'Testing..'
|
||||
sh 'PATH=$PATH:$GOBIN go test -v -count=1 -covermode=atomic -coverprofile=coverage.out | tee tests.output'
|
||||
sh 'PATH=$PATH:$GOBIN go2xunit -fail -input tests.output -output tests.xml'
|
||||
junit allowEmptyResults: true, testResults: 'tests.xml'
|
||||
}
|
||||
}
|
||||
stage('Coverage') {
|
||||
steps {
|
||||
echo 'Coverage..'
|
||||
sh 'mkdir -p ./test/reports'
|
||||
sh 'go tool cover -html=coverage.out -o test/reports/coverage.html'
|
||||
sh 'PATH=$PATH:$GOBIN; gocov convert coverage.out | gocov-xml > coverage.xml'
|
||||
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true, reportDir: 'test/reports', reportFiles: 'coverage.html', reportName: 'Go Coverage Report HTML', reportTitles: ''])
|
||||
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017 Kopano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# rndm [](https://godoc.org/stash.kopano.io/kgol/rndm)
|
||||
|
||||
Rndm is a Go package to provide helper functions which create cryptographically
|
||||
secure random values out of random data.
|
||||
|
||||
## Installation
|
||||
|
||||
```text
|
||||
go get stash.kopano.io/kgol/rndm
|
||||
```
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 Kopano
|
||||
*
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the LICENSE.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
package rndm
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
// GenerateRandomBytes returns securely generated random bytes. It will panic
|
||||
// when the system fails to provide enough secure random data.
|
||||
func GenerateRandomBytes(n int) []byte {
|
||||
b := make([]byte, n)
|
||||
_, err := ReadRandomBytes(b)
|
||||
if err != nil {
|
||||
panic("unable to read enough random bytes")
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
// ReadRandomBytes is a helper function that reads random data into the provided
|
||||
// []byte. Tt returns the number of random bytes read and an error if fewer
|
||||
// bytes were read.
|
||||
func ReadRandomBytes(b []byte) (n int, err error) {
|
||||
return rand.Read(b)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2017 Kopano
|
||||
*
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the LICENSE.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
package rndm // import "stash.kopano.io/kgol/rndm"
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright 2017 Kopano
|
||||
*
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the LICENSE.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
package rndm // import "stash.kopano.io/kgol/rndm"
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2017 Kopano
|
||||
*
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the LICENSE.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
package rndm
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
// GenerateRandomString returns a URL-safe, base64 encoded securely generated
|
||||
// random string. It will panic if the system fails to provide secure random
|
||||
// data.
|
||||
func GenerateRandomString(s int) string {
|
||||
b := GenerateRandomBytes(s)
|
||||
|
||||
return base64.RawURLEncoding.EncodeToString(b)
|
||||
}
|
||||
Reference in New Issue
Block a user