Skip to content

Commit

Permalink
Add semver equivalents of teleport.Version and api.Version (#38038) (#…
Browse files Browse the repository at this point in the history
…38152)

The teleport.MinClientVersion was also updated to be derived from
the new semver variant as well as adding a semver.Version variant.
Additionally instances of semver.New(teleport.Version) or
semver.New(api.Version) were replaced to use the newly introduced
variables. It was also noticed that auth.MinSupportedModeratedSessionsVersion
was no longer being used so it was removed.
  • Loading branch information
rosstimothy authored Feb 13, 2024
1 parent ad03706 commit e9e2641
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 49 deletions.
3 changes: 1 addition & 2 deletions api/types/trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"
"time"

"github.com/coreos/go-semver/semver"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"

Expand Down Expand Up @@ -67,7 +66,7 @@ var CertAuthTypes = []CertAuthType{HostCA, UserCA, DatabaseCA, DatabaseClientCA,
// major version, so that we can avoid erroring out when a potentially older
// remote server doesn't know about them.
func (c CertAuthType) NewlyAdded() bool {
return c.addedInMajorVer() >= semver.New(api.Version).Major
return c.addedInMajorVer() >= api.SemVersion.Major
}

// addedInVer return the major version in which given CA was added.
Expand Down
5 changes: 3 additions & 2 deletions api/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
package teleport

import (
"fmt"
"strings"
"time"

"github.com/coreos/go-semver/semver"
)

// WebAPIVersion is a current webapi version
Expand Down Expand Up @@ -681,16 +678,6 @@ const (
SystemAccessApproverUserName = "@teleport-access-approval-bot"
)

// MinClientVersion is the minimum client version required by the server.
var MinClientVersion string

func init() {
// Per https://github.com/gravitational/teleport/blob/master/rfd/0012-teleport-versioning.md,
// only one major version backwards is supported for clients.
ver := semver.New(Version)
MinClientVersion = fmt.Sprintf("%d.0.0", ver.Major-1)
}

const (
// RemoteClusterStatusOffline indicates that cluster is considered as
// offline, since it has missed a series of heartbeats
Expand Down
24 changes: 20 additions & 4 deletions integrations/kube-agent-updater/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
// Code generated by "make version". DO NOT EDIT.
/*
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package kubeversionupdater

const Version = "15.0.1"
import "github.com/gravitational/teleport/api"

// Gitref is set to the output of "git describe" during the build process.
var Gitref string
const Version = api.Version
6 changes: 1 addition & 5 deletions lib/auth/join_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ const (
challengeHeaderKey = "x-teleport-challenge"
)

var (
authTeleportVersion = semver.New(teleport.Version)
)

// validateSTSHost returns an error if the given stsHost is not a valid regional
// endpoint for the AWS STS service, or nil if it is valid. If fips is true, the
// endpoint must be a valid FIPS endpoint.
Expand Down Expand Up @@ -318,7 +314,7 @@ type iamRegisterConfig struct {

func defaultIAMRegisterConfig(fips bool) *iamRegisterConfig {
return &iamRegisterConfig{
authVersion: authTeleportVersion,
authVersion: teleport.SemVersion,
fips: fips,
}
}
Expand Down
3 changes: 0 additions & 3 deletions lib/auth/session_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"slices"
"strings"

"github.com/coreos/go-semver/semver"
"github.com/gravitational/trace"
"github.com/vulcand/predicate"

Expand All @@ -33,8 +32,6 @@ import (
"github.com/gravitational/teleport/lib/utils"
)

var MinSupportedModeratedSessionsVersion = semver.New(utils.VersionBeforeAlpha("9.0.0"))

// SessionAccessEvaluator takes a set of policies
// and uses rules to evaluate them to determine when a session may start
// and if a user can join a session.
Expand Down
38 changes: 36 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
// Code generated by "make version". DO NOT EDIT.
/*
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package teleport

const Version = "15.0.1"
import (
"github.com/coreos/go-semver/semver"

"github.com/gravitational/teleport/api"
)

const Version = api.Version

var (
// SemVersion is the Version represented as a [semver.Version].
SemVersion = api.SemVersion
// MinClientVersion is the minimum client version required by the server.
// Per https://github.com/gravitational/teleport/blob/master/rfd/0012-teleport-versioning.md,
// only one major version backwards is supported for clients.
MinClientVersion = MinClientSemVersion.String()
// MinClientSemVersion is the MinClientVersion represented as a [semver.Version].
MinClientSemVersion = semver.Version{Major: SemVersion.Major - 1}
)

// Gitref is set to the output of "git describe" during the build process.
var Gitref string
20 changes: 2 additions & 18 deletions version.mk
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
GITREF=$(shell git describe --long --tags)

# $(VERSION_GO) will be written to version.go
VERSION_GO="// Code generated by \"make version\". DO NOT EDIT.\n\
package teleport\n\n\
const Version = \"$(VERSION)\"\n\n\
// Gitref is set to the output of \"git describe\" during the build process.\n\
var Gitref string\n"

# $(API_VERSION_GO) will be written to api/version.go
API_VERSION_GO="// Code generated by \"make version\". DO NOT EDIT.\n\
package api\n\n\
import \"github.com/coreos/go-semver/semver\"\n\n\
const Version = \"$(VERSION)\"\n\n\
// Gitref is set to the output of \"git describe\" during the build process.\n\
var Gitref string\n"

# $(UPDATER_VERSION_GO) will be written to api/version.go
UPDATER_VERSION_GO="// Code generated by \"make version\". DO NOT EDIT.\n\
package kubeversionupdater\n\n\
const Version = \"$(VERSION)\"\n\n\
// Gitref is set to the output of \"git describe\" during the build process.\n\
var Gitref string\n"
var SemVersion = semver.New(Version)\n\n"

# $(GITREF_GO) will be written to gitref.go
GITREF_GO="// Code generated by \"make version\". DO NOT EDIT.\n\
Expand All @@ -31,9 +17,7 @@ func init() { Gitref = \"$(GITREF)\" }\n"
#
.PHONY:setver
setver: validate-semver helm-version tsh-version
@printf $(VERSION_GO) | gofmt > version.go
@printf $(API_VERSION_GO) | gofmt > ./api/version.go
@printf $(UPDATER_VERSION_GO) | gofmt > ./integrations/kube-agent-updater/version.go
@printf $(GITREF_GO) | gofmt > gitref.go

# helm-version automatically updates the versions of Helm charts to match the version set in the Makefile,
Expand Down

0 comments on commit e9e2641

Please sign in to comment.