daemon: use string-literals for easier grep'ing

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-05 12:13:09 +02:00
parent 6331a3a346
commit 02815416bb
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
6 changed files with 9 additions and 9 deletions

View file

@ -700,7 +700,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, daemonCfg *configStore, hos
if hostConfig.CgroupParent != "" && UsingSystemd(&daemonCfg.Config) { if hostConfig.CgroupParent != "" && UsingSystemd(&daemonCfg.Config) {
// CgroupParent for systemd cgroup should be named as "xxx.slice" // CgroupParent for systemd cgroup should be named as "xxx.slice"
if len(hostConfig.CgroupParent) <= 6 || !strings.HasSuffix(hostConfig.CgroupParent, ".slice") { if len(hostConfig.CgroupParent) <= 6 || !strings.HasSuffix(hostConfig.CgroupParent, ".slice") {
return warnings, fmt.Errorf("cgroup-parent for systemd cgroup should be a valid slice named as \"xxx.slice\"") return warnings, fmt.Errorf(`cgroup-parent for systemd cgroup should be a valid slice named as "xxx.slice"`)
} }
} }
if hostConfig.Runtime == "" { if hostConfig.Runtime == "" {
@ -753,7 +753,7 @@ func verifyDaemonSettings(conf *config.Config) error {
} }
if conf.CgroupParent != "" && UsingSystemd(conf) { if conf.CgroupParent != "" && UsingSystemd(conf) {
if len(conf.CgroupParent) <= 6 || !strings.HasSuffix(conf.CgroupParent, ".slice") { if len(conf.CgroupParent) <= 6 || !strings.HasSuffix(conf.CgroupParent, ".slice") {
return fmt.Errorf("cgroup-parent for systemd cgroup should be a valid slice named as \"xxx.slice\"") return fmt.Errorf(`cgroup-parent for systemd cgroup should be a valid slice named as "xxx.slice"`)
} }
} }
@ -1059,7 +1059,7 @@ func initBridgeDriver(controller *libnetwork.Controller, config *config.Config)
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil), libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
libnetwork.NetworkOptionDeferIPv6Alloc(deferIPv6Alloc)) libnetwork.NetworkOptionDeferIPv6Alloc(deferIPv6Alloc))
if err != nil { if err != nil {
return fmt.Errorf("Error creating default \"bridge\" network: %v", err) return fmt.Errorf(`error creating default "bridge" network: %v`, err)
} }
return nil return nil
} }

View file

@ -149,7 +149,7 @@ func TestParseSecurityOptWithDeprecatedColon(t *testing.T) {
t.Fatalf("Unexpected parseSecurityOpt error: %v", err) t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
} }
if opts.AppArmorProfile != "test_profile" { if opts.AppArmorProfile != "test_profile" {
t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", opts.AppArmorProfile) t.Fatalf(`Unexpected AppArmorProfile, expected: "test_profile", got %q`, opts.AppArmorProfile)
} }
// test seccomp // test seccomp

View file

@ -377,7 +377,7 @@ func (daemon *Daemon) createNetwork(cfg *config.Config, create types.NetworkCrea
if err != nil { if err != nil {
if errors.Is(err, libnetwork.ErrDataStoreNotInitialized) { if errors.Is(err, libnetwork.ErrDataStoreNotInitialized) {
//nolint: revive //nolint: revive
return nil, errors.New("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.") return nil, errors.New(`This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.`)
} }
return nil, err return nil, err
} }

View file

@ -28,7 +28,7 @@ func validatePSArgs(psArgs string) error {
k := group[1] k := group[1]
v := group[2] v := group[2]
if k != "pid" { if k != "pid" {
return fmt.Errorf("specifying \"%s=%s\" is not allowed", k, v) return fmt.Errorf(`specifying "%s=%s" is not allowed`, k, v)
} }
} }
} }

View file

@ -11,8 +11,8 @@ import (
func TestContainerTopValidatePSArgs(t *testing.T) { func TestContainerTopValidatePSArgs(t *testing.T) {
tests := map[string]bool{ tests := map[string]bool{
"ae -o uid=PID": true, "ae -o uid=PID": true,
"ae -o \"uid= PID\"": true, // ascii space (0x20) `ae -o "uid= PID"`: true, // ascii space (0x20)
"ae -o \"uid=PID\"": false, // unicode space (U+2003, 0xe2 0x80 0x83) `ae -o "uid=PID"`: false, // unicode space (U+2003, 0xe2 0x80 0x83)
"ae o uid=PID": true, "ae o uid=PID": true,
"aeo uid=PID": true, "aeo uid=PID": true,
"ae -O uid=PID": true, "ae -O uid=PID": true,

View file

@ -54,7 +54,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
if ctr.RemovalInProgress || ctr.Dead { if ctr.RemovalInProgress || ctr.Dead {
ctr.Unlock() ctr.Unlock()
return errCannotUpdate(ctr.ID, fmt.Errorf("container is marked for removal and cannot be \"update\"")) return errCannotUpdate(ctr.ID, fmt.Errorf(`container is marked for removal and cannot be "update"`))
} }
if err := ctr.UpdateContainer(hostConfig); err != nil { if err := ctr.UpdateContainer(hostConfig); err != nil {