Skip to content

Commit

Permalink
Merge branch 'master' into probakowski/registration-update
Browse files Browse the repository at this point in the history
  • Loading branch information
probakowski authored Oct 29, 2024
2 parents d1595e6 + 4e12566 commit c4c8938
Show file tree
Hide file tree
Showing 76 changed files with 2,092 additions and 974 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/doc-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,28 @@ jobs:
repository: "gravitational/docs"
path: "docs"

- name: Prepare docs site configuration
# Cache node_modules. Unlike the example in the actions/cache repo, this
# caches the node_modules directory instead of the yarn cache. This is
# because yarn needs to build fresh packages even when it copies files
# from the yarn cache into node_modules.
# See:
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: '${{ github.workspace }}/docs/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}/docs/yarn.lock', github.workspace)) }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install docs site dependencies
working-directory: docs
if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
# Prevent occasional `yarn install` executions that run indefinitely
timeout-minutes: 10
run: yarn install

- name: Prepare docs site configuration
# The environment we use for linting the docs differs from the one we
# use for the live docs site in that we only test a single version of
# the content.
Expand Down Expand Up @@ -85,7 +104,6 @@ jobs:
git submodule add --force -b $BRANCH -- https://github.com/gravitational/teleport
cd $GITHUB_WORKSPACE/docs
echo "{\"versions\": [{\"name\": \"teleport\", \"branch\": \"$BRANCH\", \"deprecated\": false}]}" > $GITHUB_WORKSPACE/docs/config.json
yarn install
yarn build-node
- name: Check spelling
Expand All @@ -95,7 +113,8 @@ jobs:
run: cd $GITHUB_WORKSPACE/docs && yarn markdown-lint

- name: Test the docs build
run: cd $GITHUB_WORKSPACE/docs && yarn install && yarn build
working-directory: docs
run: yarn build

stylecheck:
name: Lint docs prose style
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
- 'docs/pages/admin-guides/**'
- 'docs/pages/enroll-resources/**'
- 'docs/pages/reference/operator-resources/**'
- 'docs/pages/reference/terraform-provider.mdx'
- 'docs/pages/reference/terraform-provider/**'
- 'examples/chart/teleport-cluster/charts/teleport-operator/operator-crds'
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,6 @@ RERUN := $(TOOLINGDIR)/bin/rerun
$(RERUN): $(wildcard $(TOOLINGDIR)/cmd/rerun/*.go)
cd $(TOOLINGDIR) && go build -o "$@" ./cmd/rerun

RELEASE_NOTES_GEN := $(TOOLINGDIR)/bin/release-notes
$(RELEASE_NOTES_GEN): $(wildcard $(TOOLINGDIR)/cmd/release-notes/*.go)
cd $(TOOLINGDIR) && go build -o "$@" ./cmd/release-notes

.PHONY: tooling
tooling: ensure-gotestsum $(DIFF_TEST)

Expand Down Expand Up @@ -1822,11 +1818,13 @@ changelog:
# does not match version set it will fail to create a release. If tag doesn't exist it
# will also fail to create a release.
#
# For more information on release notes generation see ./build.assets/tooling/cmd/release-notes
# For more information on release notes generation see:
# https://github.com/gravitational/shared-workflows/tree/gus/release-notes/tools/release-notes#readme
RELEASE_NOTES_GEN = github.com/gravitational/shared-workflows/tools/release-notes@latest
.PHONY: create-github-release
create-github-release: LATEST = false
create-github-release: GITHUB_RELEASE_LABELS = ""
create-github-release: $(RELEASE_NOTES_GEN)
create-github-release:
@NOTES=$$($(RELEASE_NOTES_GEN) --labels=$(GITHUB_RELEASE_LABELS) $(VERSION) CHANGELOG.md) && gh release create v$(VERSION) \
-t "Teleport $(VERSION)" \
--latest=$(LATEST) \
Expand Down
41 changes: 36 additions & 5 deletions api/client/webclient/webclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type Config struct {
Timeout time.Duration
// TraceProvider is used to retrieve a Tracer for creating spans
TraceProvider oteltrace.TracerProvider
// UpdateGroup is used to vary the webapi response based on the
// client's auto-update group.
UpdateGroup string
}

// CheckAndSetDefaults checks and sets defaults
Expand Down Expand Up @@ -169,9 +172,18 @@ func Find(cfg *Config) (*PingResponse, error) {
ctx, span := cfg.TraceProvider.Tracer("webclient").Start(cfg.Context, "webclient/Find")
defer span.End()

endpoint := fmt.Sprintf("https://%s/webapi/find", cfg.ProxyAddr)
endpoint := &url.URL{
Scheme: "https",
Host: cfg.ProxyAddr,
Path: "/webapi/find",
}
if cfg.UpdateGroup != "" {
endpoint.RawQuery = url.Values{
"group": []string{cfg.UpdateGroup},
}.Encode()
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down Expand Up @@ -205,12 +217,21 @@ func Ping(cfg *Config) (*PingResponse, error) {
ctx, span := cfg.TraceProvider.Tracer("webclient").Start(cfg.Context, "webclient/Ping")
defer span.End()

endpoint := fmt.Sprintf("https://%s/webapi/ping", cfg.ProxyAddr)
endpoint := &url.URL{
Scheme: "https",
Host: cfg.ProxyAddr,
Path: "/webapi/ping",
}
if cfg.UpdateGroup != "" {
endpoint.RawQuery = url.Values{
"group": []string{cfg.UpdateGroup},
}.Encode()
}
if cfg.ConnectorName != "" {
endpoint = fmt.Sprintf("%s/%s", endpoint, cfg.ConnectorName)
endpoint = endpoint.JoinPath(cfg.ConnectorName)
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down Expand Up @@ -305,6 +326,10 @@ type PingResponse struct {
// reserved: license_warnings ([]string)
// AutomaticUpgrades describes whether agents should automatically upgrade.
AutomaticUpgrades bool `json:"automatic_upgrades"`
// Edition represents the Teleport edition. Possible values are "oss", "ent", and "community".
Edition string `json:"edition"`
// FIPS represents if Teleport is using FIPS-compliant cryptography.
FIPS bool `json:"fips"`
}

// PingErrorResponse contains the error from /webapi/ping.
Expand Down Expand Up @@ -336,6 +361,12 @@ type AutoUpdateSettings struct {
ToolsVersion string `json:"tools_version"`
// ToolsMode defines mode client auto update feature `enabled|disabled`.
ToolsMode string `json:"tools_mode"`
// AgentVersion defines the version of teleport that agents enrolled into autoupdates should run.
AgentVersion string `json:"agent_version"`
// AgentAutoUpdate indicates if the requesting agent should attempt to update now.
AgentAutoUpdate bool `json:"agent_auto_update"`
// AgentUpdateJitterSeconds defines the jitter time an agent should wait before updating.
AgentUpdateJitterSeconds int `json:"agent_update_jitter_seconds"`
}

// KubeProxySettings is kubernetes proxy settings
Expand Down
12 changes: 6 additions & 6 deletions api/types/autoupdate/rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
spec: &autoupdate.AutoUpdateAgentRolloutSpec{
StartVersion: "1.2.3",
TargetVersion: "2.3.4-dev",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: AgentsUpdateModeEnabled,
Strategy: AgentsStrategyHaltOnError,
},
Expand All @@ -57,7 +57,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
Spec: &autoupdate.AutoUpdateAgentRolloutSpec{
StartVersion: "1.2.3",
TargetVersion: "2.3.4-dev",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: AgentsUpdateModeEnabled,
Strategy: AgentsStrategyHaltOnError,
},
Expand All @@ -74,7 +74,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
name: "missing start version",
spec: &autoupdate.AutoUpdateAgentRolloutSpec{
TargetVersion: "2.3.4-dev",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: AgentsUpdateModeEnabled,
Strategy: AgentsStrategyHaltOnError,
},
Expand All @@ -87,7 +87,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
spec: &autoupdate.AutoUpdateAgentRolloutSpec{
StartVersion: "1.2.3",
TargetVersion: "2-3-4",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: AgentsUpdateModeEnabled,
Strategy: AgentsStrategyHaltOnError,
},
Expand All @@ -100,7 +100,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
spec: &autoupdate.AutoUpdateAgentRolloutSpec{
StartVersion: "1.2.3",
TargetVersion: "2.3.4-dev",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: "invalid-mode",
Strategy: AgentsStrategyHaltOnError,
},
Expand All @@ -126,7 +126,7 @@ func TestNewAutoUpdateAgentRollout(t *testing.T) {
spec: &autoupdate.AutoUpdateAgentRolloutSpec{
StartVersion: "1.2.3",
TargetVersion: "2.3.4-dev",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
AutoupdateMode: AgentsUpdateModeEnabled,
Strategy: "invalid-strategy",
},
Expand Down
4 changes: 3 additions & 1 deletion api/types/autoupdate/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ func checkToolsMode(mode string) error {

func checkScheduleName(schedule string) error {
switch schedule {
case AgentsScheduleRegular, AgentsScheduleImmediate:
case AgentsScheduleImmediate:
return nil
case AgentsScheduleRegular:
return trace.BadParameter("regular schedule is not implemented yet")
default:
return trace.BadParameter("unsupported schedule type: %q", schedule)
}
Expand Down
12 changes: 6 additions & 6 deletions api/types/autoupdate/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
Agents: &autoupdate.AutoUpdateVersionSpecAgents{
StartVersion: "1.2.3-dev.1",
TargetVersion: "1.2.3-dev.2",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
Mode: AgentsUpdateModeEnabled,
},
},
Expand All @@ -111,7 +111,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
Agents: &autoupdate.AutoUpdateVersionSpecAgents{
StartVersion: "1.2.3-dev.1",
TargetVersion: "1.2.3-dev.2",
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
Mode: AgentsUpdateModeEnabled,
},
},
Expand All @@ -124,7 +124,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
StartVersion: "",
TargetVersion: "1.2.3",
Mode: AgentsUpdateModeEnabled,
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
Expand All @@ -138,7 +138,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
StartVersion: "1.2.3-dev",
TargetVersion: "",
Mode: AgentsUpdateModeEnabled,
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
Expand All @@ -152,7 +152,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
StartVersion: "17-0-0",
TargetVersion: "1.2.3",
Mode: AgentsUpdateModeEnabled,
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
Expand All @@ -166,7 +166,7 @@ func TestNewAutoUpdateVersion(t *testing.T) {
StartVersion: "1.2.3",
TargetVersion: "17-0-0",
Mode: AgentsUpdateModeEnabled,
Schedule: AgentsScheduleRegular,
Schedule: AgentsScheduleImmediate,
},
},
assertErr: func(t *testing.T, err error, a ...any) {
Expand Down
8 changes: 8 additions & 0 deletions api/types/trustedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"time"

"github.com/gravitational/trace"

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

// TrustedCluster holds information needed for a cluster that can not be directly
Expand Down Expand Up @@ -60,6 +62,8 @@ type TrustedCluster interface {
SetReverseTunnelAddress(string)
// CanChangeStateTo checks the TrustedCluster can transform into another.
CanChangeStateTo(TrustedCluster) error
// Clone returns a deep copy of the TrustedCluster.
Clone() TrustedCluster
}

// NewTrustedCluster is a convenience way to create a TrustedCluster resource.
Expand Down Expand Up @@ -259,6 +263,10 @@ func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error {
return nil
}

func (c *TrustedClusterV2) Clone() TrustedCluster {
return utils.CloneProtoMsg(c)
}

// String represents a human readable version of trusted cluster settings.
func (c *TrustedClusterV2) String() string {
return fmt.Sprintf("TrustedCluster(Enabled=%v,Roles=%v,Token=%v,ProxyAddress=%v,ReverseTunnelAddress=%v)",
Expand Down
33 changes: 33 additions & 0 deletions api/utils/entraid/federation_metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2024 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package entraid

import (
"net/url"
"path"
)

// FederationMetadataURL returns the URL for the federation metadata endpoint
func FederationMetadataURL(tenantID, appID string) string {
return (&url.URL{
Scheme: "https",
Host: "login.microsoftonline.com",
Path: path.Join(tenantID, "federationmetadata", "2007-06", "federationmetadata.xml"),
RawQuery: url.Values{
"appid": {appID},
}.Encode(),
}).String()
}
2 changes: 0 additions & 2 deletions assets/aws/files/system/teleport-proxy-acm.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Restart=always
RestartSec=5
RuntimeDirectory=teleport
EnvironmentFile=-/etc/default/teleport
# TODO(gus): REMOVE IN 17.0.0 - /etc/default/teleport should be used instead
EnvironmentFile=/etc/teleport.d/conf
ExecStartPre=/usr/local/bin/teleport-ssm-get-token
ExecStart=/usr/local/bin/teleport start --config=/etc/teleport.yaml --diag-addr=127.0.0.1:3000 --pid-file=/run/teleport/teleport.pid
# systemd before 239 needs an absolute path
Expand Down
2 changes: 0 additions & 2 deletions assets/aws/files/system/teleport-proxy.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Restart=always
RestartSec=5
RuntimeDirectory=teleport
EnvironmentFile=-/etc/default/teleport
# TODO(gus): REMOVE IN 17.0.0 - /etc/default/teleport should be used instead
EnvironmentFile=/etc/teleport.d/conf
ExecStartPre=/usr/local/bin/teleport-ssm-get-token
ExecStartPre=/bin/aws s3 sync s3://${TELEPORT_S3_BUCKET}/live/${TELEPORT_DOMAIN_NAME} /var/lib/teleport
ExecStart=/usr/local/bin/teleport start --config=/etc/teleport.yaml --diag-addr=127.0.0.1:3000 --pid-file=/run/teleport/teleport.pid
Expand Down
29 changes: 0 additions & 29 deletions build.assets/tooling/cmd/release-notes/README.md

This file was deleted.

Loading

0 comments on commit c4c8938

Please sign in to comment.