Skip to content

Commit

Permalink
Fix some linter errors and ignore others
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Mar 5, 2023
1 parent 13cdf7e commit 06f7b08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ linters:
- maligned
- funlen
- maintidx
- musttag
52 changes: 26 additions & 26 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,29 @@ func (a *API) GetPluginConfig(ctx context.Context, _ *emptypb.Empty) (*structpb.
func (a *API) GetPlugins(context.Context, *emptypb.Empty) (*v1.PluginConfigs, error) {
plugins := make([]*v1.PluginConfig, 0)
a.PluginRegistry.ForEach(
func(id sdkPlugin.Identifier, p *plugin.Plugin) {
func(pluginID sdkPlugin.Identifier, plugIn *plugin.Plugin) {
requires := make(map[string]string, 0)
if p.Requires != nil {
for _, r := range p.Requires {
if plugIn.Requires != nil {
for _, r := range plugIn.Requires {
requires[r.Name] = r.Version
}
}
plugins = append(plugins, &v1.PluginConfig{
Id: &v1.PluginID{
Name: id.Name,
Version: id.Version,
RemoteUrl: id.RemoteURL,
Checksum: id.Checksum,
Name: pluginID.Name,
Version: pluginID.Version,
RemoteUrl: pluginID.RemoteURL,
Checksum: pluginID.Checksum,
},
Description: p.Description,
Authors: p.Authors,
License: p.License,
ProjectUrl: p.ProjectURL,
Config: p.Config,
Hooks: p.Hooks,
Description: plugIn.Description,
Authors: plugIn.Authors,
License: plugIn.License,
ProjectUrl: plugIn.ProjectURL,
Config: plugIn.Config,
Hooks: plugIn.Hooks,
Requires: requires,
Tags: p.Tags,
Categories: p.Categories,
Tags: plugIn.Tags,
Categories: plugIn.Categories,
})
},
)
Expand Down Expand Up @@ -127,15 +127,15 @@ func (a *API) GetPools(ctx context.Context, _ *emptypb.Empty) (*structpb.Struct,
// GetProxies returns the proxy configuration of the GatewayD.
func (a *API) GetProxies(ctx context.Context, _ *emptypb.Empty) (*structpb.Struct, error) {
proxies := make(map[string]interface{}, 0)
for name, p := range a.Proxies {
for name, proxy := range a.Proxies {
available := make([]interface{}, 0)
for _, c := range p.AvailableConnections() {
for _, c := range proxy.AvailableConnections() {
available = append(available, c)
}

busy := make([]interface{}, 0)
for _, c := range p.BusyConnections() {
busy = append(busy, c)
for _, conn := range proxy.BusyConnections() {
busy = append(busy, conn)
}

proxies[name] = map[string]interface{}{
Expand All @@ -154,14 +154,14 @@ func (a *API) GetProxies(ctx context.Context, _ *emptypb.Empty) (*structpb.Struc
// GetServers returns the server configuration of the GatewayD.
func (a *API) GetServers(ctx context.Context, _ *emptypb.Empty) (*structpb.Struct, error) {
servers := make(map[string]interface{}, 0)
for name, s := range a.Servers {
for name, server := range a.Servers {
servers[name] = map[string]interface{}{
"network": s.Network,
"address": s.Address,
"status": uint(s.Status),
"softLimit": s.SoftLimit,
"hardLimit": s.HardLimit,
"tickInterval": s.TickInterval.Nanoseconds(),
"network": server.Network,
"address": server.Address,
"status": uint(server.Status),
"softLimit": server.SoftLimit,
"hardLimit": server.HardLimit,
"tickInterval": server.TickInterval.Nanoseconds(),
}
}
serversConfig, err := structpb.NewStruct(servers)
Expand Down
2 changes: 1 addition & 1 deletion api/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func StartHTTPAPI(options *Options) {
}

// Start HTTP server (and proxy calls to gRPC server endpoint)
if err := http.ListenAndServe(options.HTTPAddress, mux); err != nil {
if err := http.ListenAndServe(options.HTTPAddress, mux); err != nil { //nolint:gosec
options.Logger.Err(err).Msg("failed to start HTTP API")
}
}

0 comments on commit 06f7b08

Please sign in to comment.