Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Agentctl enhancements #1474

Merged
merged 13 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = ""
)
38 changes: 38 additions & 0 deletions api/types/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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
}
45 changes: 45 additions & 0 deletions api/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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 LoggerListOptions struct {
Name 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