From b15ff8e67529e6e56929bbe0bc4b9066ae692012 Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Wed, 20 Nov 2024 10:41:14 +0100 Subject: [PATCH] ci: fix lint --- internal/cmd/company/rules/client.go | 16 ++++++++-------- internal/cmd/company/rules/list.go | 1 - internal/cmd/company/rules/update.go | 15 +++++++++++++++ internal/resources/rules/rules.go | 8 ++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/internal/cmd/company/rules/client.go b/internal/cmd/company/rules/client.go index d50bf4d..ee8479b 100644 --- a/internal/cmd/company/rules/client.go +++ b/internal/cmd/company/rules/client.go @@ -38,18 +38,18 @@ type IRulesClient interface { ListTenantRules(ctx context.Context, companyID string) ([]*rulesentities.SaveChangesRules, error) ListProjectRules(ctx context.Context, projectID string) ([]*rulesentities.ProjectSaveChangesRules, error) UpdateTenantRules(ctx context.Context, companyID string, rules []*rulesentities.SaveChangesRules) error - UpdateProjectRules(ctx context.Context, projectId string, rules []*rulesentities.SaveChangesRules) error + UpdateProjectRules(ctx context.Context, projectID string, rules []*rulesentities.SaveChangesRules) error } -type RulesClient struct { +type rulesClient struct { c *client.APIClient } func New(c *client.APIClient) IRulesClient { - return &RulesClient{c: c} + return &rulesClient{c: c} } -func (e *RulesClient) ListTenantRules(ctx context.Context, companyID string) ([]*rulesentities.SaveChangesRules, error) { +func (e *rulesClient) ListTenantRules(ctx context.Context, companyID string) ([]*rulesentities.SaveChangesRules, error) { request := e.c.Get().APIPath(tenantsAPIPrefix) request.SetParam("search", companyID) @@ -85,7 +85,7 @@ func (e *RulesClient) ListTenantRules(ctx context.Context, companyID string) ([] return tenant.ConfigurationManagement.SaveChangesRules, nil } -func (e *RulesClient) ListProjectRules(ctx context.Context, projectID string) ([]*rulesentities.ProjectSaveChangesRules, error) { +func (e *rulesClient) ListProjectRules(ctx context.Context, projectID string) ([]*rulesentities.ProjectSaveChangesRules, error) { request := e.c.Get().APIPath(fmt.Sprintf(getProjectAPIFmt, projectID)) request.SetParam("withTenant", "true") @@ -113,7 +113,7 @@ type UpdateRequestBody struct { ConfigurationManagement *resources.ConfigurationManagement `json:"configurationManagement"` } -func (e *RulesClient) UpdateTenantRules(ctx context.Context, companyID string, rules []*rulesentities.SaveChangesRules) error { +func (e *rulesClient) UpdateTenantRules(ctx context.Context, companyID string, rules []*rulesentities.SaveChangesRules) error { requestBody := UpdateRequestBody{ ConfigurationManagement: &resources.ConfigurationManagement{ SaveChangesRules: rules, @@ -141,7 +141,7 @@ func (e *RulesClient) UpdateTenantRules(ctx context.Context, companyID string, r return nil } -func (e *RulesClient) UpdateProjectRules(ctx context.Context, projectID string, rules []*rulesentities.SaveChangesRules) error { +func (e *rulesClient) UpdateProjectRules(ctx context.Context, projectID string, rules []*rulesentities.SaveChangesRules) error { requestBody := UpdateRequestBody{ ConfigurationManagement: &resources.ConfigurationManagement{ SaveChangesRules: rules, @@ -169,7 +169,7 @@ func (e *RulesClient) UpdateProjectRules(ctx context.Context, projectID string, return nil } -func (e *RulesClient) assertSuccessResponse(resp *client.Response) error { +func (e *rulesClient) assertSuccessResponse(resp *client.Response) error { if resp.StatusCode() >= http.StatusBadRequest { return resp.Error() } diff --git a/internal/cmd/company/rules/list.go b/internal/cmd/company/rules/list.go index 8343d1a..fe07d50 100644 --- a/internal/cmd/company/rules/list.go +++ b/internal/cmd/company/rules/list.go @@ -100,7 +100,6 @@ func printProjectList(rules []*rulesentities.ProjectSaveChangesRules, p printer. p.Keys(tableColumnLabel...) for i, rule := range rules { - ruleInfo := createRecord(rule.DisallowedRuleSet) p.Record( strconv.Itoa(i), diff --git a/internal/cmd/company/rules/update.go b/internal/cmd/company/rules/update.go index b4cf2e1..336a2af 100644 --- a/internal/cmd/company/rules/update.go +++ b/internal/cmd/company/rules/update.go @@ -1,3 +1,18 @@ +// Copyright Mia srl +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package rules import ( diff --git a/internal/resources/rules/rules.go b/internal/resources/rules/rules.go index 1f2618d..ff2d40e 100644 --- a/internal/resources/rules/rules.go +++ b/internal/resources/rules/rules.go @@ -16,20 +16,20 @@ package rules type SaveChangesRules struct { - RoleIDs []string `yaml:"roleIds,omitempty" json:"roleIds,omitempty"` + RoleIDs []string `yaml:"roleIds,omitempty" json:"roleIds,omitempty"` //nolint:tagliatelle DisallowedRuleSet []RuleSet `yaml:"disallowedRuleSet,omitempty" json:"disallowedRuleSet,omitempty"` } type ProjectSaveChangesRules struct { - RoleIDs []string `yaml:"roleIds,omitempty" json:"roleIds,omitempty"` + RoleIDs []string `yaml:"roleIds,omitempty" json:"roleIds,omitempty"` //nolint:tagliatelle DisallowedRuleSet []RuleSet `yaml:"disallowedRuleSet,omitempty" json:"disallowedRuleSet,omitempty"` IsInheritedFromTenant bool `yaml:"isInheritedFromTenant,omitempty" json:"isInheritedFromTenant,omitempty"` } type RuleSet struct { JSONPath string `yaml:"jsonPath,omitempty" json:"jsonPath,omitempty"` - Options *RuleOptions `yaml:"processingOptions,omitempty" json:"processingOptions,omitempty"` - RuleID string `yaml:"ruleId,omitempty" json:"ruleId,omitempty"` + Options *RuleOptions `yaml:"processingOptions,omitempty" json:"processingOptions,omitempty"` //nolint:tagliatelle + RuleID string `yaml:"ruleId,omitempty" json:"ruleId,omitempty"` //nolint:tagliatelle } type RuleOptions struct {