Skip to content

Commit a12c594

Browse files
authored
Merge pull request #7 from happy-game/refactor
refactor: 修改了使用到的环境变量
2 parents fc95c19 + fcbba14 commit a12c594

File tree

18 files changed

+111
-105
lines changed

18 files changed

+111
-105
lines changed

.devcontainer/docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ services:
2121
- ..:/workspace:cached
2222

2323
environment:
24-
PGPASSWORD: openGauss@123
25-
PGUSER: gaussdb
26-
PGDATABASE: data
27-
PGHOST: db
24+
GAUSSPASSWORD: openGauss@123
25+
GAUSSUSER: gaussdb
26+
GAUSSDATABASE: data
27+
GAUSSHOST: db
2828
# set this to true in the development environment until I can get SSL setup on the
2929
# docker postgres instance
30-
PGTESTNOSSL: 'true'
30+
GAUSSTESTNOSSL: 'true'
3131

3232
# Overrides default command so things don't shut down after the process ends.
3333
command: sleep infinity

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ jobs:
5151
name: Node.js ${{ matrix.node }}
5252
runs-on: ubuntu-latest
5353
env:
54-
PGUSER: ci_user
55-
PGPASSWORD: openGauss@123
56-
PGHOST: localhost
57-
PGDATABASE: ci_db_test
58-
PGTESTNOSSL: 'true'
59-
SHA256_TEST_PGUSER: sha256_test
60-
SHA256_TEST_PGPASSWORD: test4@scram
54+
GAUSSUSER: ci_user
55+
GAUSSPASSWORD: openGauss@123
56+
GAUSSHOST: localhost
57+
GAUSSDATABASE: ci_db_test
58+
GAUSSTESTNOSSL: 'true'
59+
SHA256_TEST_GAUSSUSER: sha256_test
60+
SHA256_TEST_GAUSSPASSWORD: test4@scram
6161
steps:
6262
- name: Show OS
6363
run: |

packages/gaussdb/lib/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Client extends EventEmitter {
112112
}
113113

114114
if (this.host && this.host.indexOf('/') === 0) {
115+
// TODO: is GaussDB using domain sockets?
115116
con.connect(this.host + '/.s.PGSQL.' + this.port)
116117
} else {
117118
con.connect(this.port, this.host)
@@ -475,6 +476,7 @@ class Client extends EventEmitter {
475476
const con = this.connection
476477

477478
if (this.host && this.host.indexOf('/') === 0) {
479+
// TODO: is GaussDB using domain sockets?
478480
con.connect(this.host + '/.s.PGSQL.' + this.port)
479481
} else {
480482
con.connect(this.port, this.host)

packages/gaussdb/lib/connection-parameters.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const parse = require('gaussdb-connection-string').parse // parses a connection
88

99
const val = function (key, config, envVar) {
1010
if (envVar === undefined) {
11-
envVar = process.env['PG' + key.toUpperCase()]
11+
envVar = process.env['GAUSS' + key.toUpperCase()]
1212
} else if (envVar === false) {
1313
// do nothing ... use false
1414
} else {
@@ -19,7 +19,7 @@ const val = function (key, config, envVar) {
1919
}
2020

2121
const readSSLConfigFromEnvironment = function () {
22-
switch (process.env.PGSSLMODE) {
22+
switch (process.env.GAUSSSSLMODE) {
2323
case 'disable':
2424
return false
2525
case 'prefer':
@@ -100,15 +100,15 @@ class ConnectionParameters {
100100
// a domain socket begins with '/'
101101
this.isDomainSocket = !(this.host || '').indexOf('/')
102102

103-
this.application_name = val('application_name', config, 'PGAPPNAME')
103+
this.application_name = val('application_name', config, 'GAUSSAPPNAME')
104104
this.fallback_application_name = val('fallback_application_name', config, false)
105105
this.statement_timeout = val('statement_timeout', config, false)
106106
this.lock_timeout = val('lock_timeout', config, false)
107107
this.idle_in_transaction_session_timeout = val('idle_in_transaction_session_timeout', config, false)
108108
this.query_timeout = val('query_timeout', config, false)
109109

110110
if (config.connectionTimeoutMillis === undefined) {
111-
this.connect_timeout = process.env.PGCONNECT_TIMEOUT || 0
111+
this.connect_timeout = process.env.GAUSSCONNECT_TIMEOUT || 0
112112
} else {
113113
this.connect_timeout = Math.floor(config.connectionTimeoutMillis / 1000)
114114
}

packages/gaussdb/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const GAUSSDB = function (clientConstructor) {
3434
this.utils = utils
3535
}
3636

37+
// TODO: NODE_PG_FORCE_NATIVE or NODE_GAUSS_FORCE_NATIVE
3738
if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
3839
module.exports = new GAUSSDB(require('./native'))
3940
} else {

packages/gaussdb/test/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ for (let i = 0; i < process.argv.length; i++) {
1818
}
1919
}
2020

21-
if (process.env['PG_TEST_NATIVE']) {
21+
if (process.env['GAUSS_TEST_NATIVE']) {
2222
config.native = true
2323
}
2424

packages/gaussdb/test/integration/client/appname-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ suite.test('application_name from connection string', function (done) {
8787
// TODO: make the test work for native client too
8888
if (!helper.args.native) {
8989
suite.test('application_name is read from the env', function (done) {
90-
const appName = (process.env.PGAPPNAME = 'testest')
90+
const appName = (process.env.GAUSSAPPNAME = 'testest')
9191
getAppName({}, function (res) {
92-
delete process.env.PGAPPNAME
92+
delete process.env.GAUSSAPPNAME
9393
assert.strictEqual(res, appName)
9494
done()
9595
})

packages/gaussdb/test/integration/client/configuration-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const suite = new helper.Suite()
1010
const realEnv = {}
1111
for (const key in process.env) {
1212
realEnv[key] = process.env[key]
13-
if (!key.indexOf('PG')) delete process.env[key]
13+
if (!key.indexOf('GAUSS')) delete process.env[key]
1414
}
1515

1616
suite.test('default values are used in new clients', function () {

packages/gaussdb/test/integration/client/sasl-scram-tests.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const { native } = helper.args
66
const assert = require('assert')
77

88
/**
9-
* This test only executes if the env variables SCRAM_TEST_PGUSER and
10-
* SCRAM_TEST_PGPASSWORD are defined. You can override additional values
9+
* This test only executes if the env variables SCRAM_TEST_GAUSSUSER and
10+
* SCRAM_TEST_GAUSSPASSWORD are defined. You can override additional values
1111
* for the host, port and database with other SCRAM_TEST_ prefixed vars.
1212
* If the variables are not defined the test will be skipped.
1313
*
@@ -23,17 +23,17 @@ const assert = require('assert')
2323
*
2424
* Then run this file with after exporting:
2525
*
26-
* SCRAM_TEST_PGUSER=scram_test
27-
* SCRAM_TEST_PGPASSWORD=test4scram
26+
* SCRAM_TEST_GAUSSUSER=scram_test
27+
* SCRAM_TEST_GAUSSPASSWORD=test4scram
2828
*/
2929

3030
// Base config for SCRAM tests
3131
const config = {
32-
user: process.env.SCRAM_TEST_PGUSER,
33-
password: process.env.SCRAM_TEST_PGPASSWORD,
34-
host: process.env.SCRAM_TEST_PGHOST, // optional
35-
port: process.env.SCRAM_TEST_PGPORT, // optional
36-
database: process.env.SCRAM_TEST_PGDATABASE, // optional
32+
user: process.env.SCRAM_TEST_GAUSSUSER,
33+
password: process.env.SCRAM_TEST_GAUSSPASSWORD,
34+
host: process.env.SCRAM_TEST_GAUSSHOST, // optional
35+
port: process.env.SCRAM_TEST_GAUSSPORT, // optional
36+
database: process.env.SCRAM_TEST_GAUSSDATABASE, // optional
3737
}
3838

3939
if (native) {
@@ -92,7 +92,7 @@ suite.testAsync('sasl/scram fails when password is empty', async () => {
9292
const client = new gaussdb.Client({
9393
...config,
9494
// We use a password function here so the connection defaults do not
95-
// override the empty string value with one from process.env.PGPASSWORD
95+
// override the empty string value with one from process.env.GAUSSPASSWORD
9696
password: () => '',
9797
})
9898
let usingSasl = false

packages/gaussdb/test/integration/client/sha256-password-tests.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const { native } = helper.args
66
const assert = require('assert')
77

88
/**
9-
* This test only executes if the env variables SHA256_TEST_PGUSER and
10-
* SHA256_TEST_PGPASSWORD are defined. You can override additional values
9+
* This test only executes if the env variables SHA256_TEST_GAUSSUSER and
10+
* SHA256_TEST_GAUSSPASSWORD are defined. You can override additional values
1111
* for the host, port and database with other SHA256_TEST_ prefixed vars.
1212
* If the variables are not defined the test will be skipped.
1313
*
@@ -23,17 +23,17 @@ const assert = require('assert')
2323
*
2424
* Then run this file with after exporting:
2525
*
26-
* SHA256_TEST_PGUSER=sha256_test
27-
* SHA256_TEST_PGPASSWORD=test4@scram
26+
* SHA256_TEST_GAUSSUSER=sha256_test
27+
* SHA256_TEST_GAUSSPASSWORD=test4@scram
2828
*/
2929

3030
// Base config for SHA256 tests
3131
const config = {
32-
user: process.env.SHA256_TEST_PGUSER,
33-
password: process.env.SHA256_TEST_PGPASSWORD,
34-
host: process.env.SHA256_TEST_PGHOST || 'localhost',
35-
port: process.env.SHA256_TEST_PGPORT || 5432,
36-
database: process.env.SHA256_TEST_PGDATABASE || 'ci_db_test',
32+
user: process.env.SHA256_TEST_GAUSSUSER,
33+
password: process.env.SHA256_TEST_GAUSSPASSWORD,
34+
host: process.env.SHA256_TEST_GAUSSHOST || 'localhost',
35+
port: process.env.SHA256_TEST_GAUSSPORT || 5432,
36+
database: process.env.SHA256_TEST_GAUSSDATABASE || 'ci_db_test',
3737
}
3838

3939
if (native) {

0 commit comments

Comments
 (0)