[#115] apemanager: Fix type getters

* 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 8f268ad512
3 changed files with 68 additions and 0 deletions

View file

@ -330,10 +330,18 @@ func (bt *BearerTokenBody) SetEACL(v *Table) {
}
func (t *APEOverride) GetTarget() *ape.ChainTarget {
if t == nil {
return nil
}
return t.target
}
func (t *APEOverride) GetChains() []*ape.Chain {
if t == nil {
return nil
}
return t.chains
}

View file

@ -53,6 +53,10 @@ func (c *Chain) SetKind(kind chainKind) {
}
func (c *Chain) GetKind() chainKind {
if c == nil {
return nil
}
return c.kind
}
@ -67,5 +71,9 @@ func (c *ChainRaw) SetRaw(raw []byte) {
}
func (c *ChainRaw) GetRaw() []byte {
if c == nil {
return nil
}
return c.Raw
}

View file

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