OpenAPIv2 to openapiv2

While updating kube controller dependencies, got this strange error in the gitlab pipelines. Although everthing ran smoothly locally.

vendor/k8s.io/kube-openapi/pkg/util/proto/document.go:24:2: cannot find package "." in:
	/builds/co2/cloud-delivery/stack-groups/vendor/github.com/googleapis/gnostic/openapiv2

It took some to figure out what was going, so adding this here for my reference and for someone else. In the newer version of github.com/googleapis/gnostic/openapiv2 package name has been updated from OpenAPIv2 to openapiv2.

Although it does change the name of the package locally, git doesn’t acknowledge the case change in the vendor directory as a valid change.

And git list the files still with old case.

> git ls-files | grep vendor/github.com/googleapis/gnostic
vendor/github.com/googleapis/gnostic/LICENSE
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go
vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto
vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md
vendor/github.com/googleapis/gnostic/OpenAPIv2/document.go
vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json

So in gitlab which fetches the vendor from the repository still sees the files as OpenAPIv2 and all dependencies on the package break, whereas locally it works fine.

Fixing it pretty simple, delete the files and recreate it and add to git again.

> git rm -rf vendor/github.com/googleapis/gnostic/OpenAPIv2
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go'
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go'
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto'
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md'
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/document.go'
rm 'vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json'

Recreated the files again using go mod vendor, add add the files again using git add vendor/.

This update the files as:

> git status
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.go -> vendor/github.com/googleapis/gnostic/openapiv2/OpenAPIv2.go
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.pb.go -> vendor/github.com/googleapis/gnostic/openapiv2/OpenAPIv2.pb.go
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/OpenAPIv2.proto -> vendor/github.com/googleapis/gnostic/openapiv2/OpenAPIv2.proto
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/README.md -> vendor/github.com/googleapis/gnostic/openapiv2/README.md
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/document.go -> vendor/github.com/googleapis/gnostic/openapiv2/document.go
	renamed:    vendor/github.com/googleapis/gnostic/OpenAPIv2/openapi-2.0.json -> vendor/github.com/googleapis/gnostic/openapiv2/openapi-2.0.json

Added the changes and pushed it to fix the problem.

comments powered by Disqus