mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-03 16:38:35 +08:00
* Move AssembleAppFQDN to lib/utils * Update comment for endpoint_uri * Fix comment for TotalCount, move AppServerOrSAMLIdPServiceProvider * Remove unnecessary libclient import * Add fqdn to apps returned from tsh daemon * Drop "Server" from AppServerOrSAMLIdPServiceProvider, add Go doc * Rerun make grpc
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
// 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 utils
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gravitational/teleport/api/types"
|
|
)
|
|
|
|
// AssembleAppFQDN returns the application's FQDN.
|
|
//
|
|
// If the application is running within the local cluster and it has a public
|
|
// address specified, the application's public address is used.
|
|
//
|
|
// In all other cases, i.e. if the public address is not set or the application
|
|
// is running in a remote cluster, the FQDN is formatted as
|
|
// <appName>.<localProxyDNSName>
|
|
func AssembleAppFQDN(localClusterName string, localProxyDNSName string, appClusterName string, app types.Application) string {
|
|
isLocalCluster := localClusterName == appClusterName
|
|
if isLocalCluster && app.GetPublicAddr() != "" {
|
|
return app.GetPublicAddr()
|
|
}
|
|
return fmt.Sprintf("%v.%v", app.GetName(), localProxyDNSName)
|
|
}
|