netscaler / adc-nitro-go

NITRO API SDK for Golang
Apache License 2.0
11 stars 9 forks source link

Moving resources from subfolders to parent #16

Open KalleDK opened 2 years ago

KalleDK commented 2 years ago

I'm writing a telegraf plugin to pull data from ADC's and SDX's, and I'm experiences som difficulty importing the different resources, as they are in subdirs, but named the same as their config partner. So if I import both the config and the stat resource, then I have to rename one of them.

import (
        lbconfig "github.com/citrix/adc-nitro-go/resource/config/lb"
        lbstats "github.com/citrix/adc-nitro-go/resource/stat/lb"
        networkconfig "github.com/citrix/adc-nitro-go/resource/config/network"
        networkstats "github.com/citrix/adc-nitro-go/resource/stat/network"

)

var lbs lbstats.Lbvserverstats
var lbc lbconfig.Lbvserver
var rnats networkstats.Rnatstats
var rnatc networkconfig.Rnat

What I would suggest is

import (
        res_stat "github.com/citrix/adc-nitro-go/resource/config"
        res_conf "github.com/citrix/adc-nitro-go/resource/stat"
)

var lbs res_stat.Lbvserverstats
var lbc res_conf.Lbvserver
var rnats res_stat.Rnatstats
var rnatc res_conf.Rnat

It's easy to see how this expands very exponential with imports and aliases.

I've tried to implement the move at https://github.com/KalleDK/adc-nitro-go/commits/main Also I'm cleaning up the resource structs by tagging the json with string, where the json value is a string encoded int

jantytgat commented 2 years ago

Hi KalleDK is there a way I can get in touch with you on this?

KalleDK commented 2 years ago

Ofcourse - I send you a mail with contact info