diff --git a/Godeps/LICENSES b/Godeps/LICENSES index 9247a981e4e..f8fe3a5de37 100644 --- a/Godeps/LICENSES +++ b/Godeps/LICENSES @@ -22468,6 +22468,215 @@ third-party archives. ================================================================================ +================================================================================ += vendor/k8s.io/system-validators licensed under: = + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + += vendor/k8s.io/system-validators/LICENSE e3fc50a88d0a364313df4b21ef20c29e +================================================================================ + + ================================================================================ = vendor/k8s.io/utils licensed under: = diff --git a/build/dependencies.yaml b/build/dependencies.yaml index 50612efbbfe..731dd76283d 100644 --- a/build/dependencies.yaml +++ b/build/dependencies.yaml @@ -27,10 +27,8 @@ dependencies: - name: "docker" version: 19.03 refPaths: - - path: cmd/kubeadm/app/util/system/docker_validator.go + - path: vendor/k8s.io/system-validators/validators/docker_validator.go match: latestValidatedDockerVersion - - path: cmd/kubeadm/app/util/system/docker_validator_test.go - match: ServerVersion - name: "golang" diff --git a/cmd/kubeadm/app/preflight/BUILD b/cmd/kubeadm/app/preflight/BUILD index 91a92d11474..b65c938a2ad 100644 --- a/cmd/kubeadm/app/preflight/BUILD +++ b/cmd/kubeadm/app/preflight/BUILD @@ -23,7 +23,6 @@ go_library( "//cmd/kubeadm/app/images:go_default_library", "//cmd/kubeadm/app/util/initsystem:go_default_library", "//cmd/kubeadm/app/util/runtime:go_default_library", - "//cmd/kubeadm/app/util/system:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/version:go_default_library", @@ -31,6 +30,7 @@ go_library( "//vendor/github.com/PuerkitoBio/purell:go_default_library", "//vendor/github.com/pkg/errors:go_default_library", "//vendor/k8s.io/klog:go_default_library", + "//vendor/k8s.io/system-validators/validators:go_default_library", "//vendor/k8s.io/utils/exec:go_default_library", "//vendor/k8s.io/utils/net:go_default_library", ] + select({ diff --git a/cmd/kubeadm/app/preflight/checks.go b/cmd/kubeadm/app/preflight/checks.go index ee561c29f17..723b5bd44e0 100644 --- a/cmd/kubeadm/app/preflight/checks.go +++ b/cmd/kubeadm/app/preflight/checks.go @@ -46,7 +46,7 @@ import ( "k8s.io/kubernetes/cmd/kubeadm/app/images" "k8s.io/kubernetes/cmd/kubeadm/app/util/initsystem" utilruntime "k8s.io/kubernetes/cmd/kubeadm/app/util/runtime" - "k8s.io/kubernetes/cmd/kubeadm/app/util/system" + system "k8s.io/system-validators/validators" utilsexec "k8s.io/utils/exec" utilsnet "k8s.io/utils/net" ) diff --git a/cmd/kubeadm/app/util/BUILD b/cmd/kubeadm/app/util/BUILD index 57a74d44f40..8dd4045baa7 100644 --- a/cmd/kubeadm/app/util/BUILD +++ b/cmd/kubeadm/app/util/BUILD @@ -91,7 +91,6 @@ filegroup( "//cmd/kubeadm/app/util/pubkeypin:all-srcs", "//cmd/kubeadm/app/util/runtime:all-srcs", "//cmd/kubeadm/app/util/staticpod:all-srcs", - "//cmd/kubeadm/app/util/system:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], diff --git a/cmd/kubeadm/app/util/system/cgroup_validator_test.go b/cmd/kubeadm/app/util/system/cgroup_validator_test.go deleted file mode 100644 index 08f0619e6ad..00000000000 --- a/cmd/kubeadm/app/util/system/cgroup_validator_test.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateCgroupSubsystem(t *testing.T) { - v := &CgroupsValidator{ - Reporter: DefaultReporter, - } - cgroupSpec := []string{"system1", "system2"} - for desc, test := range map[string]struct { - subsystems []string - err bool - }{ - "missing cgroup subsystem should report error": { - subsystems: []string{"system1"}, - err: true, - }, - "extra cgroup subsystems should not report error": { - subsystems: []string{"system1", "system2", "system3"}, - err: false, - }, - "subsystems the same with spec should not report error": { - subsystems: []string{"system1", "system2"}, - err: false, - }, - } { - t.Run(desc, func(t *testing.T) { - err := v.validateCgroupSubsystems(cgroupSpec, test.subsystems) - if !test.err { - assert.Nil(t, err, "%q: Expect error not to occur with cgroup", desc) - } else { - assert.NotNil(t, err, "%q: Expect error to occur with docker info", desc) - } - }) - } -} diff --git a/cmd/kubeadm/app/util/system/docker_validator_test.go b/cmd/kubeadm/app/util/system/docker_validator_test.go deleted file mode 100644 index 1617813d07c..00000000000 --- a/cmd/kubeadm/app/util/system/docker_validator_test.go +++ /dev/null @@ -1,153 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateDockerInfo(t *testing.T) { - v := &DockerValidator{ - Reporter: DefaultReporter, - } - spec := &DockerSpec{ - Version: []string{`1\.13\..*`, `17\.0[3,6,9]\..*`, `18\.0[6,9]\..*`, `19\.03\..*`}, - GraphDriver: []string{"driver_1", "driver_2"}, - } - for _, test := range []struct { - name string - info dockerInfo - err bool - warn bool - }{ - { - name: "unsupported Docker version 1.12.1", - info: dockerInfo{Driver: "driver_2", ServerVersion: "1.12.1"}, - err: true, - warn: false, - }, - { - name: "unsupported driver", - info: dockerInfo{Driver: "bad_driver", ServerVersion: "1.13.1"}, - err: true, - warn: false, - }, - { - name: "valid Docker version 1.13.1", - info: dockerInfo{Driver: "driver_1", ServerVersion: "1.13.1"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 17.03.0-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "17.03.0-ce"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 17.06.0-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "17.06.0-ce"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 17.09.0-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "17.09.0-ce"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 18.06.0-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "18.06.0-ce"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 18.09.1-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "18.09.1-ce"}, - err: false, - warn: false, - }, - { - name: "valid Docker version 19.03.1-ce", - info: dockerInfo{Driver: "driver_2", ServerVersion: "19.03.1-ce"}, - err: false, - warn: false, - }, - { - name: "Docker version 19.06.0 is not in the list of validated versions", - info: dockerInfo{Driver: "driver_2", ServerVersion: "19.06.0"}, - err: false, - warn: true, - }, - } { - t.Run(test.name, func(t *testing.T) { - warn, err := v.validateDockerInfo(spec, test.info) - if !test.err { - assert.Nil(t, err, "Expect error not to occur with docker info %+v", test.info) - } else { - assert.NotNil(t, err, "Expect error to occur with docker info %+v", test.info) - } - if !test.warn { - assert.Nil(t, warn, "Expect error not to occur with docker info %+v", test.info) - } else { - assert.NotNil(t, warn, "Expect error to occur with docker info %+v", test.info) - } - }) - } -} - -func TestUnmarshalDockerInfo(t *testing.T) { - v := &DockerValidator{} - - testCases := []struct { - name string - input string - expectedInfo dockerInfo - expectedError bool - }{ - { - name: "valid: expected dockerInfo is valid", - input: `{ "Driver":"foo", "ServerVersion":"bar" }`, - expectedInfo: dockerInfo{Driver: "foo", ServerVersion: "bar"}, - }, - { - name: "invalid: the JSON input is not valid", - input: `{ "Driver":"foo"`, - expectedError: true, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - var err error - info := dockerInfo{} - if err = v.unmarshalDockerInfo([]byte(tc.input), &info); (err != nil) != tc.expectedError { - t.Fatalf("failed unmarshaling; expected error: %v, got: %v, error: %v", tc.expectedError, (err != nil), err) - } - if err != nil { - return - } - if !reflect.DeepEqual(tc.expectedInfo, info) { - t.Fatalf("dockerInfo do not match, expected: %#v, got: %#v", tc.expectedInfo, info) - } - }) - } -} diff --git a/cmd/kubeadm/app/util/system/kernel_validator_test.go b/cmd/kubeadm/app/util/system/kernel_validator_test.go deleted file mode 100644 index 7c303ae6c55..00000000000 --- a/cmd/kubeadm/app/util/system/kernel_validator_test.go +++ /dev/null @@ -1,213 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "bytes" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateKernelVersion(t *testing.T) { - v := &KernelValidator{ - Reporter: DefaultReporter, - } - // Currently, testRegex is align with DefaultSysSpec.KernelVersion, but in the future - // they may be different. - // This is fine, because the test mainly tests the kernel version validation logic, - // not the DefaultSysSpec. The DefaultSysSpec should be tested with node e2e. - testRegex := []string{`^3\.[1-9][0-9].*$`, `^([4-9]|[1-9][0-9]+)\.([0-9]+)\.([0-9]+).*$`} - for _, test := range []struct { - name string - version string - err bool - }{ - { - name: "3.19.9-99-test first version regex matches", - version: "3.19.9-99-test", - err: false, - }, - { - name: "4.4.14+ one of version regexes matches", - version: "4.4.14+", - err: false, - }, - { - name: "2.0.0 no version regex matches", - version: "2.0.0", - err: true, - }, - { - name: "5.0.0 one of version regexes matches", - version: "5.0.0", - err: false, - }, - { - name: "10.21.1 one of version regexes matches", - version: "10.21.1", - err: false, - }, - { - name: "99.12.12 one of version regexes matches", - version: "99.12.12", - err: false, - }, - { - name: "3.9.0 no version regex matches", - version: "3.9.0", - err: true, - }, - } { - t.Run(test.name, func(t *testing.T) { - v.kernelRelease = test.version - err := v.validateKernelVersion(KernelSpec{Versions: testRegex}) - if !test.err { - assert.Nil(t, err, "Expect error not to occur with kernel version %q", test.version) - } else { - assert.NotNil(t, err, "Expect error to occur with kenrel version %q", test.version) - } - }) - } -} - -func TestValidateCachedKernelConfig(t *testing.T) { - v := &KernelValidator{ - Reporter: DefaultReporter, - } - testKernelSpec := KernelSpec{ - Required: []KernelConfig{{Name: "REQUIRED_1"}, {Name: "REQUIRED_2", Aliases: []string{"ALIASE_REQUIRED_2"}}}, - Optional: []KernelConfig{{Name: "OPTIONAL_1"}, {Name: "OPTIONAL_2"}}, - Forbidden: []KernelConfig{ - {Name: "FORBIDDEN_1", Description: "TEST FORBIDDEN"}, - {Name: "FORBIDDEN_2", Aliases: []string{"ALIASE_FORBIDDEN_2"}}, - }, - } - for _, test := range []struct { - desc string - config map[string]kConfigOption - err bool - }{ - { - desc: "meet all required configurations should not report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - }, - err: false, - }, - { - desc: "one required configuration disabled should report error", - config: map[string]kConfigOption{ - "REQUIRED_1": leftOut, - "REQUIRED_2": builtIn, - }, - err: true, - }, - { - desc: "one required configuration missing should report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - }, - err: true, - }, - { - desc: "alias of required configuration should not report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "ALIASE_REQUIRED_2": asModule, - }, - err: false, - }, - { - desc: "optional configuration set or not should not report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - "OPTIONAL_1": builtIn, - }, - err: false, - }, - { - desc: "forbidden configuration disabled should not report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - "FORBIDDEN_1": leftOut, - }, - err: false, - }, - { - desc: "forbidden configuration built-in should report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - "FORBIDDEN_1": builtIn, - }, - err: true, - }, - { - desc: "forbidden configuration built as module should report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - "FORBIDDEN_1": asModule, - }, - err: true, - }, - { - desc: "alias of forbidden configuration should report error", - config: map[string]kConfigOption{ - "REQUIRED_1": builtIn, - "REQUIRED_2": asModule, - "ALIASE_FORBIDDEN_2": asModule, - }, - err: true, - }, - } { - t.Run(test.desc, func(t *testing.T) { - // Add kernel config prefix. - for k, v := range test.config { - delete(test.config, k) - test.config[kernelConfigPrefix+k] = v - } - err := v.validateCachedKernelConfig(test.config, testKernelSpec) - if !test.err { - assert.Nil(t, err, "Expect error not to occur with kernel config %q", test.config) - } else { - assert.NotNil(t, err, "Expect error to occur with kenrel config %q", test.config) - } - }) - } -} - -func TestValidateParseKernelConfig(t *testing.T) { - config := `CONFIG_1=y -CONFIG_2=m -CONFIG_3=n` - expected := map[string]kConfigOption{ - "CONFIG_1": builtIn, - "CONFIG_2": asModule, - "CONFIG_3": leftOut, - } - v := &KernelValidator{ - Reporter: DefaultReporter, - } - got, err := v.parseKernelConfig(bytes.NewReader([]byte(config))) - assert.Nil(t, err, "Expect error not to occur when parse kernel configuration %q", config) - assert.Equal(t, expected, got) -} diff --git a/cmd/kubeadm/app/util/system/os_validator_test.go b/cmd/kubeadm/app/util/system/os_validator_test.go deleted file mode 100644 index 6c325025922..00000000000 --- a/cmd/kubeadm/app/util/system/os_validator_test.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateOS(t *testing.T) { - v := &OSValidator{ - Reporter: DefaultReporter, - } - specOS := "Linux" - for _, test := range []struct { - os string - err bool - }{ - { - os: "Linux", - err: false, - }, - { - os: "Windows", - err: true, - }, - { - os: "Darwin", - err: true, - }, - } { - t.Run(test.os, func(t *testing.T) { - err := v.validateOS(test.os, specOS) - if !test.err { - assert.Nil(t, err, "Expect error not to occur with os %q", test.os) - } else { - assert.NotNil(t, err, "Expect error to occur with os %q", test.os) - } - }) - } -} diff --git a/cmd/kubeadm/app/util/system/package_validator_test.go b/cmd/kubeadm/app/util/system/package_validator_test.go deleted file mode 100644 index ddcd08a27ab..00000000000 --- a/cmd/kubeadm/app/util/system/package_validator_test.go +++ /dev/null @@ -1,291 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package system - -import ( - "fmt" - "reflect" - "testing" - - "github.com/pkg/errors" -) - -func TestExtractUpstreamVersion(t *testing.T) { - for _, test := range []struct { - input string - expected string - }{ - { - input: "", - expected: "", - }, - { - input: "1.0.6", - expected: "1.0.6", - }, - { - input: "1:1.0.6", - expected: "1.0.6", - }, - { - input: "1.0.6-2ubuntu2.1", - expected: "1.0.6", - }, - { - input: "1:1.0.6-2ubuntu2.1", - expected: "1.0.6", - }, - } { - t.Run(fmt.Sprintf("input:%s,expected:%s", test.input, test.expected), func(t *testing.T) { - got := extractUpstreamVersion(test.input) - if test.expected != got { - t.Errorf("extractUpstreamVersion(%q) = %q, want %q", test.input, got, test.expected) - } - }) - } -} - -func TestToSemVer(t *testing.T) { - for _, test := range []struct { - input string - expected string - }{ - { - input: "", - expected: "", - }, - { - input: "1.2.3", - expected: "1.2.3", - }, - { - input: "1.8.19p1", - expected: "1.8.19", - }, - { - input: "1.8.19.p1", - expected: "1.8.19", - }, - { - input: "p1", - expected: "", - }, - { - input: "1.18", - expected: "1.18.0", - }, - { - input: "481", - expected: "481.0.0", - }, - { - input: "2.0.10.4", - expected: "2.0.10", - }, - { - input: "03", - expected: "3.0.0", - }, - { - input: "2.02", - expected: "2.2.0", - }, - { - input: "8.0.0095", - expected: "8.0.95", - }, - } { - t.Run(fmt.Sprintf("input:%s,expected:%s", test.input, test.expected), func(t *testing.T) { - got := toSemVer(test.input) - if test.expected != got { - t.Errorf("toSemVer(%q) = %q, want %q", test.input, got, test.expected) - } - }) - } -} - -func TestToSemVerRange(t *testing.T) { - for _, test := range []struct { - input string - expected string - }{ - { - input: "", - expected: "", - }, - { - input: ">=1.0.0", - expected: ">=1.0.0", - }, - { - input: ">=1.0", - expected: ">=1.0.x", - }, - { - input: ">=1", - expected: ">=1.x", - }, - { - input: ">=1 || !2.3", - expected: ">=1.x || !2.3.x", - }, - { - input: ">1 || >3.1.0 !4.2", - expected: ">1.x || >3.1.0 !4.2.x", - }, - } { - t.Run(fmt.Sprintf("input:%s,expected:%s", test.input, test.expected), func(t *testing.T) { - got := toSemVerRange(test.input) - if test.expected != got { - t.Errorf("toSemVerRange(%q) = %q, want %q", test.input, got, test.expected) - } - }) - } -} - -// testPackageManager implements the packageManager interface. -type testPackageManager struct { - packageVersions map[string]string -} - -func (m testPackageManager) getPackageVersion(packageName string) (string, error) { - if v, ok := m.packageVersions[packageName]; ok { - return v, nil - } - return "", errors.Errorf("package %q does not exist", packageName) -} - -func TestValidatePackageVersion(t *testing.T) { - testKernelRelease := "test-kernel-release" - manager := testPackageManager{ - packageVersions: map[string]string{ - "foo": "1.0.0", - "bar": "2.1.0", - "bar-" + testKernelRelease: "3.0.0", - }, - } - v := &packageValidator{ - reporter: DefaultReporter, - kernelRelease: testKernelRelease, - } - for _, test := range []struct { - desc string - specs []PackageSpec - errs []error - }{ - { - desc: "all packages meet the spec", - specs: []PackageSpec{ - {Name: "foo", VersionRange: ">=1.0"}, - {Name: "bar", VersionRange: ">=2.0 <= 3.0"}, - }, - }, - { - desc: "package version does not meet the spec", - specs: []PackageSpec{ - {Name: "foo", VersionRange: ">=1.0"}, - {Name: "bar", VersionRange: ">=3.0"}, - }, - errs: []error{ - errors.New("package \"bar 2.1.0\" does not meet the spec \"bar (>=3.0)\""), - }, - }, - { - desc: "package not installed", - specs: []PackageSpec{ - {Name: "baz"}, - }, - errs: []error{ - errors.New("package \"baz\" does not exist"), - }, - }, - { - desc: "use variable in package name", - specs: []PackageSpec{ - {Name: "bar-${KERNEL_RELEASE}", VersionRange: ">=3.0"}, - }, - }, - } { - t.Run(test.desc, func(t *testing.T) { - _, errs := v.validate(test.specs, manager) - if len(test.errs) == 0 && len(errs) > 0 { - t.Errorf("%s: v.validate(): err = %s", test.desc, errs) - } - if len(test.errs) > 0 { - if len(errs) == 0 { - t.Errorf("%s: v.validate() is expected to fail.", test.desc) - } else if len(errs) != len(test.errs) { - t.Errorf("%s: v.validate(): errs = %q, want = %q", test.desc, errs, test.errs) - } else { - for i, v := range test.errs { - if v.Error() != errs[i].Error() { - t.Errorf("%s: v.validate(): errs = %q, want = %q", test.desc, errs, test.errs) - } - } - } - } - }) - } -} - -func TestApplyPackageOverride(t *testing.T) { - for _, test := range []struct { - name string - overrides []PackageSpecOverride - osDistro string - specs []PackageSpec - expected []PackageSpec - }{ - { - name: "foo>=1.0", - specs: []PackageSpec{{Name: "foo", VersionRange: ">=1.0"}}, - expected: []PackageSpec{{Name: "foo", VersionRange: ">=1.0"}}, - }, - { - name: "ubuntu:foo>=1.0/bar>=2.0", - osDistro: "ubuntu", - overrides: []PackageSpecOverride{ - { - OSDistro: "ubuntu", - Subtractions: []PackageSpec{{Name: "foo"}}, - Additions: []PackageSpec{{Name: "bar", VersionRange: ">=2.0"}}, - }, - }, - specs: []PackageSpec{{Name: "foo", VersionRange: ">=1.0"}}, - expected: []PackageSpec{{Name: "bar", VersionRange: ">=2.0"}}, - }, - { - name: "ubuntu:foo>=1.0/debian:foo", - osDistro: "ubuntu", - overrides: []PackageSpecOverride{ - { - OSDistro: "debian", - Subtractions: []PackageSpec{{Name: "foo"}}, - }, - }, - specs: []PackageSpec{{Name: "foo", VersionRange: ">=1.0"}}, - expected: []PackageSpec{{Name: "foo", VersionRange: ">=1.0"}}, - }, - } { - t.Run(test.name, func(t *testing.T) { - got := applyPackageSpecOverride(test.specs, test.overrides, test.osDistro) - if !reflect.DeepEqual(test.expected, got) { - t.Errorf("applyPackageSpecOverride(%+v, %+v, %s) = %+v, want = %+v", test.specs, test.overrides, test.osDistro, got, test.expected) - } - }) - } -} diff --git a/go.mod b/go.mod index 907ecc0049f..c5282873622 100644 --- a/go.mod +++ b/go.mod @@ -162,6 +162,7 @@ require ( k8s.io/metrics v0.0.0 k8s.io/repo-infra v0.0.1-alpha.1 k8s.io/sample-apiserver v0.0.0 + k8s.io/system-validators v1.0.4 k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d sigs.k8s.io/kustomize v2.0.3+incompatible sigs.k8s.io/yaml v1.1.0 @@ -548,6 +549,7 @@ replace ( k8s.io/sample-apiserver => ./staging/src/k8s.io/sample-apiserver k8s.io/sample-cli-plugin => ./staging/src/k8s.io/sample-cli-plugin k8s.io/sample-controller => ./staging/src/k8s.io/sample-controller + k8s.io/system-validators => k8s.io/system-validators v1.0.4 k8s.io/utils => k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d modernc.org/cc => modernc.org/cc v1.0.0 modernc.org/golex => modernc.org/golex v1.0.0 diff --git a/go.sum b/go.sum index de71cccca9d..a66d3e1d83f 100644 --- a/go.sum +++ b/go.sum @@ -587,6 +587,8 @@ k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLy k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/repo-infra v0.0.1-alpha.1 h1:2us1n30u3cOcoPsacNfCvCssS9B9Yldr1ZGOdK0728U= k8s.io/repo-infra v0.0.1-alpha.1/go.mod h1:wO1t9WaB99V80ljbeENTnayuEEwNZt7gECYh/CEyOJ8= +k8s.io/system-validators v1.0.4 h1:sW57tJ/ciqOVbbTLN+ZNy64MJMNqUuiwrirQv8IR2Kw= +k8s.io/system-validators v1.0.4/go.mod h1:HgSgTg4NAGNoYYjKsUyk52gdNi2PVDswQ9Iyn66R7NI= k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d h1:1P0iBJsBzxRmR+dIFnM+Iu4aLxnoa7lBqozW/0uHbT8= k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.sum b/staging/src/k8s.io/apiextensions-apiserver/go.sum index dcf86970842..f7709b70069 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.sum +++ b/staging/src/k8s.io/apiextensions-apiserver/go.sum @@ -301,7 +301,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/staging/src/k8s.io/apiserver/go.sum b/staging/src/k8s.io/apiserver/go.sum index 8e2af07891c..6768b1fc7bd 100644 --- a/staging/src/k8s.io/apiserver/go.sum +++ b/staging/src/k8s.io/apiserver/go.sum @@ -235,7 +235,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/staging/src/k8s.io/cli-runtime/go.sum b/staging/src/k8s.io/cli-runtime/go.sum index a97b713243c..ca958845a22 100644 --- a/staging/src/k8s.io/cli-runtime/go.sum +++ b/staging/src/k8s.io/cli-runtime/go.sum @@ -157,7 +157,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/staging/src/k8s.io/kube-aggregator/go.sum b/staging/src/k8s.io/kube-aggregator/go.sum index 809ddcec7ef..3408b2ed87e 100644 --- a/staging/src/k8s.io/kube-aggregator/go.sum +++ b/staging/src/k8s.io/kube-aggregator/go.sum @@ -255,7 +255,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/staging/src/k8s.io/sample-apiserver/go.sum b/staging/src/k8s.io/sample-apiserver/go.sum index 7e3a979b988..e5a23c92bbd 100644 --- a/staging/src/k8s.io/sample-apiserver/go.sum +++ b/staging/src/k8s.io/sample-apiserver/go.sum @@ -252,7 +252,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/staging/src/k8s.io/sample-cli-plugin/go.sum b/staging/src/k8s.io/sample-cli-plugin/go.sum index a97b713243c..ca958845a22 100644 --- a/staging/src/k8s.io/sample-cli-plugin/go.sum +++ b/staging/src/k8s.io/sample-cli-plugin/go.sum @@ -157,7 +157,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= diff --git a/test/e2e_node/BUILD b/test/e2e_node/BUILD index a89247a63f0..9442ade53ca 100644 --- a/test/e2e_node/BUILD +++ b/test/e2e_node/BUILD @@ -210,7 +210,6 @@ go_test( "//vendor/k8s.io/klog:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:android": [ - "//cmd/kubeadm/app/util/system:go_default_library", "//pkg/kubelet/stats/pidlimit:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", @@ -224,9 +223,9 @@ go_test( "//vendor/github.com/onsi/ginkgo/config:go_default_library", "//vendor/github.com/onsi/ginkgo/reporters:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/system-validators/validators:go_default_library", ], "@io_bazel_rules_go//go/platform:linux": [ - "//cmd/kubeadm/app/util/system:go_default_library", "//pkg/kubelet/stats/pidlimit:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", @@ -240,6 +239,7 @@ go_test( "//vendor/github.com/onsi/ginkgo/config:go_default_library", "//vendor/github.com/onsi/ginkgo/reporters:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", + "//vendor/k8s.io/system-validators/validators:go_default_library", ], "//conditions:default": [], }), diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index 993086b675c..b36caaa2bba 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -34,17 +34,17 @@ import ( "testing" "time" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilyaml "k8s.io/apimachinery/pkg/util/yaml" clientset "k8s.io/client-go/kubernetes" - "k8s.io/kubernetes/cmd/kubeadm/app/util/system" commontest "k8s.io/kubernetes/test/e2e/common" "k8s.io/kubernetes/test/e2e/framework" e2econfig "k8s.io/kubernetes/test/e2e/framework/config" "k8s.io/kubernetes/test/e2e/framework/testfiles" "k8s.io/kubernetes/test/e2e/generated" "k8s.io/kubernetes/test/e2e_node/services" + system "k8s.io/system-validators/validators" "github.com/onsi/ginkgo" "github.com/onsi/ginkgo/config" diff --git a/vendor/BUILD b/vendor/BUILD index 80134ce5529..3279faf7462 100644 --- a/vendor/BUILD +++ b/vendor/BUILD @@ -485,6 +485,7 @@ filegroup( "//vendor/k8s.io/kube-openapi/pkg/schemaconv:all-srcs", "//vendor/k8s.io/kube-openapi/pkg/util:all-srcs", "//vendor/k8s.io/repo-infra/cmd/kazel:all-srcs", + "//vendor/k8s.io/system-validators/validators:all-srcs", "//vendor/k8s.io/utils/buffer:all-srcs", "//vendor/k8s.io/utils/clock:all-srcs", "//vendor/k8s.io/utils/exec:all-srcs", diff --git a/vendor/k8s.io/system-validators/LICENSE b/vendor/k8s.io/system-validators/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/vendor/k8s.io/system-validators/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/kubeadm/app/util/system/BUILD b/vendor/k8s.io/system-validators/validators/BUILD similarity index 53% rename from cmd/kubeadm/app/util/system/BUILD rename to vendor/k8s.io/system-validators/validators/BUILD index d006476ad4b..e8b95ec81cf 100644 --- a/cmd/kubeadm/app/util/system/BUILD +++ b/vendor/k8s.io/system-validators/validators/BUILD @@ -1,10 +1,4 @@ -package(default_visibility = ["//visibility:public"]) - -load( - "@io_bazel_rules_go//go:def.bzl", - "go_library", - "go_test", -) +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -21,30 +15,15 @@ go_library( "types_windows.go", "validators.go", ], - importpath = "k8s.io/kubernetes/cmd/kubeadm/app/util/system", + importmap = "k8s.io/kubernetes/vendor/k8s.io/system-validators/validators", + importpath = "k8s.io/system-validators/validators", + visibility = ["//visibility:public"], deps = [ "//vendor/github.com/blang/semver:go_default_library", "//vendor/github.com/pkg/errors:go_default_library", ], ) -go_test( - name = "go_default_test", - srcs = [ - "cgroup_validator_test.go", - "docker_validator_test.go", - "kernel_validator_test.go", - "os_validator_test.go", - "package_validator_test.go", - ], - embed = [":go_default_library"], - tags = ["e2e"], - deps = [ - "//vendor/github.com/pkg/errors:go_default_library", - "//vendor/github.com/stretchr/testify/assert:go_default_library", - ], -) - filegroup( name = "package-srcs", srcs = glob(["**"]), @@ -56,4 +35,5 @@ filegroup( name = "all-srcs", srcs = [":package-srcs"], tags = ["automanaged"], + visibility = ["//visibility:public"], ) diff --git a/cmd/kubeadm/app/util/system/cgroup_validator.go b/vendor/k8s.io/system-validators/validators/cgroup_validator.go similarity index 100% rename from cmd/kubeadm/app/util/system/cgroup_validator.go rename to vendor/k8s.io/system-validators/validators/cgroup_validator.go diff --git a/cmd/kubeadm/app/util/system/docker_validator.go b/vendor/k8s.io/system-validators/validators/docker_validator.go similarity index 89% rename from cmd/kubeadm/app/util/system/docker_validator.go rename to vendor/k8s.io/system-validators/validators/docker_validator.go index 85bb0d4de23..9ab1c04468e 100644 --- a/cmd/kubeadm/app/util/system/docker_validator.go +++ b/vendor/k8s.io/system-validators/validators/docker_validator.go @@ -20,6 +20,7 @@ import ( "encoding/json" "os/exec" "regexp" + "strings" "github.com/pkg/errors" ) @@ -32,11 +33,13 @@ type DockerValidator struct { } // dockerInfo holds a local subset of the Info struct from -// github.com/docker/docker/api/types. +// https://github.com/docker/cli/blob/master/cli/command/system/info.go +// and https://github.com/moby/moby/blob/master/api/types/types.go // The JSON output from 'docker info' should map to this struct. type dockerInfo struct { - Driver string `json:"Driver"` - ServerVersion string `json:"ServerVersion"` + Driver string `json:"Driver"` + ServerVersion string `json:"ServerVersion"` + ServerErrors []string `json:",omitempty"` } // Name is part of the system.Validator interface. @@ -81,6 +84,10 @@ func (d *DockerValidator) unmarshalDockerInfo(b []byte, info *dockerInfo) error func (d *DockerValidator) validateDockerInfo(spec *DockerSpec, info dockerInfo) ([]error, []error) { // Validate docker version. + if info.ServerErrors != nil { + return nil, []error{errors.Errorf("error verifying Docker info: %q", strings.Join(info.ServerErrors, `", "`))} + } + matched := false for _, v := range spec.Version { r := regexp.MustCompile(v) diff --git a/cmd/kubeadm/app/util/system/kernel_validator.go b/vendor/k8s.io/system-validators/validators/kernel_validator.go similarity index 100% rename from cmd/kubeadm/app/util/system/kernel_validator.go rename to vendor/k8s.io/system-validators/validators/kernel_validator.go diff --git a/cmd/kubeadm/app/util/system/kernel_validator_helper.go b/vendor/k8s.io/system-validators/validators/kernel_validator_helper.go similarity index 100% rename from cmd/kubeadm/app/util/system/kernel_validator_helper.go rename to vendor/k8s.io/system-validators/validators/kernel_validator_helper.go diff --git a/cmd/kubeadm/app/util/system/os_validator.go b/vendor/k8s.io/system-validators/validators/os_validator.go similarity index 100% rename from cmd/kubeadm/app/util/system/os_validator.go rename to vendor/k8s.io/system-validators/validators/os_validator.go diff --git a/cmd/kubeadm/app/util/system/package_validator.go b/vendor/k8s.io/system-validators/validators/package_validator.go similarity index 100% rename from cmd/kubeadm/app/util/system/package_validator.go rename to vendor/k8s.io/system-validators/validators/package_validator.go diff --git a/cmd/kubeadm/app/util/system/report.go b/vendor/k8s.io/system-validators/validators/report.go similarity index 100% rename from cmd/kubeadm/app/util/system/report.go rename to vendor/k8s.io/system-validators/validators/report.go diff --git a/cmd/kubeadm/app/util/system/types.go b/vendor/k8s.io/system-validators/validators/types.go similarity index 100% rename from cmd/kubeadm/app/util/system/types.go rename to vendor/k8s.io/system-validators/validators/types.go diff --git a/cmd/kubeadm/app/util/system/types_unix.go b/vendor/k8s.io/system-validators/validators/types_unix.go similarity index 100% rename from cmd/kubeadm/app/util/system/types_unix.go rename to vendor/k8s.io/system-validators/validators/types_unix.go diff --git a/cmd/kubeadm/app/util/system/types_windows.go b/vendor/k8s.io/system-validators/validators/types_windows.go similarity index 100% rename from cmd/kubeadm/app/util/system/types_windows.go rename to vendor/k8s.io/system-validators/validators/types_windows.go diff --git a/cmd/kubeadm/app/util/system/validators.go b/vendor/k8s.io/system-validators/validators/validators.go similarity index 100% rename from cmd/kubeadm/app/util/system/validators.go rename to vendor/k8s.io/system-validators/validators/validators.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 0b825313601..164d2fba528 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1883,6 +1883,8 @@ k8s.io/sample-apiserver/pkg/generated/openapi k8s.io/sample-apiserver/pkg/registry k8s.io/sample-apiserver/pkg/registry/wardle/fischer k8s.io/sample-apiserver/pkg/registry/wardle/flunder +# k8s.io/system-validators v1.0.4 => k8s.io/system-validators v1.0.4 +k8s.io/system-validators/validators # k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d => k8s.io/utils v0.0.0-20191030222137-2b95a09bc58d k8s.io/utils/buffer k8s.io/utils/clock