Skip to content

Commit

Permalink
Merge pull request #12 from containerum/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MargoTuleninova committed Aug 9, 2018
2 parents 6023155 + 9183823 commit 9c4daa9
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 232 deletions.
2 changes: 1 addition & 1 deletion cmd/kube-api/main.go
Expand Up @@ -7,10 +7,10 @@ import (
"github.com/urfave/cli"
)

//go:generate protoc --go_out=../../proto -I../../proto exec.proto
//go:generate swagger generate spec -m -i ../../swagger-basic.yml -o ../../swagger.json
//go:generate swagger flatten ../../swagger.json -o ../../swagger.json
//go:generate swagger validate ../../swagger.json
//go:generate protoc --go_out=../../proto -I../../proto exec.proto

func main() {
app := cli.NewApp()
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/deployment.go
Expand Up @@ -168,9 +168,9 @@ func (deploy *DeploymentKubeAPI) ToKube(nsName string, labels map[string]string)
return nil, []error{verr}
}

var imagePullSecrets []api_core.LocalObjectReference
for _, im := range deploy.ImagePullSecrets {
imagePullSecrets = append(imagePullSecrets, api_core.LocalObjectReference{im})
imagePullSecrets := make([]api_core.LocalObjectReference, len(deploy.ImagePullSecrets))
for i, im := range deploy.ImagePullSecrets {
imagePullSecrets[i] = api_core.LocalObjectReference{Name: im}
}

newDeploy := api_apps.Deployment{
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/namespace.go
Expand Up @@ -17,8 +17,8 @@ import (
const (
ownerLabel = "owner"

minNamespaceCPU = 10 //m
minNamespaceMemory = 10 //Mi
minNamespaceCPU = 10 //m
minNamespaceMemory = 10 //Mi
maxNamespaceCPU = 12000 //m
maxNamespaceMemory = 28672 //Mi
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/secret.go
Expand Up @@ -35,7 +35,7 @@ func ParseKubeSecretList(secreti interface{}, parseforuser bool) (*kube_types.Se
}
secrets = append(secrets, *newSecret)
}
return &kube_types.SecretsList{secrets}, nil
return &kube_types.SecretsList{Secrets: secrets}, nil
}

// ParseKubeSecret parses kubernetes v1.Secret to more convenient Secret struct.
Expand Down Expand Up @@ -98,7 +98,7 @@ func (secret *SecretKubeAPI) ToKube(nsName string, labels map[string]string, sec
}

func makeSecretData(data map[string]string) map[string][]byte {
newData := make(map[string][]byte, 0)
newData := make(map[string][]byte)
for k, v := range data {
newData[k] = []byte(v)
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/router/handlers/secret.go
Expand Up @@ -101,7 +101,7 @@ func GetSecretList(ctx *gin.Context) {
// '200':
// description: secret
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// default:
// $ref: '#/responses/error'
func GetSecret(ctx *gin.Context) {
Expand Down Expand Up @@ -153,12 +153,12 @@ func GetSecret(ctx *gin.Context) {
// - name: body
// in: body
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// responses:
// '201':
// description: secret created
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// default:
// $ref: '#/responses/error'
func CreateTLSSecret(ctx *gin.Context) {
Expand Down Expand Up @@ -219,12 +219,12 @@ func CreateTLSSecret(ctx *gin.Context) {
// - name: body
// in: body
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// responses:
// '201':
// description: secret created
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// default:
// $ref: '#/responses/error'
func CreateDockerSecret(ctx *gin.Context) {
Expand Down Expand Up @@ -293,12 +293,12 @@ func CreateDockerSecret(ctx *gin.Context) {
// - name: body
// in: body
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// responses:
// '202':
// description: secret updated
// schema:
// $ref: '#/definitions/SecretWithParam'
// $ref: '#/definitions/Secret'
// default:
// $ref: '#/responses/error'
func UpdateSecret(ctx *gin.Context) {
Expand Down
42 changes: 21 additions & 21 deletions pkg/utils/timeoutreader/timeoutreader.go
Expand Up @@ -49,36 +49,36 @@ func NewTimeoutReader(reader io.ReadCloser, timeout time.Duration, closeOnTimeou

// Closes the TimeoutReader.
// Also closes the underlying Reader if it was not closed already at timeout.
func (this *TimeoutReader) Close() (err error) {
this.onceClose.Do(func() {
this.close <- struct{}{}
err = this.reader.Close()
func (tr *TimeoutReader) Close() (err error) {
tr.onceClose.Do(func() {
tr.close <- struct{}{}
err = tr.reader.Close()
})
return
}

// Read from the underlying reader.
// If the underlying Read() does not return within the timeout, ErrReadTimeout
// is returned.
func (this *TimeoutReader) Read(p []byte) (int, error) {
if this.timeout <= 0 {
return this.reader.Read(p)
func (tr *TimeoutReader) Read(p []byte) (int, error) {
if tr.timeout <= 0 {
return tr.reader.Read(p)
}

if this.maxReadSize > 0 && len(p) > this.maxReadSize {
p = p[:this.maxReadSize]
if tr.maxReadSize > 0 && len(p) > tr.maxReadSize {
p = p[:tr.maxReadSize]
}

// reset the timer
select {
case <-this.timer.C:
case <-tr.timer.C:
default:
}
this.timer.Reset(this.timeout)
tr.timer.Reset(tr.timeout)

// clear the done channel
select {
case <-this.done:
case <-tr.done:
default:
}

Expand All @@ -87,35 +87,35 @@ func (this *TimeoutReader) Read(p []byte) (int, error) {
var mutex sync.Mutex

go func() {
n, err := io.ReadAtLeast(this.reader, p, 1)
n, err := io.ReadAtLeast(tr.reader, p, 1)
mutex.Lock()
defer mutex.Unlock()
finished = true
if !timedOut {
this.timer.Stop()
tr.timer.Stop()
if err == io.ErrUnexpectedEOF {
err = nil
}
this.done <- &readResponse{n: n, err: err}
tr.done <- &readResponse{n: n, err: err}
}
}()

select {
case <-this.timer.C:
case <-tr.timer.C:
mutex.Lock()
defer mutex.Unlock()
if finished {
resp := <-this.done
resp := <-tr.done
return resp.n, resp.err
}
timedOut = true
if this.closeOnTimeout {
this.reader.Close()
if tr.closeOnTimeout {
tr.reader.Close()
}
return 0, ErrReadTimeout
case <-this.close:
case <-tr.close:
return 0, io.EOF
case resp := <-this.done:
case resp := <-tr.done:
return resp.n, resp.err
}
}
128 changes: 3 additions & 125 deletions static/ab0x.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions static/b0x.yaml
Expand Up @@ -87,9 +87,6 @@ debug: false
custom:
# type: array of strings
- files:
- "../vendor/github.com/containerum/kube-client/swagger.json"
- "../vendor/github.com/containerum/utils/httputil/swagger.json"
- "../vendor/github.com/containerum/cherry/swagger.json"
- "../swagger.json"
# base is the path that will be removed from all files' path
# type: string
Expand Down

0 comments on commit 9c4daa9

Please sign in to comment.