gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.63k stars 1.76k forks source link

Bring Teleport API version to parity with our standard release versioning #12162

Open deusxanima opened 2 years ago

deusxanima commented 2 years ago

What

A number of customers have requested we have our API versioning match our standard release versioning for ease of use, security scanning...etc. Currently it does not track the teleport versioning at all. Example:

go get github.com/gravitational/teleport/api@f577413
go: finding github.com f577413
go: finding github.com/gravitational/teleport/api f577413
go: finding github.com/gravitational/teleport f577413
go: finding github.com/gravitational f577413
go: finding github.com/gravitational/teleport/api f577413
go: finding github.com/gravitational/teleport f577413

go: downloading github.com/gravitational/teleport/api v0.0.0-20220406233052-f577413d3c2a
go: downloading github.com/gravitational/teleport v1.3.3-0.20220406233052-f577413d3c2a
go: extracting github.com/gravitational/teleport/api v0.0.0-20220406233052-f577413d3c2a
go: extracting github.com/gravitational/teleport v1.3.3-0.20220406233052-f577413d3c2a
user@node:/home/user/client-demo# 
user@node:/home/user/client-demo# ls
go.mod  go.sum
user@node:/home/user/client-demo# cat go.mod 
module client-demo

go 1.13

require github.com/gravitational/teleport/api v0.0.0-20220406233052-f577413d3c2a // indirect

gz#4679

Richard-Barrett commented 2 years ago
programmerq commented 1 year ago

A path forward on this is to utilize the git sha of the tagged teleport version that you want to pin this to:

https://go.dev/ref/mod#pseudo-versions

For example, if I wanted to use the v11.1.0 tag, I can grab the git sha for that tag: git show v11.1.0 | grep commit. Go lets you refer to a commit by its first twelve characters. In this case, it is 4ef520e8175.

go get -u github.com/gravitational/teleport@4ef520e8175

Running that command inside a directory with a go.mod file should result in a longer pseudo-version being calculated and expanded:

require (
    github.com/gravitational/teleport v1.3.3-0.20221129014409-4ef520e81753 // indirect
)

One can continue with that v1.3.3-0.20221129014409-4ef520e81753 or even switch it to v0.0.0-0.20221129014409-4ef520e81753 pseudo-version format that is more in-line with how the teleport-plugins repo refers to the module in its go.mod.

zmb3 commented 1 year ago

For now, the best way to do this is by following the steps in our documentation: https://goteleport.com/docs/api/getting-started/#step-33-create-a-go-project

$ go list -f '{{.Version}}' -m "github.com/gravitational/teleport/api@$(git rev-parse $SOME_VERSION)"

The above will produce a go-gettable pseudoversion for a particular Teleport tag.

myoung34 commented 1 year ago

For those curious and willing to sin like myself

Get the git SHA for the tag you want, browse to that commits go.mod and copy in all of the replaces (minus ./api)

For example the minimum for v13.3.7 is

module github.redact.net/redact/redact

go 1.21.1

require (
        github.com/gravitational/teleport v0.0.0-00010101000000-000000000000 // replaced
        github.com/gravitational/teleport/api v0.0.0-00010101000000-000000000000 // replaced
        github.com/microsoft/go-mssqldb v0.0.0-00010101000000-000000000000 // replaced
        github.com/coreos/go-oidc v2.1.0+incompatible // replaced
        github.com/vulcand/predicate v1.2.0 // replaced
        github.com/alecthomas/kingpin/v2 v2.3.2 // replaced
        github.com/julienschmidt/httprouter v1.3.0 // replaced
        github.com/keys-pub/go-libfido2 v1.5.3-0.20220306005615-8ab03fb1ec27 // replaced
        github.com/datastax/go-cassandra-native-protocol v0.0.0-20220706104457-5e8aad05cf90
        github.com/go-mysql-org/go-mysql v1.5.0 // replaced
        github.com/go-redis/redis/v9 v9.0.0-rc.1 // replaced
        github.com/gogo/protobuf v1.3.2 // replaced
        github.com/moby/spdystream v0.2.0 // indirect
)

replace (
        github.com/gravitational/teleport => github.com/gravitational/teleport v0.0.0-20230829203008-eb15b29fe8de // ref: tags/v13.3.7
        github.com/gravitational/teleport/api => github.com/gravitational/teleport/api v0.0.0-20230829203008-eb15b29fe8de // ref: tags/v13.3.7
        github.com/coreos/go-oidc => github.com/gravitational/go-oidc v0.1.0
        github.com/microsoft/go-mssqldb => github.com/gravitational/go-mssqldb v0.11.1-0.20230331180905-0f76f1751cd3
        github.com/vulcand/predicate => github.com/gravitational/predicate v1.3.1
        github.com/alecthomas/kingpin/v2 => github.com/gravitational/kingpin/v2 v2.1.11-0.20230515143221-4ec6b70ecd33
        github.com/julienschmidt/httprouter => github.com/gravitational/httprouter v1.3.1-0.20220408074523-c876c5e705a5
        github.com/keys-pub/go-libfido2 => github.com/gravitational/go-libfido2 v1.5.3-0.20230202181331-c71192ef1c8a
        github.com/datastax/go-cassandra-native-protocol => github.com/gravitational/go-cassandra-native-protocol v0.0.0-20221005103706-b9e66c056e90
        github.com/go-mysql-org/go-mysql => github.com/gravitational/go-mysql v1.5.0-teleport.1
        github.com/go-redis/redis/v9 => github.com/gravitational/redis/v9 v9.0.0-teleport.3
        github.com/gogo/protobuf => github.com/gravitational/protobuf v1.3.2-teleport.1
        github.com/moby/spdystream => github.com/gravitational/spdystream v0.0.0-20230512133543-4e46862ca9bf
)