driftctl/pkg/middlewares/chain_middleware.go

28 lines
572 B
Go
Raw Normal View History

package middlewares
import (
"fmt"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/sirupsen/logrus"
)
type Chain []Middleware
func NewChain(middlewares ...Middleware) Chain {
return middlewares
}
2021-08-09 14:03:04 +00:00
func (c Chain) Execute(remoteResources, resourcesFromState *[]*resource.Resource) error {
for _, middleware := range c {
logrus.WithFields(logrus.Fields{
"middleware": fmt.Sprintf("%T", middleware),
}).Debug("Starting middleware")
err := middleware.Execute(remoteResources, resourcesFromState)
if err != nil {
return err
}
}
return nil
}