Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Allow the export api to be called without login #4532

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tkg/test/ui/data/aws/aws-test-1-output-config.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"AWS_AMI_ID: ami-012886bac01b37bae\nAWS_NODE_AZ: us-west-a\nAWS_NODE_AZ_1: \"\"\nAWS_NODE_AZ_2: \"\"\nAWS_PRIVATE_NODE_CIDR: \"\"\nAWS_PRIVATE_NODE_CIDR_1: \"\"\nAWS_PRIVATE_NODE_CIDR_2: \"\"\nAWS_PRIVATE_SUBNET_ID: sn4\nAWS_PRIVATE_SUBNET_ID_1: \"\"\nAWS_PRIVATE_SUBNET_ID_2: \"\"\nAWS_PROFILE: profile1\nAWS_PUBLIC_NODE_CIDR: \"\"\nAWS_PUBLIC_NODE_CIDR_1: \"\"\nAWS_PUBLIC_NODE_CIDR_2: \"\"\nAWS_PUBLIC_SUBNET_ID: sn1\nAWS_PUBLIC_SUBNET_ID_1: \"\"\nAWS_PUBLIC_SUBNET_ID_2: \"\"\nAWS_REGION: us-west-2\nAWS_SSH_KEY_NAME: myKeyPair\nAWS_VPC_CIDR: \"\"\nAWS_VPC_ID: vpc-1\nBASTION_HOST_ENABLED: \"true\"\nCLUSTER_ANNOTATIONS: 'description:,location:'\nCLUSTER_CIDR: 100.96.0.0/11\nCLUSTER_NAME: my-aws-name\nCLUSTER_PLAN: dev\nCONTROL_PLANE_MACHINE_TYPE: c6gn.medium\nENABLE_AUDIT_LOGGING: \"\"\nENABLE_CEIP_PARTICIPATION: \"true\"\nENABLE_MHC: \"false\"\nIDENTITY_MANAGEMENT_TYPE: none\nINFRASTRUCTURE_PROVIDER: aws\nLDAP_BIND_DN: \"\"\nLDAP_BIND_PASSWORD: \"\"\nLDAP_GROUP_SEARCH_BASE_DN: \"\"\nLDAP_GROUP_SEARCH_FILTER: \"\"\nLDAP_GROUP_SEARCH_GROUP_ATTRIBUTE: \"\"\nLDAP_GROUP_SEARCH_NAME_ATTRIBUTE: cn\nLDAP_GROUP_SEARCH_USER_ATTRIBUTE: DN\nLDAP_HOST: \"\"\nLDAP_ROOT_CA_DATA_B64: \"\"\nLDAP_USER_SEARCH_BASE_DN: \"\"\nLDAP_USER_SEARCH_FILTER: \"\"\nLDAP_USER_SEARCH_NAME_ATTRIBUTE: \"\"\nLDAP_USER_SEARCH_USERNAME: userPrincipalName\nNODE_MACHINE_TYPE: c6gn.medium\nOIDC_IDENTITY_PROVIDER_CLIENT_ID: \"\"\nOIDC_IDENTITY_PROVIDER_CLIENT_SECRET: \"\"\nOIDC_IDENTITY_PROVIDER_GROUPS_CLAIM: \"\"\nOIDC_IDENTITY_PROVIDER_ISSUER_URL: \"\"\nOIDC_IDENTITY_PROVIDER_NAME: \"\"\nOIDC_IDENTITY_PROVIDER_SCOPES: \"\"\nOIDC_IDENTITY_PROVIDER_USERNAME_CLAIM: \"\"\nOS_ARCH: amd64\nOS_NAME: amazon\nOS_VERSION: \"2\"\nSERVICE_CIDR: 100.64.0.0/13\nTKG_HTTP_PROXY_ENABLED: \"false\"\n"
"AWS_AMI_ID: ami-09a464de0bba738ff\nAWS_B64ENCODED_CREDENTIALS: foobar\nAWS_NODE_AZ: us-west-a\nAWS_NODE_AZ_1: \"\"\nAWS_NODE_AZ_2: \"\"\nAWS_PRIVATE_NODE_CIDR: \"\"\nAWS_PRIVATE_NODE_CIDR_1: \"\"\nAWS_PRIVATE_NODE_CIDR_2: \"\"\nAWS_PRIVATE_SUBNET_ID: sn4\nAWS_PRIVATE_SUBNET_ID_1: \"\"\nAWS_PRIVATE_SUBNET_ID_2: \"\"\nAWS_PROFILE: profile1\nAWS_PUBLIC_NODE_CIDR: \"\"\nAWS_PUBLIC_NODE_CIDR_1: \"\"\nAWS_PUBLIC_NODE_CIDR_2: \"\"\nAWS_PUBLIC_SUBNET_ID: sn1\nAWS_PUBLIC_SUBNET_ID_1: \"\"\nAWS_PUBLIC_SUBNET_ID_2: \"\"\nAWS_REGION: us-west-2\nAWS_SSH_KEY_NAME: myKeyPair\nAWS_VPC_CIDR: \"\"\nAWS_VPC_ID: vpc-1\nBASTION_HOST_ENABLED: \"true\"\nCLUSTER_ANNOTATIONS: 'description:,location:'\nCLUSTER_CIDR: 100.96.0.0/11\nCLUSTER_NAME: my-aws-name\nCLUSTER_PLAN: dev\nCONTROL_PLANE_MACHINE_TYPE: c6gn.medium\nENABLE_AUDIT_LOGGING: \"\"\nENABLE_CEIP_PARTICIPATION: \"true\"\nENABLE_MHC: \"false\"\nIDENTITY_MANAGEMENT_TYPE: none\nINFRASTRUCTURE_PROVIDER: aws\nLDAP_BIND_DN: \"\"\nLDAP_BIND_PASSWORD: \"\"\nLDAP_GROUP_SEARCH_BASE_DN: \"\"\nLDAP_GROUP_SEARCH_FILTER: \"\"\nLDAP_GROUP_SEARCH_GROUP_ATTRIBUTE: \"\"\nLDAP_GROUP_SEARCH_NAME_ATTRIBUTE: cn\nLDAP_GROUP_SEARCH_USER_ATTRIBUTE: DN\nLDAP_HOST: \"\"\nLDAP_ROOT_CA_DATA_B64: \"\"\nLDAP_USER_SEARCH_BASE_DN: \"\"\nLDAP_USER_SEARCH_FILTER: \"\"\nLDAP_USER_SEARCH_NAME_ATTRIBUTE: \"\"\nLDAP_USER_SEARCH_USERNAME: userPrincipalName\nNODE_MACHINE_TYPE: c6gn.medium\nOIDC_IDENTITY_PROVIDER_CLIENT_ID: \"\"\nOIDC_IDENTITY_PROVIDER_CLIENT_SECRET: \"\"\nOIDC_IDENTITY_PROVIDER_GROUPS_CLAIM: \"\"\nOIDC_IDENTITY_PROVIDER_ISSUER_URL: \"\"\nOIDC_IDENTITY_PROVIDER_NAME: \"\"\nOIDC_IDENTITY_PROVIDER_SCOPES: \"\"\nOIDC_IDENTITY_PROVIDER_USERNAME_CLAIM: \"\"\nOS_ARCH: amd64\nOS_NAME: amazon\nOS_VERSION: \"2\"\nSERVICE_CIDR: 100.64.0.0/13\nTKG_HTTP_PROXY_ENABLED: \"false\"\n"
10 changes: 9 additions & 1 deletion tkg/web/server/handlers/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package handlers

import (
"os"

"github.com/go-openapi/runtime/middleware"
yaml "gopkg.in/yaml.v3"

Expand Down Expand Up @@ -61,8 +63,14 @@ func (app *App) ExportAzureConfig(params azure.ExportTKGConfigForAzureParams) mi
func (app *App) ExportAWSConfig(params aws.ExportTKGConfigForAWSParams) middleware.Responder {
var config *tkgconfigproviders.AWSConfig
var configString string
var err error
var encodedCreds string

encodedCreds, err := app.awsClient.EncodeCredentials()
if os.Getenv("CLI_TEST_RUN") == "true" {
encodedCreds = "foobar"
} else {
encodedCreds, err = app.awsClient.EncodeCredentials()
}
if err == nil {
// create the provider object with the configuration data
config, err = tkgconfigproviders.New(app.AppConfig.TKGConfigDir, app.TKGConfigReaderWriter).NewAWSConfig(params.Params, encodedCreds)
Expand Down