-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tenant): Build out the onboarding system in tenant and integrate…
… it into launcher (#17558) We are adding in a setup/user route this is not in swagger at the moment but will be added once we feel it is stable.
- Loading branch information
Showing
20 changed files
with
777 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package tenant | ||
|
||
import ( | ||
"context" | ||
"path" | ||
|
||
"github.com/influxdata/influxdb/v2" | ||
"github.com/influxdata/influxdb/v2/pkg/httpc" | ||
) | ||
|
||
// OnboardClientService connects to Influx via HTTP to perform onboarding operations | ||
type OnboardClientService struct { | ||
Client *httpc.Client | ||
} | ||
|
||
// IsOnboarding determine if onboarding request is allowed. | ||
func (s *OnboardClientService) IsOnboarding(ctx context.Context) (bool, error) { | ||
var resp isOnboardingResponse | ||
err := s.Client. | ||
Get(prefixOrganizations). | ||
DecodeJSON(&resp). | ||
Do(ctx) | ||
|
||
if err != nil { | ||
return false, err | ||
} | ||
return resp.Allowed, nil | ||
} | ||
|
||
// OnboardInitialUser OnboardingResults. | ||
func (s *OnboardClientService) OnboardInitialUser(ctx context.Context, or *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error) { | ||
res := &onboardingResponse{} | ||
|
||
err := s.Client. | ||
PostJSON(or, prefixOnboard). | ||
DecodeJSON(res). | ||
Do(ctx) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bkt, err := res.Bucket.toInfluxDB() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &influxdb.OnboardingResults{ | ||
Org: &res.Organization.Organization, | ||
User: &res.User.User, | ||
Auth: res.Auth.toPlatform(), | ||
Bucket: bkt, | ||
}, nil | ||
} | ||
|
||
func (s *OnboardClientService) OnboardUser(ctx context.Context, or *influxdb.OnboardingRequest) (*influxdb.OnboardingResults, error) { | ||
res := &onboardingResponse{} | ||
|
||
err := s.Client. | ||
PostJSON(or, path.Join(prefixOnboard, "user")). | ||
DecodeJSON(res). | ||
Do(ctx) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bkt, err := res.Bucket.toInfluxDB() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &influxdb.OnboardingResults{ | ||
Org: &res.Organization.Organization, | ||
User: &res.User.User, | ||
Auth: res.Auth.toPlatform(), | ||
Bucket: bkt, | ||
}, nil | ||
} |
Oops, something went wrong.