[#115] apemanager: Fix type getters
All checks were successful
DCO action / DCO (pull_request) Successful in 43s
Tests and linters / Tests (pull_request) Successful in 1m3s
Tests and linters / Lint (pull_request) Successful in 1m22s
Tests and linters / Tests with -race (pull_request) Successful in 1m21s

* Add type instance check for nil to avoid panic by
  accessing fields.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-09-06 11:39:23 +03:00
parent c11f50efec
commit 61323c388f

View file

@ -16,6 +16,10 @@ func (r *AddChainRequest) SetBody(body *AddChainRequestBody) {
} }
func (r *AddChainRequest) GetBody() *AddChainRequestBody { func (r *AddChainRequest) GetBody() *AddChainRequestBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -30,6 +34,10 @@ func (rb *AddChainRequestBody) SetTarget(target *ape.ChainTarget) {
} }
func (rb *AddChainRequestBody) GetTarget() *ape.ChainTarget { func (rb *AddChainRequestBody) GetTarget() *ape.ChainTarget {
if rb == nil {
return nil
}
return rb.target return rb.target
} }
@ -38,6 +46,10 @@ func (rb *AddChainRequestBody) SetChain(chain *ape.Chain) {
} }
func (rb *AddChainRequestBody) GetChain() *ape.Chain { func (rb *AddChainRequestBody) GetChain() *ape.Chain {
if rb == nil {
return nil
}
return rb.chain return rb.chain
} }
@ -52,6 +64,10 @@ func (r *AddChainResponse) SetBody(body *AddChainResponseBody) {
} }
func (r *AddChainResponse) GetBody() *AddChainResponseBody { func (r *AddChainResponse) GetBody() *AddChainResponseBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -64,6 +80,10 @@ func (rb *AddChainResponseBody) SetChainID(chainID []byte) {
} }
func (rb *AddChainResponseBody) GetChainID() []byte { func (rb *AddChainResponseBody) GetChainID() []byte {
if rb == nil {
return nil
}
return rb.chainID return rb.chainID
} }
@ -78,6 +98,10 @@ func (r *RemoveChainRequest) SetBody(body *RemoveChainRequestBody) {
} }
func (r *RemoveChainRequest) GetBody() *RemoveChainRequestBody { func (r *RemoveChainRequest) GetBody() *RemoveChainRequestBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -92,6 +116,10 @@ func (rb *RemoveChainRequestBody) SetTarget(target *ape.ChainTarget) {
} }
func (rb *RemoveChainRequestBody) GetTarget() *ape.ChainTarget { func (rb *RemoveChainRequestBody) GetTarget() *ape.ChainTarget {
if rb == nil {
return nil
}
return rb.target return rb.target
} }
@ -100,6 +128,10 @@ func (rb *RemoveChainRequestBody) SetChainID(chainID []byte) {
} }
func (rb *RemoveChainRequestBody) GetChainID() []byte { func (rb *RemoveChainRequestBody) GetChainID() []byte {
if rb == nil {
return nil
}
return rb.chainID return rb.chainID
} }
@ -116,6 +148,10 @@ func (r *RemoveChainResponse) SetBody(body *RemoveChainResponseBody) {
} }
func (r *RemoveChainResponse) GetBody() *RemoveChainResponseBody { func (r *RemoveChainResponse) GetBody() *RemoveChainResponseBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -130,6 +166,10 @@ func (r *ListChainsRequest) SetBody(body *ListChainsRequestBody) {
} }
func (r *ListChainsRequest) GetBody() *ListChainsRequestBody { func (r *ListChainsRequest) GetBody() *ListChainsRequestBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -142,6 +182,10 @@ func (rb *ListChainsRequestBody) SetTarget(target *ape.ChainTarget) {
} }
func (rb *ListChainsRequestBody) GetTarget() *ape.ChainTarget { func (rb *ListChainsRequestBody) GetTarget() *ape.ChainTarget {
if rb == nil {
return nil
}
return rb.target return rb.target
} }
@ -156,6 +200,10 @@ func (r *ListChainsResponse) SetBody(body *ListChainsResponseBody) {
} }
func (r *ListChainsResponse) GetBody() *ListChainsResponseBody { func (r *ListChainsResponse) GetBody() *ListChainsResponseBody {
if r == nil {
return nil
}
return r.body return r.body
} }
@ -170,5 +218,9 @@ func (r *ListChainsResponseBody) SetChains(chains []*ape.Chain) {
} }
func (r *ListChainsResponseBody) GetChains() []*ape.Chain { func (r *ListChainsResponseBody) GetChains() []*ape.Chain {
if r == nil {
return nil
}
return r.chains return r.chains
} }