Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cmd/workflow/activate/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/viper"

"github.com/smartcontractkit/cre-cli/cmd/client"
workflowcommon "github.com/smartcontractkit/cre-cli/cmd/workflow/common"
"github.com/smartcontractkit/cre-cli/internal/environments"
"github.com/smartcontractkit/cre-cli/internal/runtime"
"github.com/smartcontractkit/cre-cli/internal/settings"
Expand Down Expand Up @@ -122,7 +123,13 @@ func (h *handler) Execute() error {
return fmt.Errorf("missing required flags for --non-interactive mode")
}

h.displayWorkflowDetails()
workflowcommon.DisplayWorkflowDetails(
h.settings,
h.runtimeContext,
"Activating",
h.inputs.WorkflowName,
h.inputs.WorkflowOwner,
)

strategy, err := newRegistryActivateStrategy(h.runtimeContext.ResolvedRegistry, h)
if err != nil {
Expand All @@ -147,11 +154,3 @@ func (h *handler) resolveWorkflowOwner(registryType settings.RegistryType) (stri

return owner, nil
}

func (h *handler) displayWorkflowDetails() {
ui.Line()
ui.Title(fmt.Sprintf("Activating Workflow: %s", h.inputs.WorkflowName))
ui.Dim(fmt.Sprintf("Target: %s", h.settings.User.TargetName))
ui.Dim(fmt.Sprintf("Owner Address: %s", h.inputs.WorkflowOwner))
ui.Line()
}
29 changes: 29 additions & 0 deletions cmd/workflow/common/display_workflow_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package common

import (
"fmt"

"github.com/smartcontractkit/cre-cli/internal/runtime"
"github.com/smartcontractkit/cre-cli/internal/settings"
"github.com/smartcontractkit/cre-cli/internal/ui"
)

func DisplayWorkflowDetails(
cfg *settings.Settings,
runtimeContext *runtime.Context,
action,
workflowName,
ownerAddress string,
) {
displayOwnerAddress := ownerAddress
if runtimeContext.ResolvedRegistry.Type() == settings.RegistryTypeOffChain {
displayOwnerAddress += " (derived)"
}

ui.Line()
ui.Title(fmt.Sprintf("%s Workflow: %s", action, workflowName))
ui.Dim(fmt.Sprintf("Registry: %s", runtimeContext.ResolvedRegistry.ID()))
ui.Dim(fmt.Sprintf("Target: %s", cfg.User.TargetName))
ui.Dim(fmt.Sprintf("Owner Address: %s", displayOwnerAddress))
ui.Line()
}
17 changes: 8 additions & 9 deletions cmd/workflow/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/viper"

"github.com/smartcontractkit/cre-cli/cmd/client"
workflowcommon "github.com/smartcontractkit/cre-cli/cmd/workflow/common"
"github.com/smartcontractkit/cre-cli/internal/credentials"
"github.com/smartcontractkit/cre-cli/internal/environments"
"github.com/smartcontractkit/cre-cli/internal/runtime"
Expand Down Expand Up @@ -133,7 +134,13 @@ func (h *handler) Execute() error {
return err
}

h.displayWorkflowDetails()
workflowcommon.DisplayWorkflowDetails(
h.settings,
h.runtimeContext,
"Deleting",
h.inputs.WorkflowName,
h.inputs.WorkflowOwner,
)

workflows, err := adapter.FetchWorkflows()
if err != nil {
Expand Down Expand Up @@ -212,11 +219,3 @@ func (h *handler) askForWorkflowDeletionConfirmation(expectedWorkflowName string

return result == expectedWorkflowName, nil
}

func (h *handler) displayWorkflowDetails() {
ui.Line()
ui.Title(fmt.Sprintf("Deleting Workflow: %s", h.inputs.WorkflowName))
ui.Dim(fmt.Sprintf("Target: %s", h.settings.User.TargetName))
ui.Dim(fmt.Sprintf("Owner Address: %s", h.inputs.WorkflowOwner))
ui.Line()
}
17 changes: 8 additions & 9 deletions cmd/workflow/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/smartcontractkit/cre-cli/cmd/client"
cmdcommon "github.com/smartcontractkit/cre-cli/cmd/common"
workflowcommon "github.com/smartcontractkit/cre-cli/cmd/workflow/common"
"github.com/smartcontractkit/cre-cli/internal/accessrequest"
"github.com/smartcontractkit/cre-cli/internal/credentials"
"github.com/smartcontractkit/cre-cli/internal/environments"
Expand Down Expand Up @@ -262,7 +263,13 @@ func (h *handler) Execute(ctx context.Context) error {
// Artifact upload is deferred to the deploy service so it runs after any
// existing-workflow update confirmation.
func (h *handler) prepareArtifacts() error {
h.displayWorkflowDetails()
workflowcommon.DisplayWorkflowDetails(
h.settings,
h.runtimeContext,
"Deploying",
h.inputs.WorkflowName,
h.inputs.WorkflowOwner,
)

if cmdcommon.IsURL(h.inputs.WasmPath) {
h.inputs.BinaryURL = h.inputs.WasmPath
Expand Down Expand Up @@ -321,14 +328,6 @@ func (h *handler) resolveWorkflowOwner(registryType settings.RegistryType) (stri
return owner, nil
}

func (h *handler) displayWorkflowDetails() {
ui.Line()
ui.Title(fmt.Sprintf("Deploying Workflow: %s", h.inputs.WorkflowName))
ui.Dim(fmt.Sprintf("Target: %s", h.settings.User.TargetName))
ui.Dim(fmt.Sprintf("Owner Address: %s", h.inputs.WorkflowOwner))
ui.Line()
}

func confirmWorkflowOverwrite(workflowName string, skipConfirmation, nonInteractive bool) error {
ui.Warning(fmt.Sprintf("Workflow %s already exists", workflowName))
ui.Dim("This will update the existing workflow.")
Expand Down
17 changes: 8 additions & 9 deletions cmd/workflow/pause/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/viper"

"github.com/smartcontractkit/cre-cli/cmd/client"
workflowcommon "github.com/smartcontractkit/cre-cli/cmd/workflow/common"
"github.com/smartcontractkit/cre-cli/internal/environments"
"github.com/smartcontractkit/cre-cli/internal/runtime"
"github.com/smartcontractkit/cre-cli/internal/settings"
Expand Down Expand Up @@ -119,7 +120,13 @@ func (h *handler) Execute() error {
return fmt.Errorf("missing required flags for --non-interactive mode")
}

h.displayWorkflowDetails()
workflowcommon.DisplayWorkflowDetails(
h.settings,
h.runtimeContext,
"Pausing",
h.inputs.WorkflowName,
h.inputs.WorkflowOwner,
)

strategy, err := newRegistryPauseStrategy(h.runtimeContext.ResolvedRegistry, h)
if err != nil {
Expand All @@ -144,11 +151,3 @@ func (h *handler) resolveWorkflowOwner(registryType settings.RegistryType) (stri

return owner, nil
}

func (h *handler) displayWorkflowDetails() {
ui.Line()
ui.Title(fmt.Sprintf("Pausing Workflow: %s", h.inputs.WorkflowName))
ui.Dim(fmt.Sprintf("Target: %s", h.settings.User.TargetName))
ui.Dim(fmt.Sprintf("Owner Address: %s", h.inputs.WorkflowOwner))
ui.Line()
}
2 changes: 1 addition & 1 deletion internal/settings/registry_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func ParseRegistryType(raw string) RegistryType {

func defaultFromEnvironmentSet(envSet *environments.EnvironmentSet) *OnChainRegistry {
return NewOnChainRegistry(
"",
fmt.Sprintf("onchain:%s", envSet.WorkflowRegistryChainName),
envSet.WorkflowRegistryAddress,
envSet.WorkflowRegistryChainName,
envSet.DonFamily,
Expand Down
Loading