Skip to content

Commit

Permalink
Refactor config and agent
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Fabry <[email protected]>
  • Loading branch information
ondrej-fabry committed Apr 17, 2020
1 parent 244bf65 commit c2d2cb5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
20 changes: 0 additions & 20 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,6 @@ type Agent interface {
Error() error
}

var (
DefaultAgent Agent = NewAgent()
)

func Init(opts ...Option) { DefaultAgent.Init(opts...) }
func Start() error { return DefaultAgent.Start() }
func Stop() error { return DefaultAgent.Stop() }
func Wait() error { return DefaultAgent.Wait() }
func Run() error { return DefaultAgent.Run() }

/*func Run() error {
if err := Start(); err != nil {
return err
}
return Wait()
}*/

// NewAgent creates a new agent using given options and registers all flags
// defined for plugins via config.ForPlugin.
func NewAgent(opts ...Option) Agent {
Expand Down Expand Up @@ -126,9 +109,6 @@ func (a *agent) Init(opts ...Option) {
for _, o := range opts {
o(&a.opts)
}
/*if err := a.init(); err != nil {
agentLogger.Fatal("agent init error:", err)
}*/
}

func (a *agent) setup() error {
Expand Down
25 changes: 25 additions & 0 deletions agent/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2020 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 agent

var (
DefaultAgent Agent = NewAgent()
)

func Init(opts ...Option) { DefaultAgent.Init(opts...) }
func Start() error { return DefaultAgent.Start() }
func Stop() error { return DefaultAgent.Stop() }
func Wait() error { return DefaultAgent.Wait() }
func Run() error { return DefaultAgent.Run() }

0 comments on commit c2d2cb5

Please sign in to comment.