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

first skeleton structure for szpt-agent #15

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Empty file added sztp-agent/README.md
Empty file.
25 changes: 25 additions & 0 deletions sztp-agent/cmd/daemon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package cmd

import (
"github.com/opiproject/sztp/sztp-agent/pkg/secureAgent"
"github.com/spf13/cobra"
)

func NewDaemonCommand() *cobra.Command {

cmd := &cobra.Command{
Use: "daemon",
Short: "Run the daemon command",
RunE: func(cmd *cobra.Command, args []string) error {
return secureAgent.RunCommandDaemon()
},
}
return cmd
}
25 changes: 25 additions & 0 deletions sztp-agent/cmd/disable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package cmd

import (
"github.com/opiproject/sztp/sztp-agent/pkg/secureAgent"
"github.com/spf13/cobra"
)

func NewDisableCommand() *cobra.Command {

cmd := &cobra.Command{
Use: "disable",
Short: "Run the disable command",
RunE: func(cmd *cobra.Command, args []string) error {
return secureAgent.RunCommandDisable()
},
}
return cmd
}
25 changes: 25 additions & 0 deletions sztp-agent/cmd/enable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package cmd

import (
"github.com/opiproject/sztp/sztp-agent/pkg/secureAgent"
"github.com/spf13/cobra"
)

func NewEnableCommand() *cobra.Command {

cmd := &cobra.Command{
Use: "enable",
Short: "Run the enable command",
RunE: func(cmd *cobra.Command, args []string) error {
return secureAgent.RunCommandEnable()
},
}
return cmd
}
25 changes: 25 additions & 0 deletions sztp-agent/cmd/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package cmd

import (
"github.com/opiproject/sztp/sztp-agent/pkg/secureAgent"
"github.com/spf13/cobra"
)

func NewRunCommand() *cobra.Command {

cmd := &cobra.Command{
Use: "run",
Short: "Exec the run command",
RunE: func(cmd *cobra.Command, args []string) error {
return secureAgent.RunCommandRun()
},
}
return cmd
}
25 changes: 25 additions & 0 deletions sztp-agent/cmd/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package cmd

import (
"github.com/opiproject/sztp/sztp-agent/pkg/secureAgent"
"github.com/spf13/cobra"
)

func NewStatusCommand() *cobra.Command {

cmd := &cobra.Command{
Use: "status",
Short: "Run the status command",
RunE: func(cmd *cobra.Command, args []string) error {
return secureAgent.RunCommandStatus()
},
}
return cmd
}
13 changes: 13 additions & 0 deletions sztp-agent/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module github.com/opiproject/sztp/stpd-agent

go 1.17

require (
github.com/TwiN/go-color v1.1.0
github.com/spf13/cobra v1.5.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
12 changes: 12 additions & 0 deletions sztp-agent/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/TwiN/go-color v1.1.0 h1:yhLAHgjp2iAxmNjDiVb6Z073NE65yoaPlcki1Q22yyQ=
github.com/TwiN/go-color v1.1.0/go.mod h1:aKVf4e1mD4ai2FtPifkDPP5iyoCwiK08YGzGwerjKo0=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
42 changes: 42 additions & 0 deletions sztp-agent/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package main

import (
"github.com/TwiN/go-color"
"github.com/opiproject/sztp/sztp-agent/cmd"

"github.com/spf13/cobra"
"log"
"os"
)

func main() {
command := newCommand()
if err := command.Execute(); err != nil {
log.Fatalf(color.InRed("[ERROR]")+"%s", err.Error())
}
}

func newCommand() *cobra.Command {
c := &cobra.Command{
Use: "sztp",
Short: "aztp is the agent command line interface to work with the sztp workflow",
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
os.Exit(1)
},
}

c.AddCommand(cmd.NewDaemonCommand())
c.AddCommand(cmd.NewStatusCommand())
c.AddCommand(cmd.NewEnableCommand())
c.AddCommand(cmd.NewDisableCommand())

return c
}
21 changes: 21 additions & 0 deletions sztp-agent/pkg/secureAgent/agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

type Agent struct {
ConfigURL string
//TBD the rest of fields
}

func NewAgent(configURL string) *Agent {
return &Agent{ConfigURL: configURL}
}

func (a Agent) GetConfigURL() string {
return a.ConfigURL
}
18 changes: 18 additions & 0 deletions sztp-agent/pkg/secureAgent/daemon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

func RunCommandDaemon() error {
a := NewAgent("")
err := a.execDaemon()
return err
}

func (a *Agent) execDaemon() error {
return nil
}
18 changes: 18 additions & 0 deletions sztp-agent/pkg/secureAgent/disable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

func RunCommandDisable() error {
a := NewAgent("")
err := a.execDisable()
return err
}

func (a *Agent) execDisable() error {
return nil
}
18 changes: 18 additions & 0 deletions sztp-agent/pkg/secureAgent/enable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

func RunCommandEnable() error {
a := NewAgent("")
err := a.execEnable()
return err
}

func (a *Agent) execEnable() error {
return nil
}
18 changes: 18 additions & 0 deletions sztp-agent/pkg/secureAgent/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

func RunCommandRun() error {
a := NewAgent("")
err := a.run()
return err
}

func (a *Agent) run() error {
return nil
}
18 changes: 18 additions & 0 deletions sztp-agent/pkg/secureAgent/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

package secureAgent

func RunCommandStatus() error {
a := NewAgent("")
err := a.execStatus()
return err
}

func (a *Agent) execStatus() error {
return nil
}