From f7a4e68b97ee79c2fb328a9fddd55520fa6531fe Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 2 Oct 2018 23:44:11 -0700 Subject: [PATCH] pkg/types/config: Drop ParseConfig and other Parse* methods With openshift-install, the config type is a one-way map from InstallConfig to Terraform, so we can drop these methods. The last consumers were removed in b6c0d8c1 (installer: remove package, 2018-09-26, #342). --- pkg/types/config/parser.go | 79 -------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 pkg/types/config/parser.go diff --git a/pkg/types/config/parser.go b/pkg/types/config/parser.go deleted file mode 100644 index cb8116b0970..00000000000 --- a/pkg/types/config/parser.go +++ /dev/null @@ -1,79 +0,0 @@ -package config - -import ( - "context" - "io/ioutil" - "time" - - "github.com/pkg/errors" - "gopkg.in/yaml.v2" - - "github.com/openshift/installer/pkg/rhcos" -) - -// ParseConfig parses a yaml string and returns, if successful, a Cluster. -func ParseConfig(data []byte) (*Cluster, error) { - cluster := defaultCluster - - if err := yaml.Unmarshal(data, &cluster); err != nil { - return nil, errors.Wrap(err, "failed to unmarshal to config.Cluster") - } - - // Deprecated: remove after openshift/release is ported to pullSecret - if cluster.PullSecretPath != "" { - if cluster.PullSecret != "" { - return nil, errors.New("pullSecretPath is deprecated; just set pullSecret") - } - - data, err := ioutil.ReadFile(cluster.PullSecretPath) - if err != nil { - return nil, errors.Wrap(err, "failed to read PullSecretPath") - } - cluster.PullSecret = string(data) - cluster.PullSecretPath = "" - } - - if cluster.Platform == PlatformAWS && cluster.EC2AMIOverride == "" { - ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second) - defer cancel() - - ami, err := rhcos.AMI(ctx, rhcos.DefaultChannel, cluster.AWS.Region) - if err != nil { - return nil, errors.Wrap(err, "failed to determine default AMI") - } - cluster.EC2AMIOverride = ami - } - - return &cluster, nil -} - -// ParseConfigFile parses a yaml file and returns, if successful, a Cluster. -func ParseConfigFile(path string) (*Cluster, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, errors.Wrap(err, "failed to read file") - } - - return ParseConfig(data) -} - -// ParseInternal parses a yaml string and returns, if successful, an internal. -func ParseInternal(data []byte) (*Internal, error) { - internal := &Internal{} - - if err := yaml.Unmarshal(data, internal); err != nil { - return nil, errors.Wrap(err, "failed to unmarshal to config.Internal") - } - - return internal, nil -} - -// ParseInternalFile parses a yaml file and returns, if successful, an internal. -func ParseInternalFile(path string) (*Internal, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, errors.Wrap(err, "failed to read file") - } - - return ParseInternal(data) -}