Skip to content

Commit

Permalink
refactor: merge firehose module files
Browse files Browse the repository at this point in the history
  • Loading branch information
spy16 committed Mar 16, 2023
1 parent 82f49b8 commit 2ba8190
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 434 deletions.
21 changes: 5 additions & 16 deletions modules/firehose/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,7 @@ const (
firehoseConsumerIDStartingSequence = "0001"
)

var (
//go:embed schema/config.json
completeConfigSchema string

//go:embed schema/scale.json
scaleActionSchema string

//go:embed schema/reset.json
resetActionSchema string
)

type moduleConfig struct {
type Config struct {
State string `json:"state"`
StopTime *time.Time `json:"stop_time"`
Telegraf map[string]interface{} `json:"telegraf"`
Expand All @@ -43,7 +32,7 @@ type moduleConfig struct {
} `json:"firehose"`
}

func (mc *moduleConfig) validateAndSanitize(r resource.Resource) error {
func (mc *Config) validateAndSanitize(r resource.Resource) error {
if mc.StopTime != nil && mc.StopTime.Before(time.Now()) {
return errors.ErrInvalid.
WithMsgf("value for stop_time must be greater than current time")
Expand All @@ -57,7 +46,7 @@ func (mc *moduleConfig) validateAndSanitize(r resource.Resource) error {
return nil
}

func (mc *moduleConfig) GetHelmReleaseConfig(r resource.Resource) (*helm.ReleaseConfig, error) {
func (mc *Config) GetHelmReleaseConfig(r resource.Resource) (*helm.ReleaseConfig, error) {
var output Output
err := json.Unmarshal(r.State.Output, &output)
if err != nil {
Expand Down Expand Up @@ -102,15 +91,15 @@ func (mc *moduleConfig) GetHelmReleaseConfig(r resource.Resource) (*helm.Release
return rc, nil
}

func (mc *moduleConfig) JSON() []byte {
func (mc *Config) JSON() []byte {
b, err := json.Marshal(mc)
if err != nil {
panic(err)
}
return b
}

func sanitiseDeploymentID(r resource.Resource, mc moduleConfig) (string, error) {
func sanitiseDeploymentID(r resource.Resource, mc Config) (string, error) {
releaseName := mc.Firehose.DeploymentID
if len(releaseName) == 0 {
releaseName = generateSafeReleaseName(r.Project, r.Name)
Expand Down
Loading

0 comments on commit 2ba8190

Please sign in to comment.