Skip to content

Commit

Permalink
Merge pull request #35 from aman-agrawal/OES-1.30.1
Browse files Browse the repository at this point in the history
Reverted - Added Interactive component for manual judgement awaited a…
  • Loading branch information
yugaa22 authored Oct 6, 2023
2 parents d964031 + 66a7a8a commit 5560a82
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
package com.netflix.spinnaker.orca.echo

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import groovy.transform.Canonical
import retrofit.client.Response
import retrofit.http.Body
import retrofit.http.GET
Expand Down Expand Up @@ -49,8 +46,6 @@ interface EchoService {

Source source
Map<String, Object> additionalContext = [:]
InteractiveActions interactiveActions
Boolean useInteractiveBot = false

static class Source {
String executionType
Expand All @@ -76,39 +71,6 @@ interface EchoService {
NORMAL,
HIGH
}
static class InteractiveActions {
String callbackServiceId
String callbackMessageId
String color = '#cccccc'
List<InteractiveAction> actions = []
}

@JsonTypeInfo(
include = JsonTypeInfo.As.EXISTING_PROPERTY,
use = JsonTypeInfo.Id.NAME,
property = "type")
@JsonSubTypes(
@JsonSubTypes.Type(value = ButtonAction.class, name = "button")
)
abstract static class InteractiveAction {
String type
String name
String value
}

@Canonical
static class ButtonAction extends InteractiveAction {
String type = "button"
String label
}

@Canonical
static class InteractiveActionCallback {
InteractiveAction actionPerformed
String serviceId
String messageId
String user
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ package com.netflix.spinnaker.orca.echo.pipeline
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonIgnore
import com.google.common.collect.ImmutableList
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.common.base.Strings
import com.netflix.spinnaker.fiat.shared.FiatStatus
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus
import com.netflix.spinnaker.orca.api.pipeline.OverridableTimeoutRetryableTask
import com.netflix.spinnaker.orca.api.pipeline.models.PipelineExecution
Expand All @@ -41,7 +36,6 @@ import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode
import groovy.util.logging.Slf4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import static com.netflix.spinnaker.orca.echo.EchoService.Notification.InteractiveActions

@Component
class ManualJudgmentStage implements StageDefinitionBuilder, AuthenticatedStage {
Expand All @@ -68,13 +62,13 @@ class ManualJudgmentStage implements StageDefinitionBuilder, AuthenticatedStage
return Optional.of(
new PipelineExecution.AuthenticationDetails(
stage.lastModified.user,
stage.lastModified.allowedAccounts))
stage.lastModified.allowedAccounts));
}

@Slf4j
@Component
@VisibleForTesting
static class WaitForManualJudgmentTask implements OverridableTimeoutRetryableTask {
public static class WaitForManualJudgmentTask implements OverridableTimeoutRetryableTask {
final long backoffPeriod = 15000
final long timeout = TimeUnit.DAYS.toMillis(3)

Expand Down Expand Up @@ -224,7 +218,6 @@ class ManualJudgmentStage implements StageDefinitionBuilder, AuthenticatedStage
}

void notify(EchoService echoService, StageExecution stage, String notificationState) {
boolean useInteractiveBot = ("manualJudgment".equalsIgnoreCase(notificationState))
echoService.create(new EchoService.Notification(
notificationType: EchoService.Notification.Type.valueOf(type.toUpperCase()),
to: address ? [address] : (publisherName ? [publisherName] : null),
Expand All @@ -246,31 +239,9 @@ class ManualJudgmentStage implements StageDefinitionBuilder, AuthenticatedStage
judgmentInputs : stage.context.judgmentInputs,
judgmentInput : stage.context.judgmentInput,
judgedBy : stage.context.lastModifiedBy
],
useInteractiveBot: useInteractiveBot,
interactiveActions: useInteractiveBot ? getInteractiveActions(stage) : null
]
))
lastNotifiedByNotificationState[notificationState] = new Date()
}

private static InteractiveActions getInteractiveActions(StageExecution stage) {
new InteractiveActions(
callbackServiceId: "orca",
callbackMessageId: "${stage.getExecution().getType()}-${stage.getExecution().getId()}-${stage.getId()}",
color: '#fcba03',
actions: ImmutableList.of(
new EchoService.Notification.ButtonAction(
name: "manual-judgement",
label: "Approve",
value: StageData.State.CONTINUE.name()
),
new EchoService.Notification.ButtonAction(
name: "manual-judgement",
label: "Reject",
value: StageData.State.STOP.name()
)
)
)
}
}
}

This file was deleted.

0 comments on commit 5560a82

Please sign in to comment.