summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorDan Duvall <dduvall@wikimedia.org>2017-10-25 10:24:11 -0700
committerDan Duvall <dduvall@wikimedia.org>2017-11-06 13:28:38 -0800
commit5b5ad0496ff75e787405ab9eec17f13214d0b834 (patch)
tree5d01e88b807514999e2bd2b4eb2cf8934bcc8885 /config
parent515d9f26eb616a9c3a0b70ba6eca88570a15b0ef (diff)
downloadblubber-5b5ad0496ff75e787405ab9eec17f13214d0b834.tar.gz
Conform to all linter warnings/advice
Summary: Fixed all linter warnings and advice except for vet's rule about unkeyed composite literals which was disabled via a `-composites=false` flag in `.arclint`. Most unkeyed literals (e.g. `build.Run{"command"}`) in this project just seem too usefully succinct compared to their more verbose keyed counterparts. Depends on D841 Test Plan: Run `arc lint --everything` and verify there are no warnings or advice. Reviewers: thcipriani, hashar, #release-engineering-team Reviewed By: thcipriani, hashar, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D845
Diffstat (limited to 'config')
-rw-r--r--config/common.go16
-rw-r--r--config/reader.go4
-rw-r--r--config/runs.go20
-rw-r--r--config/runs_test.go8
4 files changed, 24 insertions, 24 deletions
diff --git a/config/common.go b/config/common.go
index 11357d8..62fb483 100644
--- a/config/common.go
+++ b/config/common.go
@@ -18,18 +18,18 @@ type CommonConfig struct {
// Merge takes another CommonConfig and merges its fields this one's.
//
-func (cc1 *CommonConfig) Merge(cc2 CommonConfig) {
+func (cc *CommonConfig) Merge(cc2 CommonConfig) {
if cc2.Base != "" {
- cc1.Base = cc2.Base
+ cc.Base = cc2.Base
}
- cc1.Apt.Merge(cc2.Apt)
- cc1.Node.Merge(cc2.Node)
- cc1.Runs.Merge(cc2.Runs)
- cc1.SharedVolume.Merge(cc2.SharedVolume)
+ cc.Apt.Merge(cc2.Apt)
+ cc.Node.Merge(cc2.Node)
+ cc.Runs.Merge(cc2.Runs)
+ cc.SharedVolume.Merge(cc2.SharedVolume)
- if len(cc1.EntryPoint) < 1 {
- cc1.EntryPoint = cc2.EntryPoint
+ if len(cc.EntryPoint) < 1 {
+ cc.EntryPoint = cc2.EntryPoint
}
}
diff --git a/config/reader.go b/config/reader.go
index 7aa060d..7aaa22e 100644
--- a/config/reader.go
+++ b/config/reader.go
@@ -72,7 +72,7 @@ func ReadConfigFile(path string) (*Config, error) {
if err != nil {
return nil, err
- } else {
- return ReadConfig(data)
}
+
+ return ReadConfig(data)
}
diff --git a/config/runs.go b/config/runs.go
index ef9f4ea..5986112 100644
--- a/config/runs.go
+++ b/config/runs.go
@@ -17,8 +17,8 @@ const LocalLibPrefix = "/opt/lib"
type RunsConfig struct {
In string `yaml:"in"` // working directory
As string `yaml:"as"` // unprivileged user
- Uid int `yaml:"uid"` // unprivileged UID
- Gid int `yaml:"gid"` // unprivileged GID
+ UID int `yaml:"uid"` // unprivileged user ID
+ GID int `yaml:"gid"` // unprivileged group ID
Environment map[string]string `yaml:"environment"` // environment variables
}
@@ -33,11 +33,11 @@ func (run *RunsConfig) Merge(run2 RunsConfig) {
if run2.As != "" {
run.As = run2.As
}
- if run2.Uid != 0 {
- run.Uid = run2.Uid
+ if run2.UID != 0 {
+ run.UID = run2.UID
}
- if run2.Gid != 0 {
- run.Gid = run2.Gid
+ if run2.GID != 0 {
+ run.GID = run2.GID
}
if run.Environment == nil {
@@ -55,9 +55,9 @@ func (run *RunsConfig) Merge(run2 RunsConfig) {
func (run RunsConfig) Home() string {
if run.As == "" {
return "/root"
- } else {
- return "/home/" + run.As
}
+
+ return "/home/" + run.As
}
// InstructionsForPhase injects build instructions related to the runtime
@@ -92,9 +92,9 @@ func (run RunsConfig) InstructionsForPhase(phase build.Phase) []build.Instructio
if run.As != "" {
runAll.Runs = append(runAll.Runs,
build.Run{"groupadd -o -g %s -r",
- []string{strconv.Itoa(run.Gid), run.As}},
+ []string{strconv.Itoa(run.GID), run.As}},
build.Run{"useradd -o -m -d %s -r -g %s -u %s",
- []string{run.Home(), run.As, strconv.Itoa(run.Uid), run.As}},
+ []string{run.Home(), run.As, strconv.Itoa(run.UID), run.As}},
build.Run{"chown %s:%s",
[]string{run.As, run.As, LocalLibPrefix}},
)
diff --git a/config/runs_test.go b/config/runs_test.go
index c8bb2bc..3aa8825 100644
--- a/config/runs_test.go
+++ b/config/runs_test.go
@@ -28,8 +28,8 @@ func TestRunsConfig(t *testing.T) {
assert.Equal(t, "someuser", variant.Runs.As)
assert.Equal(t, "/some/directory", variant.Runs.In)
- assert.Equal(t, 666, variant.Runs.Uid)
- assert.Equal(t, 777, variant.Runs.Gid)
+ assert.Equal(t, 666, variant.Runs.UID)
+ assert.Equal(t, 777, variant.Runs.GID)
assert.Equal(t, map[string]string{"FOO": "bar"}, variant.Runs.Environment)
}
@@ -49,8 +49,8 @@ func TestRunsConfigInstructions(t *testing.T) {
cfg := config.RunsConfig{
As: "someuser",
In: "/some/directory",
- Uid: 666,
- Gid: 777,
+ UID: 666,
+ GID: 777,
Environment: map[string]string{
"fooname": "foovalue",
"barname": "barvalue",