Skip to content

Commit 63b1bfe

Browse files
authored
Merge pull request #2857 from devtron-labs/feat/secrets-mgr
chore: add a script to update target url and password during development
2 parents b7a148f + 0a75eaf commit 63b1bfe

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.test.tsx
55
.eslintrc.js
66
vite.config.mts
7+
scripts/
78

89
# The following files have eslint errors/warnings
910
src/Pages/GlobalConfigurations/Authorization/APITokens/__tests__/ApiTokens.test.tsx

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ yalc.lock
5252
!.yarn/sdks
5353
!.yarn/versions
5454
.pnp.*
55+
56+
.env.secrets
57+
scripts/

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"lint": "tsc --noEmit && eslint 'src/**/*.{js,jsx,ts,tsx}' --max-warnings 0",
5050
"lint-fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
5151
"start": "vite --open",
52+
"dev": "node scripts/secrets-mgr.js",
5253
"build": "NODE_OPTIONS=--max_old_space_size=8192 vite build",
5354
"serve": "vite preview",
5455
"build-light": "NODE_OPTIONS=--max_old_space_size=8192 GENERATE_SOURCEMAP=false vite build",

src/components/login/LoginForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const LoginForm = ({ loginList }: LoginFormType) => {
4343
const [loading, setLoading] = useState(false)
4444
const [form, setForm] = useState({
4545
username: 'admin',
46-
password: '',
46+
password: import.meta.env.VITE_ADMIN_PASSWORD ?? '',
4747
})
4848
const [errorMessage, setErrorMessage] = useState({
4949
username: {

vite.config.mts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ const jsToBottomNoModule = () => {
9494

9595
// https://vitejs.dev/config/
9696
export default defineConfig(({ mode }) => {
97-
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') }
97+
const secretsEnv = loadEnv('secrets', process.cwd(), '')
98+
const targetUrl = secretsEnv.VITE_TARGET_URL ?? TARGET_URL
99+
100+
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), ''), ...secretsEnv }
101+
98102
const baseConfig: UserConfig = {
99103
base: '/dashboard',
100104
preview: {
@@ -268,10 +272,10 @@ export default defineConfig(({ mode }) => {
268272
port: 3000,
269273
proxy: {
270274
'/orchestrator': {
271-
target: TARGET_URL,
275+
target: targetUrl,
272276
changeOrigin: true,
273277
},
274-
'/grafana': TARGET_URL,
278+
'/grafana': targetUrl,
275279
},
276280
},
277281
}

0 commit comments

Comments
 (0)