Skip to content

Commit a6770d0

Browse files
committed
fix!: remove addons
Currently, we conditionally attempt to retrieve information about addons in `@netlify/config#resolveConfig`. As far as I can tell, every query to the `listServiceInstancesForSite` (addon info) Bitballoon endpoint fails with a 500 and the following response body: ```json { error: '{"message":"Missing Authentication Token"}' } ``` ...this, despite verifying that e.g. the accounts and site info queries right next to it use the exact same API token and succeed. Unfortunately, because of the way we do error handling, when this query fails it fails all of the surrounding queries. We could change this code path to have separate `try/catch`es for each query, but the CLI (and probably other consumers) currently assume this behavior, so that would be an obtrusive change. Addons are a thing of the past and we're fairly sure no one is using them any longer. (The CLI is certainly not.) Any consumers of this module who still rely on this information and for whom this query somehow _does_ work can instead perform this query in application code. I started out just removing this from the `@netlify/config` module, but decided to remove addons entirely from this repo as to not leave this confusing vestigial concept around.
1 parent b6fa012 commit a6770d0

File tree

30 files changed

+21
-276
lines changed

30 files changed

+21
-276
lines changed

packages/build/tests/core/snapshots/tests.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,6 @@ Generated by [AVA](https://avajs.dev).
683683
684684
`{␊
685685
"accounts": [],␊
686-
"addons": [],␊
687686
"branch": "branch",␊
688687
"buildDir": "packages/build/tests/core/fixtures/basereldir/base",␊
689688
"config": {␊
-4 Bytes
Binary file not shown.

packages/config/README.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const exampleFunction = async function () {
4747
// },
4848
// ...
4949
// ],
50-
// "addons": [],
5150
// "env": {
5251
// "NODE_VERSION": { "sources": ["configFile"], "value": "16" },
5352
// ...
@@ -117,7 +116,7 @@ Path to the `netlify.toml`. It is either an absolute path or a path relative to
117116
If not specified, it is searched in the following directories (by highest priority order):
118117

119118
- `base` directory
120-
- [`repositoryRoot`](#repositoryRoot)
119+
- [`repositoryRoot`](#repositoryroot)
121120
- current directory
122121
- any parent directory
123122

@@ -205,7 +204,7 @@ _Default value_: environment variable `NETLIFY_SITE_ID`
205204

206205
Netlify Site ID.
207206

208-
This is used to retrieve [`siteInfo`](#siteinfo), [`accounts`](#accounts) and [`addons`](#addons).
207+
This is used to retrieve [`siteInfo`](#siteinfo) and [`accounts`](#accounts).
209208

210209
#### env
211210

@@ -227,8 +226,8 @@ What is calling `@netlify/config`. Can be:
227226

228227
This is used for the following cases:
229228

230-
- if `mode` is `buildbot`, [`siteInfo`](#siteinfo), [`accounts`](#accounts) and [`addons`](#addons) are not retrieved
231-
because they are also passed using another internal option.
229+
- if `mode` is `buildbot`, [`siteInfo`](#siteinfo) and [`accounts`](#accounts) are not retrieved because they are also
230+
passed using another internal option.
232231

233232
#### defaultConfig
234233

@@ -287,13 +286,13 @@ _Type_: `string`
287286
Absolute path to the build directory.
288287

289288
The build directory is the current directory in which most build operations, including the build command, execute. It is
290-
usually either the [`repositoryRoot`](#repositoryRoot) or (if specified) the `base` directory.
289+
usually either the [`repositoryRoot`](#repositoryroot) or (if specified) the `base` directory.
291290

292291
#### repositoryRoot
293292

294293
_Type_: `string`
295294

296-
The computed value of [`repositoryRoot`](#repositoryRoot).
295+
The computed value of [`repositoryRoot`](#repositoryroot).
297296

298297
#### context
299298

@@ -326,15 +325,6 @@ environment variables.
326325

327326
This might be empty depending on the options passed.
328327

329-
#### addons
330-
331-
_Type_: `object[]`
332-
333-
Netlify addons retrieved using the `listServiceInstancesForSite` Netlify API endpoint. This is used to retrieve
334-
addon-specific environment variables.
335-
336-
This might be empty depending on the options passed.
337-
338328
#### token
339329

340330
_Type_: `string`
@@ -346,8 +336,8 @@ variables.
346336

347337
_Type_: `NetlifyClient?`
348338

349-
Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo),
350-
[`accounts`](#accounts) and [`addons`](#addons).
339+
Netlify [JavaScript client instance](https://github.com/netlify/js-client) used to retrieve [`siteInfo`](#siteinfo) and
340+
[`accounts`](#accounts).
351341

352342
#### logs
353343

@@ -365,14 +355,13 @@ Site's environment variables. Each environment variable value is an object with
365355
- `sources` `string[]` among:
366356
- `general`: general environment variables set for all sites
367357
- `account`: environment variables set in the Netlify UI for a specific account
368-
- `addons`: addon-specific environment variables
369358
- `ui`: environment variables set in the Netlify UI for a specific site
370359
- `configFile`: environment variables set in `netlify.toml`
371360

372361
# Usage (CLI)
373362

374363
```bash
375-
$ netlify-config
364+
netlify-config
376365
```
377366

378367
Like [`resolveConfig()`](resolveconfig), but in the CLI. The return value is printed on `stdout`.

packages/config/src/api/site_info.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,12 @@ export const getSiteInfo = async function ({
7171
})
7272
: []
7373

74-
return { siteInfo, accounts: [], addons: [], integrations }
74+
return { siteInfo, accounts: [], integrations }
7575
}
7676

77-
const [siteInfo, accounts, addons, integrations] = await Promise.all([
77+
const [siteInfo, accounts, integrations] = await Promise.all([
7878
getSite(api, siteId, siteFeatureFlagPrefix),
7979
getAccounts(api),
80-
getAddons(api, siteId),
8180
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
8281
])
8382

@@ -87,7 +86,7 @@ export const getSiteInfo = async function ({
8786
siteInfo.build_settings.env = envelope
8887
}
8988

90-
return { siteInfo, accounts, addons, integrations }
89+
return { siteInfo, accounts, integrations }
9190
}
9291

9392
const getSite = async function (api: NetlifyAPI, siteId: string, siteFeatureFlagPrefix: string) {
@@ -128,19 +127,6 @@ const getAccounts = async function (api: NetlifyAPI): Promise<MinimalAccount[]>
128127
}
129128
}
130129

131-
const getAddons = async function (api: NetlifyAPI, siteId: string) {
132-
if (siteId === undefined) {
133-
return []
134-
}
135-
136-
try {
137-
const addons = await (api as any).listServiceInstancesForSite({ siteId })
138-
return Array.isArray(addons) ? addons : []
139-
} catch (error) {
140-
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
141-
}
142-
}
143-
144130
type GetIntegrationsOpts = {
145131
siteId?: string
146132
accountId?: string

packages/config/src/env/main.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getEnvelope } from './envelope.js'
77
import { getGitEnv } from './git.js'
88

99
// Retrieve this site's environment variable. Also take into account team-wide
10-
// environment variables and addons.
10+
// environment variables.
1111
// The buildbot already has the right environment variables. This is mostly
1212
// meant so that local builds can mimic production builds
1313
// TODO: add `netlify.toml` `build.environment`, after normalization
@@ -18,7 +18,6 @@ export const getEnv = async function ({
1818
config,
1919
siteInfo,
2020
accounts,
21-
addons,
2221
buildDir,
2322
branch,
2423
deployId,
@@ -32,20 +31,18 @@ export const getEnv = async function ({
3231

3332
const internalEnv = getInternalEnv(cachedEnv)
3433
const generalEnv = await getGeneralEnv({ siteInfo, buildDir, branch, deployId, buildId, context })
35-
const [accountEnv, addonsEnv, uiEnv, configFileEnv] = await getUserEnv({
34+
const [accountEnv, uiEnv, configFileEnv] = await getUserEnv({
3635
api,
3736
config,
3837
siteInfo,
3938
accounts,
40-
addons,
4139
context,
4240
})
4341

4442
// Sources of environment variables, in descending order of precedence.
4543
const sources = [
4644
{ key: 'configFile', values: configFileEnv },
4745
{ key: 'ui', values: uiEnv },
48-
{ key: 'addons', values: addonsEnv },
4946
{ key: 'account', values: accountEnv },
5047
{ key: 'general', values: generalEnv },
5148
{ key: 'internal', values: internalEnv },
@@ -164,12 +161,11 @@ const NETLIFY_DEFAULT_DOMAIN = '.netlify.app'
164161
const DEFAULT_SITE_NAME = 'site-name'
165162

166163
// Environment variables specified by the user
167-
const getUserEnv = async function ({ api, config, siteInfo, accounts, addons, context }) {
164+
const getUserEnv = async function ({ api, config, siteInfo, accounts, context }) {
168165
const accountEnv = await getAccountEnv({ api, siteInfo, accounts, context })
169-
const addonsEnv = getAddonsEnv(addons)
170166
const uiEnv = getUiEnv({ siteInfo })
171167
const configFileEnv = getConfigFileEnv({ config })
172-
return [accountEnv, addonsEnv, uiEnv, configFileEnv].map(cleanUserEnv)
168+
return [accountEnv, uiEnv, configFileEnv].map(cleanUserEnv)
173169
}
174170

175171
// Account-wide environment variables
@@ -191,15 +187,6 @@ const getAccountEnv = async function ({
191187
return siteEnv
192188
}
193189

194-
// Environment variables from addons
195-
const getAddonsEnv = function (addons) {
196-
return Object.assign({}, ...addons.map(getAddonEnv))
197-
}
198-
199-
const getAddonEnv = function ({ env }) {
200-
return env
201-
}
202-
203190
// Site-specific environment variables set in the UI
204191
const getUiEnv = function ({ siteInfo: { build_settings: { env = {} } = {} } }) {
205192
return env

packages/config/src/main.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { getRedirectsPath, addRedirects } from './redirects.js'
2626

2727
export type Config = {
2828
accounts: MinimalAccount[] | undefined
29-
addons: any
3029
api: any
3130
branch: any
3231
buildDir: any
@@ -99,16 +98,14 @@ export const resolveConfig = async function (opts): Promise<Config> {
9998
featureFlags,
10099
} = await normalizeOpts(optsA)
101100

102-
let { siteInfo, accounts, addons, integrations } = parsedCachedConfig || {}
101+
let { siteInfo, accounts, integrations } = parsedCachedConfig || {}
103102

104103
// If we have cached site info, we don't need to fetch it again
105-
const useCachedSiteInfo = Boolean(
106-
featureFlags?.use_cached_site_info && siteInfo && accounts && addons && integrations,
107-
)
104+
const useCachedSiteInfo = Boolean(featureFlags?.use_cached_site_info && siteInfo && accounts && integrations)
108105

109106
// I'm adding some debug logging to see if the logic is working as expected
110107
if (featureFlags?.use_cached_site_info_logging) {
111-
console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, addons, integrations })
108+
console.log('Checking site information', { useCachedSiteInfo, siteInfo, accounts, integrations })
112109
}
113110

114111
if (!useCachedSiteInfo) {
@@ -128,7 +125,6 @@ export const resolveConfig = async function (opts): Promise<Config> {
128125

129126
siteInfo = updatedSiteInfo.siteInfo
130127
accounts = updatedSiteInfo.accounts
131-
addons = updatedSiteInfo.addons
132128
integrations = updatedSiteInfo.integrations
133129
}
134130

@@ -162,7 +158,6 @@ export const resolveConfig = async function (opts): Promise<Config> {
162158
config,
163159
siteInfo,
164160
accounts,
165-
addons,
166161
buildDir,
167162
branch,
168163
deployId,
@@ -184,7 +179,6 @@ export const resolveConfig = async function (opts): Promise<Config> {
184179
siteInfo,
185180
integrations: mergedIntegrations,
186181
accounts,
187-
addons,
188182
env,
189183
configPath,
190184
redirectsPath,

0 commit comments

Comments
 (0)