Enable logs for managed stacks.
Simply fetch the checkpoint and use the local config to process logs. Fixes #1078.
This commit is contained in:
parent
2ae8d4cc36
commit
75d75a41c0
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/pulumi/pulumi/pkg/apitype"
|
||||
"github.com/pulumi/pulumi/pkg/backend"
|
||||
"github.com/pulumi/pulumi/pkg/backend/cloud/client"
|
||||
"github.com/pulumi/pulumi/pkg/backend/local"
|
||||
"github.com/pulumi/pulumi/pkg/diag"
|
||||
"github.com/pulumi/pulumi/pkg/diag/colors"
|
||||
"github.com/pulumi/pulumi/pkg/engine"
|
||||
|
@ -546,12 +547,27 @@ func convertConfig(apiConfig map[string]apitype.ConfigValue) (config.Map, error)
|
|||
}
|
||||
|
||||
func (b *cloudBackend) GetLogs(stackName tokens.QName, logQuery operations.LogQuery) ([]operations.LogEntry, error) {
|
||||
stack, err := getCloudStackIdentifier(stackName)
|
||||
stack, err := b.GetStack(stackName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b.client.GetStackLogs(stack, logQuery)
|
||||
// If we're dealing with a stack that runs its operations locally, get the stack's target and fetch the logs
|
||||
// directly
|
||||
if stack.(Stack).RunLocally() {
|
||||
target, targetErr := b.getTarget(stackName)
|
||||
if targetErr != nil {
|
||||
return nil, targetErr
|
||||
}
|
||||
return local.GetLogsForTarget(target, logQuery)
|
||||
}
|
||||
|
||||
// Otherwise, fetch the logs from the service.
|
||||
stackID, err := getCloudStackIdentifier(stackName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b.client.GetStackLogs(stackID, logQuery)
|
||||
}
|
||||
|
||||
func (b *cloudBackend) ExportDeployment(stackName tokens.QName) (*apitype.UntypedDeployment, error) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/pulumi/pulumi/pkg/engine"
|
||||
"github.com/pulumi/pulumi/pkg/operations"
|
||||
"github.com/pulumi/pulumi/pkg/resource/config"
|
||||
"github.com/pulumi/pulumi/pkg/resource/deploy"
|
||||
"github.com/pulumi/pulumi/pkg/resource/stack"
|
||||
"github.com/pulumi/pulumi/pkg/tokens"
|
||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||
|
@ -231,6 +232,11 @@ func (b *localBackend) GetLogs(stackName tokens.QName, query operations.LogQuery
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return GetLogsForTarget(target, query)
|
||||
}
|
||||
|
||||
// GetLogsForTarget fetches stack logs using the config, decrypter, and checkpoint in the given target.
|
||||
func GetLogsForTarget(target *deploy.Target, query operations.LogQuery) ([]operations.LogEntry, error) {
|
||||
contract.Assert(target != nil)
|
||||
contract.Assert(target.Snapshot != nil)
|
||||
|
||||
|
|
Loading…
Reference in a new issue