Skip to content

Commit

Permalink
🎨 Update make init. Remove cmd/main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
nkmr-jp committed May 14, 2022
1 parent 905df2c commit fa278bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,31 @@ FUNC_NAME=fetch
ENTRY_POINT=Fetch
TOPIC_NAME=$(FUNC_NAME)-topic
BUCKET_NAME=$(PROJECT_ID)-fetch
TEST_BUCKET_NAME=$(PROJECT_ID)-fetch-test

start:
export FUNCTION_TARGET=$(ENTRY_POINT) && \
go run cmd/main.go

init:
gcloud projects add-iam-policy-binding $(PROJECT_ID) \
@echo
@echo "---- add iam policy binding. ----"
-gcloud projects add-iam-policy-binding $(PROJECT_ID) \
--member=serviceAccount:service-$(PROJECT_NUMBER)@gcp-sa-pubsub.iam.gserviceaccount.com \
--role=roles/iam.serviceAccountTokenCreator
gcloud pubsub topics create $(TOPIC_NAME)
gsutil mb -c regional -l $(REGION) gs://$(BUCKET_NAME)
gsutil mb -c regional -l $(REGION) gs://$(TEST_BUCKET_NAME)
@echo
@echo "---- create pubusub topic. ----"
-gcloud pubsub topics create $(TOPIC_NAME)
@echo
@echo "---- create bucket and set versioning. ----"
-gsutil mb -c regional -l $(REGION) gs://$(BUCKET_NAME)
-gsutil versioning set on gs://$(BUCKET_NAME)
@echo
@echo "---- create bucket and set versioning, for test. ----"
-gsutil mb -c regional -l $(REGION) gs://$(BUCKET_NAME)-test
-gsutil versioning set on gs://$(BUCKET_NAME)-test
@echo
@echo "---- check resources in google cloud console. ----"
make open

test:
export BUCKET_NAME=$(TEST_BUCKET_NAME) && go test -v
Expand Down Expand Up @@ -49,6 +61,7 @@ log:
gcloud beta functions logs read $(FUNC_NAME) --gen2 --limit=100

open:
open https://console.cloud.google.com/functions/details/asia-northeast1/$(FUNC_NAME)?env=gen2
open https://console.cloud.google.com/iam-admin/serviceaccounts?project=$(PROJECT_ID)
open https://console.cloud.google.com/cloudpubsub/topic/detail/$(FUNC_NAME)-topic
open https://console.cloud.google.com/storage/browser?project=$(PROJECT_ID)
open https://console.cloud.google.com/functions/details/$(REGION)/$(FUNC_NAME)?env=gen2
22 changes: 0 additions & 22 deletions cmd/main.go

This file was deleted.

0 comments on commit fa278bf

Please sign in to comment.