Skip to content

Commit

Permalink
Exclude allocation UUID in IP update request. (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Feb 1, 2021
1 parent a776b45 commit e49359e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
24 changes: 8 additions & 16 deletions cmd/metal-api/internal/service/ip-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ func TestUpdateIP(t *testing.T) {
Name: &testdata.IP2.Name,
Description: &testdata.IP2.Description,
},
IPIdentifiable: v1.IPIdentifiable{
IPAddress: testdata.IP1.IPAddress,
},
IPAddress: testdata.IP1.IPAddress,
},
wantedStatus: http.StatusOK,
wantedDescribable: &v1.Describable{
Expand All @@ -262,10 +260,8 @@ func TestUpdateIP(t *testing.T) {
{
name: "moving from ephemeral to static",
updateRequest: v1.IPUpdateRequest{
IPIdentifiable: v1.IPIdentifiable{
IPAddress: testdata.IP1.IPAddress,
},
Type: "static",
IPAddress: testdata.IP1.IPAddress,
Type: "static",
},
wantedStatus: http.StatusOK,
wantedIPBase: &v1.IPBase{
Expand All @@ -277,21 +273,17 @@ func TestUpdateIP(t *testing.T) {
{
name: "moving from static to ephemeral must not be allowed",
updateRequest: v1.IPUpdateRequest{
IPIdentifiable: v1.IPIdentifiable{
IPAddress: testdata.IP2.IPAddress,
},
Type: "ephemeral",
IPAddress: testdata.IP2.IPAddress,
Type: "ephemeral",
},
wantedStatus: http.StatusUnprocessableEntity,
},
{
name: "internal tag machine is allowed",
updateRequest: v1.IPUpdateRequest{
IPIdentifiable: v1.IPIdentifiable{
IPAddress: testdata.IP3.IPAddress,
},
Type: "static",
Tags: []string{machineIDTag1},
IPAddress: testdata.IP3.IPAddress,
Type: "static",
Tags: []string{machineIDTag1},
},
wantedStatus: http.StatusOK,
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/v1/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type IPAllocateRequest struct {
}

type IPUpdateRequest struct {
IPIdentifiable
IPAddress string `json:"ipaddress" modelDescription:"an ip address that can be attached to a machine" description:"the address (ipv4 or ipv6) of this ip" unique:"true" readonly:"true"`
Describable
Type metal.IPType `json:"type" enum:"static|ephemeral" description:"the ip type, ephemeral leads to automatic cleanup of the ip address, static will enable re-use of the ip at a later point in time"`
Tags []string `json:"tags" description:"free tags that you associate with this ip." optional:"true"`
Expand Down
6 changes: 1 addition & 5 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,8 @@
]
},
"v1.IPUpdateRequest": {
"description": "an ip address that can be attached to a machine",
"properties": {
"allocationuuid": {
"description": "a unique identifier for this ip address allocation, can be used to distinguish between ip address allocation over time.",
"type": "string"
},
"description": {
"description": "a description for this entity",
"type": "string"
Expand Down Expand Up @@ -671,7 +668,6 @@
}
},
"required": [
"allocationuuid",
"ipaddress",
"type"
]
Expand Down

0 comments on commit e49359e

Please sign in to comment.