Browse code

Migrate scripts to use `os::log::warn`

Instead of using `echo "[WARNING]..."` scripts should instead
be using the logging utility function `os::log::warn`.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Steve Kuznetsov authored on 2016/11/05 01:19:37
Showing 6 changed files
... ...
@@ -51,7 +51,7 @@ function os::log::system::clean_up() {
51 51
     fi
52 52
 
53 53
     if ! which sadf  >/dev/null 2>&1; then
54
-        echo "[WARNING] System logger data could not be unpacked and graphed, 'sadf' binary not found in this environment."
54
+        os::log::warn "System logger data could not be unpacked and graphed, 'sadf' binary not found in this environment."
55 55
         return 0
56 56
     fi
57 57
 
... ...
@@ -201,7 +201,7 @@ readonly -f os::log::system::internal::plot
201 201
 #  - export SAR_LOGFILE
202 202
 function os::log::system::start() {
203 203
     if ! which sar >/dev/null 2>&1; then
204
-        echo "[WARNING] System logger could not be started, 'sar' binary not found in this environment."
204
+        os::log::warn "System logger could not be started, 'sar' binary not found in this environment."
205 205
         return 0
206 206
     fi
207 207
 
... ...
@@ -80,7 +80,7 @@ if [[ "${tag}" != ":latest" ]]; then
80 80
       docker pull "${OS_PUSH_BASE_REGISTRY-}${image}:${source_tag}"
81 81
     done
82 82
   else
83
-    echo "WARNING: Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
83
+    os::log::warn "Pushing local :${source_tag} images to ${OS_PUSH_BASE_REGISTRY-}*${tag}"
84 84
     if [[ -z "${OS_PUSH_ALWAYS:-}" ]]; then
85 85
       echo "  CTRL+C to cancel, or any other key to continue"
86 86
       read
... ...
@@ -44,27 +44,27 @@ os::util::environment::setup_tmpdir_vars "test-go"
44 44
 # TODO(skuznets): remove these once we've migrated all tools to the new vars
45 45
 if [[ -n "${KUBE_TIMEOUT+x}" ]]; then
46 46
     TIMEOUT="${KUBE_TIMEOUT}"
47
-    echo "[WARNING] The flag \$KUBE_TIMEOUT for $0 is deprecated, use \$TIMEOUT instead."
47
+    os::log::warn "The flag \$KUBE_TIMEOUT for $0 is deprecated, use \$TIMEOUT instead."
48 48
 fi
49 49
 
50 50
 if [[ -n "${KUBE_COVER+x}" ]]; then
51 51
     COVERAGE_SPEC="${KUBE_COVER}"
52
-    echo "[WARNING] The flag \$KUBE_COVER for $0 is deprecated, use \$COVERAGE_SPEC instead."
52
+    os::log::warn "The flag \$KUBE_COVER for $0 is deprecated, use \$COVERAGE_SPEC instead."
53 53
 fi
54 54
 
55 55
 if [[ -n "${OUTPUT_COVERAGE+x}" ]]; then
56 56
     COVERAGE_OUTPUT_DIR="${OUTPUT_COVERAGE}"
57
-    echo "[WARNING] The flag \$OUTPUT_COVERAGE for $0 is deprecated, use \$COVERAGE_OUTPUT_DIR instead."
57
+    os::log::warn "The flag \$OUTPUT_COVERAGE for $0 is deprecated, use \$COVERAGE_OUTPUT_DIR instead."
58 58
 fi
59 59
 
60 60
 if [[ -n "${KUBE_RACE+x}" ]]; then
61 61
     DETECT_RACES="${KUBE_RACE}"
62
-    echo "[WARNING] The flag \$KUBE_RACE for $0 is deprecated, use \$DETECT_RACES instead."
62
+    os::log::warn "The flag \$KUBE_RACE for $0 is deprecated, use \$DETECT_RACES instead."
63 63
 fi
64 64
 
65 65
 if [[ -n "${PRINT_PACKAGES+x}" ]]; then
66 66
     DRY_RUN="${PRINT_PACKAGES}"
67
-    echo "[WARNING] The flag \$PRINT_PACKAGES for $0 is deprecated, use \$DRY_RUN instead."
67
+    os::log::warn "The flag \$PRINT_PACKAGES for $0 is deprecated, use \$DRY_RUN instead."
68 68
 fi
69 69
 
70 70
 # Internalize environment variables we consume and default if they're not set
... ...
@@ -237,24 +237,24 @@ if [[ -n "${junit_report}" ]]; then
237 237
 
238 238
     if echo "${summary}" | grep -q ', 0 failed,'; then
239 239
         if [[ "${test_return_code}" -ne "0" ]]; then
240
-            echo "[WARNING] While the jUnit report found no failed tests, the \`go test\` process failed."
241
-            echo "[WARNING] This usually means that the unit test suite failed to compile."
240
+            os::log::warn "While the jUnit report found no failed tests, the \`go test\` process failed."
241
+            os::log::warn "This usually means that the unit test suite failed to compile."
242 242
         fi
243 243
     fi
244 244
 
245 245
     if [[ -s "${test_error_file}" ]]; then
246
-        echo "[WARNING] \`go test\` had the following output to stderr:"
246
+        os::log::warn "\`go test\` had the following output to stderr:"
247 247
         cat "${test_error_file}"
248 248
     fi
249 249
 
250 250
     if grep -q 'WARNING: DATA RACE' "${test_output_file}"; then
251 251
         locations=( $( sed -n '/WARNING: DATA RACE/=' "${test_output_file}") )
252 252
         if [[ "${#locations[@]}" -gt 1 ]]; then
253
-            echo "[WARNING] \`go test\` detected data races."
254
-            echo "[WARNING] Details can be found in the full output file at lines ${locations[*]}."
253
+            os::log::warn "\`go test\` detected data races."
254
+            os::log::warn "Details can be found in the full output file at lines ${locations[*]}."
255 255
         else
256
-            echo "[WARNING] \`go test\` detected a data race."
257
-            echo "[WARNING] Details can be found in the full output file at line ${locations[*]}."
256
+            os::log::warn "\`go test\` detected a data race."
257
+            os::log::warn "Details can be found in the full output file at line ${locations[*]}."
258 258
         fi
259 259
     fi
260 260
 
... ...
@@ -28,7 +28,7 @@ verbose="${VERBOSE:-}"
28 28
 
29 29
 # build the test executable (cgo must be disabled to have the symbol table available)
30 30
 if [[ -n "${OPENSHIFT_SKIP_BUILD:-}" ]]; then
31
-  echo "WARNING: Skipping build due to OPENSHIFT_SKIP_BUILD"
31
+  os::log::warn "Skipping build due to OPENSHIFT_SKIP_BUILD"
32 32
 else
33 33
 	CGO_ENABLED=0 "${OS_ROOT}/hack/build-go.sh" "${package}/${name}.test" -installsuffix=cgo
34 34
 fi
... ...
@@ -9,7 +9,7 @@ source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
9 9
 
10 10
 platform="$(os::build::host_platform)"
11 11
 if [[ "${platform}" != "linux/amd64" ]]; then
12
-  echo "WARNING: Generating completions on ${platform} may not be identical to running on linux/amd64 due to conditional compilation."
12
+  os::log::warn "Generating completions on ${platform} may not be identical to running on linux/amd64 due to conditional compilation."
13 13
 fi
14 14
 
15 15
 OUTPUT_REL_DIR=${1:-""}
... ...
@@ -5,7 +5,7 @@ echo "===== Verifying Generated Completions ====="
5 5
 
6 6
 platform="$(os::build::host_platform)"
7 7
 if [[ "${platform}" != "linux/amd64" ]]; then
8
-  echo "WARNING: Completions cannot be verified on non-Linux systems (${platform})"
8
+  os::log::warn "Completions cannot be verified on non-Linux systems (${platform})"
9 9
   exit 0
10 10
 fi
11 11