Skip to content

Commit

Permalink
using gopkg v0.1.2, use gopkg/strings.ToString instead of ustils.ToSt…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
kuritka committed Mar 22, 2021
1 parent d0cef5b commit efc7bf9
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 173 deletions.
29 changes: 15 additions & 14 deletions controllers/gslb_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/AbsaOSS/k8gb/controllers/providers/dns"
"github.com/AbsaOSS/k8gb/controllers/providers/metrics"

str "github.com/AbsaOSS/gopkg/strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -339,8 +340,8 @@ func TestGslbCreatesDNSEndpointCRForHealthyIngressHosts(t *testing.T) {
err = settings.client.Get(context.TODO(), settings.request.NamespacedName, dnsEndpoint)
require.NoError(t, err, "Failed to load DNS endpoint")
got := dnsEndpoint.Spec.Endpoints
prettyGot := utils.ToString(got)
prettyWant := utils.ToString(want)
prettyGot := str.ToString(got)
prettyWant := str.ToString(want)

// assert
assert.Equal(t, want, got, "got:\n %s DNSEndpoint,\n\n want:\n %s", prettyGot, prettyWant)
Expand Down Expand Up @@ -448,8 +449,8 @@ func TestCanGetExternalTargetsFromK8gbInAnotherLocation(t *testing.T) {

got := dnsEndpoint.Spec.Endpoints
hrGot := settings.gslb.Status.HealthyRecords
prettyGot := utils.ToString(got)
prettyWant := utils.ToString(want)
prettyGot := str.ToString(got)
prettyWant := str.ToString(want)

// assert
assert.Equal(t, want, got, "got:\n %s DNSEndpoint,\n\n want:\n %s", prettyGot, prettyWant)
Expand Down Expand Up @@ -532,8 +533,8 @@ func TestReturnsOwnRecordsUsingFailoverStrategyWhenPrimary(t *testing.T) {
err = settings.client.Get(context.TODO(), settings.request.NamespacedName, dnsEndpoint)
require.NoError(t, err, "Failed to get expected DNSEndpoint")
got := dnsEndpoint.Spec.Endpoints
prettyGot := utils.ToString(got)
prettyWant := utils.ToString(want)
prettyGot := str.ToString(got)
prettyWant := str.ToString(want)

// assert
assert.Equal(t, want, got, "got:\n %s DNSEndpoint,\n\n want:\n %s", prettyGot, prettyWant)
Expand Down Expand Up @@ -587,8 +588,8 @@ func TestReturnsExternalRecordsUsingFailoverStrategy(t *testing.T) {
err = settings.client.Get(context.TODO(), settings.request.NamespacedName, dnsEndpoint)
require.NoError(t, err, "Failed to get expected DNSEndpoint")
got := dnsEndpoint.Spec.Endpoints
prettyGot := utils.ToString(got)
prettyWant := utils.ToString(want)
prettyGot := str.ToString(got)
prettyWant := str.ToString(want)

// assert
assert.Equal(t, want, got, "got:\n %s DNSEndpoint,\n\n want:\n %s", prettyGot, prettyWant)
Expand Down Expand Up @@ -722,8 +723,8 @@ func TestCreatesNSDNSRecordsForRoute53(t *testing.T) {
require.NoError(t, err, "Failed to get expected DNSEndpoint")
got := dnsEndpointRoute53.Annotations["k8gb.absa.oss/dnstype"]
gotEp := dnsEndpointRoute53.Spec.Endpoints
prettyGot := utils.ToString(gotEp)
prettyWant := utils.ToString(wantEp)
prettyGot := str.ToString(gotEp)
prettyWant := str.ToString(wantEp)

// assert
assert.Equal(t, want, got, "got:\n %q annotation value,\n\n want:\n %q", got, want)
Expand Down Expand Up @@ -793,8 +794,8 @@ func TestCreatesNSDNSRecordsForNS1(t *testing.T) {
require.NoError(t, err, "Failed to get expected DNSEndpoint")
got := dnsEndpointNS1.Annotations["k8gb.absa.oss/dnstype"]
gotEp := dnsEndpointNS1.Spec.Endpoints
prettyGot := utils.ToString(gotEp)
prettyWant := utils.ToString(wantEp)
prettyGot := str.ToString(gotEp)
prettyWant := str.ToString(wantEp)

// assert
assert.Equal(t, want, got, "got:\n %q annotation value,\n\n want:\n %q", got, want)
Expand Down Expand Up @@ -835,8 +836,8 @@ func TestResolvesLoadBalancerHostnameFromIngressStatus(t *testing.T) {
err = settings.client.Get(context.TODO(), settings.request.NamespacedName, dnsEndpoint)
require.NoError(t, err, "Failed to get expected DNSEndpoint")
got := dnsEndpoint.Spec.Endpoints
prettyGot := utils.ToString(got)
prettyWant := utils.ToString(want)
prettyGot := str.ToString(got)
prettyWant := str.ToString(want)

// assert
assert.Equal(t, want, got, "got:\n %s DNSEndpoint,\n\n want:\n %s", prettyGot, prettyWant)
Expand Down
38 changes: 0 additions & 38 deletions controllers/internal/utils/string.go

This file was deleted.

117 changes: 0 additions & 117 deletions controllers/internal/utils/string_test.go

This file was deleted.

3 changes: 2 additions & 1 deletion controllers/providers/assistant/gslb.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/AbsaOSS/k8gb/controllers/internal/utils"
"github.com/AbsaOSS/k8gb/controllers/logging"

str "github.com/AbsaOSS/gopkg/strings"
"github.com/miekg/dns"
corev1 "k8s.io/api/core/v1"
v1beta1 "k8s.io/api/extensions/v1beta1"
Expand Down Expand Up @@ -131,7 +132,7 @@ func (r *GslbLoggerAssistant) SaveDNSEndpoint(namespace string, i *externaldns.D
if err != nil && errors.IsNotFound(err) {

// Create the DNSEndpoint
log.Info().Msgf("Creating a new DNSEndpoint:\n %s", utils.ToString(i))
log.Info().Msgf("Creating a new DNSEndpoint:\n %s", str.ToString(i))
err = r.client.Create(context.TODO(), i)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/AbsaOSS/k8gb
go 1.15

require (
github.com/AbsaOSS/gopkg v0.0.1
github.com/AbsaOSS/gopkg v0.1.2
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v0.4.0
github.com/go-logr/zapr v0.4.0 // indirect
Expand Down
Loading

0 comments on commit efc7bf9

Please sign in to comment.