From 2c131a1bd64ac959d04114845878f5d2a77d37c8 Mon Sep 17 00:00:00 2001 From: Vinayak Shinde Date: Tue, 16 Apr 2024 08:03:38 +0000 Subject: [PATCH] [PWX-36749] Bumped up SDK version and added NFS endpoint IP format validation --- SDK_CHANGELOG.md | 4 ++++ api/server/sdk/api/api.swagger.json | 2 +- api/spec/spec_handler.go | 4 ++++ api/spec/spec_handler_test.go | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/SDK_CHANGELOG.md b/SDK_CHANGELOG.md index d1a0371e7..fc5ffe993 100644 --- a/SDK_CHANGELOG.md +++ b/SDK_CHANGELOG.md @@ -2,6 +2,10 @@ ## Releases +### v0.182.0 - (04/16/2024) + +* Added NFS Endpoint in volume spec + ### v0.181.0 - (03/20/2024) * Add servers and APIs for defrag and schedule services diff --git a/api/server/sdk/api/api.swagger.json b/api/server/sdk/api/api.swagger.json index 887ef42d6..0ad78a6c2 100644 --- a/api/server/sdk/api/api.swagger.json +++ b/api/server/sdk/api/api.swagger.json @@ -6594,7 +6594,7 @@ }, "info": { "title": "OpenStorage SDK", - "version": "0.181.0" + "version": "0.182.0" }, "openapi": "3.0.0", "paths": { diff --git a/api/spec/spec_handler.go b/api/spec/spec_handler.go index 09a18c51d..681ebadd0 100644 --- a/api/spec/spec_handler.go +++ b/api/spec/spec_handler.go @@ -2,6 +2,7 @@ package spec import ( "fmt" + "net" "regexp" "strconv" "strings" @@ -655,6 +656,9 @@ func (d *specHandler) UpdateSpecFromOpts(opts map[string]string, spec *api.Volum if spec.ProxySpec.PureFileSpec == nil { spec.ProxySpec.PureFileSpec = &api.PureFileSpec{} } + if net.ParseIP(v) == nil { + return nil, nil, nil, fmt.Errorf("invalid Pure NFS endpoint: %v", v) + } spec.ProxySpec.PureFileSpec.NfsEndpoint = v case api.SpecIoThrottleRdIOPS: if spec.IoThrottle == nil { diff --git a/api/spec/spec_handler_test.go b/api/spec/spec_handler_test.go index 3a02ed0b0..5b8d558a1 100644 --- a/api/spec/spec_handler_test.go +++ b/api/spec/spec_handler_test.go @@ -523,7 +523,21 @@ func TestPureNFSEndpoint(t *testing.T) { require.NoError(t, err) proxySpec := spec.GetProxySpec() require.NotNil(t, proxySpec) - require.Equal(t, proxySpec.GetPureFileSpec().GetNFSEndpoint(), nfsEndpoint) + require.Equal(t, proxySpec.GetPureFileSpec().GetNfsEndpoint(), nfsEndpoint) + + nfsEndpoint = "" + _, _, _, err = s.SpecFromOpts(map[string]string{ + api.SpecPureNFSEnpoint: nfsEndpoint, + }) + require.Error(t, err, "Failed to parse nfs endpoint parameter") + require.ErrorContains(t, err, "invalid Pure NFS endpoint") + + nfsEndpoint = "abc" + _, _, _, err = s.SpecFromOpts(map[string]string{ + api.SpecPureNFSEnpoint: nfsEndpoint, + }) + require.Error(t, err, "Failed to parse nfs endpoint parameter") + require.ErrorContains(t, err, "invalid Pure NFS endpoint") } func TestXattr(t *testing.T) {