Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #56 from manifoldco/gh-status-templated-urls
Browse files Browse the repository at this point in the history
Fill in templated data correctly for status URLs.
  • Loading branch information
jelmersnoeck authored Jun 5, 2018
2 parents a76259a + baa9127 commit f50bdf2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/networkpolicy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func syncSelectedRelease(cl patchClient, ms *v1alpha1.Microservice, networkPolic
return err
}

status, err := buildNetworkStatusForRelease(np, externalRelease)
status, err := buildNetworkStatusForRelease(ms, np, externalRelease)
if err != nil {
log.Printf("Error building Network Status for release %s: %s", name, err)
return err
Expand Down
11 changes: 8 additions & 3 deletions pkg/networkpolicy/network_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import (
"github.com/manifoldco/heighliner/pkg/api/v1alpha1"
)

func buildNetworkStatusForRelease(np *v1alpha1.NetworkPolicy, release *v1alpha1.Release) (v1alpha1.NetworkPolicyStatus, error) {

func buildNetworkStatusForRelease(ms *v1alpha1.Microservice, np *v1alpha1.NetworkPolicy, release *v1alpha1.Release) (v1alpha1.NetworkPolicyStatus, error) {
ns := v1alpha1.NetworkPolicyStatus{
Domains: []v1alpha1.Domain{},
}

for _, record := range np.Spec.ExternalDNS {
url, err := templatedDomain(ms, release, getFullURL(record))
if err != nil {
// XXX: handle gracefully
panic(err)
}

domain := v1alpha1.Domain{
URL: getFullURL(record),
URL: url,
SemVer: release.SemVer,
}
ns.Domains = append(ns.Domains, domain)
Expand Down
6 changes: 4 additions & 2 deletions pkg/networkpolicy/network_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func TestNetworkStatus(t *testing.T) {
},
}

ms := &v1alpha1.Microservice{}

t.Run("with a single domain network policy", func(t *testing.T) {
np := &v1alpha1.NetworkPolicy{
Spec: v1alpha1.NetworkPolicySpec{
Expand All @@ -25,7 +27,7 @@ func TestNetworkStatus(t *testing.T) {
},
}

status, _ := buildNetworkStatusForRelease(np, release)
status, _ := buildNetworkStatusForRelease(ms, np, release)
if len(status.Domains) != 1 {
t.Errorf("Expected status domains to be of length 1, got '%d'", len(status.Domains))
}
Expand All @@ -52,7 +54,7 @@ func TestNetworkStatus(t *testing.T) {
},
}

status, _ := buildNetworkStatusForRelease(np, release)
status, _ := buildNetworkStatusForRelease(ms, np, release)
if len(status.Domains) != 2 {
t.Errorf("Expected status domains to be of length 2, got '%d'", len(status.Domains))
}
Expand Down

0 comments on commit f50bdf2

Please sign in to comment.