Skip to content

Commit

Permalink
Update to new backend
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Nov 20, 2022
1 parent 2420a41 commit 2f1e2ac
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 117 deletions.
102 changes: 0 additions & 102 deletions cli/README.md

This file was deleted.

14 changes: 5 additions & 9 deletions cli/packages/cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion cli/packages/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/util/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions cli/packages/util/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f1e2ac

Please sign in to comment.