Skip to content

Commit

Permalink
fix secret variable shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Nov 18, 2019
1 parent bab3f30 commit d6031ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ require (
github.com/nats-io/nuid v1.0.1
github.com/pkg/errors v0.8.1
)

go 1.13
11 changes: 3 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Service struct {

// nolint: gocyclo
func main() {
var err error

cloud := ""
if os.Getenv("CLOUD") != "" {
Expand Down Expand Up @@ -81,7 +82,7 @@ func main() {
if os.Getenv("EXPORT_DIR") != "" {
exportRoot = os.Getenv("EXPORT_DIR")
}
if err := os.MkdirAll(exportRoot, os.ModePerm); err != nil {
if err = os.MkdirAll(exportRoot, os.ModePerm); err != nil {
log.Println("failed to ensure destination directory", exportRoot, ":", err.Error())
os.Exit(1)
}
Expand All @@ -93,7 +94,7 @@ func main() {

secret := os.Getenv("ARI_AUTOSECRET")
if secret == "" {
secret, err := getOrCreateSecret(exportRoot)
secret, err = getOrCreateSecret(exportRoot)
if err != nil {
log.Println("failed to get secret:", err)
os.Exit(1)
Expand Down Expand Up @@ -132,12 +133,10 @@ func main() {

log.Println("asterisk-config exiting")
os.Exit(1)

}

// Run executes the Service
func (s *Service) Run() error {

renderChan := make(chan error, 1)

s.engine = kubetemplate.NewEngine(renderChan, s.Discoverer)
Expand Down Expand Up @@ -199,7 +198,6 @@ func getDiscoverer(cloud string) discover.Discoverer {
}

func getOrCreateSecret(exportRoot string) (string, error) {

secret := genSecret()
secretPath := path.Join(exportRoot, secretFilename)

Expand All @@ -217,7 +215,6 @@ func getOrCreateSecret(exportRoot string) (string, error) {
}

func render(e *kubetemplate.Engine, customRoot string, exportRoot string) error {

var fileCount int

err := filepath.Walk(customRoot, func(fn string, info os.FileInfo, err error) error {
Expand Down Expand Up @@ -259,7 +256,6 @@ func render(e *kubetemplate.Engine, customRoot string, exportRoot string) error
_, err = io.Copy(out, in)
return err
})

if err != nil {
return err
}
Expand Down Expand Up @@ -309,7 +305,6 @@ func reload(username, secret, modules string) (err error) {
}

func extractSource(source, customRoot string) (err error) {

if strings.HasPrefix(source, "http") {
source, err = downloadSource(source)
if err != nil {
Expand Down

0 comments on commit d6031ac

Please sign in to comment.