Skip to content

Commit

Permalink
create: private app without org (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
matslina authored Sep 12, 2023
1 parent bd5fee7 commit e2151fc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var createURL string

type TidbytCreateAppRequest struct {
OrganizationID string `json:"organizationID"`
Private bool `json:"private"`
}

type TidbytCreateAppReply struct {
Expand Down Expand Up @@ -82,10 +83,6 @@ var CreateCmd = &cobra.Command{
return fmt.Errorf("login with `pixlet login` or use `pixlet set-auth` to configure auth")
}

if createOrg == "" {
return fmt.Errorf("organization must not be blank")
}

app.ID, err = createPrivateApp(apiToken, createOrg)
if err != nil {
if strings.Contains(err.Error(), "user is not authorized to create apps") {
Expand Down Expand Up @@ -135,9 +132,12 @@ var CreateCmd = &cobra.Command{
},
}

// Creates private app for organization. If org is blank, attempts to
// create a per-user private app.
func createPrivateApp(apiToken string, org string) (string, error) {
createAppRequest := &TidbytCreateAppRequest{
OrganizationID: org,
Private: org == "",
}

b, err := json.Marshal(createAppRequest)
Expand Down

0 comments on commit e2151fc

Please sign in to comment.