Add go report card and fix some errors (#49)
This commit is contained in:
Родитель
a634980400
Коммит
ae6842736b
|
@ -1,4 +1,5 @@
|
|||
[![Build Status](https://travis-ci.org/salesforce/sloop.svg?branch=master)](https://travis-ci.org/salesforce/sloop)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/salesforce/sloop)](https://goreportcard.com/report/github.com/salesforce/sloop)
|
||||
# sloop - Kubernetes History Visualization
|
||||
|
||||
Sloop monitors Kubernetes, recording histories of events and resource state changes
|
||||
|
|
|
@ -217,6 +217,7 @@ func Test_getLastKubeWatchResult(t *testing.T) {
|
|||
err = tables.Db().Update(func(txn badgerwrap.Txn) error {
|
||||
return updateKubeWatchTable(tables, txn, &watchRec, metadata, true)
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = tables.Db().View(func(txn badgerwrap.Txn) error {
|
||||
prevWatch, err := getLastKubeWatchResult(tables, txn, ts, kubeextractor.NodeKind, metadata.Namespace, "differentName")
|
||||
|
|
|
@ -33,7 +33,7 @@ func NewEventCountKeyComparator(kind string, namespace string, name string, uid
|
|||
return &EventCountKey{Kind: kind, Namespace: namespace, Name: name, Uid: uid}
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) TableName() string {
|
||||
func (*EventCountKey) TableName() string {
|
||||
return "eventcount"
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (k *EventCountKey) String() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) ValidateKey(key string) error {
|
||||
func (*EventCountKey) ValidateKey(key string) error {
|
||||
newKey := EventCountKey{}
|
||||
return newKey.Parse(key)
|
||||
}
|
||||
|
|
|
@ -171,16 +171,16 @@ func Test_EventCount_getLastMatchingKeyInPartition_NotFound(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) GetTestKey() string {
|
||||
func (*EventCountKey) GetTestKey() string {
|
||||
k := NewEventCountKey(someTs, "someKind", "someNamespace", "someName", "someUuid")
|
||||
return k.String()
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) GetTestValue() *ResourceEventCounts {
|
||||
func (*EventCountKey) GetTestValue() *ResourceEventCounts {
|
||||
return &ResourceEventCounts{}
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) SetTestKeys() []string {
|
||||
func (*EventCountKey) SetTestKeys() []string {
|
||||
untyped.TestHookSetPartitionDuration(time.Hour)
|
||||
var keys []string
|
||||
i := 'a'
|
||||
|
@ -193,6 +193,6 @@ func (_ *EventCountKey) SetTestKeys() []string {
|
|||
return keys
|
||||
}
|
||||
|
||||
func (_ *EventCountKey) SetTestValue() *ResourceEventCounts {
|
||||
func (*EventCountKey) SetTestValue() *ResourceEventCounts {
|
||||
return &ResourceEventCounts{}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewResourceSummaryKeyComparator(kind string, namespace string, name string,
|
|||
return &ResourceSummaryKey{Kind: kind, Namespace: namespace, Name: name, Uid: uid}
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) TableName() string {
|
||||
func (*ResourceSummaryKey) TableName() string {
|
||||
return "ressum"
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ func (k *ResourceSummaryKey) SetPartitionId(newPartitionId string) {
|
|||
k.PartitionId = newPartitionId
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) ValidateKey(key string) error {
|
||||
func (*ResourceSummaryKey) ValidateKey(key string) error {
|
||||
newKey := ResourceSummaryKey{}
|
||||
return newKey.Parse(key)
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ func helper_update_resourcesummary_table(t *testing.T, keysFn func() []string) (
|
|||
}
|
||||
return nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
return b, rt
|
||||
}
|
||||
|
||||
|
@ -341,16 +342,16 @@ func Test_ResourceSummary_getLastMatchingKeyInPartition_NotFound(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) GetTestKey() string {
|
||||
func (*ResourceSummaryKey) GetTestKey() string {
|
||||
k := NewResourceSummaryKey(someTs, "someKind", "someNamespace", "someName", "someUuid")
|
||||
return k.String()
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) GetTestValue() *ResourceSummary {
|
||||
func (*ResourceSummaryKey) GetTestValue() *ResourceSummary {
|
||||
return &ResourceSummary{}
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) SetTestKeys() []string {
|
||||
func (*ResourceSummaryKey) SetTestKeys() []string {
|
||||
untyped.TestHookSetPartitionDuration(time.Hour)
|
||||
var keys []string
|
||||
i := 'a'
|
||||
|
@ -364,7 +365,7 @@ func (_ *ResourceSummaryKey) SetTestKeys() []string {
|
|||
return keys
|
||||
}
|
||||
|
||||
func (_ *ResourceSummaryKey) SetTestValue() *ResourceSummary {
|
||||
func (*ResourceSummaryKey) SetTestValue() *ResourceSummary {
|
||||
createTimeProto, _ := ptypes.TimestampProto(someFirstSeenTime)
|
||||
return &ResourceSummary{FirstSeen: createTimeProto}
|
||||
}
|
||||
|
|
|
@ -32,31 +32,31 @@ type KeyType struct {
|
|||
PartitionId string
|
||||
}
|
||||
|
||||
func (_ *KeyType) ValidateKey(key string) error {
|
||||
func (*KeyType) ValidateKey(key string) error {
|
||||
panic("Placeholder key type should never be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) TableName() string {
|
||||
func (*KeyType) TableName() string {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) Parse(key string) error {
|
||||
func (*KeyType) Parse(key string) error {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) GetTestKey() string {
|
||||
func (*KeyType) GetTestKey() string {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) SetTestKeys() []string {
|
||||
func (*KeyType) SetTestKeys() []string {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) String() string {
|
||||
func (*KeyType) String() string {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
func (_ *KeyType) GetTestValue() *ValueType {
|
||||
func (*KeyType) GetTestValue() *ValueType {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (p *KeyType) SetTestValue() *ValueType {
|
|||
return &ValueType{}
|
||||
}
|
||||
|
||||
func (_ *KeyType) SetPartitionId(newPartitionId string) {
|
||||
func (*KeyType) SetPartitionId(newPartitionId string) {
|
||||
panic("Placeholder key should not be used")
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ func NewWatchActivityKeyComparator(kind string, namespace string, name string, u
|
|||
return &WatchActivityKey{Kind: kind, Namespace: namespace, Name: name, Uid: uid}
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) TableName() string {
|
||||
func (*WatchActivityKey) TableName() string {
|
||||
return "watchactivity"
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (k *WatchActivityKey) String() string {
|
|||
return fmt.Sprintf("/%v/%v/%v/%v/%v/%v", k.TableName(), k.PartitionId, k.Kind, k.Namespace, k.Name, k.Uid)
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) ValidateKey(key string) error {
|
||||
func (*WatchActivityKey) ValidateKey(key string) error {
|
||||
newKey := WatchActivityKey{}
|
||||
return newKey.Parse(key)
|
||||
}
|
||||
|
|
|
@ -155,16 +155,16 @@ func Test_WatchActivity_getLastMatchingKeyInPartition_NotFound(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) GetTestKey() string {
|
||||
func (*WatchActivityKey) GetTestKey() string {
|
||||
k := NewWatchActivityKey(someMinPartition, someKind, someNamespace, someName, someUid)
|
||||
return k.String()
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) GetTestValue() *WatchActivity {
|
||||
func (*WatchActivityKey) GetTestValue() *WatchActivity {
|
||||
return &WatchActivity{}
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) SetTestKeys() []string {
|
||||
func (*WatchActivityKey) SetTestKeys() []string {
|
||||
untyped.TestHookSetPartitionDuration(time.Hour)
|
||||
var keys []string
|
||||
var partitionId string
|
||||
|
@ -179,6 +179,6 @@ func (_ *WatchActivityKey) SetTestKeys() []string {
|
|||
return keys
|
||||
}
|
||||
|
||||
func (_ *WatchActivityKey) SetTestValue() *WatchActivity {
|
||||
func (*WatchActivityKey) SetTestValue() *WatchActivity {
|
||||
return &WatchActivity{}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func NewWatchTableKeyComparator(kind string, namespace string, name string, time
|
|||
return &WatchTableKey{Kind: kind, Namespace: namespace, Name: name, Timestamp: timestamp}
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) TableName() string {
|
||||
func (*WatchTableKey) TableName() string {
|
||||
return "watch"
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (k *WatchTableKey) String() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) ValidateKey(key string) error {
|
||||
func (*WatchTableKey) ValidateKey(key string) error {
|
||||
newKey := WatchTableKey{}
|
||||
return newKey.Parse(key)
|
||||
}
|
||||
|
|
|
@ -166,16 +166,16 @@ func Test_getLastMatchingKeyInPartition_NotFound(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) GetTestKey() string {
|
||||
func (*WatchTableKey) GetTestKey() string {
|
||||
k := NewWatchTableKey(someMinPartition, someKind, someNamespace, someName, someTs)
|
||||
return k.String()
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) GetTestValue() *KubeWatchResult {
|
||||
func (*WatchTableKey) GetTestValue() *KubeWatchResult {
|
||||
return &KubeWatchResult{}
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) SetTestKeys() []string {
|
||||
func (*WatchTableKey) SetTestKeys() []string {
|
||||
untyped.TestHookSetPartitionDuration(time.Hour)
|
||||
var keys []string
|
||||
var partitionId string
|
||||
|
@ -189,6 +189,6 @@ func (_ *WatchTableKey) SetTestKeys() []string {
|
|||
return keys
|
||||
}
|
||||
|
||||
func (_ *WatchTableKey) SetTestValue() *KubeWatchResult {
|
||||
func (*WatchTableKey) SetTestValue() *KubeWatchResult {
|
||||
return &KubeWatchResult{Kind: someKind}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,9 @@ func help_get_db(t *testing.T) badgerwrap.DB {
|
|||
return txerr
|
||||
}
|
||||
|
||||
txerr = ec.Set(txn, "something", nil)
|
||||
if txerr != nil {
|
||||
return txerr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
return db
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче