Skip to content

Commit 50361b8

Browse files
committed
refactor: use consistent case for IDs
1 parent 71542b5 commit 50361b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+143
-142
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ issues:
253253
max-same-issues: 50
254254

255255
exclude:
256-
- ".*(Id|Api|Url|Http).* should be .*(ID|API|URL|HTTP).*"
256+
- ".*(Api|Url|Http).* should be .*(API|URL|HTTP).*"
257257

258258
exclude-rules:
259259
- source: "^//\\s*go:generate\\s"

api/model/api/base/member.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Member struct {
2222
// Member source ID
2323
// +kubebuilder:validation:Required
2424
// +kubebuilder:example:=user@email.com
25-
SourceId string `json:"sourceId"`
25+
SourceID string `json:"sourceId"`
2626
// Member display name
2727
DisplayName string `json:"displayName,omitempty"`
2828
// The API role associated with this Member
@@ -33,15 +33,15 @@ type Member struct {
3333
func NewGraviteeMember(username, role string) *Member {
3434
return &Member{
3535
Source: "gravitee",
36-
SourceId: username,
36+
SourceID: username,
3737
Role: role,
3838
}
3939
}
4040

4141
func NewMemoryMember(username, role string) *Member {
4242
return &Member{
4343
Source: "memory",
44-
SourceId: username,
44+
SourceID: username,
4545
Role: role,
4646
}
4747
}

api/model/api/base/page.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type PageSource struct {
2626
type AccessControl struct {
2727
// +kubebuilder:validation:Required
2828
// The ID denied or granted by the access control (currently only group names are supported)
29-
ReferenceId string `json:"referenceId,omitempty"`
29+
ReferenceID string `json:"referenceId,omitempty"`
3030
// +kubebuilder:validation:Required
3131
// +kubebuilder:validation:Enum=GROUP;
3232
// The type of reference denied or granted by the access control

api/model/api/base/plan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ type PlanValidation string
3030

3131
type Plan struct {
3232
// Plan ID
33-
Id string `json:"id,omitempty"`
33+
ID string `json:"id,omitempty"`
3434
// The plan Cross ID.
3535
// This field is used to identify plans defined for an API
3636
// that has been promoted between different environments.
37-
CrossId string `json:"crossId,omitempty"`
37+
CrossID string `json:"crossId,omitempty"`
3838
// Plan Description
3939
Description string `json:"description"`
4040
// List of plan tags
@@ -71,11 +71,11 @@ func (plan *Plan) WithStatus(status PlanStatus) *Plan {
7171
}
7272

7373
func (plan *Plan) WithID(id string) *Plan {
74-
plan.Id = id
74+
plan.ID = id
7575
return plan
7676
}
7777

7878
func (plan *Plan) WithCrossID(id string) *Plan {
79-
plan.CrossId = id
79+
plan.CrossID = id
8080
return plan
8181
}

api/model/api/base/primary_owner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package base
1717
type PrimaryOwner struct {
1818
// +kubebuilder:validation:Required
1919
// PrimaryOwner ID
20-
Id string `json:"id,omitempty"`
20+
ID string `json:"id,omitempty"`
2121
// +kubebuilder:validation:Optional
2222
// PrimaryOwner email
2323
Email string `json:"email,omitempty"`

api/model/api/v2/plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Consumer struct {
2828
// Consumer type (possible values TAG)
2929
ConsumerType ConsumerType `json:"consumerType,omitempty"`
3030
// Consumer ID
31-
ConsumerId string `json:"consumerId,omitempty"`
31+
ConsumerID string `json:"consumerId,omitempty"`
3232
}
3333

3434
type Plan struct {

api/model/api/v4/api.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package v4
1818
import (
1919
"fmt"
2020
"net/url"
21-
"strings"
2221

2322
"github.com/gravitee-io/gravitee-kubernetes-operator/api/model/api/base"
2423
"github.com/gravitee-io/gravitee-kubernetes-operator/pkg/types/k8s/custom"
@@ -223,8 +222,12 @@ func parseListener(l Listener) []string {
223222
{
224223
paths := make([]string, 0)
225224
for _, path := range t.Paths {
226-
p := fmt.Sprintf("%s/%s", path.Host, path.Path)
227-
paths = append(paths, strings.ReplaceAll(p, "//", "/"))
225+
if path.Host != "" {
226+
p := fmt.Sprintf("%s/%s", path.Host, path.Path)
227+
paths = append(paths, p)
228+
} else {
229+
paths = append(paths, path.Path)
230+
}
228231
}
229232
return paths
230233
}

api/model/application/application.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ type AppKeyMode string
2121
type SimpleSettings struct {
2222
// Application Type
2323
AppType string `json:"type"`
24-
// ClientId is the client id of the application
25-
ClientId string `json:"client_id,omitempty"`
24+
// ClientID is the client id of the application
25+
ClientID string `json:"client_id,omitempty"`
2626
}
2727

2828
type OAuthClientSettings struct {
2929
// Oauth client application type
3030
ApplicationType string `json:"application_type"`
3131
// Oauth client id
32-
ClientId string `json:"client_id,omitempty"`
32+
ClientID string `json:"client_id,omitempty"`
3333
// Oauth client secret
3434
ClientSecret string `json:"client_secret,omitempty"`
3535
// Oauth client uri
@@ -77,8 +77,8 @@ type Application struct {
7777
Description string `json:"description,omitempty"`
7878
// Application Type
7979
Type string `json:"type,omitempty"`
80-
// The ClientId identifying the application. This field is required when subscribing to an OAUTH2 / JWT plan.
81-
ClientId string `json:"clientId,omitempty"`
80+
// The ClientID identifying the application. This field is required when subscribing to an OAUTH2 / JWT plan.
81+
ClientID string `json:"clientId,omitempty"`
8282
// List of application Redirect Uris
8383
RedirectUris []string `json:"redirectUris,omitempty"`
8484

api/model/management/context.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ type Context struct {
3030
BaseUrl string `json:"baseUrl"`
3131
// An existing organization id targeted by the context on the management API instance.
3232
// +kubebuilder:validation:Required
33-
OrgId string `json:"organizationId"`
33+
OrgID string `json:"organizationId"`
3434
// An existing environment id targeted by the context within the organization.
3535
// +kubebuilder:validation:Required
36-
EnvId string `json:"environmentId"`
36+
EnvID string `json:"environmentId"`
3737
// Auth defines the authentication method used to connect to the API Management.
3838
// Can be either basic authentication credentials, a bearer token
3939
// or a reference to a kubernetes secret holding one of these two configurations.
@@ -46,14 +46,14 @@ func (c *Context) GetAuth() custom.Auth {
4646
return c.Auth
4747
}
4848

49-
// GetEnv implements custom.Context.
50-
func (c *Context) GetEnv() string {
51-
return c.EnvId
49+
// GetEnvID implements custom.Context.
50+
func (c *Context) GetEnvID() string {
51+
return c.EnvID
5252
}
5353

54-
// GetOrg implements custom.Context.
55-
func (c *Context) GetOrg() string {
56-
return c.OrgId
54+
// GetOrgID implements custom.Context.
55+
func (c *Context) GetOrgID() string {
56+
return c.OrgID
5757
}
5858

5959
// GetSecretRef implements custom.Context.

api/v1alpha1/apiv2definition_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ func (spec *ApiDefinitionV2Spec) SetDefinitionContext() {
9696
}
9797
}
9898

99-
func (api *ApiDefinition) EnvID() string {
99+
func (api *ApiDefinition) GetEnvID() string {
100100
return api.Status.EnvID
101101
}
102102

103-
func (api *ApiDefinition) ID() string {
103+
func (api *ApiDefinition) GetID() string {
104104
return api.Status.ID
105105
}
106106

107-
func (api *ApiDefinition) OrgID() string {
107+
func (api *ApiDefinition) GetOrgID() string {
108108
return api.Status.OrgID
109109
}
110110

@@ -143,17 +143,17 @@ func (api *ApiDefinition) GetDefinition() custom.ApiDefinition {
143143
func (api *ApiDefinition) PopulateIDs(_ custom.Context) {
144144
api.Spec.ID = api.pickID()
145145
api.Spec.CrossID = api.pickCrossID()
146-
api.generateEmptyPlanCrossIds()
146+
api.generateEmptyPlanCrossIDs()
147147
api.generatePageIDs()
148148
}
149149

150-
// For each plan, generate a CrossId from Api Id & Plan Name if not defined.
151-
func (api *ApiDefinition) generateEmptyPlanCrossIds() {
150+
// For each plan, generate a Cross id from Api id & Plan Name if not defined.
151+
func (api *ApiDefinition) generateEmptyPlanCrossIDs() {
152152
plans := api.Spec.Plans
153153

154154
for _, plan := range plans {
155-
if plan.CrossId == "" {
156-
plan.CrossId = uuid.FromStrings(api.Spec.ID, separator, plan.Name)
155+
if plan.CrossID == "" {
156+
plan.CrossID = uuid.FromStrings(api.Spec.ID, separator, plan.Name)
157157
}
158158
}
159159
}

0 commit comments

Comments
 (0)