Skip to content

Commit

Permalink
Merge pull request #91 from kubescape/feat/instanceType
Browse files Browse the repository at this point in the history
Adding instance type
  • Loading branch information
dwertent committed Feb 19, 2024
2 parents a0ceab8 + a829d86 commit cde5aed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions instanceidhandler/interface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package instanceidhandler

import "github.com/kubescape/k8s-interface/instanceidhandler/v1/helpers"

type IInstanceID interface {
// GetInstanceType returns the type of the instance ID
GetInstanceType() helpers.InstanceType

GetAPIVersion() string
GetNamespace() string
GetKind() string
Expand Down
5 changes: 5 additions & 0 deletions instanceidhandler/v1/containerinstance/instanceidhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
stringFormat = helpers.PrefixApiVersion + "%s" + helpers.StringFormatSeparator + helpers.PrefixNamespace + "%s" + helpers.StringFormatSeparator + helpers.PrefixKind + "%s" + helpers.StringFormatSeparator + helpers.PrefixName + "%s" + helpers.StringFormatSeparator + prefixContainer + "%s"
)

const InstanceType helpers.InstanceType = "container"

// ensure that InstanceID implements IInstanceID
var _ instanceidhandler.IInstanceID = &InstanceID{}

Expand All @@ -28,6 +30,9 @@ type InstanceID struct {
containerName string
}

func (id *InstanceID) GetInstanceType() helpers.InstanceType {
return InstanceType
}
func (id *InstanceID) GetAPIVersion() string {
return id.apiVersion
}
Expand Down
2 changes: 2 additions & 0 deletions instanceidhandler/v1/helpers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package helpers

import "github.com/kubescape/k8s-interface/k8sinterface"

type InstanceType string

// metadata keys
const (
metadataPrefix = "kubescape.io"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
stringFormat = helpers.PrefixApiVersion + "%s" + helpers.StringFormatSeparator + helpers.PrefixNamespace + "%s" + helpers.StringFormatSeparator + helpers.PrefixKind + "%s" + helpers.StringFormatSeparator + helpers.PrefixName + "%s" + helpers.StringFormatSeparator + prefixInitContainer + "%s"
)

const InstanceType helpers.InstanceType = "initContainer"

// ensure that InstanceID implements IInstanceID
var _ instanceidhandler.IInstanceID = &InstanceID{}

Expand All @@ -28,6 +30,10 @@ type InstanceID struct {
initContainerName string
}

func (id *InstanceID) GetInstanceType() helpers.InstanceType {
return InstanceType
}

func (id *InstanceID) GetAPIVersion() string {
return id.apiVersion
}
Expand Down

0 comments on commit cde5aed

Please sign in to comment.