Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

[TT-8658] Changed optional fields of CRD to pointers#627

Merged
singhpr merged 21 commits intomasterfrom
fix/TT-8658/set_optional_fields_as_pointers
May 18, 2023
Merged

[TT-8658] Changed optional fields of CRD to pointers#627
singhpr merged 21 commits intomasterfrom
fix/TT-8658/set_optional_fields_as_pointers

Conversation

@komalsukhani
Copy link
Contributor

@komalsukhani komalsukhani commented May 16, 2023

Description

Converted string and bool optional fields of APIDefinition and Security Policy to pointers.
Here is list of fields that are changed:

API Definition Bool fields

DisableHalfOpenState bool `json:"disable_half_open_state,omitempty"`
Reverse      bool   `json:"reverse,omitempty"`
UseExtendedPaths            bool              `json:"use_extended_paths,omitempty"`
IgnoreEndpointCase          bool              `json:"ignore_endpoint_case,omitempty"`
RequireSession bool   `json:"require_session,omitempty"`
RawBodyOnly    bool   `json:"raw_body_only,omitempty"`
EnableCache bool `json:"enable_cache,omitempty"`
CacheAllSafeRequests bool `json:"cache_all_safe_requests,omitempty"`
EnableUpstreamCacheControl bool `json:"enable_upstream_cache_control,omitempty"`
Active bool `json:"active,omitempty"`
EnableProxyProtocol bool `json:"enable_proxy_protocol,omitempty"`
DoNotTrack *bool `json:"do_not_track,omitempty"`
UseKeylessAccess *bool `json:"use_keyless,omitempty"`
UseOauth2 bool `json:"use_oauth2,omitempty"`
StripAuthData bool `json:"strip_auth_data,omitempty"`
UseStandardAuth bool `json:"use_standard_auth,omitempty"`
UseBasicAuth bool `json:"use_basic_auth,omitempty"`
UseMutualTLSAuth      bool     `json:"use_mutual_tls_auth,omitempty"`
EnableJWT bool `json:"enable_jwt,omitempty"`
UseGoPluginAuth bool `json:"use_go_plugin_auth,omitempty"`
EnableCoProcessAuth bool `json:"enable_coprocess_auth,omitempty"`
JWTSkipKid bool `json:"jwt_skip_kid,omitempty"`
DisableRateLimit bool `json:"disable_rate_limit,omitempty"`
DisableQuota bool `json:"disable_quota,omitempty"`
Internal bool `json:"internal,omitempty"`
EnableIPWhiteListing bool `json:"enable_ip_whitelisting,omitempty"`
EnableIPBlacklisting bool `json:"enable_ip_blacklisting,omitempty"`
EnableContextVars bool `json:"enable_context_vars,omitempty"`
EnableDetailedRecording bool `json:"enable_detailed_recording,omitempty"`
PreserveHostHeader bool `json:"preserve_host_header,omitempty"`
DisableStripSlash bool `json:"disable_strip_slash,omitempty"`
StripListenPath bool `json:"strip_listen_path,omitempty"`
EnableLoadBalancing bool `json:"enable_load_balancing,omitempty"`
CheckHostAgainstUptimeTests bool `json:"check_host_against_uptime_tests,omitempty"`
SSLInsecureSkipVerify bool `json:"ssl_insecure_skip_verify,omitempty"`
SSLForceCommonNameCheck bool `json:"ssl_force_common_name_check,omitempty"`
Enable bool `json:"enable,omitempty"`
AllowCredentials bool `json:"allow_credentials,omitempty"`
OptionsPassthrough bool `json:"options_passthrough,omitempty"`
Debug bool `json:"debug,omitempty"`
UseParam          bool            `json:"use_param,omitempty"`
UseCookie         bool            `json:"use_cookie,omitempty"`
UseCertificate    bool            `json:"use_certificate,omitempty"`
ValidateSignature bool            `json:"validate_signature,omitempty"`
DisableQueryBatching bool                    `json:"disable_query_batching,omitempty"`
Compressed bool   `json:"compressed,omitempty"`
Graph      bool   `json:"graph,omitempty"`

API Definition String fields

RewriteTo         string                `json:"rewrite_to,omitempty"`
RewriteTo string `json:"rewrite_to,omitempty"`
Path string `json:"path,omitempty"`
Query string `json:"query,omitempty"`
Path string `json:"path,omitempty"`
Query string `json:"query,omitempty"`
Namespace string `json:"namespace,omitempty"`
Expires                     string            `json:"expires,omitempty"`
OverrideTarget              string            `json:"override_target,omitempty"`
HeaderName      string `json:"header_name,omitempty"`
FormParamName   string `json:"param_name,omitempty"`
RegexExpression string `json:"regex_expression,omitempty"`
CacheControlTTLHeader string `json:"cache_control_ttl_header,omitempty"`
ID string `json:"id,omitempty" hash:"ignore"`
APIID string `json:"api_id,omitempty"`
OrgID string `json:"org_id,omitempty"`
Domain string `json:"domain,omitempty"`
JWTSigningMethod string `json:"jwt_signing_method,omitempty"`
JWTSource string `json:"jwt_source,omitempty"`
JWTIdentityBaseField string `json:"jwt_identity_base_field,omitempty"`
JWTClientIDBaseField string `json:"jwt_client_base_field,omitempty"`
JWTPolicyFieldName string `json:"jwt_policy_field_name,omitempty"`
JWTScopeClaimName string `json:"jwt_scope_claim_name,omitempty"`
CustomMiddlewareBundle string            `json:"custom_middleware_bundle,omitempty"`
ListenPath string `json:"listen_path,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
AuthLoginRedirect string `json:"auth_login_redirect,omitempty"`
ParamName         string          `json:"param_name,omitempty"`
CookieName        string          `json:"cookie_name,omitempty"`
MergedSDL            string                  `json:"merged_sdl,omitempty"`
Schema string `json:"schema,omitempty"`
GraphRef string `json:"graph_ref,omitempty"`
Body                       string                      `json:"body,omitempty"`
DefaultTypeName            string                      `json:"default_type_name,omitempty"`
TypeName   string `json:"type_name,omitempty"`
Query      string `json:"q,omitempty"`
Sort       string `json:"sort,omitempty"`
Category   string `json:"category,omitempty"`
AuthType   string `json:"auth_type,omitempty"`

Security Policy Bool fields

IsInactive        bool                        `json:"is_inactive,omitempty"`
HMACEnabled                   bool `json:"hmac_enabled,omitempty"`
EnableHTTPSignatureValidation bool `json:"enable_http_signature_validation,omitempty"`
DisableIntrospection bool `json:"disable_introspection,omitempty"`
Quota      bool `json:"quota,omitempty"`
RateLimit  bool `json:"rate_limit,omitempty"`
Complexity bool `json:"complexity,omitempty"`
Acl        bool `json:"acl,omitempty"`
PerAPI     bool `json:"per_api,omitempty"`

Security Policy String fields

MID string `json:"_id,omitempty" oss:"ignore"`
ID string `json:"id,omitempty"`
OrgID string `json:"org_id,omitempty"`
APIName string `json:"api_name,omitempty"`
APIID    string   `json:"api_id,omitempty"`
AllowanceScope string       `json:"allowance_scope,omitempty"`
TypeName string `json:"type_name,omitempty"`
FieldName string `json:"field_name,omitempty"`

Related Issue

TT-8658
Resolves #606

Motivation and Context

Test Coverage For This Change

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If PRing from your fork, don't come from your master!
  • Make sure you are making a pull request against our master branch (left side). Also, it would be best if you started your change off our latest master.
  • Make sure you are updating CHANGELOG.md based on your changes.
  • My change requires a change to the documentation.
    • If you've changed APIs, describe what needs to be updated in the documentation.
  • I have updated the documentation accordingly.
  • If you've changed API models, please update CRDs.
    • make manifests
    • make helm
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • gofmt -s -w .
    • go vet ./...
    • golangci-lint run

@komalsukhani komalsukhani changed the title Fix/tt 8658/set optional fields as pointers [TT-8658] Changed optional fields of CRD to pointers May 16, 2023
@komalsukhani komalsukhani marked this pull request as ready for review May 16, 2023 14:29
@komalsukhani komalsukhani requested a review from a team as a code owner May 16, 2023 14:29
@komalsukhani komalsukhani requested review from andrei-tyk and removed request for a team May 16, 2023 14:29
}

key := types.NamespacedName{Name: ctxRef.Name, Namespace: ctxRef.Namespace}
key := types.NamespacedName{Name: ctxRef.Name, Namespace: namespace}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is providing empty namespace safe for k8s client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it use default namespace when not set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set default value to default instead of empty

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not set, I would not explicitly set to default. I would inherit the namespace from the context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix this in another PR

Copy link

@buraksekili buraksekili left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 thanks @komalsukhani, lgtm! 🤞

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

15.8% 15.8% Coverage
1.0% 1.0% Duplication

@komalsukhani komalsukhani mentioned this pull request May 18, 2023
18 tasks
@singhpr singhpr merged commit 0fc03dd into master May 18, 2023
@singhpr singhpr deleted the fix/TT-8658/set_optional_fields_as_pointers branch May 18, 2023 11:08
buger pushed a commit that referenced this pull request May 22, 2024
* Set useKeylessAccess as bool pointer

* Convert all bool optional fields to pointers

* Convert string types to pointers

* Fix pointer references

* Fix function used to check equality of target objects

* Fix tests

* Update deepcopy

* Fix linter errors

* Converted optional bool fields of security policy to pointers

* Convert string optional field of security policy to pointer

* Update changelog

* Fix lint errors

* Fix panic

* Fix check

* Verify pointer is not nil before accessing it's value

* Define error for missing policy id

* Validate pointer is not nil before accessing it's value

* Avoid using same variable for different pointer variables

* Rename variables to camelCase

* Use "default" as default value of namespace
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TT-8658] json serialization settings cause mis-alignment between desired and live manifests

6 participants