-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6d1b34f
Showing
19 changed files
with
570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: rspec | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
ruby-version: ['3.1'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Ruby ${{ matrix.ruby-version }} | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
bundler-cache: true | ||
- name: Install dependencies | ||
run: bundle install | ||
- name: Run tests | ||
run: bundle exec rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/spec/examples.txt | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
|
||
# Used by dotenv library to load environment variables. | ||
# .env | ||
|
||
# Ignore Byebug command history file. | ||
.byebug_history | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
*.bridgesupport | ||
build-iPhoneOS/ | ||
build-iPhoneSimulator/ | ||
|
||
## Specific to RubyMotion (use of CocoaPods): | ||
# | ||
# We recommend against adding the Pods directory to your .gitignore. However | ||
# you should judge for yourself, the pros and cons are mentioned at: | ||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control | ||
# | ||
# vendor/Pods/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalization: | ||
/.bundle/ | ||
/vendor/bundle | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# Gemfile.lock | ||
# .ruby-version | ||
# .ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc | ||
|
||
# Used by RuboCop. Remote config files pulled in from inherit_from directive. | ||
.rubocop-https?--* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
gcp_scheduler (0.0.1) | ||
activesupport | ||
google-cloud-scheduler-v1 (>= 0.7.0) | ||
thor | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activesupport (7.0.4.3) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
addressable (2.8.4) | ||
public_suffix (>= 2.0.2, < 6.0) | ||
byebug (11.1.3) | ||
coderay (1.1.3) | ||
concurrent-ruby (1.2.2) | ||
diff-lcs (1.5.0) | ||
faraday (2.7.4) | ||
faraday-net_http (>= 2.0, < 3.1) | ||
ruby2_keywords (>= 0.0.4) | ||
faraday-net_http (3.0.2) | ||
faraday-retry (2.1.0) | ||
faraday (~> 2.0) | ||
gapic-common (0.18.0) | ||
faraday (>= 1.9, < 3.a) | ||
faraday-retry (>= 1.0, < 3.a) | ||
google-protobuf (~> 3.14) | ||
googleapis-common-protos (>= 1.3.12, < 2.a) | ||
googleapis-common-protos-types (>= 1.3.1, < 2.a) | ||
googleauth (~> 1.0) | ||
grpc (~> 1.36) | ||
google-cloud-errors (1.3.1) | ||
google-cloud-location (0.4.0) | ||
gapic-common (>= 0.17.1, < 2.a) | ||
google-cloud-errors (~> 1.0) | ||
google-cloud-scheduler-v1 (0.7.0) | ||
gapic-common (>= 0.18.0, < 2.a) | ||
google-cloud-errors (~> 1.0) | ||
google-cloud-location (>= 0.4, < 2.a) | ||
google-protobuf (3.22.3-x86_64-darwin) | ||
google-protobuf (3.22.3-x86_64-linux) | ||
googleapis-common-protos (1.4.0) | ||
google-protobuf (~> 3.14) | ||
googleapis-common-protos-types (~> 1.2) | ||
grpc (~> 1.27) | ||
googleapis-common-protos-types (1.5.0) | ||
google-protobuf (~> 3.14) | ||
googleauth (1.5.2) | ||
faraday (>= 0.17.3, < 3.a) | ||
jwt (>= 1.4, < 3.0) | ||
memoist (~> 0.16) | ||
multi_json (~> 1.11) | ||
os (>= 0.9, < 2.0) | ||
signet (>= 0.16, < 2.a) | ||
grpc (1.54.0-x86_64-darwin) | ||
google-protobuf (~> 3.21) | ||
googleapis-common-protos-types (~> 1.0) | ||
grpc (1.54.0-x86_64-linux) | ||
google-protobuf (~> 3.21) | ||
googleapis-common-protos-types (~> 1.0) | ||
i18n (1.12.0) | ||
concurrent-ruby (~> 1.0) | ||
jwt (2.7.0) | ||
memoist (0.16.2) | ||
method_source (1.0.0) | ||
minitest (5.18.0) | ||
multi_json (1.15.0) | ||
os (1.1.4) | ||
pry (0.14.2) | ||
coderay (~> 1.1) | ||
method_source (~> 1.0) | ||
pry-byebug (3.10.1) | ||
byebug (~> 11.0) | ||
pry (>= 0.13, < 0.15) | ||
public_suffix (5.0.1) | ||
rspec (3.12.0) | ||
rspec-core (~> 3.12.0) | ||
rspec-expectations (~> 3.12.0) | ||
rspec-mocks (~> 3.12.0) | ||
rspec-core (3.12.2) | ||
rspec-support (~> 3.12.0) | ||
rspec-expectations (3.12.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.12.0) | ||
rspec-mocks (3.12.5) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.12.0) | ||
rspec-support (3.12.0) | ||
ruby2_keywords (0.0.5) | ||
signet (0.17.0) | ||
addressable (~> 2.8) | ||
faraday (>= 0.17.5, < 3.a) | ||
jwt (>= 1.5, < 3.0) | ||
multi_json (~> 1.10) | ||
thor (1.2.1) | ||
tzinfo (2.0.6) | ||
concurrent-ruby (~> 1.0) | ||
|
||
PLATFORMS | ||
x86_64-darwin-21 | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
gcp_scheduler! | ||
pry-byebug | ||
rspec (~> 3.9) | ||
|
||
BUNDLED WITH | ||
2.5.0.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Akira Kusumoto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# gcp_scheduler | ||
|
||
gcp_schedulerは、Google Cloud Schedulerを簡単に操作できるコマンドラインツールです。 | ||
create、list、deleteのコマンドでCloud Schedulerのジョブを追加、表示、削除できます。 | ||
|
||
## インストール | ||
|
||
``` | ||
gem install gcp_scheduler | ||
``` | ||
|
||
## 使い方 | ||
|
||
以下のコマンド例を参考にして、CLIを使用してください。 | ||
|
||
各コマンドは認証情報を下記のように環境変数で設定してある状態で実行する必要があります。 | ||
|
||
``` | ||
export GOOGLE_APPLICATION_CREDENTIALS=your_credential.json | ||
``` | ||
|
||
### ジョブの作成 | ||
|
||
``` | ||
gcp_scheduler create --gcp_project your_project_name --scheduler_file path/to/scheduler.yml --uri https://your_domain.example.com --prefix development- --region asia-northeast1 --secret your_secret_token | ||
``` | ||
|
||
- scheduler_fileを元にジョブを作成します。 | ||
- prefixは、ジョブ名に付与されるプレフィックスです。 | ||
- regionは、Cloud Schedulerのリージョンです。 | ||
- uriは、スケジューラーがHTTP POSTを実行するURLです。 | ||
- すべてのジョブは一つのURLにapplication/jsonでリクエストパラメータのjob_nameにscheduler_fileのjob名が入ります。 | ||
- secretは、Http Authorization Header Bearer tokenです。 | ||
|
||
### ジョブの一覧表示 | ||
|
||
``` | ||
gcp_scheduler list --gcp_project your_project_name --prefix development- --region asia-northeast1 | ||
``` | ||
|
||
### ジョブの削除 | ||
|
||
``` | ||
gcp_scheduler delete --gcp_project your_project_name --prefix development- --region asia-northeast1 | ||
``` | ||
|
||
- prefixで指定した文字列から始まるジョブ名のジョブをすべて削除します。 | ||
|
||
## コマンドオプション | ||
|
||
| Option | Description | | ||
|---|-------------------------------------------------------------------------------------------| | ||
| `--gcp_project` | Google Cloud project name | | ||
| `--scheduler_file` | Path to the scheduler configuration file (used with `create` command) | | ||
| `--uri` | URL of the endpoint to be executed by the job (used with `create` command) | | ||
| `--prefix` | Prefix for the job name (used with `create`, `list`, and `delete` commands) | | ||
| `--region` | Cloud Scheduler region | | ||
| `--secret` | Http Authorization Header Bearer token to be sent by the job (used with `create` command) | | ||
|
||
## scheduler.yml file | ||
|
||
scheduler.ymlファイルは、ジョブのスケジュール情報を定義するために使用されます。以下は、scheduler.ymlファイルのサンプルです。 | ||
|
||
```yaml | ||
weekly_job: | ||
cron: '0 9 * * 1' | ||
``` | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/bluerabbit/gcp_scheduler. | ||
|
||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "bundler" | ||
require "rspec/core/rake_task" | ||
Bundler::GemHelper.install_tasks | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task default: :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
# | ||
|
||
require "gcp_scheduler/cli" | ||
|
||
GcpScheduler::Cli.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$LOAD_PATH.push File.expand_path("lib", __dir__) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "gcp_scheduler" | ||
s.version = "0.0.1" | ||
s.platform = Gem::Platform::RUBY | ||
s.authors = ["Akira Kusumoto"] | ||
s.email = ["akirakusumo10@gmail.com"] | ||
s.homepage = "https://github.com/bluerabbit/gcp_scheduler" | ||
s.summary = "A command-line interface for managing Google Cloud Scheduler jobs with ease" | ||
s.description = "GCP Scheduler CLI is a Ruby gem that provides a simple command-line interface for managing Google Cloud Scheduler jobs. With this tool, you can create, list, and delete Cloud Scheduler jobs using intuitive commands. It streamlines job management tasks by allowing you to define job schedules in a YAML file and supports custom job prefixes, regions, and authentication tokens." | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.require_paths = ["lib"] | ||
s.licenses = ["MIT"] | ||
|
||
s.bindir = "exe" | ||
s.executables = s.files.grep(%r{^exe/}) {|f| File.basename(f) } | ||
s.add_runtime_dependency "thor" | ||
|
||
s.add_dependency "activesupport" | ||
s.add_dependency "google-cloud-scheduler-v1", [">= 0.7.0"] | ||
s.add_development_dependency "pry-byebug" | ||
s.add_development_dependency "rspec", "~> 3.9" | ||
s.metadata["rubygems_mfa_required"] = "true" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require "active_support/all" | ||
require "google/cloud/scheduler/v1" | ||
|
||
require_relative "gcp_scheduler/cli" | ||
require_relative "gcp_scheduler/command" | ||
require_relative "gcp_scheduler/scheduler" | ||
|
||
module GcpScheduler | ||
VERSION = Gem.loaded_specs["gcp_scheduler"].version.to_s | ||
|
||
class << self | ||
def list(gcp_project:, region:, prefix: "") | ||
GcpScheduler::Command.list(gcp_project: gcp_project, prefix: prefix, region: region) | ||
end | ||
|
||
def delete(gcp_project:, region:, prefix: "") | ||
GcpScheduler::Command.delete(gcp_project: gcp_project, prefix: prefix, region: region) | ||
end | ||
|
||
def create(gcp_project:, region:, scheduler_file_path:, uri:, secret:, time_zone:, prefix: "") | ||
GcpScheduler::Command.create(gcp_project: gcp_project, | ||
region: region, | ||
prefix: prefix, | ||
scheduler_file_path: scheduler_file_path, | ||
uri: uri, | ||
secret: secret, | ||
time_zone: time_zone) | ||
end | ||
end | ||
end |
Oops, something went wrong.