Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to upstream header #1186

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: 0 additions & 2 deletions src/api/clients/IOClients/IOClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ export class IOClientFactory {
}

private static createInstanceOptions(customOptions: Partial<InstanceOptions> = {}) {
const clusterHeader = env.cluster() ? { [Headers.VTEX_UPSTREAM_TARGET]: env.cluster() } : null
const traceHeader = TraceConfig.shouldTrace() ? { [Headers.VTEX_TRACE]: TraceConfig.jaegerDebugID } : null

const defaultOptions = {
timeout: (env.envTimeout || IOClientFactory.DEFAULT_TIMEOUT) as number,
headers: {
...clusterHeader,
...traceHeader,
},
}
Expand Down
3 changes: 0 additions & 3 deletions src/api/clients/IOClients/infra/Runtime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IOContext } from '@vtex/api'
import * as url from 'url'
import WebSocket from 'ws'
import { cluster } from '../../../env'
import logger from '../../../logger'
import { Headers } from '../../../constants/Headers'
import { SessionManager } from '../../../session/SessionManager'
Expand All @@ -26,14 +25,12 @@ export class Runtime {
public async debugDotnetApp(appName: string, appVendor: string, appMajor: string, debugInst: string) {
const host = 'app.io.vtex.com'
const path = `/${appVendor}.${appName}/v${appMajor}/${this.account}/${this.workspace}/_debug/dotnet`
const clusterHeader = cluster() ? { [Headers.VTEX_UPSTREAM_TARGET]: cluster() } : null

const clientOptions = {
headers: {
Authorization: SessionManager.getSingleton().token,
Host: host,
[Headers.VTEX_RUNTIME_API]: 'true',
...clusterHeader,
},
}

Expand Down
8 changes: 0 additions & 8 deletions src/api/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,3 @@ export const getEnvironment = (): Environment => {
export enum Region {
Production = 'aws-us-east-1',
}

export const saveCluster = (cluster: string) => {
conf.set('cluster', cluster)
}

export const getCluster = () => {
return conf.get('cluster') || CLUSTER_DEFAULT_VALUE
}
4 changes: 0 additions & 4 deletions src/api/constants/Headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export enum Headers {
// Specify a specific pod to receive the request
VTEX_STICKY_HOST = 'x-vtex-sticky-host',

// Specify the target cluster for the request.
// Works only on myvtexdev domain
VTEX_UPSTREAM_TARGET = 'x-vtex-upstream-target',

// LinkID used by builder-hub to create logs/tracing correlation between all
// relink/link operations related to a initial link
VTEX_LINK_ID = 'x-vtex-bh-link-id',
Expand Down
22 changes: 5 additions & 17 deletions src/api/env.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
import { Region, getCluster } from './conf'
import { Region } from './conf'

export const envTimeout = process.env.VTEX_API_TIMEOUT as number | string

export function colossusEndpoint() {
return process.env.VTEX_COLOSSUS_ENDPOINT || `https://infra.io.vtex.com/colossus/v0`
}

export function cluster() {
return process.env.VTEX_CLUSTER || getCluster() || ''
}

// TODO (@pedro823): the following functions were related to a cluster feature which is now
// deprecated. We should remove these functions later on.
export function region(): string {
return cluster() || Region.Production
return Region.Production
}

export function publicEndpoint(): string {
return cluster() ? 'myvtexdev.com' : 'myvtex.com'
}

export function clusterIdDomainInfix(): string {
const upstreamCluster = cluster()
return upstreamCluster ? `.${upstreamCluster}` : ''
}

export function envCookies(): string {
const upstreamCluster = cluster()
return upstreamCluster ? `VtexIoClusterId=${upstreamCluster}` : ''
return 'myvtex.com'
}
4 changes: 2 additions & 2 deletions src/api/modules/url.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { clusterIdDomainInfix, publicEndpoint } from '../env'
import { publicEndpoint } from '../env'
import { SessionManager } from '../session/SessionManager'

export default () => {
const { account, workspace } = SessionManager.getSingleton()
return `https://${workspace}--${account}${clusterIdDomainInfix()}.${publicEndpoint()}`
return `https://${workspace}--${account}.${publicEndpoint()}`
}
3 changes: 0 additions & 3 deletions src/lib/sse/CustomEventSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EventSource from 'eventsource'
import { cluster, envCookies } from '../../api/env'
import userAgent from '../../user-agent'
import { Headers } from '../../api/constants/Headers'
import { SessionManager } from '../../api/session/SessionManager'
Expand Down Expand Up @@ -47,8 +46,6 @@ export class CustomEventSource {
headers: {
authorization: `bearer ${token}`,
'user-agent': userAgent,
...(envCookies() ? { cookie: envCookies() } : null),
...(cluster() ? { [Headers.VTEX_UPSTREAM_TARGET]: cluster() } : null),
...additionalHeaders,
...traceHeader,
},
Expand Down
2 changes: 0 additions & 2 deletions src/modules/apps/debugger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import streamToString from 'get-stream'
import net from 'net'
import WebSocket from 'ws'
import { cluster } from '../../api/env'
import { Headers } from '../../api/constants/Headers'
import { ManifestEditor } from '../../api/manifest'
import { SessionManager } from '../../api/session/SessionManager'
Expand Down Expand Up @@ -35,7 +34,6 @@ function webSocketTunnelHandler(host: string, path: string, server: net.Server):
Host: host,
'user-agent': userAgent,
[Headers.VTEX_RUNTIME_API]: 'true',
...(cluster() ? { [Headers.VTEX_UPSTREAM_TARGET]: cluster() } : null),
},
})

Expand Down
9 changes: 0 additions & 9 deletions src/oclif/hooks/init.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import axios from 'axios'
import os from 'os'
import help from '@oclif/plugin-help'

import * as Config from '@oclif/config'
import { HookKeyOrOptions } from '@oclif/config/lib/hooks'
import { error } from '@oclif/errors'
import { FeatureFlag } from '../../api/modules/featureFlag'
import { envCookies } from '../../api/env'
import { CLIPreTasks } from '../../CLIPreTasks/CLIPreTasks'
import { TelemetryCollector } from '../../lib/telemetry/TelemetryCollector'
import { hrTimeToMs } from '../../lib/utils/hrTimeToMs'
Expand Down Expand Up @@ -317,13 +315,6 @@ export default async function(options: HookKeyOrOptions<'init'>) {
console.log(renderedCommands)
}

axios.interceptors.request.use(config => {
if (envCookies()) {
config.headers.Cookie = `${envCookies()}; ${config.headers.Cookie || ''}`
}
return config
})

process.on('unhandledRejection', onError)

process.on('exit', () => {
Expand Down