mirror of https://github.com/harness/drone.git
feat: [CDE-332]: added an event and method for auto-stopping (#2876)
* feat: [CDE-332]: added an event and method for auto-stoppingdevcontainer-setup
parent
6035f3b73e
commit
f3016357d3
|
@ -77,7 +77,7 @@ func eventsMessageMapping() map[enum.GitspaceEventType]string {
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStartCompleted] = "Started gitspace"
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStartCompleted] = "Started gitspace"
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStartFailed] = "Starting gitspace failed"
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStartFailed] = "Starting gitspace failed"
|
||||||
|
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStop] = "Stopping gitspace"
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStop] = "Stopping gitspace..."
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStopCompleted] = "Stopped gitspace"
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStopCompleted] = "Stopped gitspace"
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStopFailed] = "Stopping gitspace failed"
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceActionStopFailed] = "Stopping gitspace failed"
|
||||||
|
|
||||||
|
@ -117,5 +117,7 @@ func eventsMessageMapping() map[enum.GitspaceEventType]string {
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportStopped] = "Gitspace is stopped"
|
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportStopped] = "Gitspace is stopped"
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportUnknown] = "Gitspace is in unknown state"
|
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportUnknown] = "Gitspace is in unknown state"
|
||||||
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportError] = "Gitspace has an error"
|
gitspaceConfigsMap[enum.GitspaceEventTypeAgentGitspaceStateReportError] = "Gitspace has an error"
|
||||||
|
|
||||||
|
gitspaceConfigsMap[enum.GitspaceEventTypeGitspaceAutoStop] = "Triggering auto-stopping due to inactivity..."
|
||||||
return gitspaceConfigsMap
|
return gitspaceConfigsMap
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,18 @@ func (c *Service) StopGitspaceAction(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Service) GitspaceAutostopAction(
|
||||||
|
ctx context.Context,
|
||||||
|
config *types.GitspaceConfig,
|
||||||
|
now time.Time,
|
||||||
|
) error {
|
||||||
|
c.EmitGitspaceConfigEvent(ctx, config, enum.GitspaceEventTypeGitspaceAutoStop)
|
||||||
|
if err := c.StopGitspaceAction(ctx, config, now); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Service) gitspaceBusyOperation(
|
func (c *Service) gitspaceBusyOperation(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
config *types.GitspaceConfig,
|
config *types.GitspaceConfig,
|
||||||
|
|
|
@ -65,6 +65,8 @@ var gitspaceEventTypes = []GitspaceEventType{
|
||||||
GitspaceEventTypeAgentGitspaceStateReportError,
|
GitspaceEventTypeAgentGitspaceStateReportError,
|
||||||
GitspaceEventTypeAgentGitspaceStateReportStopped,
|
GitspaceEventTypeAgentGitspaceStateReportStopped,
|
||||||
GitspaceEventTypeAgentGitspaceStateReportUnknown,
|
GitspaceEventTypeAgentGitspaceStateReportUnknown,
|
||||||
|
|
||||||
|
GitspaceEventTypeGitspaceAutoStop,
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -123,4 +125,7 @@ const (
|
||||||
GitspaceEventTypeAgentGitspaceStateReportError GitspaceEventType = "agent_gitspace_state_report_error"
|
GitspaceEventTypeAgentGitspaceStateReportError GitspaceEventType = "agent_gitspace_state_report_error"
|
||||||
GitspaceEventTypeAgentGitspaceStateReportStopped GitspaceEventType = "agent_gitspace_state_report_stopped"
|
GitspaceEventTypeAgentGitspaceStateReportStopped GitspaceEventType = "agent_gitspace_state_report_stopped"
|
||||||
GitspaceEventTypeAgentGitspaceStateReportUnknown GitspaceEventType = "agent_gitspace_state_report_unknown"
|
GitspaceEventTypeAgentGitspaceStateReportUnknown GitspaceEventType = "agent_gitspace_state_report_unknown"
|
||||||
|
|
||||||
|
// AutoStop action events.
|
||||||
|
GitspaceEventTypeGitspaceAutoStop GitspaceEventType = "gitspace_action_auto_stop"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue