Skip to content

Instantly share code, notes, and snippets.

View vijayakumar-psg587's full-sized avatar

Vijayakumar vijayakumar-psg587

View GitHub Profile
{
"type": "service_account",
"project_id": "XXXX",
"private_key_id": "XXXXXX",
"private_key": "-----BEGIN PRIVATE KEY-----\n+XXXXX-----END PRIVATE KEY-----\n",
"client_email": "<name of the service accnt>@<project-name>.iam.gserviceaccount.com",
"client_id": "1CXXXX",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
export interface AuthenticationModel {
keyFile?: string;
keyFilename?: string;
autoRetry?: boolean;
projectId?: string;
apiEndpoint?: string;
maxRetries?: number;
client_id?: string;
client_secret?: string;
scope?: string[];
import {Storage} from '@google-cloud/storage';
import { AuthenticationModel } from '../models/authentication.model';
import { AppUtilServiceInstance } from './app.util.service';
import * as pino from 'pino';
import { PinoLoggerServiceInstance } from './pino.logger.service';
export class GcloudAuthentication {
private gcloudAuthModel: AuthenticationModel;
private LOGGER: pino.Logger;
constructor() {
getGcloudAuthModel(): AuthenticationModel {
const authModel: GcloudAuthenticationModel = new GcloudAuthenticationModel();
authModel.autoRetry = true;
authModel.keyFilename = GCLOUD_KEY_FILE;
authModel.projectId = GCLOUD_PRJ_ID;
authModel.scope = GCLOUD_STROAGE_SCOPE;
authModel.maxRetries = GCLOUD_CONN_MAX_RETRIES;
return authModel;
}
export async function uploadEnvFiles(env_name: string) {
const LOGGER: pino.Logger = PinoLoggerServiceInstance.getLogger(__filename);
return new Promise(async (res, rej) => {
// Get the storage bucket
const str = GcloudAuthenticationInstance.createGcloudAuthenticationBucket();
// get the bucket name
const bucketToUpload = GCLOUD_ENV_STR_BUCKET_NAME;
let uploadLocalFilePath;
export async function downloadEnvFiles(env_name): Promise<any> {
const LOGGER: pino.Logger = PinoLoggerServiceInstance.getLogger(__filename);
return new Promise(async (res, rej) => {
// Get the storage
const str = GcloudAuthenticationInstance.createGcloudAuthenticationBucket();
try {
// get the file list from the storage and the bucket
const [files] = await str.bucket(GCLOUD_ENV_STR_BUCKET_NAME).getFiles();
// filter the req file
{
"name": "@feedback/cloud-storage-app",
"description": "This is the default storage app used by feedback",
"version": "1.0.12",
"author": "VijayKumar <vijay.psg587@gmail.com>",
"keywords": [
"feedback-gcloud-storate",
"feedback-storage",
"feedback-cloud-storage"
],
Node parameters: --require ts-node/register -r ts-node -r dotenv/config -r tsconfig-paths/register src/main.ts dotenv_config_path=./config/development/.env
// baiscally we need -require ts-node/register <things in nodemon exec>
NODE_ENV=dev
@vijayakumar-psg587
vijayakumar-psg587 / update-golang.md
Created September 9, 2021 07:13 — forked from nikhita/update-golang.md
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by: