Skip to content

Commit

Permalink
fix(certs-v5): fix logic for requesting all cert resources (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
cafreeman authored Oct 22, 2020
1 parent d3c36cb commit 46187e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/certs-v5/commands/certs/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let isWildcard = require('../../lib/is_wildcard.js')
let isWildcardMatch = require('../../lib/is_wildcard_match.js')
let getCertAndKey = require('../../lib/get_cert_and_key.js')
let matchDomains = require('../../lib/match_domains.js')
let checkMultiSniFeature = require('../../lib/features.js')
let { checkMultiSniFeature } = require('../../lib/features.js')
let { waitForDomains, printDomains } = require('../../lib/domains')

function Domains (domains) {
Expand Down
7 changes: 3 additions & 4 deletions packages/certs-v5/lib/endpoints.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

let checkMultiSniFeature = require('./features.js')
const { checkPrivateSniFeature } = require('./features.js')

function sslCertsPromise (app, heroku) {
return heroku.request({
Expand Down Expand Up @@ -58,12 +58,11 @@ function tagAndSort (app, allCerts) {

function * all (appName, heroku) {
const featureList = yield heroku.get(`/apps/${appName}/features`)
const multipleSniEndpointFeatureEnabled = checkMultiSniFeature(featureList)
const isSpaceApp = yield hasSpace(appName, heroku)
const privateSniFeatureEnabled = checkPrivateSniFeature(featureList)

let allCerts;

if (multipleSniEndpointFeatureEnabled && isSpaceApp) {
if (privateSniFeatureEnabled) {
// use SNI endpoints only
allCerts = yield {
ssl_certs: [],
Expand Down
10 changes: 9 additions & 1 deletion packages/certs-v5/lib/features.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
const MULTIPLE_SNI_ENDPOINT_FLAG = 'allow-multiple-sni-endpoints'
const PRIVATE_SNI_ENDPOINT_FLAG = 'private-spaces-sni'

function checkMultiSniFeature(featureList) {
return featureList.some(feature => feature.name === MULTIPLE_SNI_ENDPOINT_FLAG && feature.enabled === true)
}

module.exports = checkMultiSniFeature
function checkPrivateSniFeature(featureList) {
return featureList.some(feature => feature.name === PRIVATE_SNI_ENDPOINT_FLAG && feature.enabled === true)
}

module.exports = {
checkMultiSniFeature,
checkPrivateSniFeature
}

0 comments on commit 46187e5

Please sign in to comment.