Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace json schema with go validation #781

Merged
merged 40 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b8f2393
add go validator
antho1404 Feb 10, 2019
5f20da7
update definition
antho1404 Feb 10, 2019
2a8bb65
update service validation
antho1404 Feb 10, 2019
b797dd9
remove unused assets
antho1404 Feb 10, 2019
3d1929a
add dependency name validation
antho1404 Feb 10, 2019
07ef1c7
fix tests
antho1404 Feb 10, 2019
dc5c93e
warning on file missing instead of error
antho1404 Feb 10, 2019
eb87acb
Update service/importer/definition.go
ilgooz Feb 11, 2019
8f84d20
Copy isDomainName and export it
krhubert Feb 13, 2019
d4b1ae3
Add validator and check domain name funcs
krhubert Feb 13, 2019
a36e6e7
Validate sid,ports and dependencie image
krhubert Feb 13, 2019
6d64d38
Remove govalidator dependency
krhubert Feb 20, 2019
69a0e12
Append warning to service validation
krhubert Feb 22, 2019
498adc6
Disable gocyclo linter for xnet.IsDomainName
krhubert Feb 25, 2019
99c1769
Improving validation error
NicolasMahe Mar 8, 2019
91405ae
Fix IsDomainName on empty string
NicolasMahe Mar 8, 2019
a24fbad
Fix IsPort on port with format xx:yy
NicolasMahe Mar 8, 2019
388f927
Exclude xnet.IsDomainName func from lint
NicolasMahe Mar 8, 2019
d2d1087
fix lint
NicolasMahe Mar 8, 2019
40b0257
fix test
NicolasMahe Mar 8, 2019
871a1fd
Merge branch 'dev' into feature/go-validation
NicolasMahe Mar 8, 2019
436c386
Fix port validation
NicolasMahe Mar 11, 2019
b189d28
Fix validation url in service deploy
NicolasMahe Mar 11, 2019
408d05e
Add validation of volumesfrom
NicolasMahe Mar 11, 2019
ebf9c36
Use service.ConfigurationDependencyKey instead of hardcoded value
NicolasMahe Mar 11, 2019
bd85719
Fix nil pointer
NicolasMahe Mar 11, 2019
2612a8e
split function validateServiceStruct
NicolasMahe Mar 11, 2019
34763d6
Merge commit 'dev' into feature/go-validation
NicolasMahe Mar 11, 2019
2a4e7f4
Merge branch 'feature/go-validation' of github.com:mesg-foundation/co…
krhubert Mar 11, 2019
5cef634
Change port to portmap and lower struct filed
krhubert Mar 11, 2019
3a66346
Refactor validator funcs
krhubert Mar 11, 2019
5a2487a
Revert attempt to lowercase field
NicolasMahe Mar 11, 2019
7419e58
Merge branch 'dev' into feature/go-validation
NicolasMahe Mar 11, 2019
215a05d
Fix isDomainName validator
NicolasMahe Mar 11, 2019
a3e2140
Merge commit '7419e583d65bc62d46e7a4ca65cb7b1e3e25e2b9' into feature/…
NicolasMahe Mar 11, 2019
aad381a
Merge branch 'dev' into feature/go-validation
ilgooz Mar 11, 2019
7482339
Improve IsDomainName. Fix Sid validation on empty value.
NicolasMahe Mar 12, 2019
f14ba8e
Improve tests
NicolasMahe Mar 12, 2019
69aa8f4
Fix test
NicolasMahe Mar 12, 2019
bcf417b
Merge branch 'dev' into feature/go-validation
NicolasMahe Mar 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions commands/provider/service_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"
"io"

"github.com/asaskevich/govalidator"
"github.com/docker/cli/cli/command/image/build"
"github.com/docker/docker/pkg/archive"
"github.com/mesg-foundation/core/protobuf/coreapi"
validator "gopkg.in/go-playground/validator.v9"
)

// StatusType indicates the type of status message.
Expand Down Expand Up @@ -56,7 +56,8 @@ func (p *ServiceProvider) ServiceDeploy(path string, env map[string]string, stat
}()
go readDeployReply(stream, deployment, statuses)

if govalidator.IsURL(path) {
validate := validator.New()
if err := validate.Var(path, "url"); err == nil {
if err := stream.Send(&coreapi.DeployServiceRequest{
Value: &coreapi.DeployServiceRequest_Url{Url: path},
Env: env,
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 // indirect
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f
github.com/briandowns/spinner v0.0.0-20180822135157-9f016caa1359
github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224
github.com/containerd/continuity v0.0.0-20180712174259-0377f7d76720 // indirect
Expand All @@ -21,6 +20,8 @@ require (
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/gliderlabs/ssh v0.1.1 // indirect
github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30
github.com/go-playground/locales v0.12.1
github.com/go-playground/universal-translator v0.16.0
github.com/gogo/protobuf v1.0.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/protobuf v1.2.0
Expand All @@ -37,6 +38,7 @@ require (
github.com/kelseyhightower/envconfig v1.3.0
github.com/kevinburke/ssh_config v0.0.0-20180711164746-82cf3f926438 // indirect
github.com/kr/pty v1.1.3 // indirect
github.com/leodido/go-urn v1.1.0 // indirect
github.com/mattn/go-colorable v0.0.0-20180310133214-efa589957cd0 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mesg-foundation/prefixer v0.0.0-20180907095533-d7dbe41616bd
Expand All @@ -61,9 +63,6 @@ require (
github.com/syndtr/goleveldb v0.0.0-20180708030551-c4c61651e9e3
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5
github.com/xanzy/ssh-agent v0.2.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8 // indirect
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
Expand All @@ -74,6 +73,8 @@ require (
gopkg.in/AlecAivazis/survey.v1 v1.6.1
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v9 v9.26.0
gopkg.in/src-d/go-billy.v4 v4.2.0 // indirect
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 // indirect
gopkg.in/src-d/go-git.v4 v4.5.0
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBb
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f h1:/8NcnxL60YFll4ehCwibKotx0BR9v2ND40fomga8qDs=
github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/briandowns/spinner v0.0.0-20180822135157-9f016caa1359 h1:r5zPKnN2fbbo0UYy0OiI7leKnMra3DlF+3FWdWvtZ2c=
github.com/briandowns/spinner v0.0.0-20180822135157-9f016caa1359/go.mod h1:hw/JEQBIE+c/BLI4aKM8UU8v+ZqrD3h7HC27kKt8JQU=
github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224 h1:rnCKRrdSBqc061l0CDuYB+7X3w6w8IK/VCSChJXv62g=
Expand Down Expand Up @@ -44,6 +42,10 @@ github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30 h1:QCzzs6MtdCqGT1U1t6Ar/WFH9UmPKYCtMutthIC0XVM=
github.com/go-bindata/go-bindata v0.0.0-20181025070752-41975c0ccc30/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc=
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM=
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM=
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
Expand Down Expand Up @@ -78,6 +80,8 @@ github.com/kevinburke/ssh_config v0.0.0-20180711164746-82cf3f926438 h1:O2UbfXNOr
github.com/kevinburke/ssh_config v0.0.0-20180711164746-82cf3f926438/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/pty v1.1.3 h1:/Um6a/ZmD5tF7peoOJ5oN5KMQ0DrGVQSXLNwyckutPk=
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/mattn/go-colorable v0.0.0-20180310133214-efa589957cd0 h1:cDvUG90i1ssGJGqMNx2Ubbn+bx7VOzjdvQ45zpy0X4w=
github.com/mattn/go-colorable v0.0.0-20180310133214-efa589957cd0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
Expand Down Expand Up @@ -134,12 +138,6 @@ github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5 h1:Xim2mBRFdXzXmKRO
github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5/go.mod h1:ppEjwdhyy7Y31EnHRDm1JkChoC7LXIJ7Ex0VYLWtZtQ=
github.com/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
github.com/xanzy/ssh-agent v0.2.0/go.mod h1:0NyE30eGUDliuLEHJgYte/zncp2zdTStcOnWhgSqHD8=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f h1:mvXjJIHRZyhNuGassLTcXTwjiWq7NmjdavZsUnmFybQ=
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8 h1:h7zdf0RiEvWbYBKIx4b+q41xoUVnMmvsGZnIVE5syG8=
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
Expand Down Expand Up @@ -170,6 +168,10 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.26.0 h1:2NPPsBpD0ZoxshmLWewQru8rWmbT5JqSzz9D1ZrAjYQ=
gopkg.in/go-playground/validator.v9 v9.26.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/src-d/go-billy.v4 v4.2.0 h1:VGbrP1EsYxtvVPEiHui+4//imr4E5MGEFLx66bQtusg=
gopkg.in/src-d/go-billy.v4 v4.2.0/go.mod h1:ZHSF0JP+7oD97194otDUCD7Ofbk63+xFcfWP5bT6h+Q=
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 h1:AxUOwLW3at53ysFqs0Lg+H+8KSQXl7AEHBvWj8wEsT8=
Expand Down
1 change: 0 additions & 1 deletion scripts/generate-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# make sure script is running inside mesg/tools container.
source $(dirname $0)/require-mesg-tools.sh

go-bindata -o service/importer/assets/schema.go -pkg assets ./service/importer/assets/schema.json
go-bindata -o commands/provider/assets/readme_template.go -pkg assets ./commands/provider/assets/readme_template.md
239 changes: 0 additions & 239 deletions service/importer/assets/schema.go

This file was deleted.

Loading