Skip to content

Commit c939c6c

Browse files
committed
Replace TO-DOs with FIXMEs (nginx#95)
- Replace all TO-DOs with FIXMEs to follow our coding guidelines (TO-DOs -- actually TODOs -- must be addressed and removed before merging a PR) - Improve some messages for clarity - Remove unnecessary TO-DOs
1 parent ff2b7c8 commit c939c6c

File tree

10 files changed

+28
-29
lines changed

10 files changed

+28
-29
lines changed

cmd/gateway/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func main() {
4040

4141
MustValidateArguments(
4242
flag.CommandLine,
43-
GatewayControllerParam(domain, "nginx-gateway" /* TODO dynamically set */),
43+
GatewayControllerParam(domain, "nginx-gateway" /* FIXME(f5yacobucci) dynamically set */),
4444
)
4545

4646
logger.Info("Starting NGINX Kubernetes Gateway",

internal/events/loop.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (el *EventLoop) Start(ctx context.Context) error {
6868
}
6969
}
7070

71-
// TO-DO: think about how to avoid using an interface{} here
71+
// FIXME(pleshakov): think about how to avoid using an interface{} here
7272
func (el *EventLoop) handleEvent(ctx context.Context, event interface{}) error {
7373
var changes []state.Change
7474
var updates []state.StatusUpdate
@@ -80,7 +80,7 @@ func (el *EventLoop) handleEvent(ctx context.Context, event interface{}) error {
8080
case *DeleteEvent:
8181
changes, updates, err = el.propagateDelete(e)
8282
default:
83-
// TO-DO: panic
83+
// FIXME(pleshakov): panic because it is a coding error
8484
return fmt.Errorf("unknown event type %T", e)
8585
}
8686

@@ -99,11 +99,11 @@ func (el *EventLoop) propagateUpsert(e *UpsertEvent) ([]state.Change, []state.St
9999
return changes, statusUpdates, nil
100100
case *apiv1.Service:
101101
el.serviceStore.Upsert(r)
102-
// TO-DO: make sure the affected hosts are updated
102+
// FIXME(pleshakov): make sure the affected hosts are updated
103103
return nil, nil, nil
104104
}
105105

106-
// TO-DO: panic
106+
// FIXME(pleshakov): panic because it is a coding error
107107
return nil, nil, fmt.Errorf("unknown resource type %T", e.Resource)
108108
}
109109

@@ -114,11 +114,11 @@ func (el *EventLoop) propagateDelete(e *DeleteEvent) ([]state.Change, []state.St
114114
return changes, statusUpdates, nil
115115
case *apiv1.Service:
116116
el.serviceStore.Delete(e.NamespacedName)
117-
// TO-DO: make sure the affected hosts are updated
117+
// FIXME(pleshakov): make sure the affected hosts are updated
118118
return nil, nil, nil
119119
}
120120

121-
// TO-DO: panic
121+
// FIXME(pleshakov): panic because it is a coding error
122122
return nil, nil, fmt.Errorf("unknown resource type %T", e.Type)
123123
}
124124

@@ -132,7 +132,7 @@ func (el *EventLoop) processChangesAndStatusUpdates(ctx context.Context, changes
132132

133133
for obj, objWarnings := range warnings {
134134
for _, w := range objWarnings {
135-
// TO-DO: report warnings via Object status
135+
// FIXME(pleshakov): report warnings via Object status
136136
el.logger.Info("got warning while generating config",
137137
"kind", obj.GetObjectKind().GroupVersionKind().Kind,
138138
"namespace", obj.GetNamespace(),

internal/implementations/service/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type serviceImplementation struct {
1515
eventCh chan<- interface{}
1616
}
1717

18-
// TO-DO: serviceImplementation looks similar to httpRouteImplemenation
18+
// FIXME(pleshakov): serviceImplementation looks similar to httpRouteImplemenation
1919
// consider if it is possible to reduce the amount of code.
2020

2121
// NewServiceImplementation creates a new ServiceImplementation.

internal/manager/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const clusterTimeout = 10 * time.Second
2828
var scheme = runtime.NewScheme()
2929

3030
func init() {
31-
// TO-DO: handle errors returned by the calls bellow
31+
// FIXME(pleshakov): handle errors returned by the calls bellow
3232
_ = gatewayv1alpha2.AddToScheme(scheme)
3333
_ = apiv1.AddToScheme(scheme)
3434
}

internal/nginx/config/generator.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ func (g *GeneratorImpl) GenerateForHost(host state.Host) ([]byte, Warnings) {
4343
func generate(host state.Host, serviceStore state.ServiceStore) (server, Warnings) {
4444
warnings := newWarnings()
4545

46-
locs := make([]location, 0, len(host.PathRouteGroups)) // TO-DO: expand with g.Routes
46+
locs := make([]location, 0, len(host.PathRouteGroups)) // FIXME(pleshakov): expand with g.Routes
4747

4848
for _, g := range host.PathRouteGroups {
4949
// number of routes in a group is always at least 1
5050
// otherwise, it is a bug in the state.Configuration code, so it is OK to panic here
51-
r := g.Routes[0] // TO-DO: for now, we only handle the first route in case there are multiple routes
51+
r := g.Routes[0] // FIXME(pleshakov): for now, we only handle the first route in case there are multiple routes
5252
address, err := getBackendAddress(r.Source.Spec.Rules[r.RuleIdx].BackendRefs, r.Source.Namespace, serviceStore)
5353
if err != nil {
5454
warnings.AddWarning(r.Source, err.Error())
@@ -75,12 +75,11 @@ func generateProxyPass(address string) string {
7575
}
7676

7777
func getBackendAddress(refs []v1alpha2.HTTPBackendRef, parentNS string, serviceStore state.ServiceStore) (string, error) {
78-
// TO-DO: make sure the warnings are generated and reported to the user fot the edge cases
7978
if len(refs) == 0 {
8079
return "", errors.New("empty backend refs")
8180
}
8281

83-
// TO-DO: for now, we only support a single backend reference
82+
// FIXME(pleshakov): for now, we only support a single backend reference
8483
ref := refs[0].BackendRef
8584

8685
if ref.Kind != nil && *ref.Kind != "Service" {

internal/nginx/config/template.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ var serverTemplate = `server {
2020

2121
// templateExecutor generates NGINX configuration using a template.
2222
// Template parsing or executing errors can only occur if there is a bug in the template, so they are handled with panics.
23-
// TO-DO: for now, we only generate configuration with NGINX server.
24-
// We will also need to generate the main NGINX configuration file, upstreams.
23+
// For now, we only generate configuration with NGINX server, but in the future we will also need to generate
24+
// the main NGINX configuration file, upstreams.
2525
type templateExecutor struct {
2626
serverTemplate *template.Template
2727
}

internal/state/configuration.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (c *configurationImpl) updateListeners() ([]Change, []StatusUpdate) {
231231

232232
statusUpdates := make([]StatusUpdate, 0, len(listener.httpRoutes))
233233

234-
// TO-DO: optimize it so that we only update the status of the affected (changed) httpRoutes
234+
// FIXME(pleshakov): optimize it so that we only update the status of the affected (changed) httpRoutes
235235
// getSortedKeys is used to ensure predictable order for unit tests
236236
for _, key := range getSortedKeys(listener.httpRoutes) {
237237
route := listener.httpRoutes[key]
@@ -242,7 +242,7 @@ func (c *configurationImpl) updateListeners() ([]Change, []StatusUpdate) {
242242
Parents: []v1alpha2.RouteParentStatus{
243243
{
244244
ParentRef: v1alpha2.ParentRef{
245-
Name: "fake", // TO-DO: report the parent ref properly
245+
Name: "fake", // FIXME(pleshakov): report the parent ref properly
246246
},
247247
ControllerName: v1alpha2.GatewayController(c.gatewayCtlrName),
248248
Conditions: []metav1.Condition{
@@ -252,7 +252,7 @@ func (c *configurationImpl) updateListeners() ([]Change, []StatusUpdate) {
252252
ObservedGeneration: listener.httpRoutes[key].Generation,
253253
LastTransitionTime: metav1.NewTime(c.clock.Now()),
254254
Reason: string(v1alpha2.ConditionRouteAccepted),
255-
Message: "", // TO-DO: figure out a good message
255+
Message: "", // FIXME(pleshakov): figure out a good message
256256
},
257257
},
258258
},
@@ -263,7 +263,7 @@ func (c *configurationImpl) updateListeners() ([]Change, []StatusUpdate) {
263263
statusUpdates = append(statusUpdates, update)
264264
}
265265

266-
// TO-DO: remove the accepted condition for the excluded (no longer handled) Routes
266+
// FIXME(pleshakov): remove the accepted condition for the excluded (no longer handled) Routes
267267

268268
return changes, statusUpdates
269269
}
@@ -318,7 +318,7 @@ func createChanges(removedHosts []string, updatedHosts []string, addedHosts []st
318318
func determineChangesInHosts(listener httpListener, newHosts hosts) (removedHosts []string, updatedHosts []string, addedHosts []string) {
319319
// getSortedKeys is used to ensure predictable order for unit tests
320320

321-
// TO-DO: consider using a data structure for sets
321+
// FIXME(pleshakov): consider using a data structure for sets
322322

323323
for _, h := range getSortedKeys(listener.hosts) {
324324
_, exists := newHosts[h]

internal/state/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type ServiceStore interface {
1717
Delete(nsname types.NamespacedName)
1818
// Resolve returns the cluster IP the service specified by its namespace and name.
1919
// If the service doesn't have a cluster IP or it doesn't exist, resolve will return an error.
20-
// TO-DO: later, we will start using the Endpoints rather than cluster IPs.
20+
// FIXME(pleshakov): later, we will start using the Endpoints rather than cluster IPs.
2121
Resolve(nsname types.NamespacedName) (string, error)
2222
}
2323

internal/status/updater.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ type Updater interface {
2727
//
2828
// (1) It doesn't understand the leader election. Only the leader must report the statuses of the resources. Otherwise,
2929
// multiple replicas will step on each other when trying to report statuses for the same resources.
30-
// TO-DO: address limitation (1)
30+
// FIXME(pleshakov): address limitation (1)
3131
//
3232
// (2) It is synchronous, which means the status reporter can slow down the event loop.
3333
// Consider the following cases:
3434
// (a) Sometimes the Gateway will need to update statuses of all resources it handles, which could be ~1000. Making 1000
3535
// status API calls sequentially will take time.
3636
// (b) k8s API can become slow or even timeout. This will increase every update status API call.
3737
// Making updaterImpl asynchronous will prevent it from adding variable delays to the event loop.
38-
// TO-DO: address limitation (2)
38+
// FIXME(pleshakov) address limitation (2)
3939
//
4040
// (3) It doesn't retry on failures. This means there is a chance that some resources will not have up-to-do statuses.
4141
// Statuses are important part of the Gateway API, so we need to ensure that the Gateway always keep the resources
4242
// statuses up-to-date.
43-
// TO-DO: address limitation (3)
43+
// FIXME(pleshakov): address limitation (3)
4444
//
4545
// (4) To support new resources, updaterImpl needs to be modified. Consider making updaterImpl extendable, so that it
4646
// goes along the Open-closed principle.
47-
// TO-DO: address limitation (4)
47+
// FIXME(pleshakov): address limitation (4)
4848
type updaterImpl struct {
4949
client client.Client
5050
logger logr.Logger
@@ -77,7 +77,7 @@ func (upd *updaterImpl) ProcessStatusUpdates(ctx context.Context, updates []stat
7777

7878
upd.update(ctx, u.NamespacedName, &hr, func(object client.Object) {
7979
route := object.(*v1alpha2.HTTPRoute)
80-
// TO-DO: merge the conditions in the status with the conditions in the route.Status properly, because
80+
// FIXME(pleshakov): merge the conditions in the status with the conditions in the route.Status properly, because
8181
// right now, we are replacing the conditions.
8282
route.Status = *s
8383
})
@@ -89,7 +89,7 @@ func (upd *updaterImpl) ProcessStatusUpdates(ctx context.Context, updates []stat
8989

9090
func (upd *updaterImpl) update(ctx context.Context, nsname types.NamespacedName, obj client.Object, statusSetter func(client.Object)) {
9191
// The function handles errors by reporting them in the logs.
92-
// TO-DO: figure out appropriate log level for these errors. Perhaps 3?
92+
// FIXME(pleshakov): figure out appropriate log level for these errors. Perhaps 3?
9393

9494
// We need to get the latest version of the resource.
9595
// Otherwise, the Update status API call can fail.

pkg/sdk/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type GatewayConfigImpl interface {
2525

2626
type HTTPRouteImpl interface {
2727
Upsert(config *v1alpha2.HTTPRoute)
28-
// TO-DO: change other interfaces to use types.NamespacedName
28+
// FIXME(pleshakov): change other interfaces to use types.NamespacedName
2929
Remove(types.NamespacedName)
3030
}
3131

0 commit comments

Comments
 (0)