gofmt -r "ContainerInfoQuery->ContainerInfoRequest"
This commit is contained in:
parent
6a5a395fbd
commit
6818ac9b9f
@ -70,7 +70,7 @@ func HandleRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) er
|
||||
|
||||
log.Printf("Api - Container(%s)", containerName)
|
||||
|
||||
var query info.ContainerInfoQuery
|
||||
var query info.ContainerInfoRequest
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
err := decoder.Decode(&query)
|
||||
if err != nil && err != io.EOF {
|
||||
|
@ -98,8 +98,7 @@ func (self *Client) httpGetJsonData(data, postData interface{}, url, infoName st
|
||||
|
||||
func (self *Client) ContainerInfo(
|
||||
name string,
|
||||
query *info.ContainerInfoQuery,
|
||||
) (cinfo *info.ContainerInfo, err error) {
|
||||
query *info.ContainerInfoRequest) (cinfo *info.ContainerInfo, err error) {
|
||||
u := self.containerInfoUrl(name)
|
||||
ret := new(info.ContainerInfo)
|
||||
err = self.httpGetJsonData(ret, query, u, fmt.Sprintf("container info for %v", name))
|
||||
|
@ -92,7 +92,7 @@ func TestGetMachineinfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetContainerInfo(t *testing.T) {
|
||||
query := &info.ContainerInfoQuery{
|
||||
query := &info.ContainerInfoRequest{
|
||||
NumStats: 3,
|
||||
NumSamples: 2,
|
||||
CpuUsagePercentiles: []int{10, 50, 90},
|
||||
@ -100,7 +100,7 @@ func TestGetContainerInfo(t *testing.T) {
|
||||
}
|
||||
containerName := "/some/container"
|
||||
cinfo := itest.GenerateRandomContainerInfo(containerName, 4, query, 1*time.Second)
|
||||
client, server, err := cadvisorTestClient(fmt.Sprintf("/api/v1.0/containers%v", containerName), query, &info.ContainerInfoQuery{}, cinfo, t)
|
||||
client, server, err := cadvisorTestClient(fmt.Sprintf("/api/v1.0/containers%v", containerName), query, &info.ContainerInfoRequest{}, cinfo, t)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to get a client %v", err)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ type ContainerReference struct {
|
||||
|
||||
// ContainerInfoQuery is used when users check a container info from the REST api.
|
||||
// It specifies how much data users want to get about a container
|
||||
type ContainerInfoQuery struct {
|
||||
type ContainerInfoRequest struct {
|
||||
NumStats int `json:"num_stats,omitempty"`
|
||||
NumSamples int `json:"num_samples,omitempty"`
|
||||
|
||||
@ -68,10 +68,10 @@ type ContainerInfoQuery struct {
|
||||
MemoryUsagePercentages []int `json:"memory_usage_percentiles,omitempty"`
|
||||
}
|
||||
|
||||
func (self *ContainerInfoQuery) FillDefaults() *ContainerInfoQuery {
|
||||
func (self *ContainerInfoRequest) FillDefaults() *ContainerInfoRequest {
|
||||
ret := self
|
||||
if ret == nil {
|
||||
ret = new(ContainerInfoQuery)
|
||||
ret = new(ContainerInfoRequest)
|
||||
}
|
||||
if ret.NumStats <= 0 {
|
||||
ret.NumStats = 1024
|
||||
|
@ -68,7 +68,7 @@ func GenerateRandomContainerSpec(numCores int) *info.ContainerSpec {
|
||||
return ret
|
||||
}
|
||||
|
||||
func GenerateRandomContainerInfo(containerName string, numCores int, query *info.ContainerInfoQuery, duration time.Duration) *info.ContainerInfo {
|
||||
func GenerateRandomContainerInfo(containerName string, numCores int, query *info.ContainerInfoRequest, duration time.Duration) *info.ContainerInfo {
|
||||
stats := GenerateRandomStats(query.NumStats, numCores, duration)
|
||||
samples, _ := info.NewSamplesFromStats(stats...)
|
||||
if len(samples) > query.NumSamples {
|
||||
|
@ -30,7 +30,7 @@ type Manager interface {
|
||||
Start() error
|
||||
|
||||
// Get information about a container.
|
||||
GetContainerInfo(containerName string, query *info.ContainerInfoQuery) (*info.ContainerInfo, error)
|
||||
GetContainerInfo(containerName string, query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||
|
||||
// Get information about the machine.
|
||||
GetMachineInfo() (*info.MachineInfo, error)
|
||||
@ -106,7 +106,7 @@ func (m *manager) Start() error {
|
||||
}
|
||||
|
||||
// Get a container by name.
|
||||
func (m *manager) GetContainerInfo(containerName string, query *info.ContainerInfoQuery) (*info.ContainerInfo, error) {
|
||||
func (m *manager) GetContainerInfo(containerName string, query *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
log.Printf("Get(%s); %+v", containerName, query)
|
||||
var cont *containerData
|
||||
var ok bool
|
||||
|
@ -77,7 +77,7 @@ func TestGetContainerInfo(t *testing.T) {
|
||||
"/c2",
|
||||
}
|
||||
|
||||
query := &info.ContainerInfoQuery{
|
||||
query := &info.ContainerInfoRequest{
|
||||
NumStats: 256,
|
||||
NumSamples: 128,
|
||||
CpuUsagePercentiles: []int{10, 50, 90},
|
||||
@ -169,7 +169,7 @@ func TestGetContainerInfoWithDefaultValue(t *testing.T) {
|
||||
"/c2",
|
||||
}
|
||||
|
||||
var query *info.ContainerInfoQuery
|
||||
var query *info.ContainerInfoRequest
|
||||
query = query.FillDefaults()
|
||||
|
||||
infosMap := make(map[string]*info.ContainerInfo, len(containers))
|
||||
|
Loading…
Reference in New Issue
Block a user