Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #38 from joyent/36-add-hardware-cli
Browse files Browse the repository at this point in the history
Add CLI for hardware vendors and products
  • Loading branch information
perigrin authored Jan 16, 2020
2 parents e2a0b93 + fafab8f commit a5b3c5b
Show file tree
Hide file tree
Showing 29 changed files with 1,360 additions and 7,946 deletions.
1 change: 0 additions & 1 deletion builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func (b *Builds) GetByName(name string) (build Build) {
panic(res)
}
return

}

func (b *Builds) Create(name, description string, admins []map[string]string) (build Build) {
Expand Down
5 changes: 5 additions & 0 deletions builds_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import (
)

func TestBuildAPIintegration(t *testing.T) {
defer errorHandler()

setupAPIClient()
r := setupRecorder("fixtures/conch-v3/builds")
defer r() // Make sure recorder is stopped once done with it

var build Build
t.Run("create a build", func(t *testing.T) {
defer errorHandler()
fake := newTestBuild()
build = API.Builds().Create(
fake.Name,
Expand All @@ -20,10 +23,12 @@ func TestBuildAPIintegration(t *testing.T) {
})

t.Run("get all builds", func(t *testing.T) {
defer errorHandler()
_ = API.Builds().GetAll()
})

t.Run("get a specific build", func(t *testing.T) {
defer errorHandler()
_ = API.Builds().Get(build.ID)
})
}
18 changes: 13 additions & 5 deletions devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,17 @@ type DeviceReport map[string]interface{}

type DeviceLocation struct {
Datacenter Datacenter `json:"datacenter"`
Room Room `json:"datacenter_room"`
Rack Rack `json:"rack"`
RackUnitStart int `json:"rack_unit_start" faker:"rack_unit_start"`
AZ string `json:"az"`
RoomName string `json:"datacenter_room"`
Rack Rack
RackName string `json:"rack"`
RackUnitStart int `json:"rack_unit_start" faker:"rack_unit_start"`
TargetHardwareProduct struct {
ID uuid.UUID `json:"id" faker"uuid"`
Name string `json:"name"`
Alias string `json:"alias"`
Vendor string `json:"hardware_vendor_id"`
SKU string `json:"sku,omitempty"`
} `json:"target_hardware_product"`
}

Expand Down Expand Up @@ -217,7 +220,7 @@ func (ds *Devices) DeleteLocation(id string) {
uri := fmt.Sprintf("/device/%s/location", url.PathEscape(id))

res := ds.Do(ds.Sling().New().Delete(uri))
if res.StatusCode() != 204 {
if res.IsError() {
panic(res)
}
}
Expand Down Expand Up @@ -294,7 +297,9 @@ type deviceCore struct {
Validated time.Time `json:"validated,omitempty" faker:"-"`
Phase string `json:"phase"`

BuildID uuid.UUID `json:"build_id" faker:"-"`
BuildID uuid.UUID `json:"build_id" faker:"-"`
BuildName string `json:"build_name"`
SKU string `json:"sku"`
}

type Disk struct {
Expand Down Expand Up @@ -352,6 +357,9 @@ func (d DetailedDevice) String() string {
}

var rackRole RackRole
if (d.Location.Rack == Rack{}) {
d.Location.Rack = API.Racks().GetByName(d.Location.RackName)
}
if (d.Location.Rack.RoleID != uuid.UUID{}) {
rackRole = API.RackRoles().Get(d.Location.Rack.RoleID)
}
Expand Down
1 change: 0 additions & 1 deletion devices_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func TestDeviceAPIIntegration(t *testing.T) {
defer r() // Make sure recorder is stopped once done with it

f := newFixture()
f.setupBuild()
f.setupRackLayout()
defer f.reset()

Expand Down
46 changes: 23 additions & 23 deletions fixtures/conch-v3/builds.yaml

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions fixtures/conch-v3/datacenter.yaml

Large diffs are not rendered by default.

Loading

0 comments on commit a5b3c5b

Please sign in to comment.