No password in config file

This commit is contained in:
kota kanbe
2016-04-18 23:03:13 +09:00
parent b02b7c9081
commit 4d28de17b4
10 changed files with 117 additions and 34 deletions

View File

@@ -24,6 +24,6 @@ type JSONLoader struct {
}
// Load load the configuraiton JSON file specified by path arg.
func (c JSONLoader) Load(path string) (err error) {
func (c JSONLoader) Load(path, sudoPass, keyPass string) (err error) {
return fmt.Errorf("Not implement yet")
}

View File

@@ -18,16 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package config
// Load loads configuration
func Load(path string) error {
//TODO if path's suffix .toml
func Load(path, keyPass, sudoPass string) error {
var loader Loader
loader = TOMLLoader{}
return loader.Load(path)
return loader.Load(path, keyPass, sudoPass)
}
// Loader is interface of concrete loader
type Loader interface {
Load(string) error
Load(string, string, string) error
}

View File

@@ -31,7 +31,7 @@ type TOMLLoader struct {
}
// Load load the configuraiton TOML file specified by path arg.
func (c TOMLLoader) Load(pathToToml string) (err error) {
func (c TOMLLoader) Load(pathToToml, keyPass, sudoPass string) (err error) {
var conf Config
if _, err := toml.DecodeFile(pathToToml, &conf); err != nil {
log.Error("Load config failed", err)
@@ -53,10 +53,7 @@ func (c TOMLLoader) Load(pathToToml string) (err error) {
s.User = d.User
}
s.Password = v.Password
if s.Password == "" {
s.Password = d.Password
}
s.Password = sudoPass
s.Host = v.Host
@@ -76,10 +73,7 @@ func (c TOMLLoader) Load(pathToToml string) (err error) {
}
}
s.KeyPassword = v.KeyPassword
if s.KeyPassword == "" {
s.KeyPassword = d.KeyPassword
}
s.KeyPassword = keyPass
s.CpeNames = v.CpeNames
if len(s.CpeNames) == 0 {