https://github.com/cilium/cilium
Raw File
Tip revision: c9d9f7e34b10ad4f0295a56926dfe14dbeaa79e0 authored by André Martins on 23 November 2021, 00:47:39 UTC
Prepare for release v1.11.0-rc3
Tip revision: c9d9f7e
unamecheck.go
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 Authors of Cilium

package main

import (
	"bytes"
	"os/exec"
	"regexp"
)

var linuxRegexp = regexp.MustCompile(`(?i)linux`)

// A unameCheck checks the output of uname -a.
type unameCheck struct{}

func (unameCheck) Name() string {
	return "uname"
}

func (unameCheck) Run() (checkResult, string) {
	output, err := exec.Command("uname", "-a").CombinedOutput()
	if err != nil {
		return checkFailed, err.Error()
	}

	message := string(bytes.TrimSpace(output))
	if !linuxRegexp.Match(output) {
		return checkWarning, message
	}

	return checkOK, message
}

func (unameCheck) Hint() string {
	return ""
}
back to top