1
+ /*
2
+ Copyright 2018 The Kubernetes Authors.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
1
17
package options
2
18
3
19
import (
@@ -13,7 +29,7 @@ type Options struct {
13
29
HostnameOverride string
14
30
}
15
31
16
- //TestSetNodeNameOrDie tests for permutations of nodename, hostname and hostnameoverride
32
+ // TestSetNodeNameOrDie tests for permutations of nodename, hostname and hostnameoverride
17
33
func TestSetNodeNameOrDie (t * testing.T ) {
18
34
options := map [string ]struct {
19
35
Expected Options
@@ -88,11 +104,11 @@ func TestSetNodeNameOrDie(t *testing.T) {
88
104
}
89
105
90
106
if opt .Expected .Hostname != "" {
91
- //Changing hostname
107
+ // Changing hostname
92
108
cmd := exec .Command ("hostname" , opt .Expected .Hostname )
93
109
_ , err := cmd .CombinedOutput ()
94
110
if err != nil {
95
- //If changing hostname requires admin privilege
111
+ // If changing hostname requires admin privilege
96
112
cmd = exec .Command ("sudo" , "hostname" , opt .Expected .Hostname )
97
113
_ , err := cmd .CombinedOutput ()
98
114
if err != nil {
@@ -120,7 +136,7 @@ func TestSetNodeNameOrDie(t *testing.T) {
120
136
}
121
137
122
138
}
123
-
139
+ // Setting back the original attributes
124
140
err = os .Setenv ("NODE_NAME" , orig_node_name )
125
141
if err != nil {
126
142
fmt .Println ("Unable to set original : env NODE_NAME" )
0 commit comments