firebase

command
v0.0.0-...-d705cfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 6 Imported by: 0

README

Imagine

  • Create Firestore database, i.e. Datastore in native mode, to persist the confirmed bookings.

  • Implement CRUD

Create

Create Datastore in native mode in console for project serverless-devops-play - maybe not necessary?

Create Firebase project associated to serverless-devops-play

gcloud config list

firebase login
firebase init                         # see output in firebase_init.out
firebase projects:list
firebase database:instances:list

firebase database:instances:create bookings-play
firebase database:instances:list

Change Firestore rules

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Set Service Account to access Firestore database

export LOCAL_CREDENTIALS_DIR=<local credentials directory>

export PROJECT_ID=serverless-devops-play

SA_NAME=firestore-play

gcloud iam service-accounts create ${SA_NAME} \
    --description="Service account to access Firestore API" \
    --display-name="${SA_NAME}"
    
gcloud projects add-iam-policy-binding ${PROJECT_ID} \
    --member "serviceAccount:${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com" --role "roles/firebasedatabase.admin"    
    
    
gcloud iam service-accounts keys create ${LOCAL_CREDENTIALS_DIR}/${PROJECT_ID}-${SA_NAME}.json \
  --iam-account ${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com
  

export GOOGLE_APPLICATION_CREDENTIALS="${LOCAL_CREDENTIALS_DIR}/${PROJECT_ID}-${SA_NAME}.json"
ls -l $GOOGLE_APPLICATION_CREDENTIALS

Edit main.go and run it

go mod init

go run main.go

Play

Establish a commandline frontend and play:

Copy template directory as commandline from github.com/stefanhans/frontend-liner-play/template

See details of playing in commandline/README

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL