...

Source file src/kubevirt.io/client-go/version/version.go

Documentation: kubevirt.io/client-go/version

     1  /*
     2   * This file is part of the KubeVirt project
     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   * Copyright 2018 Red Hat, Inc.
    17   *
    18   */
    19  
    20  package version
    21  
    22  import (
    23  	"fmt"
    24  	"runtime"
    25  
    26  	"bytes"
    27  	"encoding/json"
    28  )
    29  
    30  func Get() Info {
    31  	return Info{
    32  		GitVersion:   gitVersion,
    33  		GitCommit:    gitCommit,
    34  		GitTreeState: gitTreeState,
    35  		BuildDate:    buildDate,
    36  		GoVersion:    runtime.Version(),
    37  		Compiler:     runtime.Compiler,
    38  		Platform:     fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
    39  	}
    40  }
    41  
    42  func GetCompactJSON() (string, error) {
    43  	v, err := json.Marshal(Get())
    44  	if err != nil {
    45  		return "", err
    46  	}
    47  	compactedBuffer := new(bytes.Buffer)
    48  	err = json.Compact(compactedBuffer, []byte(v))
    49  	if err != nil {
    50  		return "", err
    51  	}
    52  	return compactedBuffer.String(), nil
    53  }
    54  

View as plain text