tenco

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 9 Imported by: 0

README

tenco

Description

tenco は terraform での cloudwatch events の設定を補助するツールです

cloudwatch eventsのcron式はUTCを強制されるのでJSTでの動作を期待する場合、時差を考慮する必要があります

ref:ルールのスケジュール式 - Amazon CloudWatch Events

tenco は minutes hours day_of_weeks の3つの入力に絞り時差を考慮しつつcron式に直してtf.jsonを生成します

Synopsis

e.g. JSTで月曜日の0時
    schedule:
      minutes:      0
      hours:        0
      day_of_weeks: MON

cron式ではUTCで日曜15時

cron(0 15 ? * 1 *)
e.g. JSTで月曜の8-10時
# 範囲指定で曜日を跨ぐような場合は分割します
    schedule:
      minutes:      0
      hours:        8-10
      day_of_weeks: MON

cron式ではUTCで日曜23時,月曜0-1時

cron(0 23 ? * 1 *)
cron(0 0-1 ? * 2 *)

Usage

Usage of tenco:
  tenco config1.yaml [config2.yaml ...]
  -o string
        Write to FILE (default "-")
  -offset int
        offset (default -9)

install

Homebrew (macOS and Linux)
$ brew install mix3/tap/tenco
Binary packages

Releases

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CWCronExpr added in v0.3.0

type CWCronExpr struct {
	Minutes   [][]int
	Hours     [][]int
	DayOfWeek int
}

func (CWCronExpr) String added in v0.3.0

func (c CWCronExpr) String() string

type Config

type Config struct {
	Events []*ConfigEvent `yaml:"events"`
}

type ConfigEvent

type ConfigEvent struct {
	Name                  string                 `yaml:"name"`
	Description           string                 `yaml:"description"`
	Schedule              *Schedule              `yaml:"schedule"`
	CloudwatchEventTarget map[string]interface{} `yaml:"cloudwatch_event_target"`
	IsEnabled             bool                   `yaml:"is_enabled"`
}

func (*ConfigEvent) UnmarshalYAML added in v0.4.0

func (s *ConfigEvent) UnmarshalYAML(unmarshal func(interface{}) error) error

type CronExpr

type CronExpr struct {
	Minutes   [][]int
	Hours     [][]int
	DayOfWeek int
}

func (CronExpr) String

func (c CronExpr) String() string

type DayOfWeek

type DayOfWeek int

type DayOfWeeks

type DayOfWeeks []DayOfWeek

func (*DayOfWeeks) UnmarshalYAML

func (ws *DayOfWeeks) UnmarshalYAML(unmarshal func(interface{}) error) error

type Generator

type Generator interface {
	Generate(w io.Writer, conf Config, offset int) error
}

type Hour

type Hour int

type Hours

type Hours []Hour

func (*Hours) UnmarshalYAML

func (hs *Hours) UnmarshalYAML(unmarshal func(interface{}) error) error

type JSONGenerator added in v0.2.0

type JSONGenerator struct {
}

func (*JSONGenerator) Generate added in v0.2.0

func (g *JSONGenerator) Generate(w io.Writer, conf Config, offset int) error

type Minute added in v0.3.0

type Minute int

type Minutes

type Minutes []Minute

func (*Minutes) UnmarshalYAML

func (ms *Minutes) UnmarshalYAML(unmarshal func(interface{}) error) error

type OrigSchedule

type OrigSchedule struct {
	Minutes    string `yaml:"minutes"`
	Hours      string `yaml:"hours"`
	DayOfWeeks string `yaml:"day_of_weeks"`
}

func (OrigSchedule) String

func (o OrigSchedule) String() string

type Schedule

type Schedule struct {
	Minutes      Minutes      `yaml:"minutes"`
	Hours        Hours        `yaml:"hours"`
	DayOfWeeks   DayOfWeeks   `yaml:"day_of_weeks"`
	OrigSchedule OrigSchedule `yaml:"-"`
}

func (*Schedule) CWCronExprs added in v0.3.0

func (s *Schedule) CWCronExprs(offset int) []CWCronExpr

func (*Schedule) CronExprs

func (s *Schedule) CronExprs(offset int) []CronExpr

func (*Schedule) UnmarshalYAML

func (s *Schedule) UnmarshalYAML(unmarshal func(interface{}) error) error

type Tenco

type Tenco struct {
	// contains filtered or unexported fields
}

func Load

func Load(confs ...string) (*Tenco, error)

func LoadWithEnv

func LoadWithEnv(confs ...string) (*Tenco, error)

func (*Tenco) Write

func (t *Tenco) Write(w io.Writer, offset int, g Generator) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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