commit
382dd0bb6a
@ -0,0 +1,24 @@
|
||||
# ---> Go
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
settings.json
|
@ -0,0 +1,102 @@
|
||||
# options for analysis running
|
||||
run:
|
||||
# timeout for analysis, e.g. 30s, 5m, default is 1m
|
||||
timeout: 1m
|
||||
|
||||
# exit code when at least one issue was found, default is 1
|
||||
issues-exit-code: 0
|
||||
|
||||
# include test files or not, default is true
|
||||
tests: false
|
||||
|
||||
# which dirs to skip: issues from them won't be reported;
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
# default value is empty list, but default dirs are skipped independently
|
||||
# from this option's value (see skip-dirs-use-default).
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-dirs:
|
||||
- wasm
|
||||
- static
|
||||
- node_modules
|
||||
- documents
|
||||
- docker
|
||||
- bind-*
|
||||
|
||||
# default is true. Enables skipping of directories:
|
||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||
skip-dirs-use-default: true
|
||||
|
||||
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
|
||||
# If invoked with -mod=readonly, the go command is disallowed from the implicit
|
||||
# automatic updating of go.mod described above. Instead, it fails when any changes
|
||||
# to go.mod are needed. This setting is most useful to check that go.mod does
|
||||
# not need updates, such as in a continuous integration and testing system.
|
||||
# If invoked with -mod=vendor, the go command assumes that the vendor
|
||||
# directory holds the correct copies of dependencies and ignores
|
||||
# the dependency descriptions in go.mod.
|
||||
modules-download-mode: mod
|
||||
|
||||
# Allow multiple parallel golangci-lint instances running.
|
||||
# If false (default) - golangci-lint acquires file lock on start.
|
||||
allow-parallel-runners: true
|
||||
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
|
||||
# default is "colored-line-number"
|
||||
format: colored-line-number
|
||||
|
||||
# print lines of code with issue, default is true
|
||||
print-issued-lines: true
|
||||
|
||||
# print linter name in the end of issue text, default is true
|
||||
print-linter-name: true
|
||||
|
||||
# make issues output unique by line, default is true
|
||||
uniq-by-line: true
|
||||
|
||||
# add a prefix to the output file references; default is no prefix
|
||||
path-prefix: ""
|
||||
|
||||
# sorts results by: filepath, line and column
|
||||
sort-results: false
|
||||
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
gofmt:
|
||||
# simplify code: gofmt with `-s` option, true by default
|
||||
simplify: true
|
||||
staticcheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.19"
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
checks: ["all"]
|
||||
stylecheck:
|
||||
# Select the Go version to target. The default is '1.13'.
|
||||
go: "1.19"
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
checks: ["all"]
|
||||
errcheck:
|
||||
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
|
||||
# default is false: such cases aren't reported by default.
|
||||
check-blank: true
|
||||
|
||||
linters:
|
||||
enable:
|
||||
# go install github.com/kisielk/errcheck@latest
|
||||
# go install github.com/gordonklaus/ineffassign@latest
|
||||
# go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||
# go install gitlab.com/opennota/check/cmd/varcheck@latest
|
||||
# go install github.com/go-critic/go-critic/cmd/gocritic@latest
|
||||
- errcheck
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- ineffassign
|
||||
- varcheck
|
||||
- gofmt
|
||||
- gocritic
|
||||
- wsl
|
||||
fast: false
|
@ -0,0 +1,18 @@
|
||||
package actions
|
||||
|
||||
type Action int
|
||||
|
||||
const (
|
||||
StartContainer = iota
|
||||
StopContainer
|
||||
ExecContainer
|
||||
RemoveContainer
|
||||
GetContainers
|
||||
GetContainerWithSameName
|
||||
GetContainerLog
|
||||
PullImage
|
||||
GetConfig
|
||||
Ping
|
||||
Test
|
||||
TestError
|
||||
)
|
@ -0,0 +1,33 @@
|
||||
package callbacks
|
||||
|
||||
type Callback int
|
||||
|
||||
const (
|
||||
BeforeStartContainerCallback = iota
|
||||
AfterStartContainerCallback
|
||||
BeforeCreateContainerCallback
|
||||
AfterCreateContainerCallback
|
||||
BeforeExecContainerCallback
|
||||
AfterExecContainerCallback
|
||||
BeforeStopContainerCallback
|
||||
AfterStopContainerCallback
|
||||
BeforeRemoveContainerCallback
|
||||
AfterRemoveContainerCallback
|
||||
BeforeGetContainersCallback
|
||||
AfterGetContainersCallback
|
||||
BeforeGetContainerWithSameNameCallback
|
||||
AfterGetContainerWithSameNameCallback
|
||||
BeforeGetContainerLogCallback
|
||||
AfterGetContainerLogCallback
|
||||
BeforePullImageCallback
|
||||
AfterPullImageCallback
|
||||
BeforeGetConfigCallback
|
||||
AfterGetConfigCallback
|
||||
BeforePingCallback
|
||||
AfterPingCallback
|
||||
BeforeTestCallback
|
||||
AfterTestCallback
|
||||
BeforeTestErrorCallback
|
||||
AfterTestErrorCallback
|
||||
Log
|
||||
)
|
@ -0,0 +1,6 @@
|
||||
package credentials
|
||||
|
||||
type RegistryCredentials struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package errors
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
DockerPull = iota
|
||||
CreateContainer
|
||||
StopContainer
|
||||
StartContainer
|
||||
ExecContainer
|
||||
RemoveContainer
|
||||
GetContainers
|
||||
WaitContainer
|
||||
GetContainerLog
|
||||
Server
|
||||
ImageURLValidation
|
||||
ImageNameValidation
|
||||
MaxContainersReached
|
||||
NonExistingContainer
|
||||
)
|
||||
|
||||
type AppError struct {
|
||||
Type Type `json:"type"`
|
||||
SourceErrorMessage string `json:"sourceerrormessage"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (e AppError) String() string {
|
||||
errorString := ""
|
||||
|
||||
switch e.Type {
|
||||
case DockerPull:
|
||||
errorString = "Error pulling the image."
|
||||
case CreateContainer:
|
||||
errorString = "Error creating the container."
|
||||
case StopContainer:
|
||||
errorString = "Error stopping the container."
|
||||
case StartContainer:
|
||||
errorString = "Error starting the container."
|
||||
case ExecContainer:
|
||||
errorString = "Error executing command in the container."
|
||||
case RemoveContainer:
|
||||
errorString = "Error removing the container."
|
||||
case GetContainers:
|
||||
errorString = "Error retrieving the running containers."
|
||||
case WaitContainer:
|
||||
errorString = "Error waiting for the started container."
|
||||
case GetContainerLog:
|
||||
errorString = "Error getting the container log."
|
||||
case Server:
|
||||
errorString = "Internal server error."
|
||||
case ImageNameValidation:
|
||||
errorString = "Docker image name invalid."
|
||||
case ImageURLValidation:
|
||||
errorString = "Docker image URL invalid."
|
||||
case MaxContainersReached:
|
||||
errorString = "Maximum number of containers reached."
|
||||
case NonExistingContainer:
|
||||
errorString = "Non existing container."
|
||||
default:
|
||||
errorString = "Unexpected error"
|
||||
}
|
||||
|
||||
return errorString
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
module codefirst.iut.uca.fr/git/thomas.bellembois/codefirst-dockerrunner-common/v2
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/docker/docker v20.10.17+incompatible
|
||||
|
||||
require (
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.2 // indirect
|
||||
)
|
@ -0,0 +1,43 @@
|
||||
github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE=
|
||||
github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
||||
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
||||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
|
||||
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
@ -0,0 +1,17 @@
|
||||
package messages
|
||||
|
||||
import (
|
||||
"codefirst.iut.uca.fr/git/thomas.bellembois/codefirst-dockerrunner-common/v2/errors"
|
||||
"codefirst.iut.uca.fr/git/thomas.bellembois/codefirst-dockerrunner-common/v2/models"
|
||||
"github.com/docker/docker/api/types"
|
||||
)
|
||||
|
||||
type WSMessage struct {
|
||||
Action int `json:"action,omitempty"`
|
||||
Container models.CodeFirstContainer `json:"container,omitempty"`
|
||||
Containers []models.CodeFirstContainer `json:"containers,omitempty"`
|
||||
Config models.CodefirstConfig `json:"config,omitempty"`
|
||||
Exec types.ExecConfig `json:"exec,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Error *errors.AppError `json:"error,omitempty"`
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package models
|
||||
|
||||
type CodefirstConfig struct {
|
||||
MaxAllowedContainers int `json:"maxallowedcontainers"`
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
type CodeFirstContainer struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ImageURL string `json:"imageurl"`
|
||||
EndpointURL string `json:"endpointurl"`
|
||||
Base64Credentials string `json:"base64credentials,omitempty"`
|
||||
Env []string `json:"env,omitempty"`
|
||||
Private bool `json:"private,omitempty"`
|
||||
Overwrite bool `json:"overwrite,omitempty"`
|
||||
IsStarting bool `json:"isstarting,omitempty"`
|
||||
IsDeleting bool `json:"isdeleting,omitempty"`
|
||||
}
|
Loading…
Reference in new issue