Update to new backend

This commit is contained in:
Maidul Islam
2022-11-20 18:47:21 -05:00
parent 2420a41bb7
commit 2f1e2acc69
6 changed files with 13 additions and 117 deletions

View File

@@ -28,8 +28,9 @@ var loginCmd = &cobra.Command{
PreRun: toggleDebug,
Run: func(cmd *cobra.Command, args []string) {
hasUserLoggedInbefore, currentLoggedInUserEmail, err := util.IsUserLoggedIn()
if err != nil {
log.Debugln(err)
log.Debugln("Unable to get current logged in user.", err)
}
if hasUserLoggedInbefore {
@@ -45,12 +46,6 @@ var loginCmd = &cobra.Command{
}
}
if err != nil {
log.Errorln("Unable to get current logged in user.")
log.Debugln(err)
return
}
email, password, err := askForLoginCredentials()
if err != nil {
log.Errorln("Unable to parse email and password for authentication")
@@ -160,6 +155,7 @@ func askForLoginCredentials() (email string, password string, err error) {
}
func getFreshUserCredentials(email string, password string) (*models.LoginTwoResponse, error) {
log.Debugln("getFreshUserCredentials:", "email", email, "password", password)
httpClient := resty.New()
httpClient.SetRetryCount(5)
@@ -180,7 +176,7 @@ func getFreshUserCredentials(email string, password string) (*models.LoginTwoRes
R().
SetBody(loginOneRequest).
SetResult(&loginOneResponseResult).
Post(fmt.Sprintf("%v/%v", util.INFISICAL_URL, "login1"))
Post(fmt.Sprintf("%v/v1/auth/login1", util.INFISICAL_URL))
if err != nil {
return nil, err
@@ -216,7 +212,7 @@ func getFreshUserCredentials(email string, password string) (*models.LoginTwoRes
R().
SetBody(LoginTwoRequest).
SetResult(&loginTwoResponseResult).
Post(fmt.Sprintf("%v/%v", util.INFISICAL_URL, "login2"))
Post(fmt.Sprintf("%v/v1/auth/login2", util.INFISICAL_URL))
if err != nil {
return nil, err

View File

@@ -30,5 +30,5 @@ func Execute() {
func init() {
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.PersistentFlags().BoolVarP(&debugLogging, "debug", "d", false, "Enable verbose logging")
rootCmd.PersistentFlags().StringVar(&util.INFISICAL_URL, "domain", "http://localhost:4000", "Point the CLI to your own backend")
rootCmd.PersistentFlags().StringVar(&util.INFISICAL_URL, "domain", "https://app.infisical.com/api", "Point the CLI to your own backend")
}

View File

@@ -12,7 +12,7 @@ const (
INFISICAL_SERVICE_TOKEN = "INFISICAL_SERVICE_TOKEN"
)
var INFISICAL_URL = "https://api.infisical.com"
var INFISICAL_URL = "https://app.infisical.com/api"
func GetHomeDir() (string, error) {
directory, err := os.UserHomeDir()

View File

@@ -81,7 +81,7 @@ func IsUserLoggedIn() (hasUserLoggedIn bool, theUsersEmail string, err error) {
response, err := httpClient.
R().
Post(fmt.Sprintf("%v/%v", INFISICAL_URL, "checkAuth"))
Post(fmt.Sprintf("%v/v1/auth/checkAuth", INFISICAL_URL))
if err != nil {
return false, "", err

View File

@@ -31,7 +31,9 @@ func GetSecretsFromAPIUsingCurrentLoggedInUser(envName string, userCreds models.
SetQueryParam("environment", envName).
SetQueryParam("channel", "cli").
SetResult(&pullSecretsRequestResponse).
Get(fmt.Sprintf("%v/%v/%v", INFISICAL_URL, "secret", workspace.WorkspaceId)) // need to change workspace id
Get(fmt.Sprintf("%v/v1/secret/%v", INFISICAL_URL, workspace.WorkspaceId)) // need to change workspace id
log.Debugln("Response from get secrets:", response)
if err != nil {
return nil, err
@@ -116,7 +118,7 @@ func GetSecretsFromAPIUsingInfisicalToken(infisicalToken string, envName string,
SetQueryParam("environment", envName).
SetQueryParam("channel", "cli").
SetResult(&pullSecretsByInfisicalTokenResponse).
Get(fmt.Sprintf("%v/secret/%v/service-token", INFISICAL_URL, projectId))
Get(fmt.Sprintf("%v/v1/secret/%v/service-token", INFISICAL_URL, projectId))
if err != nil {
return nil, err
@@ -191,7 +193,7 @@ func GetWorkSpacesFromAPI(userCreds models.UserCredentials) (workspaces []models
response, err := httpClient.
R().
SetResult(&getWorkSpacesResponse).
Get(fmt.Sprintf("%v/%v", INFISICAL_URL, "workspace"))
Get(fmt.Sprintf("%v/v1/workspace", INFISICAL_URL))
if err != nil {
return nil, err