feat(cli): Implement address flag for boundary targets create/update

This commit adds CLI support for addresses to be attached directly to a
Target, for all current types of Target (ssh and tcp).

It also clarifies the relevant documentation regarding the autogen of
API option functionality.
This commit is contained in:
Hugo Vieira committed 2023-01-09 15:39:55 +00:00
1 parent 61c90c5623
commit c82d2efb14
12 files changed
+221 -125

No files matched your search

+24
View File
@@ -1,6 +1,7 @@
package targets_test
import (
"context"
"fmt"
"net/http"
"strings"
@@ -379,6 +380,29 @@ func TestList(t *testing.T) {
assert.Equal(filterItem.Id, ul.Items[0].Id)
}
func TestCreateTarget_DirectlyAttachedAddress(t *testing.T) {
tc := controller.NewTestController(t, nil)
t.Cleanup(tc.Shutdown)
client := tc.Client()
at := tc.Token()
client.SetToken(at.Token)
_, proj := iam.TestScopes(t, tc.IamRepo(), iam.WithUserId(at.UserId))
addr := "127.0.0.1"
rsp, err := targets.NewClient(client).Create(context.Background(), "tcp", proj.PublicId,
targets.WithName("test_target"),
targets.WithTcpTargetDefaultPort(22),
targets.WithAddress(addr),
)
require.NoError(t, err)
require.NotNil(t, rsp)
require.NotNil(t, rsp.Item)
// TODO: Assert that the address has been persisted, when the actual
// functionality is implemented - See below.
// require.Equal(t, addr, rsp.Item.Address)
}
func comparableSlice(in []*targets.Target) []targets.Target {
var filtered []targets.Target
for _, i := range in {