github.com/openshift/installer@v1.4.17/pkg/destroy/destroyer.go (about) 1 package destroy 2 3 import ( 4 "github.com/pkg/errors" 5 "github.com/sirupsen/logrus" 6 7 "github.com/openshift/installer/pkg/asset/cluster/metadata" 8 "github.com/openshift/installer/pkg/destroy/providers" 9 ) 10 11 // New returns a Destroyer based on `metadata.json` in `rootDir`. 12 func New(logger logrus.FieldLogger, rootDir string) (providers.Destroyer, error) { 13 metadata, err := metadata.Load(rootDir) 14 if err != nil { 15 return nil, err 16 } 17 18 platform := metadata.Platform() 19 if platform == "" { 20 return nil, errors.New("no platform configured in metadata") 21 } 22 23 creator, ok := providers.Registry[platform] 24 if !ok { 25 return nil, errors.Errorf("no destroyers registered for %q", platform) 26 } 27 return creator(logger, metadata) 28 }