Skip to content

Commit f7cd542

Browse files
committed
feat: initial version of google-cloud-sql CLI app
0 parents  commit f7cd542

40 files changed

Lines changed: 15986 additions & 0 deletions

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
end_of_line = lf
11+
insert_final_newline = true
12+
13+
[*.adoc]
14+
trim_trailing_whitespace = false
15+

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"prettier"
10+
],
11+
"rules": {
12+
"@typescript-eslint/no-explicit-any": 2
13+
}
14+
}
15+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Continuous Integration
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build app
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Read .nvmrc
14+
id: nvmrc
15+
run: echo "::set-output name=node::$(cat .nvmrc)"
16+
17+
- name: Use Node.js ${{ steps.nvmrc.outputs.node }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ steps.nvmrc.outputs.node }}
21+
22+
- name: Read npm cache
23+
uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: node-cache-${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
node-cache-${{ runner.os }}-npm-
29+
30+
- name: Install packages
31+
run: npm ci
32+
33+
- name: Lint
34+
run: npm run lint
35+
36+
- name: Build
37+
run: npm run bundle

.gitignore

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,node
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,node
3+
4+
bin/
5+
6+
### Node ###
7+
# Logs
8+
logs
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
.pnpm-debug.log*
15+
16+
# Diagnostic reports (https://nodejs.org/api/report.html)
17+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
18+
19+
# Runtime data
20+
pids
21+
*.pid
22+
*.seed
23+
*.pid.lock
24+
25+
# Directory for instrumented libs generated by jscoverage/JSCover
26+
lib-cov
27+
28+
# Coverage directory used by tools like istanbul
29+
coverage
30+
*.lcov
31+
32+
# nyc test coverage
33+
.nyc_output
34+
35+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36+
.grunt
37+
38+
# Bower dependency directory (https://bower.io/)
39+
bower_components
40+
41+
# node-waf configuration
42+
.lock-wscript
43+
44+
# Compiled binary addons (https://nodejs.org/api/addons.html)
45+
build/Release
46+
47+
# Dependency directories
48+
node_modules/
49+
jspm_packages/
50+
51+
# Snowpack dependency directory (https://snowpack.dev/)
52+
web_modules/
53+
54+
# TypeScript cache
55+
*.tsbuildinfo
56+
57+
# Optional npm cache directory
58+
.npm
59+
60+
# Optional eslint cache
61+
.eslintcache
62+
63+
# Optional stylelint cache
64+
.stylelintcache
65+
66+
# Microbundle cache
67+
.rpt2_cache/
68+
.rts2_cache_cjs/
69+
.rts2_cache_es/
70+
.rts2_cache_umd/
71+
72+
# Optional REPL history
73+
.node_repl_history
74+
75+
# Output of 'npm pack'
76+
*.tgz
77+
78+
# Yarn Integrity file
79+
.yarn-integrity
80+
81+
# dotenv environment variable files
82+
.env
83+
.env.development.local
84+
.env.test.local
85+
.env.production.local
86+
.env.local
87+
88+
# parcel-bundler cache (https://parceljs.org/)
89+
.cache
90+
.parcel-cache
91+
92+
# Next.js build output
93+
.next
94+
out
95+
96+
# Nuxt.js build / generate output
97+
.nuxt
98+
dist
99+
100+
# Gatsby files
101+
.cache/
102+
# Comment in the public line in if your project uses Gatsby and not Next.js
103+
# https://nextjs.org/blog/next-9-1#public-directory-support
104+
# public
105+
106+
# vuepress build output
107+
.vuepress/dist
108+
109+
# vuepress v2.x temp and cache directory
110+
.temp
111+
112+
# Docusaurus cache and generated files
113+
.docusaurus
114+
115+
# Serverless directories
116+
.serverless/
117+
118+
# FuseBox cache
119+
.fusebox/
120+
121+
# DynamoDB Local files
122+
.dynamodb/
123+
124+
# TernJS port file
125+
.tern-port
126+
127+
# Stores VSCode versions used for testing VSCode extensions
128+
.vscode-test
129+
130+
# yarn v2
131+
.yarn/cache
132+
.yarn/unplugged
133+
.yarn/build-state.yml
134+
.yarn/install-state.gz
135+
.pnp.*
136+
137+
### Node Patch ###
138+
# Serverless Webpack directories
139+
.webpack/
140+
141+
# Optional stylelint cache
142+
143+
# SvelteKit build / generate output
144+
.svelte-kit
145+
146+
### VisualStudioCode ###
147+
.vscode/*
148+
!.vscode/settings.json
149+
!.vscode/tasks.json
150+
!.vscode/launch.json
151+
!.vscode/extensions.json
152+
!.vscode/*.code-snippets
153+
154+
# Local History for Visual Studio Code
155+
.history/
156+
157+
# Built Visual Studio Code Extensions
158+
*.vsix
159+
160+
### VisualStudioCode Patch ###
161+
# Ignore all local history of files
162+
.history
163+
.ionide
164+
165+
# Support for Project snippet scope
166+
167+
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node
168+

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint

.nvmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
16.13.2
2+

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"printWidth": 90
5+
}

README.adoc

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
:toc: macro
2+
:toc-title:
3+
:toclevels: 10
4+
5+
= ⛅ google-cloud-sql
6+
7+
image:https://img.shields.io/github/package-json/v/edosrecki/google-cloud-sql-cli/release?color=blue&label=google-cloud-sql["google-cloud-sql CLI Version"]
8+
image:https://img.shields.io/github/workflow/status/edosrecki/google-cloud-sql-cli/Continuous Integration["Build Status", link="https://github.com/edosrecki/google-cloud-sql-cli/actions"]
9+
10+
A CLI app which establishes a connection to a private Google Cloud SQL instance and port-forwards it to a local machine.
11+
12+
Connection is established by running a Google Cloud SQL Auth Proxy pod in a Google Kubernetes Engine cluster which runs in the same VPC network as the private Cloud SQL instance. Connection is then port-forwarded to the local machine, where a user can connect to the instance on localhost. Configurations in the app can be saved for practical future usage.
13+
14+
The app relies on local `gcloud` and `kubectl` commands which have to be configured and authenticated with the proper Google Cloud user and Kubernetes cluster.
15+
16+
---
17+
18+
toc::[]
19+
20+
== Install
21+
=== Homebrew
22+
[source,bash]
23+
----
24+
brew install edosrecki/tools/google-cloud-sql
25+
26+
# Update
27+
brew upgrade google-cloud-sql
28+
----
29+
30+
=== Releases
31+
Download a corresponding distribution from https://github.com/edosrecki/google-cloud-sql-cli/releases[Releases] and add
32+
the executable to your `PATH`.
33+
34+
=== Build from source
35+
Build the app from source by building and packaging it manually: see _Build_ and
36+
_Package_ sections.
37+
38+
== Use
39+
=== Prerequisites
40+
* Install https://cloud.google.com/sdk/docs/install[`gcloud`] tool
41+
* Install https://kubernetes.io/docs/tasks/tools/#kubectl[`kubectl`] tool
42+
* Authenticate to Google Cloud: `gcloud auth login`
43+
* Get GKE cluster credentials: `gcloud container clusters get-credentials`
44+
45+
=== Run
46+
[source,bash]
47+
----
48+
# Help
49+
google-cloud-sql help
50+
51+
# Create configuration
52+
google-cloud-sql configurations create
53+
54+
# Run configuration
55+
google-cloud-sql configurations run
56+
57+
## Connect to the instance on localhost
58+
psql -h localhost -p <LOCAL_PORT> -U <USER>
59+
----
60+
61+
== Build
62+
[source,bash]
63+
----
64+
npm run clean
65+
npm run build
66+
----
67+
68+
== Package
69+
=== Pre-configured
70+
Package the app for Node.JS 16 on MacOS, Linux, and Windows.
71+
72+
[source,bash]
73+
----
74+
npm run bundle
75+
----
76+
77+
=== Manual
78+
See https://www.npmjs.com/package/pkg#targets[pkg] for details.
79+
80+
[source,bash]
81+
----
82+
npx pkg <NODE_RANGE>-<PLATFORM>-<ARCH>
83+
----

0 commit comments

Comments
 (0)