Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel DeLeo <[email protected]>
  • Loading branch information
danielsdeleo committed Feb 8, 2021
1 parent 5397d98 commit b8dddc6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ func RootCmd() *cobra.Command {
return r
}

// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd().Execute(); err != nil {
log.Error(err)
Expand Down
4 changes: 0 additions & 4 deletions components/notifications-service2/habitat/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ port = {{cfg.service.port}}
external_fqdn = "{{cfg.service.external_fqdn}}"
log_level = "{{cfg.log.level}}"

## TODO: is this needed?
# export CACHE_TIMEOUT_MS_EVENT_RULE="{{cfg.cache.event_rule_timeout_ms}}"
# export EVENT_DEDUP_WINDOW_SECONDS="{{cfg.service.dedup_window_seconds}}"

[postgres]
database = "{{cfg.storage.database}}"
schema_path = "{{pkg.path}}/schema"
Expand Down
9 changes: 1 addition & 8 deletions components/notifications-service2/habitat/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ accept = false
[service]
external_fqdn="http://localhost"
host = "localhost"
port = 4001

# How long in seconds must pass before we consider
# an inbound event with the same id and type as not a duplicate
dedup_window_seconds = 300
port = 10125

[storage]
database = "notifications_service"
max_open_conns = 10
max_idle_conns = 10


[cache]
event_rule_timeout_ms = 5000
24 changes: 4 additions & 20 deletions components/notifications-service2/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ pkg_binds=(
pkg_bin_dirs=(bin)
pkg_lib_dirs=(lib)

# The service files and directories
# NOTE: this has nothing to do with habitat. It is used for
# determining when a build is stale in the studiorc
pkg_srcs=(
server/lib
server/priv
server/rel
server/config.exs
server/Makefile
server/mix.exs
server/mix.lock

# TODO: VERSION should be in this list
)

pkg_scaffolding="${local_scaffolding_origin:-chef}/automate-scaffolding-go"
scaffolding_go_base_path=github.com/chef
scaffolding_go_repo_name=automate
Expand All @@ -55,10 +40,10 @@ scaffolding_go_binary_list=(
"${scaffolding_go_import_path}/cmd/${pkg_name}"
)

## . scaffolding_go_import_path="${scaffolding_go_base_path}/${scaffolding_go_repo_name}/components/${pkg_name}"
## . scaffolding_go_binary_list=(
## . "${scaffolding_go_import_path}/cmd/${pkg_name}"
## . )
## scaffolding_go_import_path="${scaffolding_go_base_path}/${scaffolding_go_repo_name}/components/${pkg_name}"
## scaffolding_go_binary_list=(
## "${scaffolding_go_import_path}/cmd/${pkg_name}"
## )

do_install() {
do_default_install
Expand All @@ -72,4 +57,3 @@ do_strip() {
return 0
}


8 changes: 4 additions & 4 deletions components/notifications-service2/pkg/config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Secrets struct {
// certs), sets derived config and populates global state (e.g., log level,
// etc.)
func FromFile(path string) (*Notifications, error) {
n, err := marshalFromFile(path)
n, err := MarshalFromFile(path)
if err != nil {
return nil, err
}
Expand All @@ -53,14 +53,14 @@ func FromFile(path string) (*Notifications, error) {
if err := n.SetLogLevel(); err != nil {
return nil, err
}
if err := n.readCerts(); err != nil {
if err := n.ReadCerts(); err != nil {
return nil, err
}

return n, nil
}

func marshalFromFile(path string) (*Notifications, error) {
func MarshalFromFile(path string) (*Notifications, error) {
viper.SetConfigFile(path)

err := viper.ReadInConfig()
Expand Down Expand Up @@ -94,7 +94,7 @@ func (n *Notifications) SetLogLevel() error {
return n.Service.SetLogLevel()
}

func (n *Notifications) readCerts() error {
func (n *Notifications) ReadCerts() error {
certs, err := n.TLSConfig.ReadCerts()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions components/notifications-service2/pkg/config/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestConfigMarshaling(t *testing.T) {
err = f.Close()
require.NoError(t, err)

unmarshaled, err := marshalFromFile(f.Name())
unmarshaled, err := MarshalFromFile(f.Name())
require.NoError(t, err)
assert.Equal(t, original, unmarshaled)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func TestConfigReadCerts(t *testing.T) {
RootCACertPath: "/src/dev/certs/Chef_Automate_FAKE_Dev.crt",
},
}
err := nValid.readCerts()
err := nValid.ReadCerts()
require.NoError(t, err)

}

0 comments on commit b8dddc6

Please sign in to comment.