Skip to content

Commit

Permalink
k8s: Add URN method to KubernetesCluster. (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Apr 8, 2021
1 parent 3239bef commit 7305c69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ type KubernetesCluster struct {
UpdatedAt time.Time `json:"updated_at,omitempty"`
}

// URN returns the Kubernetes cluster's ID in the format of DigitalOcean URN.
func (kc KubernetesCluster) URN() string {
return ToURN("Kubernetes", kc.ID)
}

// KubernetesClusterUser represents a Kubernetes cluster user.
type KubernetesClusterUser struct {
Username string `json:"username,omitempty"`
Expand Down
16 changes: 13 additions & 3 deletions kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ func TestKubernetesClusters_Get(t *testing.T) {
require.Equal(t, want, got)
}

func TestKubernetesCluster_ToURN(t *testing.T) {
cluster := &KubernetesCluster{
ID: "deadbeef-dead-4aa5-beef-deadbeef347d",
}
want := "do:kubernetes:deadbeef-dead-4aa5-beef-deadbeef347d"
got := cluster.URN()

require.Equal(t, want, got)
}

func TestKubernetesClusters_GetUser(t *testing.T) {
setup()
defer teardown()
Expand Down Expand Up @@ -1034,21 +1044,21 @@ func TestKubernetesClusters_ListAssociatedResourcesForDeletion(t *testing.T) {
}
jBlob := `
{
"volumes":
"volumes":
[
{
"id": "2241",
"name":"test-volume-1"
}
],
"volume_snapshots":
"volume_snapshots":
[
{
"id":"2425",
"name":"test-volume-snapshot-1"
}
],
"load_balancers":
"load_balancers":
[
{
"id":"4235",
Expand Down

0 comments on commit 7305c69

Please sign in to comment.