Browse Source

fix: user groups is string, not []string

main
Andy Cobaugh 4 years ago
parent
commit
335c8db546
  1. 6
      main.go
  2. 11
      main_test.go

6
main.go

@ -22,7 +22,7 @@ type CloudConfigUser struct {
CreateGroups bool `yaml:"create_groups"` CreateGroups bool `yaml:"create_groups"`
GECOS string `yaml:"gecos"` GECOS string `yaml:"gecos"`
LockPasswd bool `yaml:"lock_passwd"` LockPasswd bool `yaml:"lock_passwd"`
Groups []string `yaml:"groups"` Groups string `yaml:"groups"`
Homedir string `yaml:"homedir"` Homedir string `yaml:"homedir"`
Name string `yaml:"name"` Name string `yaml:"name"`
NoLogInit bool `yaml:"no_log_init"` NoLogInit bool `yaml:"no_log_init"`
@ -198,8 +198,8 @@ func createUser(u CloudConfigUser) error {
args = append(args, "--gid", u.PrimaryGroup) args = append(args, "--gid", u.PrimaryGroup)
} }
if len(u.Groups) > 0 { if u.Groups != "" {
args = append(args, "--groups", strings.Join(u.Groups, ",")) args = append(args, "--groups", u.Groups)
} }
if u.NoUserGroup { if u.NoUserGroup {

11
main_test.go

@ -1,6 +1,15 @@
package main package main
import "testing" import (
"fmt"
"testing"
)
func TestProcessUserData(T *testing.T) {
err := processUserData("test")
fmt.Println(err)
}
func TestProcessMetaData(T *testing.T) { func TestProcessMetaData(T *testing.T) {

Loading…
Cancel
Save