Skip to content

Commit

Permalink
remove group level user
Browse files Browse the repository at this point in the history
  • Loading branch information
AshutoshPatole committed Aug 13, 2024
1 parent 5e3a3af commit 28441cd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
5 changes: 3 additions & 2 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func ListToConnectServers(group, environment string) (string, string, error) {

for _, grp := range config.Groups {
if grp.Name == group {
user = grp.User
for _, env := range grp.Environment {
if environment != "" {
if environment == env.Name {
Expand All @@ -83,7 +82,7 @@ func ListToConnectServers(group, environment string) (string, string, error) {
Environment: env.Name,
HostName: server.HostName,
IP: server.IP,
User: user,
User: server.User,
}
serverOptions = append(serverOptions, serverOption)
}
Expand All @@ -95,6 +94,7 @@ func ListToConnectServers(group, environment string) (string, string, error) {
Environment: env.Name,
HostName: server.HostName,
IP: server.IP,
User: server.User,
}
serverOptions = append(serverOptions, serverOption)
}
Expand Down Expand Up @@ -123,6 +123,7 @@ func ListToConnectServers(group, environment string) (string, string, error) {
selectedEnvName = serverOption.Environment
selectedHostName = strings.Split(serverOption.HostName, " (")[0]
selectedHostIP = serverOption.IP
user = serverOption.User
break
}
}
Expand Down
11 changes: 3 additions & 8 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,15 @@ func readFile() {
if allGroup {
for _, group := range config.Groups {
fmt.Println("Importing ", group.Name)
password, err := ssh.AskPassword()
if err != nil {
logrus.Fatalln(err)
return
}
for _, environment := range group.Environment {
for _, host := range environment.Servers {
if host.User == group.User {
ssh.InitSSHConnection(host.User, password, host.HostName, group.Name, environment.Name, host.Alias, setupDotFile)
} else {
logrus.Info("User %s for %s does not matches with group user %s", host.User, host.HostName, group.User)
newPassword, _ := ssh.AskPassword()
ssh.InitSSHConnection(host.User, newPassword, host.HostName, group.Name, environment.Name, host.Alias, setupDotFile)
}
newPassword, _ := ssh.AskPassword()
ssh.InitSSHConnection(host.User, newPassword, host.HostName, group.Name, environment.Name, host.Alias, setupDotFile)

}
}
}
Expand Down
1 change: 0 additions & 1 deletion internal/store/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Env struct {

type Group struct {
Name string `yaml:"name"`
User string `yaml:"user"`
Environment []Env `yaml:"environment"`
}

Expand Down
1 change: 0 additions & 1 deletion internal/store/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func Save(group, environment, host, user, alias string) {
if !doesGroupExist {
newGroup := Group{
Name: group,
User: user,
Environment: []Env{env},
}
c.Groups = append(c.Groups, newGroup)
Expand Down

0 comments on commit 28441cd

Please sign in to comment.