-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoreOS host architecture detection fix (#882)
* Fix missing host detection on CoreOS Signed-off-by: Artiom Diomin <[email protected]> * golden tests for pkg/scripts Signed-off-by: Artiom Diomin <[email protected]> * fix boilerplate Signed-off-by: Artiom Diomin <[email protected]> * fix linting Signed-off-by: Artiom Diomin <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,639 additions
and
58 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
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,48 @@ | ||
/* | ||
Copyright 2019 The KubeOne 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 scripts | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kubermatic/kubeone/pkg/testhelper" | ||
) | ||
|
||
func TestCopyPKIHome(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
workdir string | ||
err error | ||
}{ | ||
{name: "kubeone1", workdir: "test-dir1"}, | ||
{name: "kubeone2", workdir: "./subdir/test"}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.workdir, func(t *testing.T) { | ||
got, err := CopyPKIHome(tt.workdir) | ||
if err != tt.err { | ||
t.Fatalf("CopyPKIHome() error = %v, wantErr %v", err, tt.err) | ||
} | ||
|
||
testhelper.DiffOutput(t, testhelper.FSGoldenName(t), got, *updateFlag) | ||
}) | ||
} | ||
} |
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,86 @@ | ||
/* | ||
Copyright 2019 The KubeOne 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 scripts | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kubermatic/kubeone/pkg/testhelper" | ||
) | ||
|
||
func TestKubernetesAdminConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
got, err := KubernetesAdminConfig() | ||
if err != nil { | ||
t.Fatalf("KubernetesAdminConfig() error = %v", err) | ||
} | ||
|
||
testhelper.DiffOutput(t, testhelper.FSGoldenName(t), got, *updateFlag) | ||
} | ||
|
||
func TestSaveCloudConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
workdir string | ||
wantErr error | ||
}{ | ||
{name: "kubeone1", workdir: "test-dir1"}, | ||
{name: "kubeone2", workdir: "./subdir/test"}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := SaveCloudConfig(tt.workdir) | ||
if err != tt.wantErr { | ||
t.Errorf("SaveCloudConfig() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
|
||
testhelper.DiffOutput(t, testhelper.FSGoldenName(t), got, *updateFlag) | ||
}) | ||
} | ||
} | ||
|
||
func TestSaveAuditPolicyConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
workdir string | ||
err error | ||
}{ | ||
{name: "kubeone1", workdir: "test-dir1"}, | ||
{name: "kubeone2", workdir: "./subdir/test"}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := SaveAuditPolicyConfig(tt.workdir) | ||
if err != tt.err { | ||
t.Errorf("SaveAuditPolicyConfig() error = %v, wantErr %v", err, tt.err) | ||
return | ||
} | ||
|
||
testhelper.DiffOutput(t, testhelper.FSGoldenName(t), got, *updateFlag) | ||
}) | ||
} | ||
} |
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,33 @@ | ||
/* | ||
Copyright 2019 The KubeOne 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 scripts | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kubermatic/kubeone/pkg/testhelper" | ||
) | ||
|
||
func TestVerifyPrerequisites(t *testing.T) { | ||
got, err := VerifyPrerequisites() | ||
if err != nil { | ||
t.Errorf("VerifyPrerequisites() error = %v", err) | ||
return | ||
} | ||
|
||
testhelper.DiffOutput(t, testhelper.FSGoldenName(t), got, *updateFlag) | ||
} |
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,35 @@ | ||
/* | ||
Copyright 2019 The KubeOne 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 scripts | ||
|
||
func detectHostArch() string { | ||
return ` | ||
HOST_ARCH="" | ||
case $(uname -m) in | ||
x86_64) | ||
HOST_ARCH="amd64" | ||
;; | ||
aarch64) | ||
HOST_ARCH="arm64" | ||
;; | ||
*) | ||
echo "unsupported CPU architecture, exiting" | ||
exit 1 | ||
;; | ||
esac | ||
` | ||
} |
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
Oops, something went wrong.