Skip to content

Commit

Permalink
refactor: Agentctl enhancements (ligato#1474)
Browse files Browse the repository at this point in the history
* Fix doc comment for agentctl

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Use defined name in usage line

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Fix http client

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Refactor agentctl

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Fix problems reported by golangcibot

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Cleanup client options

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Define KVDBAPIClient

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Cleanup code

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Resolve comments

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Resolve comments

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Fix response

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Resolve review comments

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>

* Remove unused model list option

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
  • Loading branch information
ondrej-fabry authored and VladoLavor committed Oct 4, 2019
1 parent 7e70a01 commit 9a195a0
Show file tree
Hide file tree
Showing 95 changed files with 5,146 additions and 9,164 deletions.
42 changes: 20 additions & 22 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ required = [
name = "github.com/gogo/protobuf"
version = "1.2.0"

[[constraint]]
branch = "master"
name = "github.com/logrusorgru/aurora.git"

[[constraint]]
name = "github.com/namsral/flag"
version = "1.7.4-pre"
Expand Down Expand Up @@ -106,7 +102,3 @@ required = [
[[prune.project]]
name = "github.com/gogo/protobuf"
unused-packages = false

[[constraint]]
branch = "master"
name = "github.com/common-nighthawk/go-figure"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ agent: ## Build agent
@echo "=> installing agent ${VERSION}"
@go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent

agentctl: # Build agentctl
agentctl: ## Build agentctl
@echo "=> installing agentctl ${VERSION}"
@go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/agentctl

Expand Down Expand Up @@ -276,7 +276,7 @@ prod-image: ## Build production image


.PHONY: help \
build clean install \
agent agentctl build clean install \
cmd examples clean-examples \
test test-cover test-cover-html test-cover-xml \
generate genereate-binapi generate-proto get-binapi-generators get-proto-generators \
Expand Down
19 changes: 19 additions & 0 deletions api/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package api

const (
DefaultVersion = ""
)
39 changes: 39 additions & 0 deletions api/types/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2019 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package types

type Model struct {
Name string
Module string
Type string
Version string
Alias string `json:",omitempty"`
KeyPrefix string
NameTemplate string
ProtoName string
ProtoFile string
}

type ModelListOptions struct {
}

type SchedulerDumpOptions struct {
KeyPrefix string
View string
}

type SchedulerValuesOptions struct {
KeyPrefix string
}
41 changes: 41 additions & 0 deletions api/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package types

// ErrorResponse represents an error.
type ErrorResponse struct {
Message string `json:"message"`
}

// ComponentVersion describes the version information for a specific component.
type ComponentVersion struct {
Name string
Version string
Details map[string]string `json:",omitempty"`
}

// Version contains response of Engine API:
// GET "/version"
type Version struct {
Components []ComponentVersion

Version string
APIVersion string
MinAPIVersion string
GitCommit string
GoVersion string
Os string
Arch string
KernelVersion string
BuildTime string
}

// Ping contains response of Engine API:
// GET "/_ping"
type Ping struct {
APIVersion string
OSType string
}

type Logger struct {
Logger string `json:"logger,omitempty"`
Level string `json:"level,omitempty"`
}
19 changes: 14 additions & 5 deletions cmd/agentctl/agentctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package main

import (
"fmt"
"os"

agentcli "github.com/ligato/vpp-agent/cmd/agentctl/cli"
"github.com/ligato/vpp-agent/cmd/agentctl/commands"
)

Expand All @@ -30,13 +32,20 @@ const logo = `
`

func runAgentctl(cli *agentcli.AgentCli) error {
cmd, err := commands.NewRootCommand(cli)
if err != nil {
return err
}
cmd.Long = logo
return cmd.Execute()
}

func main() {
cli := commands.NewAgentCli()

agentCtl := commands.NewRootCommand(cli)
agentCtl.Long = logo

if err := agentCtl.Execute(); err != nil {
os.Exit(-1)
if err := runAgentctl(cli); err != nil {
fmt.Fprintln(cli.Err(), err)
os.Exit(commands.ExitCode(err))
}
}
Loading

0 comments on commit 9a195a0

Please sign in to comment.