@@ -30,7 +30,6 @@ type putContainerContext struct {
3030 // must be filled when verifying raw data from e
3131 cID cid.ID
3232 cnr containerSDK.Container
33- d containerSDK.Domain
3433}
3534
3635// Process a new container from the user by checking the container sanity
@@ -120,10 +119,11 @@ func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
120119 return fmt .Errorf ("incorrect homomorphic hashing setting: %w" , err )
121120 }
122121
123- // check native name and zone
124- err = checkNNS (ctx , ctx .cnr )
125- if err != nil {
126- return fmt .Errorf ("NNS: %w" , err )
122+ if ctx .e .DomainName != "" { // if PutNamed event => check if values in-container domain name and zone correspond to args
123+ err = checkNNS (ctx .cnr , ctx .e .DomainName , ctx .e .DomainZone )
124+ if err != nil {
125+ return fmt .Errorf ("NNS: %w" , err )
126+ }
127127 }
128128
129129 return nil
@@ -238,19 +238,16 @@ func (cp *Processor) approveDeleteContainer(e containerEvent.RemoveContainerRequ
238238 }
239239}
240240
241- func checkNNS (ctx * putContainerContext , cnr containerSDK.Container ) error {
241+ func checkNNS (cnr containerSDK.Container , name , zone string ) error {
242242 // fetch domain info
243- ctx . d = cnr .ReadDomain ()
243+ d : = cnr .ReadDomain ()
244244
245- // if PutNamed event => check if values in container correspond to args
246- if ctx .e .DomainName != "" {
247- if ctx .e .DomainName != ctx .d .Name () {
248- return fmt .Errorf ("names differ %s/%s" , ctx .e .DomainName , ctx .d .Name ())
249- }
245+ if name != d .Name () {
246+ return fmt .Errorf ("names differ %s/%s" , name , d .Name ())
247+ }
250248
251- if ctx .e .DomainZone != ctx .d .Zone () {
252- return fmt .Errorf ("zones differ %s/%s" , ctx .e .DomainZone , ctx .d .Zone ())
253- }
249+ if zone != d .Zone () {
250+ return fmt .Errorf ("zones differ %s/%s" , zone , d .Zone ())
254251 }
255252
256253 return nil
0 commit comments