Skip to content

Commit

Permalink
Merge pull request #5 from iwashi623/feature/add_jobsettingfile_option
Browse files Browse the repository at this point in the history
Feature/add jobsettingfile option
  • Loading branch information
iwashi623 authored Feb 3, 2023
2 parents fc70455 + d38ccf0 commit 2acb877
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Glue Job にのみ関心を持つツールで、Glue のスクリプトや設定
## Use gjobctl

### 準備

GlueJobのリポジトリ例
```bash
sample-job
├── gjobctl.yml ## <- gjobctl設定ファイル
Expand All @@ -21,6 +21,7 @@ sample-job
```yml:gjobctl.yml
region: ap-northeast-1
job_name: sample-job
job_setting_file: sample-job.json
```

json の Glue Job 定義ファイルは下記する`gjobctl get`コマンドを使うと簡単に手に入ります。
Expand Down
8 changes: 5 additions & 3 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ type CreateOption struct {
func (app *App) Create(opt *CreateOption) error {
// JSONファイルからGlue Jobの設定を読み込む
var settingFileName string
if opt.JobSettingFile == nil {
settingFileName = app.config.JobName + ".json"
} else {
if opt.JobSettingFile != nil {
settingFileName = *opt.JobSettingFile
} else if app.config.JobSettingFile != "" {
settingFileName = app.config.JobSettingFile
} else {
settingFileName = app.config.JobName + ".json"
}
f, err := os.Open(settingFileName)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions gjobctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (app *App) setup() error {
}

type AppConfig struct {
Region string `yaml:"region"`
JobName string `yaml:"job_name"`
Region string `yaml:"region"`
JobName string `yaml:"job_name"`
JobSettingFile string `yaml:"job_setting_file"`
}
8 changes: 5 additions & 3 deletions script_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ type ScriptDeployOption struct {
func (app *App) ScriptDeploy(opt *ScriptDeployOption) error {
// JSONファイルからGlue Jobの設定を読み込む
var settingFileName string
if opt.JobSettingFile == nil {
settingFileName = app.config.JobName + ".json"
} else {
if opt.JobSettingFile != nil {
settingFileName = *opt.JobSettingFile
} else if app.config.JobSettingFile != "" {
settingFileName = app.config.JobSettingFile
} else {
settingFileName = app.config.JobName + ".json"
}
f, err := os.Open(settingFileName)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ type UpdateOption struct {
func (app *App) Update(opt *UpdateOption) error {
// JSONファイルからGlue Jobの設定を読み込む
var settingFileName string
if opt.JobSettingFile == nil {
settingFileName = app.config.JobName + ".json"
} else {
if opt.JobSettingFile != nil {
settingFileName = *opt.JobSettingFile
} else if app.config.JobSettingFile != "" {
settingFileName = app.config.JobSettingFile
} else {
settingFileName = app.config.JobName + ".json"
}
f, err := os.Open(settingFileName)
if err != nil {
Expand Down

0 comments on commit 2acb877

Please sign in to comment.