Class: SOULs::Functions
- Inherits:
-
Thor
- Object
- Thor
- SOULs::Functions
- Defined in:
- lib/souls/cli/gcloud/functions/index.rb
Instance Method Summary collapse
- #all_url ⇒ Object
- #delete(name) ⇒ Object
- #deploy ⇒ Object
- #describe ⇒ Object
- #dev ⇒ Object
- #url ⇒ Object
Instance Method Details
#all_url ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 49 def all_url require(SOULs.get_mother_path.to_s + "/config/souls") project_id = SOULs.configuration.project_id Dir.chdir(SOULs.get_mother_path.to_s) do souls_functions = Dir["apps/cf_*"] cf_dir = souls_functions.map { |n| n.split("/").last } cf_dir.each do |dir| SOULs::Painter.success(`gcloud functions describe #{dir} --project=#{project_id}| grep url`) end end end |
#delete(name) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 30 def delete(name) require(SOULs.get_mother_path.to_s + "/config/souls") project_id = SOULs.configuration.project_id system("gcloud functions delete #{name} --project=#{project_id}") Dir.chdir(SOULs.get_mother_path.to_s) do FileUtils.rm_rf("apps/#{name}") end SOULs::Painter.success("Deleted #{name} functions!") end |
#deploy ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 4 def deploy require(SOULs.get_mother_path.to_s + "/config/souls") project_id = SOULs.configuration.project_id current_dir = FileUtils.pwd.split("/").last unless current_dir.match?(/^cf_/) SOULs::Painter.error("You are at wrong dir!\nPlease go to `apps/functions` dir!") return false end runtime = current_dir.match(/cf_(\D+\d+)_/)[1] system( " gcloud functions deploy #{current_dir} --project=#{project_id} \ --runtime #{runtime} --trigger-http --allow-unauthenticated --env-vars-file .env.yaml " ) end |
#describe ⇒ Object
23 24 25 26 27 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 23 def describe require(SOULs.get_mother_path.to_s + "/config/souls") project_id = SOULs.configuration.project_id system("gcloud functions describe souls_functions --project=#{project_id}") end |
#dev ⇒ Object
62 63 64 65 66 67 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 62 def dev Dir.chdir(SOULs.get_functions_path.to_s) do current_dir = FileUtils.pwd.split("/").last system("bundle exec functions-framework-ruby --target #{current_dir}") end end |
#url ⇒ Object
41 42 43 44 45 46 |
# File 'lib/souls/cli/gcloud/functions/index.rb', line 41 def url require(SOULs.get_mother_path.to_s + "/config/souls") project_id = SOULs.configuration.project_id current_dir = FileUtils.pwd.split("/").last SOULs::Painter.success(`gcloud functions describe #{current_dir} --project=#{project_id}| grep url`) end |