Skip to content

Commit

Permalink
Merge branch 'master' into strideynet/output-kubernetes-template-with…
Browse files Browse the repository at this point in the history
…out-exec-plugin
  • Loading branch information
strideynet authored Jun 25, 2024
2 parents d4e1514 + 833ddc9 commit 98dc4af
Show file tree
Hide file tree
Showing 15 changed files with 2,335 additions and 2,093 deletions.
22 changes: 22 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6086,6 +6086,28 @@ message PluginOAuth2AuthorizationCodeCredentials {
// PluginStatus is the user-facing status for the plugin instance.
message PluginStatusV1 {
PluginStatusCode code = 1;
// error_message is a human-readable error message that can be displayed to the user.
string error_message = 2;
// last_sync_time is the last time the plugin was run.
google.protobuf.Timestamp last_sync_time = 3 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// details contains provider-specific plugin status details.
oneof details {
// gitlab is the status details for the Gitlab plugin.
PluginGitlabStatusV1 gitlab = 4;
}
}

// PluginGitlabStatusV1 is the status details for the Gitlab plugin.
message PluginGitlabStatusV1 {
// imported_users is the number of users imported from Gitlab.
uint32 imported_users = 1;
// imported_groups is the number of groups imported from Gitlab.
uint32 imported_groups = 2;
// imported_projects is the number of projects imported from Gitlab.
uint32 imported_projects = 3;
}

enum PluginStatusCode {
Expand Down
24 changes: 20 additions & 4 deletions api/types/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ type PluginCredentials interface {
// PluginStatus is the plugin status
type PluginStatus interface {
GetCode() PluginStatusCode
GetErrorMessage() string
GetLastSyncTime() time.Time
GetGitlab() *PluginGitlabStatusV1
}

// NewPluginV1 creates a new PluginV1 resource.
Expand Down Expand Up @@ -427,7 +430,7 @@ func (p *PluginV1) SetCredentials(creds PluginCredentials) error {

// GetStatus implements Plugin
func (p *PluginV1) GetStatus() PluginStatus {
return p.Status
return &p.Status
}

// SetStatus implements Plugin
Expand All @@ -436,10 +439,13 @@ func (p *PluginV1) SetStatus(status PluginStatus) error {
p.Status = PluginStatusV1{}
return nil
}
p.Status = PluginStatusV1{
Code: status.GetCode(),
switch status := status.(type) {
case *PluginStatusV1:
p.Status = *status
return nil
default:
return trace.BadParameter("unsupported plugin status type %T", status)
}
return nil
}

// GetGeneration returns the plugin generation.
Expand Down Expand Up @@ -658,6 +664,16 @@ func (c PluginStatusV1) GetCode() PluginStatusCode {
return c.Code
}

// GetErrorMessage returns the error message
func (c PluginStatusV1) GetErrorMessage() string {
return c.ErrorMessage
}

// GetLastSyncTime returns the last run of the plugin.
func (c PluginStatusV1) GetLastSyncTime() time.Time {
return c.LastSyncTime
}

// CheckAndSetDefaults checks that the required fields for the Gitlab plugin are set.
func (c *PluginGitlabSettings) Validate() error {
if c.ApiEndpoint == "" {
Expand Down
Loading

0 comments on commit 98dc4af

Please sign in to comment.