Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new resource opsgenie_team_membership, refs #65 #156

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
ci-test:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: fmt check
run: make fmtcheck

-
name: Test GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: build --skip-validate --rm-dist
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.3 (August 14, 2020)

IMPROVEMENTS:
* **Integration Actions :** add priority for create action (#157)

## 0.4.2 (August 13, 2020)

BUGFIX:
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PKG_NAME=opsgenie
default: build

build: fmtcheck
go install
goreleaser build --skip-validate --rm-dist

test: fmtcheck
go test -i $(TEST) || exit 1
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.14
require (
github.com/hashicorp/go-retryablehttp v0.6.6
github.com/hashicorp/terraform-plugin-sdk v1.15.0
github.com/opsgenie/opsgenie-go-sdk-v2 v1.1.2-0.20200728120710-9ec24baa3544
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.1-0.20200814082615-0451657a72bb
github.com/pkg/errors v0.8.1
)
14 changes: 2 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U=
github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
Expand Down Expand Up @@ -52,7 +51,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4 h1:87PNWwrRvUSnqS4dlcBU/ftvOIBep4sYuBLlh6rX2wk=
Expand All @@ -61,7 +59,6 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down Expand Up @@ -142,12 +139,10 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
Expand All @@ -174,8 +169,8 @@ github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY7
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/opsgenie/opsgenie-go-sdk-v2 v1.1.2-0.20200728120710-9ec24baa3544 h1:CcYQ/JYODbXvSyVwc7CDh8OhK0rGMrxcxqJkTvR8KA4=
github.com/opsgenie/opsgenie-go-sdk-v2 v1.1.2-0.20200728120710-9ec24baa3544/go.mod h1:VOkJ7STzYj+nXRhMcBTcmt8uZZ17KZKJdZtJpgHLbT8=
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.1-0.20200814082615-0451657a72bb h1:jrc1HVw4t8jZxd4LhiRCF9zp+NUsufZ5+KbLZ76ENOg=
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.1-0.20200814082615-0451657a72bb/go.mod h1:VOkJ7STzYj+nXRhMcBTcmt8uZZ17KZKJdZtJpgHLbT8=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand All @@ -200,12 +195,10 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/vmihailenco/msgpack v3.3.3+incompatible h1:wapg9xDUZDzGCNFlwc5SqI1rvcciqcxEHac4CYj89xI=
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.2.1 h1:vGMsygfmeCl4Xb6OA5U5XVAaQZ69FvoG7X2jUtQujb8=
github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
Expand Down Expand Up @@ -264,7 +257,6 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -302,15 +294,13 @@ google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRn
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200310143817-43be25429f5a h1:lRlI5zu6AFy3iU/F8YWyNrAmn/tPCnhiTxfwhWb76eU=
google.golang.org/genproto v0.0.0-20200310143817-43be25429f5a/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
Expand Down
1 change: 1 addition & 0 deletions opsgenie/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func Provider() terraform.ResourceProvider {

"opsgenie_team": resourceOpsGenieTeam(),
"opsgenie_team_routing_rule": resourceOpsGenieTeamRoutingRule(),
"opsgenie_team_membership": resourceOpsGenieTeamMembership(),
"opsgenie_user": resourceOpsGenieUser(),
"opsgenie_user_contact": resourceOpsGenieUserContact(),
"opsgenie_notification_policy": resourceOpsGenieNotificationPolicy(),
Expand Down
8 changes: 8 additions & 0 deletions opsgenie/resource_opsgenie_integration_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ func resourceOpsgenieIntegrationAction() *schema.Resource {
Optional: true,
Default: 1,
},
"priority": {
Type: schema.TypeString,
Optional: true,
},
"filter": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -513,6 +517,9 @@ func expandOpsgenieIntegrationActions(input interface{}) []integration.Integrati
action.Order = inputMap["order"].(int)
action.User = inputMap["user"].(string)
action.Note = inputMap["note"].(string)
if priority := inputMap["priority"]; priority != nil {
action.Priority = priority.(string)
}
filters := expandOpsgenieFilter(inputMap["filter"].([]interface{}))
action.Filter = &filters

Expand Down Expand Up @@ -593,6 +600,7 @@ func flattenOpsgenieIntegrationActions(input []integration.IntegrationAction) []
actionMap["filter"] = flattenOpsgenieFilter(action.Filter)
if action.Type == "create" {
actionMap["source"] = action.Source
actionMap["priority"] = action.Priority
actionMap["message"] = action.Message
actionMap["description"] = action.Description
actionMap["entity"] = action.Entity
Expand Down
1 change: 1 addition & 0 deletions opsgenie/resource_opsgenie_integration_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ resource "opsgenie_integration_action" "test_api" {
message = "{{message}}"
description = "{{description}}"
entity = "{{entity}}"
priority = "P2"
alert_actions = ["Check error rate"]
extra_properties = map(
"Environment", "test-env",
Expand Down
159 changes: 159 additions & 0 deletions opsgenie/resource_opsgenie_team_membership.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package opsgenie

import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/opsgenie/opsgenie-go-sdk-v2/team"
"log"
"strings"
)

func resourceOpsGenieTeamMembership() *schema.Resource { //TODO encode the e-mail addrs (e.g. because of +)? https://github.com/opsgenie/opsgenie-go-sdk-v2/issues/62
arnisoph marked this conversation as resolved.
Show resolved Hide resolved
return &schema.Resource{
Create: resourceOpsGenieTeamMembershipCreate,
Read: handleNonExistentResource(resourceOpsGenieTeamMembershipRead),
//Update: resourceOpsGenieTeamMembershipUpdate, // requires https://github.com/opsgenie/opsgenie-go-sdk-v2/issues/59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't quite understand the issue in go-sdk can you describe the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to update a member ship with go-sdk, that's why don't support it here too. Updating a membership would only involve changing a role without removing+adding the user from the team.

Delete: resourceOpsGenieTeamMembershipDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"user_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"role": {
Type: schema.TypeString,
Optional: true,
Default: "user",
ForceNew: true,
},
"team_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
}
}

func resourceOpsGenieTeamMembershipCreate(d *schema.ResourceData, meta interface{}) error {

userID := d.Get("user_id").(string)
role := d.Get("role").(string)
teamID := d.Get("team_id").(string)

log.Printf("[INFO] Adding user %q to team %q", teamID, userID)

client, err := team.NewClient(meta.(*OpsgenieClient).client.Config)
if err != nil {
return err
}

// add member to team
_, err = client.AddMember(context.Background(), &team.AddTeamMemberRequest{
TeamIdentifierType: team.Id,
TeamIdentifierValue: teamID,
User: team.User{
ID: userID,
},
Role: role,
})
if err != nil {
return err
}

d.SetId(buildTwoPartID(teamID, userID))

return resourceOpsGenieTeamMembershipRead(d, meta)
}

func resourceOpsGenieTeamMembershipRead(d *schema.ResourceData, meta interface{}) error {

teamID, userID, err := parseTwoPartID(d.Id(), "teamID", "userID")
if err != nil {
return err
}

getRequest := &team.GetTeamRequest{
IdentifierType: team.Id,
IdentifierValue: teamID,
}

log.Printf("[INFO] Retrieving membership of user %q in team %q", userID, teamID)

client, err := team.NewClient(meta.(*OpsgenieClient).client.Config)
if err != nil {
return err
}

getResponse, err := client.Get(context.Background(), getRequest)
if err != nil {
return err
}

role, err := getUserRole(userID, teamID, getResponse.Members)
if err != nil {
return err
}

d.Set("user_id", userID)
d.Set("role", role)
d.Set("team_id", teamID)

return nil
}

func resourceOpsGenieTeamMembershipDelete(d *schema.ResourceData, meta interface{}) error {
userID := d.Get("user_id").(string)
teamID := d.Get("team_id").(string)

log.Printf("[INFO] Deleting membership of user %q in team %q", userID, teamID)

client, err := team.NewClient(meta.(*OpsgenieClient).client.Config)
if err != nil {
return err
}

_, err = client.RemoveMember(context.Background(), &team.RemoveTeamMemberRequest{
TeamIdentifierType: team.Id,
TeamIdentifierValue: teamID,
MemberIdentifierType: team.Id,
arnisoph marked this conversation as resolved.
Show resolved Hide resolved
MemberIdentifierValue: userID,
})
if err != nil {
return err
}

return nil
}

func getUserRole(userID string, teamID string, input []team.Member) (string, error) {
role := ""

for _, inputMember := range input {
if inputMember.User.ID == userID {
role = inputMember.Role
return role, nil
}
}

return "", fmt.Errorf("did not found user %q in team %q (%#v)", userID, teamID, input)
}

// format the strings into an id `a:b`
func buildTwoPartID(a, b string) string {
return fmt.Sprintf("%s:%s", a, b)
}

// return the pieces of id `left:right` as left, right
func parseTwoPartID(id, left, right string) (string, string, error) {
parts := strings.SplitN(id, ":", 2)
if len(parts) != 2 {
return "", "", fmt.Errorf("unexpected ID format %q, expected %s:%s", id, left, right)
}

return parts[0], parts[1], nil
}
Loading