From 8ba06fb09975be8042c07b538f643d18b35907e8 Mon Sep 17 00:00:00 2001 From: Michael Gaffney Date: Wed, 3 Jun 2020 09:30:47 -0400 Subject: [PATCH] Change min address size to allow '1.1.1.1' address --- internal/db/migrations/postgres.gen.go | 2 +- internal/db/migrations/postgres/10_static_host.up.sql | 2 +- internal/host/static/repository.go | 2 +- internal/host/static/static_test.go | 8 ++++---- internal/host/static/store/static.pb.go | 2 +- .../controller/storage/host/static/store/v1/static.proto | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/db/migrations/postgres.gen.go b/internal/db/migrations/postgres.gen.go index f7e88d45ea..b8b81f597f 100644 --- a/internal/db/migrations/postgres.gen.go +++ b/internal/db/migrations/postgres.gen.go @@ -571,7 +571,7 @@ begin; description text, address text not null check( - length(trim(address)) > 7 + length(trim(address)) > 6 and length(trim(address)) < 256 ), diff --git a/internal/db/migrations/postgres/10_static_host.up.sql b/internal/db/migrations/postgres/10_static_host.up.sql index 5d111d5e5a..95f6d8f96f 100644 --- a/internal/db/migrations/postgres/10_static_host.up.sql +++ b/internal/db/migrations/postgres/10_static_host.up.sql @@ -40,7 +40,7 @@ begin; description text, address text not null check( - length(trim(address)) > 7 + length(trim(address)) > 6 and length(trim(address)) < 256 ), diff --git a/internal/host/static/repository.go b/internal/host/static/repository.go index 0f8464e1f4..5d1828aed6 100644 --- a/internal/host/static/repository.go +++ b/internal/host/static/repository.go @@ -275,7 +275,7 @@ func (r *Repository) CreateHost(ctx context.Context, h *Host, opt ...Option) (*H // h must contain a valid PublicId. Only h.Name, h.Description, and // h.Address can be updated. If h.Name is set to a non-empty string, it // must be unique within h.StaticHostCatalogId. h.Address must contain a -// string where 7 < len(h.Address) < 256. +// string where 6 < len(h.Address) < 256. // // An attribute of h will be set to NULL in the database if the attribute // in h is the zero value and it is included in fieldMask. diff --git a/internal/host/static/static_test.go b/internal/host/static/static_test.go index ea6d06f2e5..1123804f94 100644 --- a/internal/host/static/static_test.go +++ b/internal/host/static/static_test.go @@ -192,12 +192,12 @@ func TestHost_New(t *testing.T) { name: "address-to-short", args: args{ catalogId: cat.GetPublicId(), - address: "1234567", + address: "123456", }, want: &Host{ Host: &store.Host{ StaticHostCatalogId: cat.GetPublicId(), - Address: "1234567", + Address: "123456", }, }, wantWriteErr: true, @@ -206,12 +206,12 @@ func TestHost_New(t *testing.T) { name: "minimum-address", args: args{ catalogId: cat.GetPublicId(), - address: "12345678", + address: "1234567", }, want: &Host{ Host: &store.Host{ StaticHostCatalogId: cat.GetPublicId(), - Address: "12345678", + Address: "1234567", }, }, }, diff --git a/internal/host/static/store/static.pb.go b/internal/host/static/store/static.pb.go index c88f06a505..ce4c7f609f 100644 --- a/internal/host/static/store/static.pb.go +++ b/internal/host/static/store/static.pb.go @@ -154,7 +154,7 @@ type Host struct { // @inject_tag: gorm:"not_null" StaticHostCatalogId string `protobuf:"bytes,6,opt,name=static_host_catalog_id,json=staticHostCatalogId,proto3" json:"static_host_catalog_id,omitempty" gorm:"not_null"` // address is the IP Address or DNS name of the host. It must be set and - // it must be 7 < len(address) < 256. + // it must be 6 < len(address) < 256. // @inject_tag: gorm:"not_null" Address string `protobuf:"bytes,7,opt,name=address,proto3" json:"address,omitempty" gorm:"not_null"` } diff --git a/internal/proto/local/controller/storage/host/static/store/v1/static.proto b/internal/proto/local/controller/storage/host/static/store/v1/static.proto index 837d8b05f3..2e63f55c36 100644 --- a/internal/proto/local/controller/storage/host/static/store/v1/static.proto +++ b/internal/proto/local/controller/storage/host/static/store/v1/static.proto @@ -61,7 +61,7 @@ message Host { string static_host_catalog_id = 6; // address is the IP Address or DNS name of the host. It must be set and - // it must be 7 < len(address) < 256. + // it must be 6 < len(address) < 256. // @inject_tag: gorm:"not_null" string address = 7; }