Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General cleanup #27

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Our default golangci-lint configuration
# If these linters fail then it should fail the build.
# If these linters fail, then it should fail the build.
run:
timeout: 5m
linters:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ It effectively deals with the issues mentioned by creating special versions just

This section describes how to create a working environment for developing _Dynamic Environment_.
While it's not mandatory to follow these instructions or use the same tools, it's highly recommended
to keep the versions and some install procedures (e.g, _Istio_ installation into kubernetes) to make
sure everything passes the tests correctly.
to keep the versions and some installation procedures (e.g., _Istio_ installation into kubernetes)
to make sure everything passes the tests correctly.

### Tool Versions

Expand All @@ -50,7 +50,7 @@ asdf install
You should now have the right versions of the tools installed. As long as you installed _asdf_
correctly, and you're running from within the repository root you'll be using the right versions.

Here are other tools, that while not required, can make life easier:
Here are other tools that while not required, can make life easier:

* `kubectl`: Make sure it's a version that matches our cluster version according to the [version
skew policy][skew] (if you don't want to mess with multiple versions, and you're using minikube
Expand Down Expand Up @@ -80,15 +80,15 @@ similar to the _CI_ as possible).
We will use [minikube][] as our development cluster. Feel free to use whichever cluster suits you
best, but try to preserve the kubernetes version.

After installing minikube we need to start a new
After installing minikube, we need to start a new
cluster. You can play a little with the _memory_ and the _cpus_ but since we're going to run
resources on it, it's better to give it more resources than the default:

```shell
minikube start --kubernetes-version v1.26.3 --memory 8g --cpus 4
```

For the rest of the command make sure your _kubectl_ is operating on the minikube context:
For the rest of the commands, make sure your _kubectl_ is operating on the minikube context:

```shell
kubectx -c # should return 'minikube'
Expand Down Expand Up @@ -122,7 +122,7 @@ It's better to stop minikube when you're done working for the day_.
Some tests should run against a dedicated cluster. It is recommended that you'll have a
default named _Kind_ cluster for testing.

A prerequisite for running _Kind_ is a docker service. Make sure you have one installed (e.g,
A prerequisite for running _Kind_ is a docker service. Make sure you have one installed (e.g.,
_Rancher Desktop_). Assuming you followed the instructions above you should have the right version
of _Kind_ installed.

Expand All @@ -140,7 +140,7 @@ Install required dependencies and controller docker image:

`

**From now on make sure your k8s context points to the test cluster.**
**From now on, make sure your k8s context points to the test cluster.**

Deploy the controller to the cluster (this step should be repeated every time you update the
controller code):
Expand All @@ -149,7 +149,7 @@ controller code):
./e2e-testing/scripts/setup.sh deploy
````

If you want to clean up the test cluster you can run one of the following commands:
If you want to clean up the test cluster, you can run one of the following commands:

```shell
# Undeploy the controller and dependencies
Expand Down Expand Up @@ -204,7 +204,7 @@ sure you follow the rules for creating tests:

* Your first test manifest should create a new namespace (preferably named like your test directory)
and all test resources (deployments, destination rules, virtual services, etc.) should be deployed
to that namespace. If required create more than one namespace. This will prevent collisions
to that namespace. If required, create more than one namespace. This will prevent collisions
between test cases.
* Every namespace added (per the previous step) should contain an _Istio_ namespace:
```yaml
Expand Down Expand Up @@ -237,7 +237,7 @@ kuttl test --start-kind=false -n default --timeout 20 ./e2e-testing/kuttl --test

While we run default linters during our _test_ stage, it's advisable to occasionally run other
linters. These should not break the build (and not included in our configuration) and might contain
a lot of false positives, however you should occasionally run them to manually search for errors:
a lot of false positives, however, you should occasionally run them to manually search for errors:

```shell
# get a list of linters (at the end of the output there are some convenient presets)
Expand Down
49 changes: 0 additions & 49 deletions api/v1alpha1/condition_types.go

This file was deleted.

23 changes: 12 additions & 11 deletions api/v1alpha1/dynamicenv_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
Ready GlobalReadyStatus = "ready"
Processing GlobalReadyStatus = "processing"

// Whether it's consumer or subset.
// Whether it's a consumer or subset.
SUBSET SubsetOrConsumer = iota
CONSUMER SubsetOrConsumer = iota
)
Expand Down Expand Up @@ -179,8 +179,8 @@ type DynamicEnvSpec struct {
Subsets []Subset `json:"subsets"`

// Consumers are like subsets but for deployments that do not open a service but connect to external resources for
// their work (e.g, offline workers). They are equivalent to subsets in the sense that they launch overriding
// deployments with custom image and/or settings. However, since they are only consumers no virtual service or
// their work (e.g., offline workers). They are equivalent to subsets in the sense that they launch overriding
// deployments with custom image and/or settings. However, since they are only consumers, no virtual service or
// destination route will be pointing to them.
Consumers []Subset `json:"consumers,omitempty"`
}
Expand All @@ -207,7 +207,7 @@ type StringMatch struct {
Regex string `json:"regex,omitempty"`
}

// Subsets defines how to generate subsets from existing Deployments
// Subsets define how to generate subsets from existing Deployments
type Subset struct {
// Deployment name (without namespace)
Name string `json:"name"`
Expand Down Expand Up @@ -237,7 +237,7 @@ type Subset struct {
// and the relevant overrides
type ContainerOverrides struct {
// Container name to override in multiple containers' environment. If not
// specified we will use the first container.
// specified, we will use the first container.
ContainerName string `json:"containerName"`

// Docker image name overridden to the desired subset
Expand All @@ -257,9 +257,9 @@ type ContainerOverrides struct {

// DynamicEnvStatus defines the observed state of DynamicEnv
type DynamicEnvStatus struct {
// Represents the latest available observations of a deployment's current state.
Conditions []Condition `json:"conditions,omitempty"`
SubsetsStatus map[string]SubsetStatus `json:"subsetsStatus"`
// A detailed status of each subset
SubsetsStatus map[string]SubsetStatus `json:"subsetsStatus"`
// A detailed status of each consumer
ConsumersStatus map[string]ConsumerStatus `json:"consumersStatus,omitempty"`
State GlobalReadyStatus `json:"state,omitempty"`
// desired subsets and consumers count
Expand All @@ -277,7 +277,7 @@ type DynamicEnvList struct {
Items []DynamicEnv `json:"items"`
}

// SubsetStatus Contains aggregation of all resources status connected to set subset.
// SubsetStatus Contains aggregation of all resource status connected to set subset.
type SubsetStatus struct {
// Status of the deployment that belongs to the subset
Deployment ResourceStatus `json:"deployment,omitempty"`
Expand Down Expand Up @@ -327,7 +327,8 @@ func (rs ResourceStatus) IsEqual(other ResourceStatus) bool {

// StatusError shows an error we want to display in the status with the last time it happened. This
// *does not* have to be the only time it happened. The idea is that a list of errors should only
// contain single occurrence of an error (just the last).
//
// contain a single occurrence of an error (just the last).
type StatusError struct {
// The error message
Error string `json:"error"`
Expand All @@ -336,7 +337,7 @@ type StatusError struct {
}

// SubsetMessages contains a list of messages (errors) that occurred during Reconcile loop. At the
// end of each loop these messages should be synced to the matching subset status.
// end of each loop, these messages should be synced to the matching subset status.
type SubsetMessages struct {
Deployment []string
DestinationRule []string
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/dynamicenv_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (de *DynamicEnv) validateIstioMatchAnyOf() error {
return nil
}

// Validates certain aspects of the subset. Should be used both on create and update.
// Validates certain aspects of the subset. Should be used both on creation and update.
func (de *DynamicEnv) validateSubsetsProperties() error {
subsets := append(de.Spec.Subsets, de.Spec.Consumers...)
for _, s := range subsets {
Expand Down Expand Up @@ -164,7 +164,7 @@ func (de *DynamicEnv) validateIstioMatchImmutable(old runtime.Object) error {
}

// validatePartialUpdateSubsets verifies that update only occurs within a subset. The name/namespace
// of the subsets should not be updated (e.g. should not delete or create new subsets).
// of the subsets should not be updated (e.g., should not delete or create new subsets).
func (de *DynamicEnv) validatePartialUpdateSubsets(old runtime.Object) error {
oldSubsets := append(old.(*DynamicEnv).Spec.Subsets, old.(*DynamicEnv).Spec.Consumers...)
newSubsets := append(de.Spec.Subsets, de.Spec.Consumers...)
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is a group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "riskified.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
Expand Down
24 changes: 0 additions & 24 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading