package configs

import (
	"fmt"
	"ocl/portainer-devtool/utils"
)

func (config *Config) configureLoginCredential() {
	var loginCredential LoginCredential
	loginCredential.Username = utils.Prompt("Set Login Credential Username(admin)")
	if loginCredential.Username == "" {
		loginCredential.Username = "admin"
	}

	for {
		loginCredential.Password = utils.Prompt("Set Login Credential Password(*****)")
		if loginCredential.Password != "" {
			break
		}

		utils.WarnPrint("Login Credential Password must be provided")
	}

	loginCredential.Address = utils.Prompt("Set Login Address(127.0.0.1)")
	if loginCredential.Address == "" {
		loginCredential.Address = "http://127.0.0.1:9000/api/auth"
	} else {
		loginCredential.Address = fmt.Sprintf("http://%s:9000/api/auth", loginCredential.Address)
	}

	config.LoginCredential = loginCredential
}
