github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/command/volume_create_csi.go (about) 1 package command 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/hcl/hcl/ast" 7 "github.com/hashicorp/nomad/api" 8 ) 9 10 func (c *VolumeCreateCommand) csiCreate(client *api.Client, ast *ast.File) int { 11 vol, err := csiDecodeVolume(ast) 12 if err != nil { 13 c.Ui.Error(fmt.Sprintf("Error decoding the volume definition: %s", err)) 14 return 1 15 } 16 17 vols, _, err := client.CSIVolumes().Create(vol, nil) 18 if err != nil { 19 c.Ui.Error(fmt.Sprintf("Error creating volume: %s", err)) 20 return 1 21 } 22 for _, vol := range vols { 23 // note: the command only ever returns 1 volume from the API 24 c.Ui.Output(fmt.Sprintf( 25 "Created external volume %s with ID %s", vol.ExternalID, vol.ID)) 26 } 27 28 return 0 29 }