diff --git a/CHANGELOG.md b/CHANGELOG.md index da3e24e00d..5126a01dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,78 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- resolved cookstyle error: resources/container.rb:71:3 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:204:18 warning: `Lint/RedundantTypeConversion` +- resolved cookstyle error: resources/container.rb:474:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:475:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:476:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:477:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:478:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:479:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:480:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:481:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:482:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:483:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:484:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:485:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:486:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:487:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:489:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:490:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:491:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:492:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:493:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:494:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:495:9 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:496:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:497:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:498:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:499:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:500:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:501:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:502:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:503:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:504:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:505:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:506:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:507:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:508:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:509:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:510:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:511:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:512:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:513:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:516:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:517:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:518:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:519:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:520:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:521:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:522:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:524:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:525:13 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:528:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:529:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:530:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:531:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:532:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:533:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:534:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:535:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:536:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:537:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:538:11 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/container.rb:694:43 convention: `Style/RedundantParentheses` +- resolved cookstyle error: resources/exec.rb:10:3 convention: `Layout/HashAlignment` +- resolved cookstyle error: resources/installation_package.rb:122:5 convention: `Style/RedundantReturn` +- resolved cookstyle error: resources/installation_package.rb:127:5 convention: `Style/RedundantReturn` +- resolved cookstyle error: resources/partial/_base.rb:30:11 convention: `Layout/ArrayAlignment` +- resolved cookstyle error: resources/partial/_base.rb:31:11 convention: `Layout/ArrayAlignment` +- resolved cookstyle error: resources/partial/_base.rb:32:11 convention: `Layout/ArrayAlignment` +- resolved cookstyle error: test/cookbooks/docker_test/recipes/container.rb:314:5 convention: `Layout/FirstHashElementIndentation` +- resolved cookstyle error: test/cookbooks/docker_test/recipes/container.rb:315:5 convention: `Layout/HashAlignment` +- resolved cookstyle error: test/cookbooks/docker_test/recipes/container.rb:316:5 convention: `Layout/HashAlignment` +- resolved cookstyle error: test/cookbooks/docker_test/recipes/container.rb:317:3 convention: `Layout/FirstHashElementIndentation` Standardise files with files in sous-chefs/repo-management Standardise files with files in sous-chefs/repo-management diff --git a/resources/container.rb b/resources/container.rb index 5e52c76187..52c098cf62 100644 --- a/resources/container.rb +++ b/resources/container.rb @@ -68,7 +68,7 @@ property :sysctls, Hash, default: {} property :timeout, Integer, desired_state: false property :tmpfs, [Hash, Array], default: {}, coerce: proc { |v| coerce_tmpfs(v) }, - description: 'A hash or array of tmpfs mounts to add to the container. Hash format: { "/path" => "size=100M,uid=1000" }. Array format: ["/path", "/path2"]. See https://docs.docker.com/storage/tmpfs/' + description: 'A hash or array of tmpfs mounts to add to the container. Hash format: { "/path" => "size=100M,uid=1000" }. Array format: ["/path", "/path2"]. See https://docs.docker.com/storage/tmpfs/' property :tty, [true, false], default: false property :ulimits, [Array, nil], coerce: proc { |v| coerce_ulimits(v) } property :user, String @@ -201,7 +201,7 @@ def coerce_volumes(v) PartialHash[v] else b = [] - v = Array(v).to_a # in case v.is_A?(Chef::Node::ImmutableArray) + v = Array(v) # in case v.is_A?(Chef::Node::ImmutableArray) v.delete_if do |x| parts = x.split(':') b << x if parts.length > 1 @@ -471,71 +471,71 @@ def load_container_labels with_retries do config = { - 'name' => new_resource.container_name, - 'Image' => new_resource.tag.to_s.start_with?('sha256:') ? "#{new_resource.repo}@#{new_resource.tag}" : "#{new_resource.repo}:#{new_resource.tag}", - 'Labels' => new_resource.labels, - 'Cmd' => to_shellwords(new_resource.command), - 'AttachStderr' => new_resource.attach_stderr, - 'AttachStdin' => new_resource.attach_stdin, - 'AttachStdout' => new_resource.attach_stdout, - 'Domainname' => new_resource.domain_name, - 'Entrypoint' => to_shellwords(new_resource.entrypoint), - 'Env' => new_resource.env + read_env_file, - 'ExposedPorts' => new_resource.exposed_ports, - 'Healthcheck' => new_resource.health_check, - 'Hostname' => parsed_hostname, - 'MacAddress' => new_resource.mac_address, + 'name' => new_resource.container_name, + 'Image' => new_resource.tag.to_s.start_with?('sha256:') ? "#{new_resource.repo}@#{new_resource.tag}" : "#{new_resource.repo}:#{new_resource.tag}", + 'Labels' => new_resource.labels, + 'Cmd' => to_shellwords(new_resource.command), + 'AttachStderr' => new_resource.attach_stderr, + 'AttachStdin' => new_resource.attach_stdin, + 'AttachStdout' => new_resource.attach_stdout, + 'Domainname' => new_resource.domain_name, + 'Entrypoint' => to_shellwords(new_resource.entrypoint), + 'Env' => new_resource.env + read_env_file, + 'ExposedPorts' => new_resource.exposed_ports, + 'Healthcheck' => new_resource.health_check, + 'Hostname' => parsed_hostname, + 'MacAddress' => new_resource.mac_address, 'NetworkDisabled' => new_resource.network_disabled, - 'OpenStdin' => new_resource.open_stdin, - 'StdinOnce' => new_resource.stdin_once, - 'Tty' => new_resource.tty, - 'User' => new_resource.user, - 'Volumes' => new_resource.volumes, - 'WorkingDir' => new_resource.working_dir, - 'HostConfig' => { - 'Binds' => new_resource.volumes_binds, - 'CapAdd' => new_resource.cap_add, - 'CapDrop' => new_resource.cap_drop, - 'CgroupParent' => new_resource.cgroup_parent, - 'CgroupnsMode' => new_resource.cgroup_ns, - 'CpuShares' => new_resource.cpu_shares, - 'CpusetCpus' => new_resource.cpuset_cpus, - 'Devices' => new_resource.devices, - 'Dns' => new_resource.dns, - 'DnsSearch' => new_resource.dns_search, - 'ExtraHosts' => new_resource.extra_hosts, - 'IpcMode' => new_resource.ipc_mode, - 'Init' => new_resource.init, - 'KernelMemory' => new_resource.kernel_memory, - 'Links' => new_resource.links, - 'LogConfig' => log_config, - 'Memory' => new_resource.memory, - 'MemorySwap' => new_resource.memory_swap, + 'OpenStdin' => new_resource.open_stdin, + 'StdinOnce' => new_resource.stdin_once, + 'Tty' => new_resource.tty, + 'User' => new_resource.user, + 'Volumes' => new_resource.volumes, + 'WorkingDir' => new_resource.working_dir, + 'HostConfig' => { + 'Binds' => new_resource.volumes_binds, + 'CapAdd' => new_resource.cap_add, + 'CapDrop' => new_resource.cap_drop, + 'CgroupParent' => new_resource.cgroup_parent, + 'CgroupnsMode' => new_resource.cgroup_ns, + 'CpuShares' => new_resource.cpu_shares, + 'CpusetCpus' => new_resource.cpuset_cpus, + 'Devices' => new_resource.devices, + 'Dns' => new_resource.dns, + 'DnsSearch' => new_resource.dns_search, + 'ExtraHosts' => new_resource.extra_hosts, + 'IpcMode' => new_resource.ipc_mode, + 'Init' => new_resource.init, + 'KernelMemory' => new_resource.kernel_memory, + 'Links' => new_resource.links, + 'LogConfig' => log_config, + 'Memory' => new_resource.memory, + 'MemorySwap' => new_resource.memory_swap, 'MemorySwappiness' => new_resource.memory_swappiness, 'MemoryReservation' => new_resource.memory_reservation, - 'NanoCpus' => new_resource.cpus, - 'NetworkMode' => normalize_container_network_mode(new_resource.network_mode), - 'OomKillDisable' => new_resource.oom_kill_disable, - 'OomScoreAdj' => new_resource.oom_score_adj, - 'Privileged' => new_resource.privileged, - 'PidMode' => new_resource.pid_mode, - 'PortBindings' => new_resource.port_bindings, + 'NanoCpus' => new_resource.cpus, + 'NetworkMode' => normalize_container_network_mode(new_resource.network_mode), + 'OomKillDisable' => new_resource.oom_kill_disable, + 'OomScoreAdj' => new_resource.oom_score_adj, + 'Privileged' => new_resource.privileged, + 'PidMode' => new_resource.pid_mode, + 'PortBindings' => new_resource.port_bindings, 'PublishAllPorts' => new_resource.publish_all_ports, - 'RestartPolicy' => { - 'Name' => new_resource.restart_policy, + 'RestartPolicy' => { + 'Name' => new_resource.restart_policy, 'MaximumRetryCount' => new_resource.restart_maximum_retry_count, }, - 'ReadonlyRootfs' => new_resource.ro_rootfs, - 'Runtime' => new_resource.runtime, - 'SecurityOpt' => new_resource.security_opt, - 'ShmSize' => new_resource.shm_size, - 'Sysctls' => new_resource.sysctls, - 'Tmpfs' => new_resource.tmpfs, - 'Ulimits' => ulimits_to_hash, - 'UsernsMode' => new_resource.userns_mode, - 'UTSMode' => new_resource.uts_mode, - 'VolumesFrom' => new_resource.volumes_from, - 'VolumeDriver' => new_resource.volume_driver, + 'ReadonlyRootfs' => new_resource.ro_rootfs, + 'Runtime' => new_resource.runtime, + 'SecurityOpt' => new_resource.security_opt, + 'ShmSize' => new_resource.shm_size, + 'Sysctls' => new_resource.sysctls, + 'Tmpfs' => new_resource.tmpfs, + 'Ulimits' => ulimits_to_hash, + 'UsernsMode' => new_resource.userns_mode, + 'UTSMode' => new_resource.uts_mode, + 'VolumesFrom' => new_resource.volumes_from, + 'VolumeDriver' => new_resource.volume_driver, }, } net_config = { @@ -691,7 +691,7 @@ def validate_container_create raise Chef::Exceptions::ValidationFailed, 'restart_policy must be either no, always, unless-stopped, or on-failure.' end - if new_resource.autoremove == true && (new_resource.property_is_set?(:restart_policy) && new_resource.restart_policy != 'no') + if new_resource.autoremove == true && new_resource.property_is_set?(:restart_policy) && new_resource.restart_policy != 'no' raise Chef::Exceptions::ValidationFailed, 'Conflicting options restart_policy and autoremove.' end diff --git a/resources/exec.rb b/resources/exec.rb index b79136ebd7..051c9ba5d7 100644 --- a/resources/exec.rb +++ b/resources/exec.rb @@ -7,7 +7,7 @@ property :timeout, Numeric, default: 60, desired_state: false property :container_obj, Docker::Container, desired_state: false property :returns, [ Integer, Array ], coerce: proc { |v| Array(v) }, default: [0], - description: 'The return value for a command. This may be an array of accepted values. An exception is raised when the return value(s) do not match.' + description: 'The return value for a command. This may be an array of accepted values. An exception is raised when the return value(s) do not match.' alias_method :cmd, :command diff --git a/resources/installation_package.rb b/resources/installation_package.rb index d95fc4e199..acecce1de5 100644 --- a/resources/installation_package.rb +++ b/resources/installation_package.rb @@ -119,12 +119,12 @@ def version_string(v) if v.to_f < 18.06 && !bionic? return "#{v}~ce-0~debian" if debian? - return "#{v}~ce-0~ubuntu" if ubuntu? + "#{v}~ce-0~ubuntu" if ubuntu? elsif v.to_f >= 23.0 && ubuntu? "5:#{v}-1~ubuntu.#{node['platform_version']}~#{codename}" elsif v.to_f >= 18.09 && debuntu? return "5:#{v}~#{test_version}-0~debian-#{codename}" if debian? - return "5:#{v}~#{test_version}-0~ubuntu-#{codename}" if ubuntu? + "5:#{v}~#{test_version}-0~ubuntu-#{codename}" if ubuntu? else return "#{v}~ce~#{test_version}-0~debian" if debian? return "#{v}~ce~#{test_version}-0~ubuntu" if ubuntu? diff --git a/resources/partial/_base.rb b/resources/partial/_base.rb index 138752f736..3506b5ada2 100644 --- a/resources/partial/_base.rb +++ b/resources/partial/_base.rb @@ -27,9 +27,9 @@ def with_retries(&_block) yield # Only catch errors that can be fixed with retries. rescue Docker::Error::ServerError, # 500 - Docker::Error::UnexpectedResponseError, # 400 - Docker::Error::TimeoutError, - Docker::Error::IOError + Docker::Error::UnexpectedResponseError, # 400 + Docker::Error::TimeoutError, + Docker::Error::IOError tries -= 1 retry if tries > 0 raise diff --git a/test/cookbooks/docker_test/recipes/container.rb b/test/cookbooks/docker_test/recipes/container.rb index 56beb99cba..29e569d49d 100644 --- a/test/cookbooks/docker_test/recipes/container.rb +++ b/test/cookbooks/docker_test/recipes/container.rb @@ -311,10 +311,10 @@ tag '3.1' command 'df -h' tmpfs({ - '/tmpfs1' => '', - '/tmpfs2' => 'size=20M,uid=1000', - '/tmpfs3' => 'rw,noexec,nosuid,size=50M', - }) + '/tmpfs1' => '', + '/tmpfs2' => 'size=20M,uid=1000', + '/tmpfs3' => 'rw,noexec,nosuid,size=50M', + }) action :run_if_missing end