66 "io"
77 "io/ioutil"
88 "os"
9- "path"
109
1110 "gopkg.in/yaml.v3"
1211)
@@ -25,8 +24,6 @@ func parseOrSetupConfigFile(fn string) (*configEntry, error) {
2524}
2625
2726func parseConfigFile (fn string ) (* configEntry , error ) {
28- migrateConfigFile ()
29-
3027 f , err := os .Open (fn )
3128 if err != nil {
3229 return nil , err
@@ -65,44 +62,3 @@ func parseConfig(r io.Reader) (*configEntry, error) {
6562 }
6663 return nil , fmt .Errorf ("could not find config entry for %q" , defaultHostname )
6764}
68-
69- // This is a temporary function that will migrate the config file. It can be removed
70- // in January.
71- //
72- // If the config dir is a file, convert it to a directory and place the file
73- // into a file named config.yml
74- func migrateConfigFile () {
75- p := ConfigDir ()
76- fi , err := os .Stat (p )
77- if err != nil { // This means the file doesn't exist, and that is fine.
78- return
79- }
80- if fi .Mode ().IsDir () {
81- return
82- }
83-
84- content , err := ioutil .ReadFile (p )
85- if err != nil {
86- fmt .Fprintf (os .Stderr , "migration error: failed to read config at %s" , p )
87- return
88- }
89-
90- err = os .Remove (p )
91- if err != nil {
92- fmt .Fprintf (os .Stderr , "migration error: failed to remove %s" , p )
93- return
94- }
95-
96- err = os .MkdirAll (p , 0771 )
97- if err != nil {
98- fmt .Fprintf (os .Stderr , "migration error: failed to mkdir %s" , p )
99- return
100- }
101-
102- newPath := path .Join (p , "config.yml" )
103- err = ioutil .WriteFile (newPath , []byte (content ), 0771 )
104- if err != nil {
105- fmt .Fprintf (os .Stderr , "migration error: failed write to new config path %s" , newPath )
106- return
107- }
108- }
0 commit comments