mirror of
https://github.com/gravitational/teleport
synced 2024-10-19 16:53:57 +00:00
Implement tctl create -f
for devices (#23801)
* Implement `tctl create -f` for devices * Update e/ reference
This commit is contained in:
parent
5478cde0e6
commit
79d9812a29
2
e
2
e
|
@ -1 +1 @@
|
|||
Subproject commit 219ed708e460ac6f04025fab33861839168d7262
|
||||
Subproject commit 31c66422be08b3931ec03359e0db5d4cb256705f
|
|
@ -784,25 +784,38 @@ func (rc *ResourceCommand) createSAMLIdPServiceProvider(ctx context.Context, cli
|
|||
}
|
||||
|
||||
func (rc *ResourceCommand) createDevice(ctx context.Context, client auth.ClientI, raw services.UnknownResource) error {
|
||||
if rc.IsForced() {
|
||||
fmt.Printf("Warning: Devices cannot be overwritten with the --force flag\n")
|
||||
}
|
||||
|
||||
dev, err := device.UnmarshalDevice(raw.Raw)
|
||||
if err != nil {
|
||||
return trace.Wrap(err)
|
||||
}
|
||||
|
||||
// TODO(codingllama): Figure out a way to call BulkCreateDevices here?
|
||||
_, err = client.DevicesClient().CreateDevice(ctx, &devicepb.CreateDeviceRequest{
|
||||
Device: dev,
|
||||
CreateAsResource: true,
|
||||
})
|
||||
if rc.IsForced() {
|
||||
_, err = client.DevicesClient().UpsertDevice(ctx, &devicepb.UpsertDeviceRequest{
|
||||
Device: dev,
|
||||
CreateAsResource: true,
|
||||
})
|
||||
// err checked below
|
||||
} else {
|
||||
_, err = client.DevicesClient().CreateDevice(ctx, &devicepb.CreateDeviceRequest{
|
||||
Device: dev,
|
||||
CreateAsResource: true,
|
||||
})
|
||||
// err checked below
|
||||
}
|
||||
if err != nil {
|
||||
return trail.FromGRPC(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Device %v/%v added to the inventory\n", dev.AssetTag, devicetrust.FriendlyOSType(dev.OsType))
|
||||
verb := "created"
|
||||
if rc.IsForced() {
|
||||
verb = "updated"
|
||||
}
|
||||
|
||||
fmt.Printf("Device %v/%v %v\n",
|
||||
dev.AssetTag,
|
||||
devicetrust.FriendlyOSType(dev.OsType),
|
||||
verb,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue