This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SetupDaemonConfig no longer needs a file (#214)
- Loading branch information
1 parent
d61bf5c
commit 452c5b5
Showing
4 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,11 @@ func main() { | |
cmdLine := strings.Join(os.Args[1:], " ") | ||
logrus.WithContext(ctx).Info("Command line: " + cmdLine) | ||
|
||
conf, err := guber.SetupDaemonConfig(log, configFile) | ||
configFileReader, err := os.Open(configFile) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Baliedge
Contributor
|
||
if err != nil { | ||
return fmt.Errorf("while opening config file: %s", err) | ||
} | ||
conf, err := guber.SetupDaemonConfig(log, configFileReader) | ||
if err != nil { | ||
return err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package gubernator | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParsesGrpcAddress(t *testing.T) { | ||
os.Clearenv() | ||
s := ` | ||
# a comment | ||
GUBER_GRPC_ADDRESS=10.10.10.10:9000` | ||
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s)) | ||
require.NoError(t, err) | ||
require.Equal(t, "10.10.10.10:9000", daemonConfig.GRPCListenAddress) | ||
require.NotEmpty(t, daemonConfig.InstanceID) | ||
} | ||
|
||
func TestDefaultGrpcAddress(t *testing.T) { | ||
os.Clearenv() | ||
s := ` | ||
# a comment` | ||
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s)) | ||
require.NoError(t, err) | ||
require.Equal(t, fmt.Sprintf("%s:81", LocalHost()), daemonConfig.GRPCListenAddress) | ||
require.NotEmpty(t, daemonConfig.InstanceID) | ||
} | ||
|
||
func TestDefaultInstanceId(t *testing.T) { | ||
os.Clearenv() | ||
s := `` | ||
daemonConfig, err := SetupDaemonConfig(logrus.StandardLogger(), strings.NewReader(s)) | ||
require.NoError(t, err) | ||
require.NotEmpty(t, daemonConfig.InstanceID) | ||
} |
This appears to make not defining a config file a hard error. Something never previously needed and a breaking change from the last version.
Trying to upgrade from 2.3.2 to 2.4.0 in my images is a hard fail now.