Skip to content

Commit

Permalink
Add kubernetes resource
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Jul 25, 2019
1 parent 75f3003 commit f73e235
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/add_resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Add a resource

43 changes: 43 additions & 0 deletions resource/kubernetes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package resource

import "github.com/SimonBaeumer/goss/system"

type Kubernetes struct {
Title string `json:"title,omitempty" yaml:"title,omitempty"`
Meta meta `json:"meta,omitempty" yaml:"meta,omitempty"`
Name string `json:"-" yaml:"-"`
ResourceType string `json:"resource-type" yaml:"resource-type"`
}

func (k *Kubernetes) ID() string {
return k.Name
}

func (k *Kubernetes) SetID(id string) {
k.Name = id
}

func (k *Kubernetes) GetTitle() string {
return k.Title
}

func (k *Kubernetes) GetMeta() meta {
return k.Meta
}

func (k *Kubernetes) Validate(sys *system.System) []TestResult {
var results []TestResult

result := TestResult{
Successful: true,
Result: SUCCESS,
}

results = append(results, result)
return results
}

// TODO: add feature
func NewKubernetes() {

}
2 changes: 1 addition & 1 deletion resource/resource_list_genny.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cheekybits/genny/generic"
)

//go:generate genny -in=$GOFILE -out=resource_list.go gen "ResourceType=Addr,Command,DNS,File,Gossfile,Group,Package,Port,Process,Service,User,KernelParam,Mount,Interface,HTTP"
//go:generate genny -in=$GOFILE -out=resource_list.go gen "ResourceType=Addr,Command,DNS,File,Gossfile,Group,Package,Port,Process,Service,User,KernelParam,Mount,Interface,HTTP,Kubernetes"
//go:generate sed -i -e "/^\\/\\/ +build genny/d" resource_list.go
//go:generate goimports -w resource_list.go resource_list.go

Expand Down
22 changes: 22 additions & 0 deletions system/kubernetes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package system

type Kubernetes interface {
Status() string
ResourceType() string
}

type DefKubernetes struct {
pod string
}

func (k *DefKubernetes) setup() error {
return nil
}

func Status() string {
return "pending"
}

func ResourceType() string {
return "pod"
}
1 change: 1 addition & 0 deletions system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type System struct {
NewMount func(string, *System, util2.Config) Mount
NewInterface func(string, *System, util2.Config) Interface
NewHTTP func(string, *System, util2.Config) HTTP
NewKubernetes func(string, *System, util2.Config) Kubernetes
ports map[string][]GOnetstat.Process
portsOnce sync.Once
procMap map[string][]ps.Process
Expand Down

0 comments on commit f73e235

Please sign in to comment.