Skip to content
  •  
  •  
  •  
454 changes: 454 additions & 0 deletions .golangci.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apis/gateway/ratelimit/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "gateway.kyma-project.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
6 changes: 3 additions & 3 deletions apis/gateway/ratelimit/v1alpha1/ratelimit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type LocalConfig struct {
Buckets []BucketConfig `json:"buckets,omitempty"`
}

// RateLimitSpec defines the desired state of RateLimit
// RateLimitSpec defines the desired state of RateLimit.
type RateLimitSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinProperties=1
Expand All @@ -67,7 +67,7 @@ type RateLimitSpec struct {
Enforce bool `json:"enforce,omitempty"`
}

// RateLimitStatus defines the observed state of RateLimit
// RateLimitStatus defines the observed state of RateLimit.
type RateLimitStatus struct {
// Description defines the description of current State of RateLimit.
Description string `json:"description,omitempty"`
Expand Down Expand Up @@ -106,7 +106,7 @@ type RateLimit struct {

//+kubebuilder:object:root=true

// RateLimitList contains a list of RateLimit
// RateLimitList contains a list of RateLimit.
type RateLimitList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
31 changes: 16 additions & 15 deletions apis/gateway/v1beta1/apirule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@ limitations under the License.
package v1beta1

import (
"github.com/kyma-project/api-gateway/apis/gateway/versions"
"istio.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/kyma-project/api-gateway/apis/gateway/versions"
)

// Status code describing APIRule.
type StatusCode string

const (
//StatusOK is set when the reconciliation finished succefully
// StatusOK is set when the reconciliation finished succefully.
StatusOK StatusCode = "OK"
//StatusSkipped is set when reconcilation of the APIRule component was skipped
// StatusSkipped is set when reconcilation of the APIRule component was skipped.
StatusSkipped StatusCode = "SKIPPED"
//StatusError is set when an error happened during reconciliation of the APIRule
// StatusError is set when an error happened during reconciliation of the APIRule.
StatusError StatusCode = "ERROR"
//StatusWarning is set if an user action is required
// StatusWarning is set if an user action is required.
StatusWarning StatusCode = "WARNING"
)

// Defines the desired state of ApiRule.
// Defines the desired state of APIRule.
type APIRuleSpec struct {
// Specifies the URL of the exposed service.
// +kubebuilder:validation:MinLength=3
Expand All @@ -60,7 +61,7 @@ type APIRuleSpec struct {
Timeout *Timeout `json:"timeout,omitempty"`
}

// Describes the observed state of ApiRule.
// Describes the observed state of APIRule.
type APIRuleStatus struct {
LastProcessedTime metav1.Time `json:"lastProcessedTime,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand All @@ -78,7 +79,7 @@ func (s *APIRuleStatus) ApiRuleStatusVersion() versions.Version {
return versions.V1beta1
}

// APIRule is the Schema for ApiRule APIs.
// APIRule is the Schema for APIRule APIs.
// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:resource:categories={kyma-api-gateway}
Expand All @@ -96,10 +97,10 @@ type APIRule struct {

// +kubebuilder:object:root=true

// APIRuleList contains a list of ApiRule
// APIRuleList contains a list of APIRule.
type APIRuleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
metav1.TypeMeta ` json:",inline"`
metav1.ListMeta ` json:"metadata,omitempty"`
Items []APIRule `json:"items"`
}

Expand Down Expand Up @@ -187,13 +188,13 @@ func (j *JwtConfig) GetObjectKind() schema.ObjectKind {
return schema.EmptyObjectKind
}

// JwtAuthorization contains an array of required scopes
// JwtAuthorization contains an array of required scopes.
type JwtAuthorization struct {
RequiredScopes []string `json:"requiredScopes"`
Audiences []string `json:"audiences"`
}

// JwtAuthentication Config for Jwt Istio authentication
// JwtAuthentication Config for Jwt Istio authentication.
type JwtAuthentication struct {
Issuer string `json:"issuer"`
JwksUri string `json:"jwksUri"`
Expand All @@ -203,7 +204,7 @@ type JwtAuthentication struct {
FromParams []string `json:"fromParams,omitempty"`
}

// JwtHeader for specifying from header for the Jwt token
// JwtHeader for specifying from header for the Jwt token.
type JwtHeader struct {
Name string `json:"name"`
// +optional
Expand Down Expand Up @@ -242,7 +243,7 @@ func (s StringMatch) ToIstioStringMatchArray() (out []*v1beta1.StringMatch) {
}

// CorsPolicy allows configuration of CORS headers received downstream. If this is not defined, the default values are applied.
// If CorsPolicy is configured, CORS headers received downstream will be only those defined on the APIRule
// If CorsPolicy is configured, CORS headers received downstream will be only those defined on the APIRule.
type CorsPolicy struct {
AllowHeaders []string `json:"allowHeaders,omitempty"`
AllowMethods []string `json:"allowMethods,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/gateway/v1beta1/authorization_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package v1beta1_test

import (
"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
)

var _ = Describe("Authorization", func() {
Expand Down
4 changes: 2 additions & 2 deletions apis/gateway/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "gateway.kyma-project.io", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
3 changes: 2 additions & 1 deletion apis/gateway/v1beta1/mutators_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package v1beta1_test

import (
"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
)

var _ = Describe("Mutators", func() {
Expand Down
1 change: 0 additions & 1 deletion apis/gateway/v1beta1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (r *Rule) GetCookieMutator() (CookieMutatorConfig, error) {

for _, mutator := range r.Mutators {
if mutator.Name == CookieMutator {

err := json.Unmarshal(mutator.Config.Raw, &mutatorConfig)

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions apis/gateway/v1beta1/rule_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package v1beta1_test

import (
"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
)

var _ = Describe("Rule", func() {
Expand Down
12 changes: 5 additions & 7 deletions apis/gateway/v2/apirule_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package v2

import (
"encoding/json"

"slices"
"time"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/conversion"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
)

var beta1toV2StatusConversionMap = map[v1beta1.StatusCode]State{
Expand All @@ -31,7 +31,7 @@ func convertMap(m map[v1beta1.StatusCode]State) map[State]v1beta1.StatusCode {
return inv
}

// The 2 => 1 map is generated automatically based on 1 => 2 map
// The 2 => 1 map is generated automatically based on 1 => 2 map.
var v2to1beta1statusConversionMap = convertMap(beta1toV2StatusConversionMap)

const (
Expand All @@ -40,7 +40,7 @@ const (
v1beta1SpecAnnotationKey = "gateway.kyma-project.io/v1beta1-spec"
)

// ConvertTo Converts this ApiRule (v2) to the Hub version (v1beta1)
// ConvertTo Converts this APIRule (v2) to the Hub version (v1beta1).
func (apiRule *APIRule) ConvertTo(hub conversion.Hub) error {
apiRuleBeta1 := hub.(*v1beta1.APIRule)

Expand Down Expand Up @@ -191,7 +191,7 @@ func (apiRule *APIRule) ConvertTo(hub conversion.Hub) error {
return nil
}

// Converts from the Hub version (v1beta1) into this ApiRule (v2)
// Converts from the Hub version (v1beta1) into this APIRule (v2).
func (apiRule *APIRule) ConvertFrom(hub conversion.Hub) error {
apiRuleBeta1 := hub.(*v1beta1.APIRule)

Expand Down Expand Up @@ -268,7 +268,6 @@ func (apiRule *APIRule) ConvertFrom(hub conversion.Hub) error {
}
if apiRuleBeta1.Annotations != nil {
if annotation, ok := apiRuleBeta1.Annotations[v2RulesAnnotationKey]; ok {

var v2Rules []Rule
err := json.Unmarshal([]byte(annotation), &v2Rules)
if err != nil {
Expand Down Expand Up @@ -332,7 +331,6 @@ func (apiRule *APIRule) ConvertFrom(hub conversion.Hub) error {
}
apiRule.Spec.Rules = append(apiRule.Spec.Rules, ruleV1Alpha2)
}

}

return nil
Expand Down
5 changes: 3 additions & 2 deletions apis/gateway/v2/apirule_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"time"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
"github.com/kyma-project/api-gateway/apis/gateway/v2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"

"github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
v2 "github.com/kyma-project/api-gateway/apis/gateway/v2"
)

var _ = Describe("APIRule Conversion", func() {
Expand Down
21 changes: 11 additions & 10 deletions apis/gateway/v2/apirule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ limitations under the License.
package v2

import (
"github.com/kyma-project/api-gateway/apis/gateway/versions"
"istio.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/kyma-project/api-gateway/apis/gateway/versions"
)

type State string
Expand All @@ -33,7 +34,7 @@ const (
Warning State = "Warning"
)

// APIRuleSpec defines the desired state of ApiRule.
// APIRuleSpec defines the desired state of APIRule.
type APIRuleSpec struct {
// Specifies the URLs of the exposed service.
// +kubebuilder:validation:MinItems=1
Expand Down Expand Up @@ -61,7 +62,7 @@ type APIRuleSpec struct {
// +kubebuilder:validation:XValidation:rule=`self.matches('^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?:\\.[a-z0-9]{2,63}))?$')`,message="Host must be a lowercase RFC 1123 label (must consist of lowercase alphanumeric characters or '-', and must start and end with an lowercase alphanumeric character) or a fully qualified domain name"
type Host string

// APIRuleStatus describes the observed state of ApiRule.
// APIRuleStatus describes the observed state of APIRule.
type APIRuleStatus struct {
LastProcessedTime metav1.Time `json:"lastProcessedTime,omitempty"`
// State signifies current state of APIRule.
Expand All @@ -77,7 +78,7 @@ func (s *APIRuleStatus) ApiRuleStatusVersion() versions.Version {
return versions.V2
}

// APIRule is the Schema for ApiRule APIs.
// APIRule is the Schema for APIRule APIs.
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:categories={kyma-api-gateway}
Expand All @@ -93,10 +94,10 @@ type APIRule struct {

// +kubebuilder:object:root=true

// APIRuleList contains a list of ApiRule
// APIRuleList contains a list of APIRule.
type APIRuleList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
metav1.TypeMeta ` json:",inline"`
metav1.ListMeta ` json:"metadata,omitempty"`
Items []APIRule `json:"items"`
}

Expand Down Expand Up @@ -190,7 +191,7 @@ type JwtAuthorization struct {
Audiences []string `json:"audiences,omitempty"`
}

// JwtAuthentication Config for Jwt Istio authentication
// JwtAuthentication Config for Jwt Istio authentication.
type JwtAuthentication struct {
Issuer string `json:"issuer"`
JwksUri string `json:"jwksUri"`
Expand All @@ -200,7 +201,7 @@ type JwtAuthentication struct {
FromParams []string `json:"fromParams,omitempty"`
}

// JwtHeader for specifying from header for the Jwt token
// JwtHeader for specifying from header for the Jwt token.
type JwtHeader struct {
Name string `json:"name"`
// +optional
Expand Down Expand Up @@ -249,7 +250,7 @@ func (s StringMatch) ToIstioStringMatchArray() (out []*v1beta1.StringMatch) {
}

// CorsPolicy allows configuration of CORS headers received downstream. If this is not defined, the default values are applied.
// If CorsPolicy is configured, CORS headers received downstream will be only those defined on the APIRule
// If CorsPolicy is configured, CORS headers received downstream will be only those defined on the APIRule.
type CorsPolicy struct {
AllowHeaders []string `json:"allowHeaders,omitempty"`
AllowMethods []string `json:"allowMethods,omitempty"`
Expand Down
3 changes: 2 additions & 1 deletion apis/gateway/v2/authorization_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package v2_test

import (
v2 "github.com/kyma-project/api-gateway/apis/gateway/v2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

v2 "github.com/kyma-project/api-gateway/apis/gateway/v2"
)

var _ = Describe("Authorization", func() {
Expand Down
5 changes: 3 additions & 2 deletions apis/gateway/v2/extauth_conversion_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package v2_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

apirulev1beta1 "github.com/kyma-project/api-gateway/apis/gateway/v1beta1"
apirulev2 "github.com/kyma-project/api-gateway/apis/gateway/v2"
builder "github.com/kyma-project/api-gateway/internal/builders/builders_test/v2_test"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

const annotationKey = "gateway.kyma-project.io/v2alpha1-rules"
Expand Down
Loading
Loading