Skip to content

Commit

Permalink
Merge pull request #6 from AbsaOSS/gopkg-controller
Browse files Browse the repository at this point in the history
gopkg v0.1.1
  • Loading branch information
kuritka authored Mar 19, 2021
2 parents c6504f1 + 78f228d commit 3f998c5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1,214 deletions.
28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ if !k8s.ContainsAnnotations(currentIngress.ObjectMeta, expectedIngress.ObjectMet
}
```

### reflect
Package reflect provides helper functions related to reflection.
#### Overview
Package reflect contains following functions:
- `GetType(v interface{}) string` returns name of any type. Function is useful in factory testing,
when you assert returned type.
#### Usage
```go
impl := NewSomeFactory(someConfig).Get() // returns MyImplementationA, MyImplementationB or nil
// assert
assert.NotNil(t, provider)
assert.Equal(t, "*MyImplementationA", reflect.GetType(impl))
}
```

### shell
Shell command runner
#### Overview
Expand All @@ -111,15 +96,10 @@ o, _ = shell.Execute(cmd)
### strings
Package strings provide helper functions related to string
#### Overview
Package contains following functions:
- `MergeAnnotations(target *metav1.ObjectMeta, source *metav1.ObjectMeta)` adds or updates annotations from
defaultSource to defaultTarget
- `ContainsAnnotations(target *metav1.ObjectMeta, source *metav1.ObjectMeta) bool` checks if defaultTarget
contains all annotations of defaultSource
Any kubernetes resource having ObjectMeta can be passed.
Package strings contains extensions of standard strings and formatting functions:
- `Format(v interface{}) string` Format converts type to formatted string. If value is struct, function returns formatted JSON.

#### Usage
```go
if !k8s.ContainsAnnotations(currentIngress.ObjectMeta, expectedIngress.ObjectMeta) {
MergeAnnotations(currentIngress.ObjectMeta, expectedIngress.ObjectMeta)
}
log.Debug().Msgf("current config: %s",utils.ToString(config))
```
59 changes: 0 additions & 59 deletions controller/result.go

This file was deleted.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ require (
github.com/stretchr/testify v1.7.0
k8s.io/api v0.20.4
k8s.io/apimachinery v0.20.4
sigs.k8s.io/controller-runtime v0.8.3
)
Loading

0 comments on commit 3f998c5

Please sign in to comment.