Skip to content

Fix go-swagger to work with Go 1.14#40523

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:go_swagger_1.14
Feb 14, 2020
Merged

Fix go-swagger to work with Go 1.14#40523
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:go_swagger_1.14

Conversation

@thaJeztah
Copy link
Member

relates to #40353

full diff: kolyshkin/go-swagger@5793aa6...5e6cb12

The template used was broken with Go 1.14, which has some stricter
rules, introduced in https://golang.org/cl/206124

root@b5beaed18589:/go/src/github.com/docker/docker# ./hack/generate-swagger-api.sh
2020/02/07 15:12:01 trying to read config from /go/src/github.com/docker/docker/api/swagger-gen.yaml
2020/02/07 15:12:02 rendering 1 templates for model ErrorResponse
2020/02/07 15:12:02 name field ErrorResponse
2020/02/07 15:12:02 package field types
2020/02/07 15:12:02 creating "error_response.go" in "api/types" as definition
model: template: schematype:2:18: executing "schemaType" at <(len .AllOf) gt 0>: can't give argument to non-function len .AllOf

This update includes the fix from kolyshkin/go-swagger#1. Opening this as a separate pull request, so that we can backport this to release branches to prepare them for future Go updates

The template used was broken with Go 1.14, which has some stricter
rules, introduced in https://golang.org/cl/206124

```
root@b5beaed18589:/go/src/github.com/docker/docker# ./hack/generate-swagger-api.sh
2020/02/07 15:12:01 trying to read config from /go/src/github.com/docker/docker/api/swagger-gen.yaml
2020/02/07 15:12:02 rendering 1 templates for model ErrorResponse
2020/02/07 15:12:02 name field ErrorResponse
2020/02/07 15:12:02 package field types
2020/02/07 15:12:02 creating "error_response.go" in "api/types" as definition
model: template: schematype:2:18: executing "schemaType" at <(len .AllOf) gt 0>: can't give argument to non-function len .AllOf
```

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

ping @SamWhited @kolyshkin @AkihiroSuda PTAL 🤗

@SamWhited
Copy link
Contributor

LGTM

@thaJeztah
Copy link
Member Author

bringing this one in

@thaJeztah thaJeztah merged commit b2b8056 into moby:master Feb 14, 2020
@thaJeztah thaJeztah deleted the go_swagger_1.14 branch February 14, 2020 19:50
@cpuguy83
Copy link
Member

Master tests do not like this.

[2020-02-14T19:58:01.544Z] + docker run --rm -t --privileged -v /home/ubuntu/workspace/moby_master/bundles:/go/src/github.com/docker/docker/bundles -v /home/ubuntu/workspace/moby_master/.git:/go/src/github.com/docker/docker/.git --name docker-pr367 -e DOCKER_EXPERIMENTAL -e DOCKER_GITCOMMIT=b2b80564dbcf6b0643a4c29a405c17bb91840dae -e DOCKER_GRAPHDRIVER -e TEST_FORCE_VALIDATE -e VALIDATE_REPO=https://github.com/moby/moby.git -e VALIDATE_BRANCH= docker:b2b80564dbcf6b0643a4c29a405c17bb91840dae hack/validate/default

[2020-02-14T19:58:02.108Z] 0 adds, 0 deletions; nothing to validate! :)

[2020-02-14T19:58:07.376Z] Congratulations!  Seccomp profile generation is done correctly.

[2020-02-14T19:58:07.376Z] Congratulations!  Packages in "./pkg/..." are safely isolated from internal code.

[2020-02-14T19:58:15.485Z] Congratulations!  The swagger spec at "api/swagger.yaml" is valid against swagger specification 2.0

[2020-02-14T19:58:17.381Z] The result of hack/generate-swagger-api.sh differs

[2020-02-14T19:58:17.381Z] 

[2020-02-14T19:58:17.381Z] diff --git a/api/types/container/container_wait.go b/api/types/container/container_wait.go

[2020-02-14T19:58:17.381Z] index 49e05ae669..c2e69b5b25 100644

[2020-02-14T19:58:17.381Z] --- a/api/types/container/container_wait.go

[2020-02-14T19:58:17.381Z] +++ b/api/types/container/container_wait.go

[2020-02-14T19:58:17.381Z] @@ -6,14 +6,6 @@ package container // import "github.com/docker/docker/api/types/container"

[2020-02-14T19:58:17.381Z]  // See hack/generate-swagger-api.sh

[2020-02-14T19:58:17.381Z]  // ----------------------------------------------------------------------------

[2020-02-14T19:58:17.381Z]  

[2020-02-14T19:58:17.381Z] -// ContainerWaitOKBodyError container waiting error, if any

[2020-02-14T19:58:17.381Z] -// swagger:model ContainerWaitOKBodyError

[2020-02-14T19:58:17.381Z] -type ContainerWaitOKBodyError struct {

[2020-02-14T19:58:17.381Z] -

[2020-02-14T19:58:17.381Z] -	// Details of an error

[2020-02-14T19:58:17.381Z] -	Message string `json:"Message,omitempty"`

[2020-02-14T19:58:17.381Z] -}

[2020-02-14T19:58:17.381Z] -

[2020-02-14T19:58:17.381Z]  // ContainerWaitOKBody OK response to ContainerWait operation

[2020-02-14T19:58:17.381Z]  // swagger:model ContainerWaitOKBody

[2020-02-14T19:58:17.381Z]  type ContainerWaitOKBody struct {

[2020-02-14T19:58:17.381Z] @@ -26,3 +18,11 @@ type ContainerWaitOKBody struct {

[2020-02-14T19:58:17.381Z]  	// Required: true

[2020-02-14T19:58:17.381Z]  	StatusCode int64 `json:"StatusCode"`

[2020-02-14T19:58:17.381Z]  }

[2020-02-14T19:58:17.381Z] +

[2020-02-14T19:58:17.381Z] +// ContainerWaitOKBodyError container waiting error, if any

[2020-02-14T19:58:17.381Z] +// swagger:model ContainerWaitOKBodyError

[2020-02-14T19:58:17.381Z] +type ContainerWaitOKBodyError struct {

[2020-02-14T19:58:17.381Z] +

[2020-02-14T19:58:17.381Z] +	// Details of an error

[2020-02-14T19:58:17.381Z] +	Message string `json:"Message,omitempty"`

[2020-02-14T19:58:17.381Z] +}

[2020-02-14T19:58:17.381Z] 

[2020-02-14T19:58:17.381Z] Please update api/swagger.yaml with any API changes, then 

[2020-02-14T19:58:17.381Z] run hack/generate-swagger-api.sh.

script returned exit code 1

@thaJeztah
Copy link
Member Author

@cpuguy83 that looks like the standard map randomisation problem we already have (#36714 was meant to replace it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants