├── .assets └── gravitee-logo-cyan.svg ├── .circleci └── config.yml ├── .dockerignore ├── .github ├── CODEOWNERS ├── renovate.json └── workflows │ ├── schedule-test.yml │ ├── trigger-e2e.yml │ └── trigger-release.yml ├── .gitignore ├── .golangci.yml ├── .mergify.yml ├── CHANGELOG.md ├── CONTRIBUTING.adoc ├── Dockerfile ├── Dockerfile.debug ├── LICENSE.txt ├── LICENSE_TEMPLATE.txt ├── Makefile ├── PROJECT ├── README.adoc ├── api ├── model │ ├── api │ │ ├── base │ │ │ ├── api.go │ │ │ ├── flow.go │ │ │ ├── http.go │ │ │ ├── keystore.go │ │ │ ├── member.go │ │ │ ├── metadata.go │ │ │ ├── notification.go │ │ │ ├── package_markers.go │ │ │ ├── page.go │ │ │ ├── plan.go │ │ │ ├── plugin.go │ │ │ ├── properties.go │ │ │ ├── resource.go │ │ │ ├── status.go │ │ │ └── zz_generated.deepcopy.go │ │ ├── v2 │ │ │ ├── analytics.go │ │ │ ├── api.go │ │ │ ├── endpoints.go │ │ │ ├── flow.go │ │ │ ├── package_markers.go │ │ │ ├── page.go │ │ │ ├── plan.go │ │ │ ├── proxy.go │ │ │ ├── services.go │ │ │ └── zz_generated.deepcopy.go │ │ └── v4 │ │ │ ├── analytics.go │ │ │ ├── api.go │ │ │ ├── endpoints.go │ │ │ ├── enum.go │ │ │ ├── flow.go │ │ │ ├── listeners.go │ │ │ ├── package_markers.go │ │ │ ├── page.go │ │ │ ├── plan.go │ │ │ ├── services.go │ │ │ └── zz_generated.deepcopy.go │ ├── application │ │ ├── application.go │ │ ├── package_markers.go │ │ ├── status.go │ │ └── zz_generated.deepcopy.go │ ├── group │ │ ├── group.go │ │ ├── package_markers.go │ │ └── zz_generated.deepcopy.go │ ├── management │ │ ├── context.go │ │ ├── package_markers.go │ │ └── zz_generated.deepcopy.go │ ├── notification │ │ ├── notification.go │ │ ├── package_markers.go │ │ └── zz_generated.deepcopy.go │ ├── policygroups │ │ ├── package_markers.go │ │ ├── sharedpolicygroups.go │ │ ├── status.go │ │ └── zz_generated.deepcopy.go │ ├── refs │ │ ├── namespace.go │ │ ├── package_markers.go │ │ └── zz_generated.deepcopy.go │ ├── status │ │ ├── package_markers.go │ │ ├── status.go │ │ └── zz_generated.deepcopy.go │ ├── subscription │ │ ├── package_markers.go │ │ ├── subscription.go │ │ └── zz_generated.deepcopy.go │ └── utils │ │ ├── maps.go │ │ ├── package_markers.go │ │ ├── reference.go │ │ └── zz_generated.deepcopy.go └── v1alpha1 │ ├── apiresource_types.go │ ├── apiv2definition_types.go │ ├── apiv4definition_types.go │ ├── application_types.go │ ├── group_types.go │ ├── managementcontext_types.go │ ├── notification_types.go │ ├── package_markers.go │ ├── sharedpolicygroups_types.go │ ├── subscription_types.go │ └── zz_generated.deepcopy.go ├── bundle.Dockerfile ├── commitlint.config.js ├── controllers └── apim │ ├── apidefinition │ ├── apidefinitionv2_controller.go │ ├── apidefinitionv4_controller.go │ ├── controller.go │ └── internal │ │ ├── api_definition_template.go │ │ ├── api_resources.go │ │ ├── api_shared_policy_groups.go │ │ ├── config_map.go │ │ ├── delete.go │ │ ├── groups.go │ │ ├── notification.go │ │ ├── refs.go │ │ ├── status.go │ │ └── update.go │ ├── apiresource │ ├── apiresource_controller.go │ └── internal │ │ └── delete.go │ ├── application │ ├── application_controller.go │ └── internal │ │ ├── delete.go │ │ ├── status.go │ │ └── update.go │ ├── group │ ├── group_controller.go │ └── internal │ │ ├── delete.go │ │ ├── status.go │ │ └── update.go │ ├── ingress │ ├── ingress_controller.go │ └── internal │ │ ├── api_definition.go │ │ ├── api_definition_template.go │ │ ├── delete.go │ │ ├── mapper │ │ ├── mapper.go │ │ └── opts.go │ │ ├── secret.go │ │ └── update.go │ ├── managementcontext │ ├── internal │ │ ├── delete.go │ │ ├── secret.go │ │ └── update.go │ └── managementcontext_controller.go │ ├── notification │ ├── internal │ │ ├── delete.go │ │ ├── groups.go │ │ └── update_status.go │ └── notification_controller.go │ ├── policygroups │ ├── internal │ │ ├── delete.go │ │ ├── status.go │ │ └── update.go │ └── sharedpolicygroups_controller.go │ └── subscription │ ├── internal │ ├── delete.go │ ├── status.go │ └── update.go │ └── subscription_controller.go ├── docs ├── api │ └── reference.md └── guides │ ├── deploy-crd-with-helm │ ├── README.md │ └── src │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── templates │ │ ├── _helpers.tpl │ │ ├── api-definition.tpl │ │ └── management-context.tpl │ │ └── values │ │ ├── dev │ │ ├── apis.yaml │ │ └── common.yaml │ │ └── staging │ │ ├── apis.yaml │ │ └── common.yaml │ └── monitoring │ └── README.md ├── examples ├── apim │ ├── api_definition │ │ ├── v2 │ │ │ ├── api-with-api-key-plan.yml │ │ │ ├── api-with-cache-redis-resource-ref.yml │ │ │ ├── api-with-cache-redis-resource.yml │ │ │ ├── api-with-cache-resource-ref.yml │ │ │ ├── api-with-cache-resource.yml │ │ │ ├── api-with-context.yml │ │ │ ├── api-with-disabled-policy.yml │ │ │ ├── api-with-endpoint-groups.yml │ │ │ ├── api-with-groups-members.yml │ │ │ ├── api-with-health-check-disabled.yml │ │ │ ├── api-with-health-check.yml │ │ │ ├── api-with-http-auth-provider-ref.yml │ │ │ ├── api-with-http-auth-provider.yml │ │ │ ├── api-with-ids.yml │ │ │ ├── api-with-inline-auth-provider-ref.yml │ │ │ ├── api-with-inline-auth-provider.yml │ │ │ ├── api-with-jwt-plan.yml │ │ │ ├── api-with-keycloak-adapter-ref.yml │ │ │ ├── api-with-keycloak-adapter.yml │ │ │ ├── api-with-ldap-auth-provider-ref.yml │ │ │ ├── api-with-ldap-auth-provider.yml │ │ │ ├── api-with-logging.yml │ │ │ ├── api-with-metadata.yml │ │ │ ├── api-with-no-plan.yml │ │ │ ├── api-with-notifications-and-groups.yml │ │ │ ├── api-with-oauth2-am-resource-ref.yml │ │ │ ├── api-with-oauth2-am-resource.yml │ │ │ ├── api-with-oauth2-generic-resource-ref.yml │ │ │ ├── api-with-oauth2-generic-resource.yml │ │ │ ├── api-with-page-markdown.yml │ │ │ ├── api-with-page-swagger-http-fetcher.yml │ │ │ ├── api-with-rate-limit.yml │ │ │ ├── api-with-service-discovery.yml │ │ │ ├── api-with-state-stopped.yml │ │ │ ├── api-with-sync-from-apim.yml │ │ │ ├── api-with-template-annotation.yml │ │ │ ├── api-with-templating-config-map.yml │ │ │ ├── api-with-templating-secret.yml │ │ │ ├── api-with-templating.yml │ │ │ └── api.yml │ │ └── v4 │ │ │ ├── api-v4-native-with-context.yml │ │ │ ├── api-v4-native.yml │ │ │ ├── api-v4-with-api-key-plan.yml │ │ │ ├── api-v4-with-cache-redis-resource-ref.yml │ │ │ ├── api-v4-with-cache-redis-resource.yml │ │ │ ├── api-v4-with-context.yml │ │ │ ├── api-v4-with-disabled-policy.yml │ │ │ ├── api-v4-with-groups-members.yml │ │ │ ├── api-v4-with-health-check-disabled.yml │ │ │ ├── api-v4-with-health-check.yml │ │ │ ├── api-v4-with-http-auth-provider-ref.yml │ │ │ ├── api-v4-with-http-auth-provider.yml │ │ │ ├── api-v4-with-inline-auth-provider-ref.yml │ │ │ ├── api-v4-with-inline-auth-provider.yml │ │ │ ├── api-v4-with-jwt-plan.yml │ │ │ ├── api-v4-with-keycloak-adapter-ref.yml │ │ │ ├── api-v4-with-keycloak-adapter.yml │ │ │ ├── api-v4-with-ldap-auth-provider-ref.yml │ │ │ ├── api-v4-with-ldap-auth-provider.yml │ │ │ ├── api-v4-with-logging.yml │ │ │ ├── api-v4-with-metadata.yml │ │ │ ├── api-v4-with-notifications-and-groups.yml │ │ │ ├── api-v4-with-oauth2-am-resource-ref.yml │ │ │ ├── api-v4-with-oauth2-am-resource.yml │ │ │ ├── api-v4-with-oauth2-generic-res-ref.yml │ │ │ ├── api-v4-with-oauth2-generic-resource.yml │ │ │ ├── api-v4-with-page-markdown.yml │ │ │ ├── api-v4-with-page-swagger-http-fetcher.yml │ │ │ ├── api-v4-with-rate-limit.yml │ │ │ ├── api-v4-with-shared-policy-group.yml │ │ │ ├── api-v4-with-state-stopped.yml │ │ │ ├── api-v4-with-sync-from-apim.yml │ │ │ ├── api-v4-with-templating.yml │ │ │ └── api-v4.yml │ ├── api_resource │ │ ├── api-resource-cache-redis.yml │ │ ├── api-resource-cache.yml │ │ ├── api-resource-http-auth-provider.yml │ │ ├── api-resource-inline-auth-provider.yml │ │ ├── api-resource-keycloak-adapter.yml │ │ ├── api-resource-ldap-auth-provider.yml │ │ ├── api-resource-oauth2-am.yml │ │ └── api-resource-oauth2-generic.yml │ ├── application │ │ ├── application-with-client-cert.yml │ │ ├── application-with-client-id.yml │ │ ├── application-with-oauth-backend-to-backend-settings.yml │ │ ├── application-with-oauth-native-settings.yml │ │ ├── application-with-oauth-spa-settings.yml │ │ ├── application-with-oauth-webapp-settings.yml │ │ └── application.yml │ ├── group │ │ └── group.yml │ ├── notification │ │ ├── notification-no-group.yml │ │ └── notification-with-groups.yml │ ├── shared_policy_groups │ │ └── shared_policy_groups.yml │ └── subscription │ │ └── subscription.yml ├── embed.go ├── ingress │ ├── ingress-pem-registry.yml │ ├── ingress-response-404-config-map.yml │ ├── ingress-with-api-template.yml │ ├── ingress-with-multiple-hosts.yml │ ├── ingress-with-tls-secret.yml │ ├── ingress-with-tls.yml │ └── ingress-without-api-template.yml ├── management_context │ ├── cloud │ │ ├── cloud-bearer-secret.yml │ │ ├── cloud-mctx-with-bearer-secret-ref.yml │ │ ├── cloud-mctx-with-secret-ref-and-auth-secret-ref.yml │ │ ├── cloud-mctx-with-secret-ref.yml │ │ ├── cloud-mctx-with-unknown-secret-ref.yml │ │ └── cloud-token-secret.yml │ ├── cluster │ │ ├── management-context-secret.yml │ │ ├── management-context-with-credentials.yml │ │ └── management-context-with-secret-ref.yml │ ├── debug │ │ ├── management-context-secret.yml │ │ ├── management-context-with-credentials.yml │ │ └── management-context-with-secret-ref.yml │ └── dev │ │ ├── management-context-secret.yml │ │ ├── management-context-with-bearer-token.yml │ │ ├── management-context-with-credentials.yml │ │ └── management-context-with-secret-ref.yml └── usecase │ ├── subscribe-to-jwt-plan │ ├── README.md │ ├── pki │ │ ├── get_token.sh │ │ ├── private.key │ │ └── public.key │ └── resources │ │ ├── api.yml │ │ ├── application.yml │ │ ├── jwt-key.yml │ │ ├── management-context.yml │ │ └── subscription.yml │ └── subscribe-to-mtls-plan │ ├── README.md │ ├── pki │ ├── ca.crt │ ├── ca.key │ ├── client.crt │ ├── client.key │ ├── server.crt │ └── server.key │ └── resources │ ├── api.yml │ ├── application.yml │ ├── management-context.yml │ ├── subscription.yml │ └── tls-client.yml ├── go.mod ├── go.sum ├── hack ├── crdoc │ ├── markdown.tmpl │ └── toc.yaml ├── kind │ ├── apim │ │ ├── values-dbless.yaml │ │ └── values.yaml │ ├── httpbin │ │ └── httpbin.yaml │ └── kind.yaml ├── license.go.txt ├── make │ ├── build.mk │ ├── dev.mk │ ├── doc.mk │ ├── docker.mk │ ├── helm.mk │ ├── lint.mk │ ├── test.mk │ └── tool.mk ├── scripts │ ├── annotate-crds.mjs │ ├── create-cluster-admin-sa.mjs │ ├── generate-changelog.mjs │ ├── get-chart-version.mjs │ ├── get-release-branch.mjs │ ├── lib │ │ ├── circleci.mjs │ │ ├── index.mjs │ │ └── version.mjs │ ├── release-helm-chart.mjs │ ├── run-kind.mjs │ ├── submit-changelog.mjs │ ├── trigger-e2e-test.mjs │ ├── trigger-release.mjs │ └── trigger-test.mjs └── tools.go ├── helm └── gko │ ├── .helmignore │ ├── Chart.yaml │ ├── README.md │ ├── README.md.gotmpl │ ├── crds │ ├── gravitee.io_apidefinitions.yaml │ ├── gravitee.io_apiresources.yaml │ ├── gravitee.io_apiv4definitions.yaml │ ├── gravitee.io_applications.yaml │ ├── gravitee.io_groups.yaml │ ├── gravitee.io_managementcontexts.yaml │ ├── gravitee.io_notifications.yaml │ ├── gravitee.io_sharedpolicygroups.yaml │ └── gravitee.io_subscriptions.yaml │ ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── debug │ │ ├── deployment.yaml │ │ └── service.yaml │ ├── manager │ │ ├── config.yaml │ │ └── deployment.yaml │ ├── metrics │ │ ├── prometheus-instance.yaml │ │ ├── prometheus-service-monitor.yaml │ │ └── service.yaml │ ├── rbac │ │ ├── admission-webhook-cluster-role-binding.yaml │ │ ├── admission-webhook-cluster-role.yaml │ │ ├── leader-election-role-binding.yaml │ │ ├── leader-election-role.yaml │ │ ├── manager-cluster-role-binding.yaml │ │ ├── manager-cluster-role.yaml │ │ ├── manager-role-binding.yaml │ │ ├── manager-role.yaml │ │ ├── metrics-cluster-role-binding.yaml │ │ ├── metrics-cluster-role.yaml │ │ ├── resource-patch-cluster-role-binding.yaml │ │ ├── resource-patch-cluster-role.yaml │ │ └── service-account.yaml │ └── webhook │ │ ├── mutation-webhook.yaml │ │ ├── secret.yaml │ │ ├── service.yaml │ │ └── validation-webhook.yaml │ ├── tests │ ├── manager │ │ ├── config_test.yaml │ │ └── deployment_test.yaml │ ├── metrics │ │ └── service_test.yaml │ ├── rbac │ │ ├── leader-election-role-binding_test.yaml │ │ ├── leader-election-role_test.yaml │ │ ├── manager-cluster-role-binding_test.yaml │ │ ├── manager-cluster-role_test.yaml │ │ ├── manager-role-binding_test.yaml │ │ ├── manager-role_test.yaml │ │ ├── metrics-cluster-role-binding_test.yaml │ │ ├── metrics-cluster-role_test.yaml │ │ ├── resource-patch-cluster-role-binding_test.yaml │ │ ├── resource-patch-cluster-role_test.yaml │ │ ├── service-account_test.yaml │ │ ├── validation-webhook-cluster-role-binding_test.yaml │ │ └── validation-webhook-cluster-role_test.yaml │ └── webhook │ │ ├── secret_test.yaml │ │ ├── service_test.yaml │ │ └── validation_webhook_test.yaml │ └── values.yaml ├── internal ├── admission │ ├── api │ │ ├── base │ │ │ ├── configmap.go │ │ │ ├── notifications.go │ │ │ ├── pages.go │ │ │ ├── paths.go │ │ │ ├── plans.go │ │ │ ├── resource.go │ │ │ └── validate.go │ │ ├── v2 │ │ │ ├── ctrl.go │ │ │ └── validate.go │ │ └── v4 │ │ │ ├── api_type.go │ │ │ ├── ctrl.go │ │ │ ├── flows.go │ │ │ ├── shared_policy_group.go │ │ │ └── validate.go │ ├── application │ │ ├── ctrl.go │ │ └── validate.go │ ├── ctxref │ │ └── validate.go │ ├── group │ │ ├── crtl.go │ │ └── validate.go │ ├── mctx │ │ ├── ctrl.go │ │ ├── default.go │ │ └── validate.go │ ├── policygroups │ │ ├── ctrl.go │ │ └── validate.go │ ├── resource │ │ ├── ctrl.go │ │ └── validate.go │ ├── subscription │ │ ├── ctrl.go │ │ └── validate.go │ └── template.go ├── apim │ ├── apim.go │ ├── auth.go │ ├── client │ │ └── client.go │ ├── model │ │ ├── api.go │ │ ├── api_key.go │ │ ├── application.go │ │ ├── env.go │ │ ├── page.go │ │ ├── sharedpolicygroups.go │ │ ├── subscription.go │ │ └── user.go │ └── service │ │ ├── apis.go │ │ ├── applications.go │ │ ├── env.go │ │ ├── org.go │ │ ├── pages.go │ │ ├── sharedpolicygroups.go │ │ └── subscriptions.go ├── core │ ├── interface.go │ └── keys.go ├── el │ └── el.go ├── env │ └── env.go ├── errors │ ├── admission.go │ └── errors.go ├── event │ └── event.go ├── gateway │ └── config.go ├── hash │ └── hash.go ├── http │ ├── auth.go │ ├── headers.go │ ├── http.go │ ├── json.go │ ├── url.go │ └── yaml.go ├── k8s │ ├── annotation.go │ ├── client.go │ ├── dynamic │ │ ├── apis.go │ │ ├── applications.go │ │ ├── client.go │ │ ├── convert.go │ │ ├── group.go │ │ ├── gvr.go │ │ ├── kind.go │ │ ├── mctx.go │ │ ├── notification.go │ │ ├── resolve.go │ │ ├── resource.go │ │ └── secret.go │ └── ingress.go ├── log │ └── log.go ├── predicate │ └── predicate.go ├── search │ ├── assert.go │ ├── indexer.go │ └── search.go ├── template │ ├── compiler.go │ └── tree.go ├── types │ └── list │ │ └── list.go ├── uuid │ └── uuid.go ├── watch │ └── watch.go └── webhook │ └── certs.go ├── main.go ├── openapi ├── Gravitee.io GKO - Management API Selected Endpoints.postman_collection.json └── openapi.yml ├── sonar-project.properties └── test ├── e2e └── chainsaw │ ├── commands │ ├── callGateway.mjs │ ├── createApiFromJson.mjs │ └── exportApiAsYaml.mjs │ ├── config.yaml │ └── tests │ └── apis │ ├── create-update-delete │ ├── v2 │ │ ├── chainsaw-test.yaml │ │ └── keyless-v2.yaml │ └── v4 │ │ ├── chainsaw-test.yaml │ │ └── keyless-v4.yaml │ └── export-import │ ├── v2 │ ├── chainsaw-test.yaml │ └── v2-api-config-rich.json │ └── v4 │ ├── chainsaw-test.yaml │ └── v4-api-config-rich.json ├── integration ├── README.md ├── admission │ ├── api │ │ ├── v2 │ │ │ ├── create_withContext_andMissingConsoleNotification_test.go │ │ │ ├── create_withContext_andMissingGroupAndEventsConsoleNotification_test.go │ │ │ ├── create_withContext_andMissingParentPage_test.go │ │ │ ├── create_withContext_andTooManyConsoleNotification_test.go │ │ │ ├── create_withContext_andUnknownContext_test.go │ │ │ ├── create_withContext_andUnknownResourceRef_test.go │ │ │ ├── create_withoutContext_andConflictingPath_test.go │ │ │ ├── create_withoutContext_andNoPlansWhileStarted_test.go │ │ │ ├── create_withoutContext_templatingWithMissingConfigmapKey_test.go │ │ │ ├── create_withoutContext_templatingWithMissingConfigmap_test.go │ │ │ ├── create_withoutContext_templatingWithMissingSecreteKey_test.go │ │ │ ├── create_withoutContext_templatingWithMissingSecrete_test.go │ │ │ ├── delete_withContext_andSubscription_test.go │ │ │ ├── suite_test.go │ │ │ ├── update_withContext_andUnknownCategory_test.go │ │ │ ├── update_withContext_andUnknownMember_test.go │ │ │ ├── update_withContext_deletingSubscribedPlan_test.go │ │ │ ├── update_withoutContext_templatingWithMissingConfigmapKey_test.go │ │ │ ├── update_withoutContext_templatingWithMissingConfigmap_test.go │ │ │ └── update_withoutContext_templatingWithMissingSecrete_test.go │ │ └── v4 │ │ │ ├── create_withContext_andInvalidResourceConfig_test.go │ │ │ ├── create_withContext_andMissingConsoleNotification_test.go │ │ │ ├── create_withContext_andMissingGroupAndEventsConsoleNotification_test.go │ │ │ ├── create_withContext_andMissingParentPage_test.go │ │ │ ├── create_withContext_andMissingSharedPolicyGroup_test.go │ │ │ ├── create_withContext_andTooManyConsoleNotification_test.go │ │ │ ├── create_withContext_andUnknownContext_test.go │ │ │ ├── create_withContext_andUnknownResourceRef_test.go │ │ │ ├── create_withContext_andWrongSharedPolicyGroupPhase_test.go │ │ │ ├── create_withoutContext_andConflictingPath_test.go │ │ │ ├── create_withoutContext_andNoPlans_test.go │ │ │ ├── create_withoutContext_templatingWithMissingConfigmap_test.go │ │ │ ├── create_withoutContext_templatingWithMissingSecreteKey_test.go │ │ │ ├── create_withoutContext_templatingWithMissingSecrete_test.go │ │ │ ├── create_withoutContext_withInvalidFlows.go │ │ │ ├── delete_withContext_andSubscription_test.go │ │ │ ├── suite_test.go │ │ │ ├── update_withContext_andInvalidResourceConfig_test.go │ │ │ ├── update_withContext_andUnknownCategory_test.go │ │ │ ├── update_withContext_andUnknownContext_test.go │ │ │ ├── update_withContext_andUnknownMember_test.go │ │ │ ├── update_withContext_deletingSubscribedPlan_test.go │ │ │ ├── update_withoutContext_andConflictingPath_test.go │ │ │ ├── update_withoutContext_andNoPlans_test.go │ │ │ ├── update_withoutContext_templatingWithMissingConfigmapKey_test.go │ │ │ ├── update_withoutContext_templatingWithMissingConfigmap_test.go │ │ │ ├── update_withoutContext_templatingWithMissingSecrete_test.go │ │ │ ├── update_withoutContext_withInvalidAPIType.go │ │ │ └── update_withoutContext_withInvalidFlows.go │ ├── application │ │ ├── create_withContext_andUnknownContext_test.go │ │ ├── create_withContext_andUnknown_group_test.go │ │ ├── create_withContext_andWrongSettings_test.go │ │ ├── create_withContext_templatingWithMissingConfigmap_test.go │ │ ├── create_withContext_templatingWithMissingSecreteKey_test.go │ │ ├── create_withContext_templatingWithMissingSecrete_test.go │ │ ├── delete_withContext_andSubscription_test.go │ │ ├── suite_test.go │ │ ├── update_withContext_changingOAuthType_test.go │ │ ├── update_withContext_movingFromSimpleToOAuthSettings_test.go │ │ ├── update_withContext_templatingWithMissingConfigmap_test.go │ │ └── update_withContext_templatingWithMissingSecrete_test.go │ ├── group │ │ ├── suite_test.go │ │ └── update_withContext_andPrimaryOwner_test.go │ ├── managementcontext │ │ ├── create_templatingWithMissingConfigmap_test.go │ │ ├── create_templatingWithMissingSecrete_test.go │ │ ├── create_withBadCredentials_test.go │ │ ├── create_withEnvironmentNotFound_test.go │ │ ├── create_withMissingSecret_test.go │ │ ├── create_withNetworkError_test.go │ │ ├── defaults_withCloudMissingSecretRef_test.go │ │ ├── defaults_withCloudSecretRefAndAuthRef_test.go │ │ ├── defaults_withCloudSecretRefWrongKey_test.go │ │ ├── defaults_withCloudSecretRef_test.go │ │ ├── delete_withRef_test.go │ │ ├── suite_test.go │ │ ├── update_templatingWithMissingConfigmap_test.go │ │ ├── update_templatingWithMissingSecrete_test.go │ │ ├── update_withMissingSecret_test.go │ │ └── update_withNetworkError_test.go │ ├── sharedpolicygroups │ │ ├── create_withContext_andInvalidPhasePlugin_test.go │ │ ├── create_withContext_andInvalidPhase_test.go │ │ ├── create_withContext_andInvalidStep_test.go │ │ ├── suite_test.go │ │ ├── update_withContext_andInvalidImmutableFields.go │ │ └── update_withContext_andInvalidStep_test.go │ └── subscription │ │ ├── create_withContext_and_contextMissmatch_test.go │ │ ├── create_withContext_and_invalidEndingAt_test.go │ │ ├── create_withContext_and_noClientID_test.go │ │ ├── create_withContext_and_stoppedAPI_test.go │ │ ├── create_withContext_and_syncFromKubernetesV2_test.go │ │ ├── create_withContext_and_syncFromKubernetes_test.go │ │ ├── create_withContext_and_unknownAPI_test.go │ │ ├── create_withContext_and_unknownApp_test.go │ │ ├── create_withContext_and_unknownPlanV2_test.go │ │ ├── create_withContext_and_unknownPlan_test.go │ │ ├── suite_test.go │ │ ├── update_withContext_and_invalidEndingAt_test.go │ │ └── update_withContext_mutatingIllegalProps_test.go ├── apidefinition │ ├── v2 │ │ ├── create_withContext_andGroupRef_test.go │ │ ├── create_withContext_andLocalFalse_test.go │ │ ├── create_withContext_andMardownPage_test.go │ │ ├── create_withContext_andMemberWithoutRole_test.go │ │ ├── create_withContext_andNotificationWithGroupRef_test.go │ │ ├── create_withContext_andOneCategory_test.go │ │ ├── create_withContext_andOneGroup_test.go │ │ ├── create_withContext_andPageWithACL_test.go │ │ ├── create_withContext_andSwaggerHTTPFetcher_test.go │ │ ├── create_withContext_fromExport_test.go │ │ ├── create_withContext_inOtherNamespace_test.go │ │ ├── create_withContext_test.go │ │ ├── create_withWrongContext_test.go │ │ ├── create_withoutContext_test.go │ │ ├── delete_withContext_notFoundInAPIM_test.go │ │ ├── delete_withContext_test.go │ │ ├── delete_withoutContext_asTemplate_test.go │ │ ├── delete_withoutContext_test.go │ │ ├── start_withContext_test.go │ │ ├── start_withoutContext_test.go │ │ ├── stop_withContext_test.go │ │ ├── stop_withoutContext_test.go │ │ ├── subscribe_withContext_test.go │ │ ├── suite_test.go │ │ ├── update_withContext_andLocalFalse_test.go │ │ ├── update_withContext_andMardownPage_test.go │ │ ├── update_withContext_andNotificationWithGroupRef_test.go │ │ ├── update_withContext_changingMemberRole_test.go │ │ ├── update_withContext_createMultipleCategoriesAndDeleteOne_test.go │ │ ├── update_withContext_createMultipleGroupsAndDeleteOne_test.go │ │ ├── update_withContext_deletingPage_test.go │ │ ├── update_withContext_removingMember_test.go │ │ ├── update_withContext_test.go │ │ ├── update_withoutContext_asTemplate_test.go │ │ └── update_withoutContext_test.go │ └── v4 │ │ ├── create_withContext_andGroupRef_test.go │ │ ├── create_withContext_andLocalFalse_test.go │ │ ├── create_withContext_andMemberWithoutRole_test.go │ │ ├── create_withContext_andNotificationWithGroupRef_test.go │ │ ├── create_withContext_andOneCategory_test.go │ │ ├── create_withContext_andOneGroup_test.go │ │ ├── create_withContext_andSwaggerHTTPFetcher_test.go │ │ ├── create_withContext_test.go │ │ ├── create_withWrongContext_test.go │ │ ├── create_withoutContext_test.go │ │ ├── delete_withContext_notFoundInAPIM_test.go │ │ ├── delete_withContext_test.go │ │ ├── delete_withoutContext_test.go │ │ ├── start_withContext_test.go │ │ ├── start_withoutContext_test.go │ │ ├── stop_withContext_test.go │ │ ├── stop_withoutContext_test.go │ │ ├── subscribe_withContext_test.go │ │ ├── suite_test.go │ │ ├── update_withContext_andLocalFalse_test.go │ │ ├── update_withContext_andNotificationWithGroupRef_test.go │ │ ├── update_withContext_changingMemberRole_test.go │ │ ├── update_withContext_createMultipleCategoriesAndDeleteOne_test.go │ │ ├── update_withContext_createMultipleGroupsAndDeleteOne_test.go │ │ ├── update_withContext_removingMember_test.go │ │ ├── update_withContext_test.go │ │ ├── update_withoutContext_test.go │ │ ├── v4-create_withContext_andMardownPage_test.go │ │ ├── v4-update_withContext_andMardownPage_test.go │ │ ├── v4-update_withContext_deletingPage_test.go │ │ └── v4_create_withContext_test.go ├── apiresource │ ├── create_withContext_test.go │ ├── create_withoutContext_test.go │ ├── delete_withoutContext_test.go │ ├── suite_test.go │ ├── update_WithContext_test.go │ ├── v4-create_withContext_test.go │ ├── v4_create_withoutContext_test.go │ ├── v4_delete_withoutContext_test.go │ └── v4_update_WithContext_test.go ├── application │ ├── create_withContext_test.go │ ├── delete_withContext_test.go │ ├── suite_test.go │ └── update_withContext_test.go ├── ingress │ ├── create_withoutContext_andMultipleHosts_test.go │ ├── create_withoutContext_andTLS_test.go │ ├── create_withoutContext_andTemplate_test.go │ ├── create_withoutContext_test.go │ ├── delete_withoutContext_andTLS_test.go │ ├── delete_withoutContext_test.go │ ├── suite_test.go │ └── update_withoutContext_test.go ├── managementcontext │ ├── delete_withContext_forApi_test.go │ ├── delete_withContext_forApplication_test.go │ ├── delete_withContext_forSharedPolicyGroup_test.go │ ├── delete_withContext_for_Api_v4_test.go │ └── suite_test.go ├── notification │ ├── create_withContext_test.go │ ├── delete_when_referenced_withContext_test.go │ ├── delete_withContext_test.go │ ├── suite_test.go │ └── update_withContext_test.go ├── secret │ ├── delete_withContext_andSecretRef.go │ └── suite_test.go ├── sharedpolicygroups │ ├── create_withContext_test.go │ ├── delete_withContext_for_Api_v4_test.go │ ├── suite_test.go │ └── update_withContext_test.go ├── usecase │ ├── subscribe_withContext_andJWT_test.go │ ├── subscribe_withContext_andJWT_v2_test.go │ ├── subscribe_withContext_andMTLS_test.go │ └── suite_test.go └── webhook │ ├── suite_test.go │ ├── webhook_generate_secretes_withoutContext.go │ ├── webhook_patch_admission_webhook_configuration_withoutContext.go │ └── webhook_patch_secret_withoutContext.go ├── internal └── integration │ ├── apim │ ├── apim.go │ ├── export.go │ └── notification.go │ ├── assert │ └── assert.go │ ├── constants │ └── constants.go │ ├── fixture │ ├── apply.go │ ├── build.go │ ├── decode.go │ └── objects.go │ ├── http │ └── client.go │ ├── jwt │ └── jwt.go │ ├── labels │ └── labels.go │ ├── manager │ ├── client.go │ └── manager.go │ ├── random │ └── names.go │ └── sort │ └── comparators.go └── unit ├── admission └── mctx │ ├── cloud_object.go │ ├── mctx_default.go │ └── suite_test.go ├── apim ├── error_test.go └── suite_test.go ├── ingress ├── keystore.go ├── properties.go └── suite_test.go └── uuid └── suite_test.go /.dockerignore: -------------------------------------------------------------------------------- 1 | # More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file 2 | # Ignore build and test binaries. 3 | bin/ 4 | testbin/ 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default 2 | * @gravitee-io/archi @gravitee-io/gko 3 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "schedule:earlyMondays", 5 | ":semanticCommits", 6 | ":semanticCommitTypeAll(chore)" 7 | ], 8 | "prConcurrentLimit": 3, 9 | "rebaseWhen": "conflicted", 10 | "postUpdateOptions": ["gomodTidy"], 11 | "gomod": { 12 | "enabled": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/workflows/schedule-test.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Schedule Integration Test Suite 16 | 17 | on: 18 | schedule: 19 | - cron: "00 05 * * 1-5" 20 | jobs: 21 | trigger-test-suite: 22 | runs-on: ubuntu-latest 23 | env: 24 | BRANCH: ${{ matrix.branch }} 25 | CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }} 26 | strategy: 27 | fail-fast: false 28 | matrix: 29 | branch: 30 | - 4.4.x 31 | - 4.5.x 32 | - 4.6.x 33 | - 4.7.x 34 | - master 35 | steps: 36 | - uses: actions/checkout@v4 37 | with: 38 | fetch-depth: 0 39 | persist-credentials: false 40 | - name: "Trigger test pipeline and notify on failure" 41 | run: | 42 | echo "🧪 Triggering test pipeline" 43 | npx zx hack/scripts/trigger-test.mjs --notify true --branch ${BRANCH} 44 | -------------------------------------------------------------------------------- /.github/workflows/trigger-e2e.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Trigger E2E 16 | 17 | on: 18 | workflow_dispatch: 19 | inputs: 20 | pipeline-branch: 21 | description: "CircleCI pipeline branch" 22 | required: false 23 | default: "" 24 | type: string 25 | jobs: 26 | trigger-test-suite: 27 | runs-on: ubuntu-latest 28 | env: 29 | CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }} 30 | PIPELINE_BRANCH: ${{ inputs.pipeline-branch }} 31 | steps: 32 | - uses: actions/checkout@v4 33 | with: 34 | fetch-depth: 0 35 | persist-credentials: false 36 | - name: "Trigger E2E pipeline" 37 | run: | 38 | echo "🧪 Triggering E2E test pipeline" 39 | npx zx hack/scripts/trigger-e2e-test.mjs --pipeline-branch ${PIPELINE_BRANCH} 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Binaries for programs and plugins 3 | *.exe 4 | *.exe~ 5 | *.dll 6 | *.so 7 | *.dylib 8 | bin 9 | testbin/* 10 | .env 11 | __debug_bin* 12 | 13 | # Test binary, build with `go test -c` 14 | *.test 15 | 16 | # Output of the go coverage tool, specifically when used with LiteIDE 17 | *.out 18 | *.out.* 19 | junit.xml 20 | 21 | # Kubernetes Generated files - skip generated files, except for vendored files 22 | 23 | !vendor/**/zz_generated.* 24 | 25 | # editor and IDE paraphernalia 26 | .idea 27 | .vscode 28 | *.swp 29 | *.swo 30 | *~ 31 | __debug_bin 32 | 33 | # Build files by Makefile 34 | gko-config-default.yml 35 | 36 | # K8S OLM 37 | cache/ 38 | bundle/ 39 | bundle.yml 40 | 41 | # MacOS 42 | .DS_Store 43 | 44 | # Kyverno Chainsaw E2E tests 45 | chainsaw/reports/ 46 | node_modules 47 | license.key 48 | -------------------------------------------------------------------------------- /LICENSE_TEMPLATE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) 2 | ifeq (,$(shell go env GOBIN)) 3 | GOBIN=$(shell go env GOPATH)/bin 4 | else 5 | GOBIN=$(shell go env GOBIN) 6 | endif 7 | 8 | # Setting SHELL to bash allows bash commands to be executed by recipes. 9 | # This is a requirement for 'setup-envtest.sh' in the test target. 10 | # Options are set to exit when a recipe line exits non-zero or a piped command fails. 11 | SHELL = /usr/bin/env bash -o pipefail 12 | .SHELLFLAGS = -ec 13 | 14 | include hack/make/tool.mk 15 | include hack/make/build.mk 16 | include hack/make/docker.mk 17 | include hack/make/helm.mk 18 | include hack/make/dev.mk 19 | include hack/make/lint.mk 20 | include hack/make/test.mk 21 | include hack/make/doc.mk 22 | 23 | .PHONY: all 24 | all: build 25 | 26 | ##@ General 27 | 28 | .PHONY: help 29 | help: ## Display this help. 30 | @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) 31 | -------------------------------------------------------------------------------- /PROJECT: -------------------------------------------------------------------------------- 1 | domain: gravitee.io 2 | layout: 3 | - go.kubebuilder.io/v3 4 | plugins: 5 | manifests.sdk.operatorframework.io/v2: {} 6 | scorecard.sdk.operatorframework.io/v2: {} 7 | projectName: gko 8 | repo: github.com/gravitee-io/gravitee-kubernetes-operator 9 | resources: 10 | - api: 11 | crdVersion: v1 12 | namespaced: true 13 | controller: true 14 | domain: gravitee.io 15 | kind: ApiDefinition 16 | path: github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1 17 | version: v1alpha1 18 | - api: 19 | crdVersion: v1 20 | namespaced: true 21 | controller: true 22 | domain: gravitee.io 23 | kind: ManagementContext 24 | path: github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1 25 | version: v1alpha1 26 | - api: 27 | crdVersion: v1 28 | namespaced: true 29 | controller: true 30 | domain: gravitee.io 31 | kind: ApiResource 32 | path: github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1 33 | version: v1alpha1 34 | version: "3" 35 | -------------------------------------------------------------------------------- /api/model/api/base/metadata.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package base 16 | 17 | // +kubebuilder:validation:Enum=STRING;NUMERIC;BOOLEAN;DATE;MAIL;URL; 18 | type MetadataFormat string 19 | 20 | type MetadataEntry struct { 21 | // Metadata Key 22 | Key string `json:"key"` 23 | // Metadata Name 24 | Name string `json:"name"` 25 | // Metadata Format 26 | Format MetadataFormat `json:"format"` 27 | // Metadata Value 28 | Value string `json:"value,omitempty"` 29 | // Metadata Default value 30 | // +kubebuilder:validation:Optional 31 | DefaultValue *string `json:"defaultValue,omitempty"` 32 | } 33 | -------------------------------------------------------------------------------- /api/model/api/base/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package base 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/api/base/properties.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package base 16 | 17 | type Property struct { 18 | // Property Key 19 | // +kubebuilder:validation:Optional 20 | Key *string `json:"key,omitempty"` 21 | // Property Value 22 | // +kubebuilder:validation:Optional 23 | Value *string `json:"value,omitempty"` 24 | // Property Encrypted or not? 25 | // +kubebuilder:validation:Optional 26 | Encrypted *bool `json:"encrypted,omitempty"` 27 | // Property is dynamic or not? 28 | // +kubebuilder:validation:Optional 29 | Dynamic *bool `json:"dynamic,omitempty"` 30 | // Property is encryptable or not? 31 | // +kubebuilder:validation:Optional 32 | Encryptable *bool `json:"encryptable,omitempty"` 33 | } 34 | -------------------------------------------------------------------------------- /api/model/api/v2/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package v2 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/api/v2/page.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2 16 | 17 | import "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/api/base" 18 | 19 | type Page struct { 20 | *base.Page `json:",inline"` 21 | // If the page is private, defines a set of user groups with access 22 | // +kubebuilder:validation:Optional 23 | // +kubebuilder:default:={} 24 | AccessControls []base.AccessControl `json:"accessControls"` 25 | // if true, the references defined in the accessControls list will be 26 | // denied access instead of being granted 27 | // +kubebuilder:validation:Optional 28 | ExcludedAccessControl *bool `json:"excludedAccessControls"` 29 | } 30 | -------------------------------------------------------------------------------- /api/model/api/v4/enum.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v4 16 | 17 | import "strings" 18 | 19 | type Enum string 20 | 21 | func (e Enum) ToGatewayDefinition() string { 22 | return strings.ReplaceAll(strings.ToLower(string(e)), "_", "-") 23 | } 24 | -------------------------------------------------------------------------------- /api/model/api/v4/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package v4 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/api/v4/page.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v4 16 | 17 | import "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/api/base" 18 | 19 | type Page struct { 20 | *base.Page `json:",inline"` 21 | } 22 | -------------------------------------------------------------------------------- /api/model/application/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package application 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/group/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package group 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/management/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package management 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/notification/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package notification 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/policygroups/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package policygroups 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/refs/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package refs 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/refs/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package refs 22 | 23 | import () 24 | 25 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 26 | func (in *NamespacedName) DeepCopyInto(out *NamespacedName) { 27 | *out = *in 28 | } 29 | 30 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespacedName. 31 | func (in *NamespacedName) DeepCopy() *NamespacedName { 32 | if in == nil { 33 | return nil 34 | } 35 | out := new(NamespacedName) 36 | in.DeepCopyInto(out) 37 | return out 38 | } 39 | -------------------------------------------------------------------------------- /api/model/status/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package status 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/status/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package status 16 | 17 | type Errors struct { 18 | // warning errors do not block object reconciliation, 19 | // most of the time because the value is ignored or defaulted 20 | // when the API gets synced with APIM 21 | Warning []string `json:"warning,omitempty"` 22 | // severe errors do not pass admission and will block reconcile 23 | // hence, this field should always be during the admission phase 24 | // and is very unlikely to be persisted in the status 25 | Severe []string `json:"severe,omitempty"` 26 | } 27 | -------------------------------------------------------------------------------- /api/model/subscription/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package subscription 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/utils/package_markers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +kubebuilder:object:generate=true 16 | 17 | package utils 18 | 19 | // placeholder files for package level markers 20 | -------------------------------------------------------------------------------- /api/model/utils/reference.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import "golang.org/x/exp/constraints" 20 | 21 | func ToReference[T any](t T) *T { 22 | return &t 23 | } 24 | 25 | func ToStringValue(s *string) string { 26 | if s == nil { 27 | return "" 28 | } 29 | 30 | return *s 31 | } 32 | 33 | func ToNumberValue[T constraints.Float | constraints.Integer | constraints.Unsigned](t *T) T { 34 | if t == nil { 35 | return 0 36 | } 37 | 38 | return *t 39 | } 40 | -------------------------------------------------------------------------------- /api/model/utils/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package utils 22 | 23 | import () 24 | 25 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GenericStringMap. 26 | func (in *GenericStringMap) DeepCopy() *GenericStringMap { 27 | if in == nil { 28 | return nil 29 | } 30 | out := new(GenericStringMap) 31 | in.DeepCopyInto(out) 32 | return out 33 | } 34 | -------------------------------------------------------------------------------- /api/v1alpha1/package_markers.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 DAVID BRASSELY. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package v1alpha1 contains API Schema definitions for the v1alpha1 API group 18 | // +kubebuilder:object:generate=true 19 | // +groupName=gravitee.io 20 | package v1alpha1 21 | 22 | import ( 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | "sigs.k8s.io/controller-runtime/pkg/scheme" 25 | ) 26 | 27 | var ( 28 | // GroupVersion is group version used to register these objects. 29 | GroupVersion = schema.GroupVersion{Group: "gravitee.io", Version: "v1alpha1"} 30 | 31 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme. 32 | SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} 33 | 34 | // AddToScheme adds the types in this group-version to the given scheme. 35 | AddToScheme = SchemeBuilder.AddToScheme 36 | ) 37 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module.exports = { 18 | extends: ['@commitlint/config-conventional'], 19 | rules: { 20 | 'body-max-line-length': [2, 'always', 120], 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /controllers/apim/apidefinition/internal/refs.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 19 | "k8s.io/apimachinery/pkg/types" 20 | ) 21 | 22 | func getNamespacedName(ref core.ObjectRef, apiNs string) types.NamespacedName { 23 | if ref.GetNamespace() == "" { 24 | return types.NamespacedName{ 25 | Name: ref.GetName(), 26 | Namespace: apiNs, 27 | } 28 | } 29 | return ref.NamespacedName() 30 | } 31 | -------------------------------------------------------------------------------- /controllers/apim/apidefinition/internal/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 22 | ) 23 | 24 | func UpdateStatusSuccess(ctx context.Context, api core.Object) error { 25 | if !api.GetDeletionTimestamp().IsZero() { 26 | return nil 27 | } 28 | 29 | api.GetStatus().SetProcessingStatus(core.ProcessingStatusCompleted) 30 | return k8s.GetClient().Status().Update(ctx, api) 31 | } 32 | 33 | func UpdateStatusFailure(ctx context.Context, api core.Object) error { 34 | api.GetStatus().SetProcessingStatus(core.ProcessingStatusFailed) 35 | return k8s.GetClient().Status().Update(ctx, api) 36 | } 37 | -------------------------------------------------------------------------------- /controllers/apim/application/internal/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 23 | ) 24 | 25 | func UpdateStatusSuccess(ctx context.Context, application *v1alpha1.Application) error { 26 | if application.IsBeingDeleted() { 27 | return nil 28 | } 29 | 30 | application.Status.ProcessingStatus = core.ProcessingStatusCompleted 31 | return k8s.GetClient().Status().Update(ctx, application) 32 | } 33 | 34 | func UpdateStatusFailure(ctx context.Context, application *v1alpha1.Application) error { 35 | application.Status.ProcessingStatus = core.ProcessingStatusFailed 36 | return k8s.GetClient().Status().Update(ctx, application) 37 | } 38 | -------------------------------------------------------------------------------- /controllers/apim/application/internal/update.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 23 | ) 24 | 25 | func CreateOrUpdate(ctx context.Context, application *v1alpha1.Application) error { 26 | spec := &application.Spec 27 | 28 | apim, err := apim.FromContextRef(ctx, spec.Context, application.GetNamespace()) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | application.PopulateIDs(apim.Context) 34 | 35 | status, mgmtErr := apim.Applications.CreateOrUpdate(&spec.Application) 36 | if mgmtErr != nil { 37 | return errors.NewContextError(mgmtErr) 38 | } 39 | 40 | status.DeepCopyInto(&application.Status.Status) 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /controllers/apim/group/internal/delete.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 23 | util "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" 24 | ) 25 | 26 | func Delete(ctx context.Context, group *v1alpha1.Group) error { 27 | if !util.ContainsFinalizer(group, core.GroupFinalizer) { 28 | return nil 29 | } 30 | 31 | ns := group.Namespace 32 | 33 | apim, err := apim.FromContextRef(ctx, group.ContextRef(), ns) 34 | if err != nil { 35 | return err 36 | } 37 | 38 | return apim.Env.DeleteGroup(group.Status.ID) 39 | } 40 | -------------------------------------------------------------------------------- /controllers/apim/group/internal/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 23 | ) 24 | 25 | func UpdateStatusSuccess(ctx context.Context, group *v1alpha1.Group) error { 26 | if group.IsBeingDeleted() { 27 | return nil 28 | } 29 | 30 | group.Status.ProcessingStatus = core.ProcessingStatusCompleted 31 | return k8s.GetClient().Status().Update(ctx, group) 32 | } 33 | 34 | func UpdateStatusFailure(ctx context.Context, group *v1alpha1.Group) error { 35 | group.Status.ProcessingStatus = core.ProcessingStatusFailed 36 | return k8s.GetClient().Status().Update(ctx, group) 37 | } 38 | -------------------------------------------------------------------------------- /controllers/apim/group/internal/update.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim" 22 | ) 23 | 24 | func CreateOrUpdate(ctx context.Context, group *v1alpha1.Group) error { 25 | ns := group.Namespace 26 | spec := group.Spec 27 | 28 | apim, err := apim.FromContextRef(ctx, group.ContextRef(), ns) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | group.PopulateIDs(apim.Context) 34 | 35 | status, err := apim.Env.ImportGroup(spec.Type) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | group.Status.ID = status.ID 41 | group.Status.OrgID = apim.Context.GetOrgID() 42 | group.Status.EnvID = apim.Context.GetEnvID() 43 | group.Status.Members = status.Members 44 | 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /controllers/apim/ingress/internal/delete.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/log" 21 | v1 "k8s.io/api/networking/v1" 22 | ) 23 | 24 | func Delete( 25 | ctx context.Context, 26 | ingress *v1.Ingress) error { 27 | if err := deleteIngressTLSReference(ctx, ingress); err != nil { 28 | log.Error(ctx, err, "An error occurred while updating the TLS secrets", log.KeyValues(ingress)...) 29 | return err 30 | } 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /controllers/apim/ingress/internal/update.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/log" 21 | v1 "k8s.io/api/networking/v1" 22 | ) 23 | 24 | func CreateOrUpdate( 25 | ctx context.Context, 26 | desired *v1.Ingress) error { 27 | if err := updateIngressTLSReference(ctx, desired); err != nil { 28 | log.Error( 29 | ctx, 30 | err, 31 | "An error occurred while updating the gateway PEM registry", 32 | log.KeyValues(desired)..., 33 | ) 34 | return err 35 | } 36 | 37 | _, err := createOrUpdateApiDefinition(ctx, desired) 38 | if err != nil { 39 | log.Error( 40 | ctx, 41 | err, 42 | "An error occurs while mapping ingress to an API definition", 43 | log.KeyValues(desired)..., 44 | ) 45 | return err 46 | } 47 | 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /controllers/apim/policygroups/internal/update.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 23 | ) 24 | 25 | func CreateOrUpdate(ctx context.Context, spg *v1alpha1.SharedPolicyGroup) error { 26 | spec := &spg.Spec 27 | 28 | apim, err := apim.FromContextRef(ctx, spec.Context, spg.GetNamespace()) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | spg.PopulateIDs(apim.Context) 34 | 35 | status, mgmtErr := apim.SharedPolicyGroup.CreateOrUpdate(spec.SharedPolicyGroup) 36 | if mgmtErr != nil { 37 | return errors.NewContextError(mgmtErr) 38 | } 39 | 40 | status.DeepCopyInto(&spg.Status.Status) 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /controllers/apim/subscription/internal/status.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package internal 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 23 | ) 24 | 25 | func UpdateStatusSuccess(ctx context.Context, subscription *v1alpha1.Subscription) error { 26 | if subscription.IsBeingDeleted() { 27 | return nil 28 | } 29 | 30 | subscription.Status.ProcessingStatus = core.ProcessingStatusCompleted 31 | return k8s.GetClient().Status().Update(ctx, subscription) 32 | } 33 | 34 | func UpdateStatusFailure(ctx context.Context, subscription *v1alpha1.Subscription) error { 35 | subscription.Status.ProcessingStatus = core.ProcessingStatusFailed 36 | return k8s.GetClient().Status().Update(ctx, subscription) 37 | } 38 | -------------------------------------------------------------------------------- /docs/guides/deploy-crd-with-helm/src/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /docs/guides/deploy-crd-with-helm/src/templates/management-context.tpl: -------------------------------------------------------------------------------- 1 | apiVersion: gravitee.io/v1alpha1 2 | kind: ManagementContext 3 | metadata: 4 | name: {{ regexReplaceAll "\\W+" .Values.context.name "-" | lower }} 5 | spec: 6 | baseUrl: {{ .Values.context.baseUrl }} 7 | environmentId: {{ .Values.context.environmentId }} 8 | organizationId: {{ .Values.context.organizationId }} 9 | auth: 10 | bearerToken: {{ .Values.context.token | quote }} 11 | 12 | -------------------------------------------------------------------------------- /docs/guides/deploy-crd-with-helm/src/values/dev/apis.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apis: 16 | - name: bored 17 | version: "1.0.0" 18 | proxy: 19 | groups: 20 | - endpoints: 21 | - target: "https://www.boredapi.com/api/activity" 22 | - name: catfact 23 | version: "1.0.0" 24 | proxy: 25 | groups: 26 | - endpoints: 27 | - target: "https://catfact.ninja/fact" 28 | -------------------------------------------------------------------------------- /docs/guides/deploy-crd-with-helm/src/values/staging/apis.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apis: 16 | - name: bored 17 | version: "1.0.0" 18 | proxy: 19 | groups: 20 | - endpoints: 21 | - target: "https://www.boredapi.com/api/activity" 22 | - name: catfact 23 | version: "1.0.0" 24 | proxy: 25 | groups: 26 | - endpoints: 27 | - target: "https://catfact.ninja/fact" 28 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-api-key-plan.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-api-key 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "api-with-api-key" 24 | version: "1.0" 25 | description: "Api managed by Gravitee Kubernetes Operator with Key plan" 26 | plans: 27 | - name: "API_KEY" 28 | description: "Api key plan" 29 | security: API_KEY 30 | proxy: 31 | virtual_hosts: 32 | - path: "/api-with-api-key" 33 | groups: 34 | - name: default-group 35 | endpoints: 36 | - name: "Default" 37 | target: "https://api.gravitee.io/echo" 38 | local: true 39 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-context.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-context 20 | spec: 21 | name: "Echo API" 22 | contextRef: 23 | name: "dev-ctx" 24 | version: "1.1" 25 | description: "Gravitee Kubernetes Operator sample" 26 | plans: 27 | - name: "KEY_LESS" 28 | description: "FREE" 29 | security: "KEY_LESS" 30 | proxy: 31 | virtual_hosts: 32 | - path: "/echo" 33 | groups: 34 | - endpoints: 35 | - name: "Default" 36 | target: "https://api.gravitee.io/echo" 37 | local: true 38 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-groups-members.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-groups-members 20 | spec: 21 | contextRef: 22 | name: dev-ctx 23 | name: "Echo API with groups and members" 24 | version: "1.1" 25 | description: "API with groups and members Gravitee Kubernetes Operator sample" 26 | plans: 27 | - name: "KEY_LESS" 28 | description: "FREE" 29 | security: "KEY_LESS" 30 | proxy: 31 | virtual_hosts: 32 | - path: "/api-with-groups-members" 33 | groups: 34 | - endpoints: 35 | - name: "Default" 36 | target: "https://api.gravitee.io/echo" 37 | local: true 38 | groups: 39 | - developers 40 | members: 41 | - source: memory 42 | sourceId: api1 43 | role: USER 44 | - source: memory 45 | sourceId: user 46 | role: USER 47 | notifyMembers: false 48 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-health-check-disabled.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: with-disabled-hc 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "With disabled health check" 24 | version: "1.0" 25 | description: "API with disabled health check" 26 | services: 27 | health-check: 28 | enabled: false 29 | schedule: "*/1 * * * * *" 30 | plans: 31 | - name: "KEY_LESS" 32 | description: "FREE" 33 | security: "KEY_LESS" 34 | proxy: 35 | virtual_hosts: 36 | - path: "/with-disabled-hc" 37 | groups: 38 | - endpoints: 39 | - name: "Default" 40 | target: "https://api.gravitee.io/echo" 41 | local: true 42 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-logging.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-logging 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "With logging" 24 | version: "1.0" 25 | description: "API with logging" 26 | plans: 27 | - name: "KEY_LESS" 28 | description: "FREE" 29 | security: "KEY_LESS" 30 | proxy: 31 | logging: 32 | mode: "CLIENT_PROXY" 33 | content: "HEADERS_PAYLOADS" 34 | scope: "REQUEST_RESPONSE" 35 | virtual_hosts: 36 | - path: "/with-logging" 37 | groups: 38 | - endpoints: 39 | - name: "Default" 40 | target: "https://api.gravitee.io/echo" 41 | local: true 42 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-metadata.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: with-metadata 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "With metadata" 24 | version: "1.0" 25 | description: "API with metadata" 26 | proxy: 27 | virtual_hosts: 28 | - path: "/with-metadata" 29 | groups: 30 | - endpoints: 31 | - name: "Default" 32 | target: "https://api.gravitee.io/echo" 33 | plans: 34 | - name: "KEY_LESS" 35 | description: "FREE" 36 | security: "KEY_LESS" 37 | metadata: 38 | - key: "build-version" 39 | name: "build-version" 40 | format: "STRING" 41 | value: "0.0.1" 42 | local: true 43 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-no-plan.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-context-no-plan 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "K8s No Plan Example" 24 | version: "1.0" 25 | description: "Api managed by Gravitee Kubernetes Operator with no plan" 26 | proxy: 27 | virtual_hosts: 28 | - path: "/api-with-context-no-plan" 29 | groups: 30 | - name: default-group 31 | endpoints: 32 | - name: "Default" 33 | target: "https://api.gravitee.io/echo" 34 | local: true 35 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-notifications-and-groups.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-notification 20 | spec: 21 | contextRef: 22 | name: dev-ctx 23 | name: "Echo API with groups and notification" 24 | version: "1.1" 25 | description: "API with groups and notification Gravitee Kubernetes Operator sample" 26 | plans: 27 | - name: "KEY_LESS" 28 | description: "FREE" 29 | security: "KEY_LESS" 30 | proxy: 31 | virtual_hosts: 32 | - path: "/api-with-notification" 33 | groups: 34 | - endpoints: 35 | - name: "Default" 36 | target: "https://api.gravitee.io/echo" 37 | local: true 38 | groups: 39 | - developers 40 | notificationsRefs: 41 | - name: api-notification-groups 42 | notifyMembers: false 43 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-state-stopped.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-state-stopped 20 | spec: 21 | name: "api-with-state-stopped" 22 | version: "1.0" 23 | description: "This API is stopped and will not be available for HTTP calls" 24 | state: STOPPED 25 | plans: 26 | - name: "KEY_LESS" 27 | description: "FREE" 28 | security: "KEY_LESS" 29 | proxy: 30 | virtual_hosts: 31 | - path: "/api-with-state-stopped" 32 | groups: 33 | - endpoints: 34 | - name: "Default" 35 | target: "https://api.gravitee.io/echo" 36 | local: true 37 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-sync-from-apim.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-with-sync-from-apim 20 | spec: 21 | name: api-with-sync-from-apim 22 | version: "1.0" 23 | description: "When local is set to false, no config map is created and the API is synced from the APIM datastore" 24 | contextRef: 25 | name: dev-ctx 26 | state: STARTED 27 | plans: 28 | - name: "KEY_LESS" 29 | description: "FREE" 30 | security: "KEY_LESS" 31 | proxy: 32 | virtual_hosts: 33 | - path: "/api-with-sync-from-apim" 34 | groups: 35 | - endpoints: 36 | - name: "Default" 37 | target: "https://api.gravitee.io/echo" 38 | local: false 39 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-template-annotation.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: api-template-with-api-key-plan 20 | annotations: 21 | gravitee.io/template: "true" 22 | spec: 23 | contextRef: 24 | name: "dev-ctx" 25 | name: "K8s ApiKey Example" 26 | version: "1.0" 27 | description: "Api managed by Gravitee Kubernetes Operator with Key plan" 28 | plans: 29 | - name: "Apikey" 30 | description: "Api key plan" 31 | security: API_KEY 32 | status: "PUBLISHED" 33 | local: true 34 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-templating-config-map.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: ConfigMap 17 | metadata: 18 | name: graviteeio-templating 19 | data: 20 | target: https://api.gravitee.io/echo 21 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-templating-secret.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Secret 17 | type: Opaque 18 | metadata: 19 | name: graviteeio-templating 20 | data: 21 | security: S0VZX0xFU1M= 22 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api-with-templating.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: basic-api-example-templating 20 | spec: 21 | name: "K8s Basic Example Templating" 22 | version: "1.0" 23 | description: "Basic api managed by Gravitee Kubernetes Operator with templating" 24 | plans: 25 | - name: "KEY_LESS" 26 | description: "FREE" 27 | security: "[[ secret `graviteeio-templating/security` ]]" 28 | proxy: 29 | virtual_hosts: 30 | - path: "/k8s-basic-templating" 31 | groups: 32 | - endpoints: 33 | - name: "Default" 34 | target: "[[ configmap `graviteeio-templating/target` ]]" 35 | local: true 36 | -------------------------------------------------------------------------------- /examples/apim/api_definition/v2/api.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiDefinition 18 | metadata: 19 | name: basic-api-example 20 | spec: 21 | name: "K8s Basic Example" 22 | version: "1.0" 23 | description: "Basic api managed by Gravitee Kubernetes Operator" 24 | plans: 25 | - name: "KEY_LESS" 26 | description: "FREE" 27 | security: "KEY_LESS" 28 | proxy: 29 | virtual_hosts: 30 | - path: "/k8s-basic" 31 | groups: 32 | - endpoints: 33 | - name: "Default" 34 | target: "https://api.gravitee.io/echo" 35 | local: true 36 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-cache-redis.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-cache-redis 20 | spec: 21 | name: "redis-cache" 22 | type: "cache-redis" 23 | enabled: true 24 | configuration: 25 | releaseCache: false 26 | maxTotal: 8 27 | timeToLiveSeconds: 0 28 | timeout: 2000 29 | useSsl: true 30 | standalone: 31 | enabled: true 32 | host: "localhost" 33 | port: 6379 34 | sentinel: 35 | enabled: false 36 | masterId: "sentinel-master" 37 | password: "redispassword" 38 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-cache.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-cache 20 | spec: 21 | name: "cache-resource" 22 | type: "cache" 23 | enabled: true 24 | configuration: 25 | timeToIdleSeconds: 0 26 | timeToLiveSeconds: 0 27 | maxEntriesLocalHeap: 1000 28 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-http-auth-provider.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-http-auth-provider 20 | spec: 21 | name: "http-auth" 22 | type: "auth-provider-http-resource" 23 | enabled: true 24 | configuration: 25 | method: "POST" 26 | condition: "{#authResponse.status == 200}" 27 | url: "https://authorization-server.com/basic" 28 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-inline-auth-provider.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-inline-auth-provider 20 | spec: 21 | name: "inline-auth" 22 | type: "auth-provider-inline-resource" 23 | enabled: true 24 | configuration: 25 | users: 26 | - username: "user" 27 | password: "password" 28 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-keycloak-adapter.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-keycloak-adapter 20 | spec: 21 | name: "keycloak-adapter" 22 | type: "oauth2-keycloak-resource" 23 | enabled: true 24 | configuration: 25 | validateTokenLocally: true 26 | userClaim: "sub" 27 | verifyHost: false 28 | trustAll: true 29 | keycloakConfiguration: |- 30 | { 31 | "auth-server-url": "http://localhost:8080/auth", 32 | "confidential-port": 0, 33 | "credentials": { 34 | "secret": "f1c9ff64-abcf-4671-9ddb-4fe4a172390d" 35 | }, 36 | "policy-enforcer": {}, 37 | "realm": "gravitee", 38 | "resource": "gravitee", 39 | "ssl-required": "external" 40 | } 41 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-ldap-auth-provider.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-ldap-auth-provider 20 | spec: 21 | name: "ldap-auth" 22 | type: "auth-provider-ldap-resource" 23 | enabled: true 24 | configuration: 25 | contextSourceUrl: "ldap://localhost:1389" 26 | userSearchFilter: "uid={0}" 27 | userSearchBase: "ou=users" 28 | cacheMaxElements: 100 29 | cacheTimeToLive: 60000 30 | connectTimeout: 5000 31 | responseTimeout: 5000 32 | minPoolSize: 1 33 | maxPoolSize: 1 34 | contextSourceBase: "dc=example,dc=com" 35 | contextSourceUsername: "cn=Directory Manager" 36 | contextSourcePassword: "password" 37 | -------------------------------------------------------------------------------- /examples/apim/api_resource/api-resource-oauth2-am.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: ApiResource 18 | metadata: 19 | name: reusable-resource-oauth2-am 20 | spec: 21 | name: "oauth2-am-resource" 22 | type: "oauth2-am-resource" 23 | enabled: true 24 | configuration: 25 | useSystemProxy: false 26 | version: "V3_X" 27 | userClaim: "sub" 28 | serverURL: "https://authorization-server.com/authorize" 29 | securityDomain: "gravitee" 30 | clientId: "0roMt9mBy1Fm_78suKoTdpIh" 31 | clientSecret: "0roMt9mBy1Fm_78suKoTdpIh" 32 | -------------------------------------------------------------------------------- /examples/apim/application/application-with-client-id.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: Application 18 | metadata: 19 | name: simple-application-with-client-id 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "simple-application-with-client-id" 24 | domain: "https://example.com" 25 | description: | 26 | A hands-free application. 27 | Using this type, you will be able to define the client_id by your own. 28 | settings: 29 | app: 30 | type: WEB 31 | clientId: "my-client-id" 32 | -------------------------------------------------------------------------------- /examples/apim/application/application-with-oauth-backend-to-backend-settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Application 17 | metadata: 18 | name: backend-to-backend-application 19 | spec: 20 | contextRef: 21 | name: "dev-ctx" 22 | name: "backend-to-backend-application" 23 | description: "OAuth settings for machine to machine interaction" 24 | domain: "https://example.com" 25 | settings: 26 | oauth: 27 | applicationType: BACKEND_TO_BACKEND 28 | redirectUris: 29 | - "https://example.com" 30 | grantTypes: 31 | - "client_credentials" 32 | metadata: 33 | - name: "test metadata 1" 34 | format: DATE 35 | -------------------------------------------------------------------------------- /examples/apim/application/application-with-oauth-native-settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Application 17 | metadata: 18 | name: native-application 19 | spec: 20 | contextRef: 21 | name: "dev-ctx" 22 | name: "native-application" 23 | description: "OAuth settings for a native application (IOS, Android ...)" 24 | domain: "https://example.com" 25 | settings: 26 | oauth: 27 | applicationType: NATIVE 28 | redirectUris: 29 | - "https://example.com" 30 | grantTypes: 31 | - authorization_code 32 | - refresh_token 33 | -------------------------------------------------------------------------------- /examples/apim/application/application-with-oauth-spa-settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Application 17 | metadata: 18 | name: spa-application 19 | spec: 20 | contextRef: 21 | name: "dev-ctx" 22 | name: "spa-application" 23 | description: "OAuth settings for a Single Page Application" 24 | domain: "https://example.com" 25 | settings: 26 | oauth: 27 | applicationType: BROWSER 28 | redirectUris: 29 | - "https://example.com" 30 | grantTypes: 31 | - "authorization_code" 32 | -------------------------------------------------------------------------------- /examples/apim/application/application-with-oauth-webapp-settings.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Application 17 | metadata: 18 | name: web-application 19 | spec: 20 | contextRef: 21 | name: "dev-ctx" 22 | name: "web-application" 23 | description: "OAuth settings for a webapp application" 24 | domain: "https://example.com" 25 | settings: 26 | oauth: 27 | applicationType: WEB 28 | redirectUris: 29 | - "https://example.com" 30 | grantTypes: 31 | - authorization_code 32 | -------------------------------------------------------------------------------- /examples/apim/application/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: Application 18 | metadata: 19 | name: simple-application 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "simple-app" 24 | domain: "https://example.com" 25 | description: | 26 | A hands-free application. 27 | Using this type, you will be able to define the client_id by your own. 28 | settings: 29 | app: 30 | type: WEB 31 | metadata: 32 | - name: "test metadata 1" 33 | format: "STRING" 34 | - name: "test metadata 2" 35 | format: "STRING" 36 | -------------------------------------------------------------------------------- /examples/apim/group/group.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: Group 18 | metadata: 19 | name: developers 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "developers" 24 | notifyMembers: false 25 | members: 26 | - source: memory 27 | sourceId: api1 28 | roles: 29 | API: OWNER 30 | APPLICATION: OWNER 31 | INTEGRATION: USER 32 | -------------------------------------------------------------------------------- /examples/apim/notification/notification-no-group.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Notification 17 | metadata: 18 | name: api-notification 19 | spec: 20 | target: console 21 | eventType: api 22 | console: 23 | apiEvents: 24 | - API_STARTED 25 | - API_STOPPED -------------------------------------------------------------------------------- /examples/apim/notification/notification-with-groups.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Notification 17 | metadata: 18 | name: api-notification-groups 19 | spec: 20 | target: console 21 | eventType: api 22 | console: 23 | apiEvents: 24 | - API_STARTED 25 | - API_STOPPED 26 | groupRefs: 27 | - name: developers -------------------------------------------------------------------------------- /examples/apim/shared_policy_groups/shared_policy_groups.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: SharedPolicyGroup 18 | metadata: 19 | name: simple-shared-policy-groups 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "simple-shared-policy-groups" 24 | description: "Simple shared policy groups" 25 | apiType: "PROXY" 26 | phase: "REQUEST" 27 | steps: 28 | - name: Rate Limit 29 | description: k8s rate limit 30 | enabled: true 31 | policy: rate-limit 32 | configuration: 33 | async: false 34 | addHeaders: true 35 | rate: 36 | useKeyOnly: false 37 | periodTime: 1 38 | limit: 10 39 | periodTimeUnit: MINUTES 40 | key: "" -------------------------------------------------------------------------------- /examples/apim/subscription/subscription.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Subscription 17 | metadata: 18 | name: echo-subscription 19 | spec: 20 | api: 21 | name: api-v4-with-jwt-plan 22 | application: 23 | name: simple-application-with-client-id 24 | plan: JWT 25 | endingAt: "2040-12-25T09:12:28Z" 26 | -------------------------------------------------------------------------------- /examples/embed.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package examples 16 | 17 | import "embed" 18 | 19 | //go:embed * 20 | var FS embed.FS 21 | -------------------------------------------------------------------------------- /examples/ingress/ingress-pem-registry.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: ConfigMap 17 | metadata: 18 | name: pem-registry 19 | labels: 20 | "gravitee.io/component": "kubernetes-pem-registry" 21 | "kubernetes.io/ingress.class": "graviteeio" 22 | data: {} 23 | -------------------------------------------------------------------------------- /examples/ingress/ingress-response-404-config-map.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: ConfigMap 17 | metadata: 18 | name: template-404 19 | data: 20 | content: '{ "message": "not-found-test" }' 21 | contentType: application/json 22 | -------------------------------------------------------------------------------- /examples/ingress/ingress-with-api-template.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: networking.k8s.io/v1 15 | kind: Ingress 16 | metadata: 17 | name: ingress-with-api-template 18 | annotations: 19 | kubernetes.io/ingress.class: graviteeio 20 | gravitee.io/template: api-template-with-api-key-plan 21 | labels: 22 | gravitee.io/ingress: graviteeio 23 | spec: 24 | rules: 25 | - host: httpbin.example.com 26 | http: 27 | paths: 28 | - path: /templated 29 | pathType: Prefix 30 | backend: 31 | service: 32 | name: httpbin-1 33 | port: 34 | number: 8080 35 | -------------------------------------------------------------------------------- /examples/ingress/ingress-with-tls.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: networking.k8s.io/v1 15 | kind: Ingress 16 | metadata: 17 | name: ingress-with-tls 18 | annotations: 19 | kubernetes.io/ingress.class: graviteeio 20 | labels: 21 | gravitee.io/ingress: graviteeio 22 | spec: 23 | tls: 24 | - hosts: 25 | - httpbin.example.com 26 | secretName: httpbin.example.com 27 | rules: 28 | - host: httpbin.example.com 29 | http: 30 | paths: 31 | - path: /secured 32 | pathType: Prefix 33 | backend: 34 | service: 35 | name: httpbin-1 36 | port: 37 | number: 8080 38 | -------------------------------------------------------------------------------- /examples/ingress/ingress-without-api-template.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: networking.k8s.io/v1 15 | kind: Ingress 16 | metadata: 17 | name: ingress-without-api-template 18 | annotations: 19 | kubernetes.io/ingress.class: graviteeio 20 | labels: 21 | gravitee.io/ingress: graviteeio 22 | spec: 23 | rules: 24 | - host: httpbin.example.com 25 | http: 26 | paths: 27 | - path: /httpbin 28 | pathType: Prefix 29 | backend: 30 | service: 31 | name: httpbin-1 32 | port: 33 | number: 8080 34 | -------------------------------------------------------------------------------- /examples/management_context/cloud/cloud-bearer-secret.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Secret 17 | metadata: 18 | name: apim-context-bearer-token 19 | data: 20 | bearerToken: "eHl6" 21 | -------------------------------------------------------------------------------- /examples/management_context/cloud/cloud-mctx-with-bearer-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | cloud: 20 | secretRef: 21 | name: apim-context-bearer-token 22 | -------------------------------------------------------------------------------- /examples/management_context/cloud/cloud-mctx-with-secret-ref-and-auth-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | auth: 20 | secretRef: 21 | name: apim-context-credentials 22 | cloud: 23 | secretRef: 24 | name: apim-cloud-context-token 25 | -------------------------------------------------------------------------------- /examples/management_context/cloud/cloud-mctx-with-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | cloud: 20 | secretRef: 21 | name: apim-cloud-context-token 22 | -------------------------------------------------------------------------------- /examples/management_context/cloud/cloud-mctx-with-unknown-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | cloud: 20 | secretRef: 21 | name: unknown 22 | -------------------------------------------------------------------------------- /examples/management_context/cluster/management-context-secret.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Secret 17 | metadata: 18 | name: apim-context-credentials 19 | data: 20 | password: YWRtaW4= 21 | username: YWRtaW4= 22 | -------------------------------------------------------------------------------- /examples/management_context/cluster/management-context-with-credentials.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://apim-apim3-api.default.svc:83 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | credentials: 24 | username: admin 25 | password: admin 26 | -------------------------------------------------------------------------------- /examples/management_context/cluster/management-context-with-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://apim-apim3-api.default.svc:83 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | secretRef: 24 | name: apim-context-credentials 25 | -------------------------------------------------------------------------------- /examples/management_context/debug/management-context-secret.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Secret 17 | metadata: 18 | name: apim-context-credentials 19 | data: 20 | password: YWRtaW4= 21 | username: YWRtaW4= 22 | -------------------------------------------------------------------------------- /examples/management_context/debug/management-context-with-credentials.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # Use this context if you are running APIM and GKO locally 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: ManagementContext 17 | metadata: 18 | name: dev-ctx 19 | spec: 20 | baseUrl: http://localhost:8083 21 | environmentId: DEFAULT 22 | organizationId: DEFAULT 23 | auth: 24 | credentials: 25 | username: admin 26 | password: admin 27 | -------------------------------------------------------------------------------- /examples/management_context/debug/management-context-with-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:8083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | secretRef: 24 | name: apim-context-credentials 25 | -------------------------------------------------------------------------------- /examples/management_context/dev/management-context-secret.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v1 16 | kind: Secret 17 | metadata: 18 | name: apim-context-credentials 19 | data: 20 | password: YWRtaW4= 21 | username: YWRtaW4= 22 | -------------------------------------------------------------------------------- /examples/management_context/dev/management-context-with-bearer-token.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:30083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | # WARNING: replace with your generate bearer token 24 | bearerToken: xxxx-yyyy-zzzz 25 | -------------------------------------------------------------------------------- /examples/management_context/dev/management-context-with-credentials.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:30083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | credentials: 24 | username: admin 25 | password: admin 26 | -------------------------------------------------------------------------------- /examples/management_context/dev/management-context-with-secret-ref.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:30083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | secretRef: 24 | name: apim-context-credentials 25 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-jwt-plan/pki/get_token.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 17 | 18 | pem=$( cat "${dir}/private.key" ) 19 | client_id="echo-client" 20 | sub="echo-client" 21 | 22 | now=$( date +%s ) 23 | iat="${now}" 24 | # shellcheck disable=SC2004 25 | exp=$((${now} + 3600)) 26 | header_raw='{"alg":"RS256", "typ": "JWT"}' 27 | header=$( echo -n "${header_raw}" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n' ) 28 | payload_raw='{"iat":'"$iat"',"exp":'"$exp"',"client_id":"'"$client_id"'", "sub":"'"$sub"'"}' 29 | payload=$( echo -n "${payload_raw}" | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n' ) 30 | header_payload="${header}"."${payload}" 31 | signature=$( openssl dgst -sha256 -sign <(echo -n "${pem}") <(echo -n "${header_payload}") | openssl base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n' ) 32 | echo "${header}.${payload}.${signature}" 33 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-jwt-plan/pki/public.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAv8YGSPoQEl7lXnp8OHkb 3 | AOPYZ81rzXkmO83d0P8G78qWzi3gPnODm6Qxi2NbgcWXqQlZXxPkDTS3Xck1V3WY 4 | E9voqQE7UEwpFBolqtUHQqL4w2vr/eUtZv9t3DdtoCcIj4xLmJUw7PS7jAb9quq0 5 | XiVN692d6LI62T+9LyN+kcWHTpUyMBB8oxfQ9ekkGHskTc6LgYovKK+9lKoJv6gg 6 | 0ge8YAFbpjJBZbVX3jV8qeszgw9Xdhs3w/S8QnvWa3Cv0+c47oxZjXwpAa8ARzfn 7 | D/5oK4CWRRy+t3QUndSR0cBR+bU0YFks3mmbl514/ywOXRf/sZmXaJkNejfNHQVa 8 | hJgj/Z3W3F8GKksuFF14+BK2KX30bsQL3e4SeN0Wv6DF1UloG0T396yDd/o7L3ZC 9 | DBlRB44OZ8sO3h8iSW7wVX0sGj/OKc4smo5dgP0r4+Fm2EVmVFU5YvEkFcy0Xoth 10 | QmLwq0lJc7BdRMpAfRZLbW5WSlb2jgvxA/VI/ScLTRWZI7DGbzHRBS6J8Rnt3Inq 11 | jo7mUV1juBs3RhpxdOmg1LpGLAtQdcSSnX3IyyEVbzTVb22Px0EGAlKzMs6bnTJf 12 | 3TbZd/C0iqd6QOyaTh7D4Nr7ClfWAaYGZBA/FsHWA88fOsIQCtovWjp9A8i1+VQ5 13 | HEy1rpaHPGHt1DFt2hu+d3MCAwEAAQ== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-jwt-plan/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: Application 18 | metadata: 19 | name: echo-client 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "echo-client" 24 | description: "echo API client" 25 | settings: 26 | app: 27 | type: WEB 28 | clientId: echo-client 29 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-jwt-plan/resources/management-context.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:30083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | credentials: 24 | username: admin 25 | password: admin 26 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-jwt-plan/resources/subscription.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Subscription 17 | metadata: 18 | name: echo-client-subscription 19 | spec: 20 | api: 21 | name: jwt-demo 22 | application: 23 | name: echo-client 24 | plan: JWT 25 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-mtls-plan/pki/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDDTCCAfWgAwIBAgIUfsf4QIH0pEgE9HHVcpABk26oecowDQYJKoZIhvcNAQEL 3 | BQAwDjEMMAoGA1UEAwwDR0tPMB4XDTI0MTEyNzE3MjU1NVoXDTI1MTEyNzE3MjU1 4 | NVowDjEMMAoGA1UEAwwDR0tPMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC 5 | AQEAuqar5b6nsegCvMlNaw6+HVM1YgGhZM1QIIx0SkJCv80GkVXokXVPxwges2Dc 6 | UN3hGhwxYT+E1qH803N5qxp+KxMBTXJ71apzsy4oprTBi9BDQqmeOe+MOKOXQg4z 7 | i2SjObfPFBHdUbrkJTXXv3vlvzbIP/8ccnGhSX21/dv1TT0AnCkhUZ+cRry1idN0 8 | 9hxLQ2WS18AITwr5h/PvVPV2OJr+Qf2Ea7nOUpOvxn9bPPAFX+VquHBlADCTgBvX 9 | B4NPheYk/W+nNn3HpChjPRelaV/V87qREKgMzMA73uU5A4TQjalygvRop0yg10yg 10 | MbUGeS26v+gseFhsaOrkPM/TKQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4G 11 | A1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBStaW4Y0CjoALKOZdmdxu3j79wB/jAd 12 | BgNVHQ4EFgQUrWluGNAo6ACyjmXZncbt4+/cAf4wDQYJKoZIhvcNAQELBQADggEB 13 | AF1YCCNysKHs953HUnXo/8TJGmBd79V/NQeSfZEP5M3XRpiGwSGrLuU3SIzNwv6K 14 | ZeOXQNTvPZharnyeu+aawWHcIXqtm6B0n4qULyf/eMu4256miSrybeJ2W6pMinkp 15 | eiderPRs7He4tGfYSvLsbzqQXNGjXi3WFCChflcITkf4iJikSLskwo0lj0XPwXPz 16 | Zr2awcrFPlHHrIkumFu84aibde6sfeefmjV3NlYGiRMCrS44M4rBKTuL58fN8Qf+ 17 | gYvMpEhhYQVpy6v30SboGLsmyzvAdjh1RuaOzsJNzGbfmc+jvy/R1uAC2NgNQVty 18 | XUupVUcyfCNFfa1UGPGY2G8= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-mtls-plan/resources/application.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | apiVersion: gravitee.io/v1alpha1 17 | kind: Application 18 | metadata: 19 | name: echo-client 20 | spec: 21 | contextRef: 22 | name: "dev-ctx" 23 | name: "echo-client" 24 | description: "echo API client" 25 | settings: 26 | app: 27 | type: WEB 28 | tls: 29 | clientCertificate: "[[ secret `tls-client/tls.crt` ]]" 30 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-mtls-plan/resources/management-context.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | apiVersion: gravitee.io/v1alpha1 15 | kind: ManagementContext 16 | metadata: 17 | name: dev-ctx 18 | spec: 19 | baseUrl: http://localhost:30083 20 | environmentId: DEFAULT 21 | organizationId: DEFAULT 22 | auth: 23 | credentials: 24 | username: admin 25 | password: admin 26 | -------------------------------------------------------------------------------- /examples/usecase/subscribe-to-mtls-plan/resources/subscription.yml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: Subscription 17 | metadata: 18 | name: echo-client-subscription 19 | spec: 20 | api: 21 | name: mtls-demo 22 | application: 23 | name: echo-client 24 | plan: MTLS 25 | -------------------------------------------------------------------------------- /hack/crdoc/toc.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | metadata: 16 | title: "Gravitee Kubernetes Operator" 17 | weight: 1 18 | description: "API Reference" 19 | groups: 20 | - group: gravitee.io 21 | version: v1alpha1 22 | kinds: 23 | - name: ManagementContext 24 | - name: ApiDefinition 25 | - name: ApiV4Definition 26 | - name: ApiResource 27 | - name: Application 28 | - name: Subscription 29 | - name: SharedPolicyGroup 30 | - name: Notification 31 | - name: Group 32 | -------------------------------------------------------------------------------- /hack/kind/kind.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: kind.x-k8s.io/v1alpha4 16 | kind: Cluster 17 | name: gravitee 18 | networking: 19 | apiServerPort: 6443 20 | nodes: 21 | - role: control-plane 22 | extraPortMappings: 23 | # gravitee-apim-console 24 | - containerPort: 30080 25 | hostPort: 30080 26 | # gravitee-apim-portal 27 | - containerPort: 30081 28 | hostPort: 30081 29 | # gravitee-apim-api 30 | - containerPort: 30082 31 | hostPort: 30082 32 | # gravitee-apim-gateway (http) 33 | - containerPort: 30083 34 | hostPort: 30083 35 | # gravitee-apim-gateway (https) 36 | - containerPort: 30084 37 | hostPort: 30084 38 | # gko-controller debug port 39 | - containerPort: 32767 40 | hostPort: 32767 41 | -------------------------------------------------------------------------------- /hack/license.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ -------------------------------------------------------------------------------- /hack/make/build.mk: -------------------------------------------------------------------------------- 1 | ##@ 🔨Build 2 | 3 | .PHONY: build 4 | build: generate ## Build manager binary. 5 | go build -o bin/manager main.go 6 | 7 | .PHONY: manifests 8 | manifests: ## Generate CustomResourceDefinition objects. 9 | $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=helm/gko/crds 10 | @npx zx hack/scripts/annotate-crds.mjs 11 | $(MAKE) add-license 12 | 13 | .PHONY: generate 14 | generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. 15 | $(CONTROLLER_GEN) object:headerFile="hack/license.go.txt" paths="./..." 16 | 17 | -------------------------------------------------------------------------------- /hack/make/dev.mk: -------------------------------------------------------------------------------- 1 | ##@ 💻 Development 2 | 3 | .PHONY: start-cluster 4 | start-cluster: ## Init and start a local cluster 5 | @npx zx ./hack/scripts/run-kind.mjs 6 | 7 | .PHONY: delete-cluster 8 | delete-cluster: ## Delete local cluster 9 | @kind delete cluster --name gravitee 10 | 11 | .PHONY: use-cluster 12 | use-cluster: ## Switch current kubectl context to local cluster 13 | @kubectl config use-context kind-gravitee 14 | 15 | .PHONY: cluster-admin 16 | cluster-admin: ## Gain a kubernetes context with admin role on the local cluster 17 | @kubectl config use-context kind-gravitee 18 | @npx zx ./hack/scripts/create-cluster-admin-sa.mjs 19 | ifndef ignore-not-found 20 | ignore-not-found = false 21 | endif 22 | 23 | .PHONY: install 24 | install: ## Install CRDss into the current cluster 25 | @kubectl apply -f helm/gko/crds 26 | 27 | .PHONY: uninstall 28 | uninstall: ## Uninstall CRDs from the current cluster 29 | @kubectl delete -f helm/gko/crds 30 | 31 | .PHONY: run 32 | run: ## Run a controller from your host 33 | @go run ./main.go 34 | -------------------------------------------------------------------------------- /hack/make/doc.mk: -------------------------------------------------------------------------------- 1 | ##@ 📄 Documentation 2 | 3 | .PHONY: reference 4 | reference: ## Generate the CRDs reference documentation 5 | $(CRDOC) --resources helm/gko/crds --output docs/api/reference.md --template hack/crdoc/markdown.tmpl -c hack/crdoc/toc.yaml 6 | 7 | .PHONY: 8 | helm-reference: ## Generates helm chart documentation 9 | npx @bitnami/readme-generator-for-helm -v helm/gko/values.yaml -r helm/gko/README.md 10 | -------------------------------------------------------------------------------- /hack/make/docker.mk: -------------------------------------------------------------------------------- 1 | ##@ 🐳 Docker 2 | 3 | # Image URL to use all building/pushing image targets 4 | IMG ?= graviteeio/kubernetes-operator 5 | TAG ?= latest 6 | 7 | # DEV 8 | 9 | .PHONY: docker-build 10 | docker-build: ## Build docker image with the manager. 11 | docker build -t ${IMG}:${TAG} . 12 | 13 | .PHONY: docker-push 14 | docker-push: ## Push docker image with the manager. 15 | docker push ${IMG}:${TAG} 16 | 17 | docker-build-debug: ## Build docker image with remote debug enabled 18 | docker build -f Dockerfile.debug -t ${IMG}:${TAG} . 19 | -------------------------------------------------------------------------------- /hack/make/helm.mk: -------------------------------------------------------------------------------- 1 | ##@ ☸ Helm 2 | 3 | .PHONY: helm-template 4 | helm-template: manifests ## Generates legacy bundle.yml file from helm chart 5 | helm template --include-crds helm/gko -n gko-system > bundle.yml 6 | -------------------------------------------------------------------------------- /hack/make/lint.mk: -------------------------------------------------------------------------------- 1 | ##@ 🧹 Lint 2 | 3 | ALL_LINT=lint-commits lint-sources lint-licenses 4 | 5 | .PHONY: lint 6 | lint: lint-commits lint-sources lint-licenses ## Run all linters and fail on error 7 | 8 | .PHONY: lint-commits 9 | lint-commits: ## Run commitlint and fail on error 10 | @echo "Linting commits ..." 11 | @npm i -g @commitlint/config-conventional @commitlint/cli 12 | @commitlint -x @commitlint/config-conventional --edit 13 | 14 | .PHONY: lint-sources 15 | lint-sources: ## Run golangci-lint and fail on error 16 | @echo "Linting go sources ..." 17 | @$(GOLANGCILINT) --concurrency 2 run ./... 18 | @npx --yes prettier --check hack/scripts 19 | 20 | .PHONY: lint-licenses 21 | lint-licenses: ## Run addlicense linter and fail on error 22 | @echo "Checking license headers ..." 23 | @$(ADDLICENSE) -check -f LICENSE_TEMPLATE.txt \ 24 | -ignore ".circleci/**" \ 25 | -ignore ".mergify.yml" \ 26 | -ignore "config/**" \ 27 | -ignore ".idea/**" . 28 | 29 | .PHONY: add-license 30 | add-license: ## Add license headers to files 31 | @echo "Adding license headers ..." 32 | @$(ADDLICENSE) -f LICENSE_TEMPLATE.txt \ 33 | -ignore ".circleci/**" \ 34 | -ignore ".mergify.yml" \ 35 | -ignore "config/**" \ 36 | -ignore ".idea/**" . 37 | 38 | .PHONY: clean-tools ## Run all linters 39 | lint: $(ALL_LINT) 40 | 41 | .PHONY: lint-fix 42 | lint-fix: ## Fix whatever golangci-lint can fix and add licenses headers 43 | @$(GOLANGCILINT) run ./... --fix 44 | @$(MAKE) add-license 45 | @npx --yes prettier --write hack/scripts 46 | -------------------------------------------------------------------------------- /hack/make/test.mk: -------------------------------------------------------------------------------- 1 | ##@ 🧪 Test 2 | 3 | .PHONY: helm-test 4 | helm-test: 5 | @echo "Running helm unit tests ..." 6 | @cd helm; helm unittest -f 'tests/**/*.yaml' gko 7 | 8 | 9 | IT_ARGS ?= "" 10 | TIMEOUT ?= 1200s 11 | 12 | .PHONY: it 13 | it: use-cluster install ## Run integration tests 14 | $(GINKGO) $(IT_ARGS) --timeout $(TIMEOUT) test/integration/... 15 | 16 | UT_ARGS ?= "" 17 | unit: ## Run unit tests 18 | $(GINKGO) $(UT_ARGS) test/unit/... 19 | -------------------------------------------------------------------------------- /hack/make/tool.mk: -------------------------------------------------------------------------------- 1 | ##@ 🛠️ Tools 2 | 3 | ## Location to install dependencies to 4 | LOCALBIN ?= $(shell pwd)/bin 5 | $(LOCALBIN): 6 | @mkdir -p $(LOCALBIN) 7 | 8 | ## Tool Binaries 9 | CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen 10 | GINKGO ?= $(LOCALBIN)/ginkgo 11 | CRDOC ?= $(LOCALBIN)/crdoc 12 | GOLANGCILINT ?= $(LOCALBIN)/golangci-lint 13 | ADDLICENSE ?= $(LOCALBIN)/addlicense 14 | 15 | .PHONY: clean-tools 16 | clean-tools: $(LOCALBIN) ## Cleans (delete) all binary tools 17 | @echo "Cleaning tools" 18 | @find $(LOCALBIN) -type f -delete 19 | 20 | .PHONY: download 21 | download: ## Download all project dependencies 22 | @echo "Downloading go.mod dependencies" 23 | @go mod download 24 | 25 | .PHONY: install-go-tools 26 | install-go-tools: download ## Installs all required GO tools 27 | @echo "Installing GO tools" 28 | @cat hack/tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -I % sh -c 'GOBIN=$(LOCALBIN) go install %' 29 | 30 | .PHONY: install-tools 31 | install-tools: install-go-tools ## Installs all required tools 32 | @echo "Installing helm-unittest ..." 33 | @helm plugin list | grep -q unittest || helm plugin install https://github.com/quintush/helm-unittest > /dev/null 2>&1 34 | 35 | .PHONY: reinstall-tools 36 | re-install-tools: clean-tools install-tools ## Clean and install tools again 37 | -------------------------------------------------------------------------------- /hack/scripts/annotate-crds.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { HELM } from "./lib/index.mjs"; 18 | 19 | await HELM.annotateCRDs(await HELM.getChartVersion()); 20 | -------------------------------------------------------------------------------- /hack/scripts/get-chart-version.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { HELM, LOG } from "./lib/index.mjs"; 18 | 19 | LOG.log(await HELM.getChartVersion()); 20 | -------------------------------------------------------------------------------- /hack/scripts/get-release-branch.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { LOG, isEmptyString } from "./lib/index.mjs"; 18 | 19 | import { Version } from "./lib/version.mjs"; 20 | 21 | const VERSION = argv.version; 22 | 23 | if (isEmptyString(VERSION)) { 24 | LOG.red("You must specify a version using the --version flag"); 25 | process.exit(1); 26 | } 27 | 28 | LOG.log(new Version(VERSION).branch()); 29 | -------------------------------------------------------------------------------- /hack/scripts/lib/version.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export class Version { 18 | majorDigit; 19 | minorDigit; 20 | patchDigit; 21 | suffix; 22 | 23 | constructor(version) { 24 | const [majorDigit, minorDigit, patchDigit, suffix] = [ 25 | ...version.split(".").map(Number), 26 | ]; 27 | Object.assign(this, { majorDigit, minorDigit, patchDigit, suffix }); 28 | } 29 | 30 | branch() { 31 | return `${this.majorDigit}.${this.minorDigit}.x`; 32 | } 33 | 34 | minor() { 35 | return `${this.majorDigit}.${this.minorDigit}`; 36 | } 37 | 38 | isNoPatch() { 39 | return this.patchDigit === 0; 40 | } 41 | 42 | isPreRelease() { 43 | return !!this.suffix; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /hack/scripts/trigger-e2e-test.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { triggerPipeline } from "./lib/circleci.mjs"; 18 | 19 | import { toggleVerbosity, LOG } from "./lib/index.mjs"; 20 | 21 | const VERBOSE = argv.verbose; 22 | const PIPELINE_BRANCH = argv["pipeline-branch"]; 23 | 24 | toggleVerbosity(VERBOSE); 25 | 26 | LOG.blue(`Triggering E2E test pipeline`); 27 | 28 | const parameters = { 29 | trigger: "e2e", 30 | }; 31 | 32 | LOG.blue(` 33 | Parameters: ${JSON.stringify(parameters)}, 34 | `); 35 | 36 | const pipelineURL = await triggerPipeline(parameters, PIPELINE_BRANCH); 37 | 38 | LOG.blue(`Pipeline is running at ${pipelineURL}`); 39 | -------------------------------------------------------------------------------- /hack/scripts/trigger-test.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 The Gravitee team (http://gravitee.io) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { triggerPipeline } from "./lib/circleci.mjs"; 18 | 19 | import { toggleVerbosity, LOG } from "./lib/index.mjs"; 20 | 21 | const VERBOSE = argv.verbose; 22 | const BRANCH = argv["branch"]; 23 | const NOTIFY = argv["notify"] === "true" || argv["notify"] === true; 24 | 25 | toggleVerbosity(VERBOSE); 26 | 27 | LOG.blue(`Triggering test pipeline`); 28 | 29 | const parameters = { 30 | trigger: "test", 31 | notify: NOTIFY, 32 | }; 33 | 34 | LOG.blue(` 35 | Parameters: ${JSON.stringify(parameters)}, 36 | Branch: ${BRANCH} 37 | `); 38 | 39 | const pipelineURL = await triggerPipeline(parameters, BRANCH); 40 | 41 | LOG.blue(`Pipeline is running at ${pipelineURL}`); 42 | -------------------------------------------------------------------------------- /hack/tools.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build tools 16 | // +build tools 17 | 18 | package hack 19 | 20 | import ( 21 | _ "fybrik.io/crdoc" 22 | _ "github.com/golangci/golangci-lint/cmd/golangci-lint" 23 | _ "github.com/google/addlicense" 24 | _ "github.com/onsi/ginkgo/v2/ginkgo" 25 | _ "sigs.k8s.io/controller-tools/cmd/controller-gen" 26 | ) 27 | -------------------------------------------------------------------------------- /helm/gko/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | 25 | # Tests 26 | tests 27 | -------------------------------------------------------------------------------- /helm/gko/Chart.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: v2 16 | appVersion: 0.13.1 17 | version: 0.13.1 18 | kubeVersion: ">=1.14.0-0" 19 | type: application 20 | name: gko 21 | description: The Gravitee Kubernetes Operator Helm Chart 22 | icon: https://avatars2.githubusercontent.com/u/12655666?s=200&v=4 23 | home: https://gravitee.io 24 | sources: 25 | - https://github.com/gravitee-io/gravitee-kubernetes-operator 26 | keywords: 27 | - gravitee.io 28 | - kubernetes 29 | - operator 30 | - API management 31 | -------------------------------------------------------------------------------- /helm/gko/README.md.gotmpl: -------------------------------------------------------------------------------- 1 | # G.K.O. 2 | 3 | {{ template "chart.description" . }} 4 | 5 | {{ template "chart.typeBadge" . }}{{ template "chart.versionBadge" . }}{{ template "chart.appVersionBadge" . }} 6 | 7 | ## Installing the Chart 8 | 9 | To install the chart with the release name `graviteeio-gko`: 10 | 11 | ```console 12 | $ helm repo add graviteeio https://helm.gravitee.io 13 | $ helm install graviteeio-gko graviteeio/{{ template "chart.name" . }} 14 | ``` 15 | 16 | {{ template "chart.requirementsSection" . }} 17 | 18 | {{ template "chart.valuesSection" . }} 19 | 20 | {{ template "helm-docs.versionFooter" . }} 21 | -------------------------------------------------------------------------------- /helm/gko/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | Thank you for installing {{ .Chart.Description }} ! 2 | 3 | To learn more about your release, try: 4 | 5 | $ helm status {{ .Release.Name }} 6 | $ helm get all {{ .Release.Name }} 7 | 8 | {{- if and .Values.manager.metrics.enabled .Values.manager.metrics.prometheus.instance.create }} 9 | Operator metrics are available from withing the cluster at the following endpoint: 10 | 11 | http://prometheus-operated.{{ .Release.Namespace }}.svc:9090 12 | 13 | To access them from your host, run the following command: 14 | 15 | kubectl port-forward services/prometheus-operated 9090:9090 -n {{ .Release.Namespace }} 16 | 17 | And access them using the following endpoint: 18 | 19 | http://localhost:9090 20 | {{- end }} 21 | 22 | Please visit our documentation to learn about custom resources managed by the operator: 23 | 24 | https://documentation.gravitee.io/gravitee-kubernetes-operator-gko 25 | 26 | -------------------------------------------------------------------------------- /helm/gko/templates/debug/service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | {{- if .Values.dev.debug.enabled }} 15 | --- 16 | apiVersion: v1 17 | kind: Service 18 | metadata: 19 | name: gko-controller-manager-debug-service 20 | namespace: '{{ .Release.Namespace }}' 21 | labels: 22 | control-plane: controller-manager 23 | app.kubernetes.io/instance: {{ .Release.Name }} 24 | app.kubernetes.io/managed-by: {{ .Release.Service }} 25 | app.kubernetes.io/name: {{ template "helm.name" . }} 26 | app.kubernetes.io/version: {{ .Chart.AppVersion }} 27 | annotations: 28 | meta.helm.sh/release-name: {{ .Release.Name }} 29 | meta.helm.sh/release-namespace: {{ .Release.Namespace }} 30 | spec: 31 | type: ClusterIP 32 | ports: 33 | - name: debug 34 | port: {{ .Values.dev.debug.port }} 35 | targetPort: {{ .Values.dev.debug.port }} 36 | selector: 37 | control-plane: controller-manager 38 | {{- end }} 39 | -------------------------------------------------------------------------------- /helm/gko/templates/metrics/service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | {{- if .Values.manager.metrics.enabled }} 15 | --- 16 | apiVersion: v1 17 | kind: Service 18 | metadata: 19 | name: gko-controller-manager-metrics-service 20 | namespace: '{{ .Release.Namespace }}' 21 | labels: 22 | control-plane: controller-manager 23 | app.kubernetes.io/instance: {{ .Release.Name }} 24 | app.kubernetes.io/managed-by: {{ .Release.Service }} 25 | app.kubernetes.io/name: {{ template "helm.name" . }} 26 | app.kubernetes.io/version: {{ .Chart.AppVersion }} 27 | annotations: 28 | meta.helm.sh/release-name: {{ .Release.Name }} 29 | meta.helm.sh/release-namespace: {{ .Release.Namespace }} 30 | spec: 31 | ports: 32 | - name: https 33 | port: 8443 34 | protocol: TCP 35 | targetPort: {{ .Values.manager.metrics.port }} 36 | selector: 37 | control-plane: controller-manager 38 | {{- end }} 39 | -------------------------------------------------------------------------------- /helm/gko/templates/rbac/service-account.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | {{- if .Values.serviceAccount.create }} 16 | --- 17 | apiVersion: v1 18 | kind: ServiceAccount 19 | metadata: 20 | name: {{ template "rbac.serviceAccountName" . }} 21 | namespace: '{{ .Release.Namespace }}' 22 | labels: 23 | app.kubernetes.io/instance: {{ .Release.Name }} 24 | app.kubernetes.io/managed-by: {{ .Release.Service }} 25 | app.kubernetes.io/name: {{ template "helm.name" . }} 26 | app.kubernetes.io/version: {{ .Chart.AppVersion }} 27 | annotations: 28 | meta.helm.sh/release-name: {{ .Release.Name }} 29 | meta.helm.sh/release-namespace: {{ .Release.Namespace }} 30 | {{- end }} 31 | -------------------------------------------------------------------------------- /helm/gko/templates/webhook/secret.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | {{- if and .Values.manager.webhook.enabled .Values.manager.webhook.cert.create }} 16 | apiVersion: v1 17 | kind: Secret 18 | metadata: 19 | labels: 20 | app.kubernetes.io/instance: {{ .Release.Name }} 21 | app.kubernetes.io/managed-by: {{ .Release.Service }} 22 | app.kubernetes.io/name: {{ template "helm.name" . }} 23 | app.kubernetes.io/version: {{ .Chart.AppVersion }} 24 | annotations: 25 | meta.helm.sh/release-name: {{ .Release.Name }} 26 | meta.helm.sh/release-namespace: {{ .Release.Namespace }} 27 | name: {{ .Values.manager.webhook.cert.secret.name }} 28 | namespace: {{ .Release.Namespace }} 29 | 30 | {{- end }} -------------------------------------------------------------------------------- /helm/gko/templates/webhook/service.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | {{- if .Values.manager.webhook.enabled }} 16 | apiVersion: v1 17 | kind: Service 18 | metadata: 19 | labels: 20 | app.kubernetes.io/instance: {{ .Release.Name }} 21 | app.kubernetes.io/managed-by: {{ .Release.Service }} 22 | app.kubernetes.io/name: {{ template "helm.name" . }} 23 | app.kubernetes.io/version: {{ .Chart.AppVersion }} 24 | annotations: 25 | meta.helm.sh/release-name: {{ .Release.Name }} 26 | meta.helm.sh/release-namespace: {{ .Release.Namespace }} 27 | name: {{ .Values.manager.webhook.service.name }} 28 | namespace: {{ .Release.Namespace }} 29 | spec: 30 | ports: 31 | - port: 443 32 | protocol: TCP 33 | targetPort: 9443 34 | selector: 35 | control-plane: controller-manager 36 | {{- end }} 37 | -------------------------------------------------------------------------------- /helm/gko/tests/manager/deployment_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: manager deployment 16 | tests: 17 | - it: Should not have image pull secrets by default 18 | template: "manager/deployment.yaml" 19 | asserts: 20 | - isNull: 21 | path: spec.template.spec.imagePullSecrets 22 | 23 | - it: Should have manager image pull secret 24 | template: "manager/deployment.yaml" 25 | set: 26 | manager: 27 | image: 28 | pullSecret: 29 | name: hush-hush 30 | asserts: 31 | - isNotNull: 32 | path: spec.template.spec.imagePullSecrets 33 | - lengthEqual: 34 | path: spec.template.spec.imagePullSecrets 35 | count: 1 36 | - equal: 37 | path: spec.template.spec.imagePullSecrets[0] 38 | value: 39 | name: hush-hush 40 | 41 | -------------------------------------------------------------------------------- /helm/gko/tests/metrics/service_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: metrics service 16 | templates: 17 | - "metrics/service.yaml" 18 | tests: 19 | - it: Should have service 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: Service 25 | - isAPIVersion: 26 | of: v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-controller-manager-metrics-service 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have service with metrics disabled 35 | set: 36 | manager: 37 | metrics: 38 | enabled: false 39 | asserts: 40 | - hasDocuments: 41 | count: 0 42 | -------------------------------------------------------------------------------- /helm/gko/tests/rbac/leader-election-role-binding_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: leader election role binding 16 | templates: 17 | - "rbac/leader-election-role-binding.yaml" 18 | tests: 19 | - it: Should have leader election role binding 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: RoleBinding 25 | - isAPIVersion: 26 | of: rbac.authorization.k8s.io/v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-controller-manager-leader-election-role-binding 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have leader election role binding with rbac disabled 35 | set: 36 | rbac: 37 | create: false 38 | asserts: 39 | - hasDocuments: 40 | count: 0 41 | 42 | -------------------------------------------------------------------------------- /helm/gko/tests/rbac/leader-election-role_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: leader election role 16 | templates: 17 | - "rbac/leader-election-role.yaml" 18 | tests: 19 | - it: Should have leader election role 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: Role 25 | - isAPIVersion: 26 | of: rbac.authorization.k8s.io/v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-controller-manager-leader-election-role 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have leader election role with rbac disabled 35 | set: 36 | rbac: 37 | create: false 38 | asserts: 39 | - hasDocuments: 40 | count: 0 41 | 42 | -------------------------------------------------------------------------------- /helm/gko/tests/webhook/secret_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: webhook service 16 | templates: 17 | - "webhook/secret.yaml" 18 | tests: 19 | - it: Should have secret 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: Secret 25 | - isAPIVersion: 26 | of: v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-webhook-cert 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have secret with webhook disabled 35 | set: 36 | manager: 37 | webhook: 38 | enabled: false 39 | asserts: 40 | - hasDocuments: 41 | count: 0 42 | -------------------------------------------------------------------------------- /helm/gko/tests/webhook/service_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: webhook service 16 | templates: 17 | - "webhook/service.yaml" 18 | tests: 19 | - it: Should have service 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: Service 25 | - isAPIVersion: 26 | of: v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-webhook 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have service with webhook disabled 35 | set: 36 | manager: 37 | webhook: 38 | enabled: false 39 | asserts: 40 | - hasDocuments: 41 | count: 0 42 | -------------------------------------------------------------------------------- /helm/gko/tests/webhook/validation_webhook_test.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | suite: webhook service 16 | templates: 17 | - "webhook/validation-webhook.yaml" 18 | tests: 19 | - it: Should have Validating Webhook Configuration 20 | asserts: 21 | - hasDocuments: 22 | count: 1 23 | - isKind: 24 | of: ValidatingWebhookConfiguration 25 | - isAPIVersion: 26 | of: admissionregistration.k8s.io/v1 27 | - equal: 28 | path: metadata.name 29 | value: gko-validating-webhook-configurations 30 | - equal: 31 | path: metadata.namespace 32 | value: NAMESPACE 33 | 34 | - it: Should not have Validating Webhook Configuration with webhook disabled 35 | set: 36 | manager: 37 | webhook: 38 | enabled: false 39 | asserts: 40 | - hasDocuments: 41 | count: 0 42 | -------------------------------------------------------------------------------- /internal/admission/api/base/plans.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package base 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 19 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 20 | ) 21 | 22 | func validatePlans(api core.ApiDefinitionObject) *errors.AdmissionError { 23 | if !api.HasPlans() && api.GetState() != "STOPPED" { 24 | return errors.NewSeveref( 25 | "cannot apply API [%s]. "+ 26 | "Its state is set to STARTED, but the API has no plans. "+ 27 | "APIs must have at least one plan in order to be deployed.", 28 | api.GetName(), 29 | ) 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /internal/admission/api/v4/api_type.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v4 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 19 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 20 | ) 21 | 22 | func validateApiType(oldApi, newAPI core.ApiDefinitionObject) *errors.AdmissionError { 23 | if nativeAPI == oldApi.GetType() && oldApi.GetType() != newAPI.GetType() { 24 | return errors.NewSeveref("it is not possible to change the API type 'NATIVE' "+ 25 | "to something else [%s]", newAPI.GetType()) 26 | } else if nativeAPI != oldApi.GetType() && nativeAPI == newAPI.GetType() { 27 | return errors.NewSevere("it is not possible to convert a none NATIVE API to a NATIVE API") 28 | } 29 | 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /internal/admission/template.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package admission 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/template" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | ) 24 | 25 | func CompileAndValidateTemplate(ctx context.Context, obj runtime.Object) *errors.AdmissionError { 26 | err := template.Compile(ctx, obj, false) 27 | 28 | if err != nil { 29 | return errors.NewSeveref("%s", err.Error()) 30 | } 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /internal/apim/model/api_key.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | type ApiKeyEntity struct { 18 | ID string `json:"id"` 19 | Key string `json:"key"` 20 | } 21 | -------------------------------------------------------------------------------- /internal/apim/model/env.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | type Env struct { 18 | ID string `json:"id"` 19 | Name string `json:"name"` 20 | } 21 | 22 | type Group struct { 23 | ID string `json:"id,omitempty"` 24 | Name string `json:"name,omitempty"` 25 | } 26 | 27 | type GroupStatus struct { 28 | Members uint `json:"members"` 29 | } 30 | 31 | type Category struct { 32 | ID string `json:"id,omitempty"` 33 | Name string `json:"name,omitempty"` 34 | } 35 | -------------------------------------------------------------------------------- /internal/apim/model/subscription.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | type SubscriptionResponse struct { 18 | ID string `json:"id"` 19 | } 20 | 21 | type SubscriptionRequest struct { 22 | AppID string `json:"applicationId"` 23 | PlanID string `json:"planId"` 24 | } 25 | 26 | type Subscription struct { 27 | ID string `json:"id"` 28 | ApiID string `json:"apiId"` 29 | AppID string `json:"applicationId"` 30 | PlanID string `json:"planId"` 31 | Status string `json:"status"` 32 | StartingAt string `json:"startingAt"` 33 | EndingAt string `json:"endingAt"` 34 | } 35 | 36 | type SubscriptionStatus struct { 37 | ID string `json:"id,omitempty"` 38 | StartingAt string `json:"startingAt,omitempty"` 39 | EndingAt string `json:"endingAt,omitempty"` 40 | } 41 | -------------------------------------------------------------------------------- /internal/apim/model/user.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package model 16 | 17 | type User struct { 18 | ID string `json:"id,omitempty"` 19 | FirstName string `json:"firstname,omitempty"` 20 | Email string `json:"email,omitempty"` 21 | LastName string `json:"lastname,omitempty"` 22 | Service bool `json:"service,omitempty"` 23 | } 24 | 25 | func NewServiceAccount(name string) *User { 26 | return &User{LastName: name, Service: true} 27 | } 28 | -------------------------------------------------------------------------------- /internal/apim/service/org.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package service 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/client" 19 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/apim/model" 20 | ) 21 | 22 | // Org brings support for managing gravitee.io APIM support for organization level operations. 23 | // This service is used for testing purposes only and not initialized by the operator manager. 24 | type Org struct { 25 | *client.Client 26 | } 27 | 28 | func NewOrg(client *client.Client) *Org { 29 | return &Org{Client: client} 30 | } 31 | 32 | func (svc *Org) CreateUser(user *model.User) error { 33 | url := svc.OrgTarget("users") 34 | return svc.HTTP.Post(url.String(), user, user) 35 | } 36 | -------------------------------------------------------------------------------- /internal/hash/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package hash 16 | 17 | import ( 18 | "crypto/sha256" 19 | "encoding/hex" 20 | "encoding/json" 21 | ) 22 | 23 | func Calculate(i interface{}) string { 24 | data, err := json.Marshal(i) 25 | if err != nil { 26 | return "" 27 | } 28 | hash := sha256.Sum256(data) 29 | return hex.EncodeToString(hash[:]) 30 | } 31 | -------------------------------------------------------------------------------- /internal/http/headers.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package http 16 | 17 | const ( 18 | AuthorizationHeader = "Authorization" 19 | ContentTypeHeader = "Content-Type" 20 | ContentTypeTextPlain = "text/plain" 21 | ContentTypeJSON = "application/json" 22 | ) 23 | -------------------------------------------------------------------------------- /internal/http/json.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package http 16 | 17 | import ( 18 | "bytes" 19 | "encoding/json" 20 | "io" 21 | "net/http" 22 | ) 23 | 24 | func WriteJSON(resp *http.Response, entity any) error { 25 | if resp.Body == nil || entity == nil { 26 | return nil 27 | } 28 | return json.NewDecoder(resp.Body).Decode(entity) 29 | } 30 | 31 | func ReadJSON(entity any) (io.Reader, error) { 32 | buf := new(bytes.Buffer) 33 | if entity == nil { 34 | return buf, nil 35 | } 36 | return buf, json.NewEncoder(buf).Encode(entity) 37 | } 38 | -------------------------------------------------------------------------------- /internal/http/yaml.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package http 16 | 17 | import ( 18 | "io" 19 | "net/http" 20 | 21 | "sigs.k8s.io/yaml" 22 | ) 23 | 24 | func WriteYAML(resp *http.Response, entity any) error { 25 | if resp.Body == nil || entity == nil { 26 | return nil 27 | } 28 | 29 | bytes, err := io.ReadAll(resp.Body) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | return yaml.Unmarshal(bytes, entity) 35 | } 36 | -------------------------------------------------------------------------------- /internal/k8s/annotation.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package k8s 16 | 17 | import "sigs.k8s.io/controller-runtime/pkg/client" 18 | 19 | func AddAnnotation(o client.Object, key, value string) { 20 | a := o.GetAnnotations() 21 | if a == nil { 22 | a = make(map[string]string) 23 | } 24 | 25 | a[key] = value 26 | o.SetAnnotations(a) 27 | } 28 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/applications.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | ) 23 | 24 | func ResolveApplication(ctx context.Context, ref core.ObjectRef, parentNs string) (core.ApplicationObject, error) { 25 | app, err := resolveRef(ctx, ref, parentNs, ApplicationGVR, new(v1alpha1.Application)) 26 | if err != nil { 27 | return nil, err 28 | } 29 | 30 | return app, nil 31 | } 32 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/client.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "sync" 19 | 20 | "k8s.io/client-go/dynamic" 21 | 22 | ctrl "sigs.k8s.io/controller-runtime" 23 | ) 24 | 25 | var dynamicClient *dynamic.DynamicClient 26 | var once sync.Once 27 | 28 | func GetClient() *dynamic.DynamicClient { 29 | once.Do(func() { 30 | dynamicClient = dynamic.NewForConfigOrDie(ctrl.GetConfigOrDie()) 31 | }) 32 | return dynamicClient 33 | } 34 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/convert.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "encoding/json" 19 | ) 20 | 21 | func convert[T any](source any, target T) (T, error) { 22 | b, err := json.Marshal(source) 23 | if err != nil { 24 | return target, err 25 | } 26 | 27 | if err = json.Unmarshal(b, target); err != nil { 28 | return target, err 29 | } 30 | 31 | return target, nil 32 | } 33 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/group.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 23 | ) 24 | 25 | func ResolveGroup(ctx context.Context, ref core.ObjectRef, namespace string) (*v1alpha1.Group, error) { 26 | refKind := ref.GetKind() 27 | if ref.GetKind() == "" { 28 | refKind = GroupGVR.Resource 29 | } 30 | kind := PluralizeKind(refKind) 31 | switch kind { 32 | case GroupGVR.Resource: 33 | return resolveRef(ctx, ref, namespace, NotificationGVR, new(v1alpha1.Group)) 34 | default: 35 | return nil, errors.NewSevere("Group kind is mandatory") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/kind.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | func PluralizeKind(kind string) string { 22 | return strings.TrimRight(strings.ToLower(kind), "s") + "s" 23 | } 24 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/notification.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/v1alpha1" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/errors" 23 | ) 24 | 25 | func ResolveNotification(ctx context.Context, ref core.ObjectRef, namespace string) (*v1alpha1.Notification, error) { 26 | refKind := ref.GetKind() 27 | if ref.GetKind() == "" { 28 | refKind = NotificationGVR.Resource 29 | } 30 | kind := PluralizeKind(refKind) 31 | switch kind { 32 | case NotificationGVR.Resource: 33 | return resolveRef(ctx, ref, namespace, NotificationGVR, new(v1alpha1.Notification)) 34 | default: 35 | return nil, errors.NewSevere("Notification kind is mandatory") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/resource.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/api/base" 21 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 22 | ) 23 | 24 | func ExpectResolvedResource(ctx context.Context, ref core.ObjectRef, parentNs string) error { 25 | if _, err := ResolveResource(ctx, ref, parentNs); err != nil { 26 | return err 27 | } 28 | return nil 29 | } 30 | 31 | func ResolveResource(ctx context.Context, ref core.ObjectRef, parentNs string) (core.ResourceModel, error) { 32 | res, err := resolveRefSpec(ctx, ref, parentNs, ResourceGVR, new(base.Resource)) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | return res, nil 38 | } 39 | -------------------------------------------------------------------------------- /internal/k8s/dynamic/secret.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dynamic 16 | 17 | import ( 18 | "context" 19 | 20 | coreV1 "k8s.io/api/core/v1" 21 | 22 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | func ExpectResolvedSecret(ctx context.Context, ref core.ObjectRef, parentNs string) error { 27 | if _, err := ResolveSecret(ctx, ref, parentNs); err != nil { 28 | return err 29 | } 30 | return nil 31 | } 32 | 33 | func ResolveSecret(ctx context.Context, ref core.ObjectRef, parentNs string) (*coreV1.Secret, error) { 34 | return resolveRef(ctx, ref, parentNs, schema.GroupVersionResource{ 35 | Group: "", 36 | Version: "v1", 37 | Resource: "secrets", 38 | }, new(coreV1.Secret)) 39 | } 40 | -------------------------------------------------------------------------------- /internal/k8s/ingress.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package k8s 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/core" 19 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/env" 20 | netV1 "k8s.io/api/networking/v1" 21 | ) 22 | 23 | func IsGraviteeIngress(ingress *netV1.Ingress) bool { 24 | var ingressClassName string 25 | if ingressClassName = ingress.GetAnnotations()[core.IngressClassAnnotation]; ingress.Spec.IngressClassName != nil { 26 | ingressClassName = *(ingress.Spec.IngressClassName) 27 | } 28 | 29 | for _, ingressClass := range env.Config.IngressClasses { 30 | if ingressClassName == ingressClass { 31 | return true 32 | } 33 | } 34 | return false 35 | } 36 | -------------------------------------------------------------------------------- /internal/search/search.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package search 16 | 17 | import ( 18 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/refs" 19 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 20 | "golang.org/x/net/context" 21 | "k8s.io/apimachinery/pkg/fields" 22 | "sigs.k8s.io/controller-runtime/pkg/client" 23 | ) 24 | 25 | func FindByFieldReferencing( 26 | ctx context.Context, 27 | field IndexField, 28 | ref refs.NamespacedName, 29 | result client.ObjectList, 30 | ) error { 31 | filter := &client.ListOptions{ 32 | FieldSelector: fields.SelectorFromSet(fields.Set{field.String(): ref.String()}), 33 | } 34 | 35 | return k8s.GetClient().List(ctx, result, filter) 36 | } 37 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=gravitee-io_gravitee-kubernetes-operator 2 | sonar.projectName=gravitee-kubernetes-operator 3 | sonar.organization=gravitee-io 4 | sonar.host.url=https://sonarcloud.io 5 | 6 | sonar.sources=. 7 | sonar.exclusions=test/**/*,hack/scripts/**/*,hack/kind/**/*,examples/**/*,**/zz_generated.deepcopy.go,main.go 8 | 9 | sonar.tests=. 10 | sonar.test.inclusions=**/*_test.go 11 | 12 | sonar.go.coverage.reportPaths=/tmp/junit/reports/cover-withContext.out,/tmp/junit/reports/cover-withoutContext.out,/tmp/junit/reports/cover-unit.out 13 | -------------------------------------------------------------------------------- /test/e2e/chainsaw/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha2.json 16 | apiVersion: chainsaw.kyverno.io/v1alpha2 17 | kind: Configuration 18 | metadata: 19 | name: chainsaw-e2e-tests 20 | spec: 21 | discovery: 22 | testFile: chainsaw-test 23 | timeouts: 24 | apply: 5s 25 | assert: 5s 26 | cleanup: 10s 27 | delete: 15s 28 | error: 10s 29 | exec: 30s 30 | report: 31 | format: XML 32 | name: chainsaw-junit-reports 33 | path: /tmp/junit/reports-e2e 34 | -------------------------------------------------------------------------------- /test/e2e/chainsaw/tests/apis/create-update-delete/v2/keyless-v2.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | apiVersion: gravitee.io/v1alpha1 16 | kind: ApiDefinition 17 | metadata: 18 | name: chainsaw-keyless-v2 19 | spec: 20 | name: chainsaw-keyless-v2 21 | contextRef: 22 | name: "dev-ctx" 23 | namespace: "default" 24 | version: "initial" 25 | description: "keyless v2 API - Created by Chainsaw E2E test" 26 | local: false 27 | plans: 28 | - name: "KEY_LESS" 29 | description: "FREE" 30 | security: "KEY_LESS" 31 | proxy: 32 | virtual_hosts: 33 | - path: "/chainsaw-keyless-v2" 34 | groups: 35 | - endpoints: 36 | - name: "Default" 37 | target: "https://api.gravitee.io/echo" -------------------------------------------------------------------------------- /test/integration/admission/group/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package group 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Group Admission Suite") 31 | } 32 | 33 | var _ = SynchronizedBeforeSuite(func() { 34 | // NOSONAR mandatory noop 35 | }, func() { 36 | }) 37 | 38 | var _ = SynchronizedAfterSuite(func() { 39 | By("Tearing down the test environment") 40 | gexec.KillAndWait(5 * time.Second) 41 | }, func() { 42 | // NOSONAR ignore this noop func 43 | }) 44 | -------------------------------------------------------------------------------- /test/integration/admission/subscription/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package subscription 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Subscription Admission Suite") 31 | } 32 | 33 | var _ = SynchronizedBeforeSuite(func() { 34 | // NOSONAR mandatory noop 35 | }, func() { 36 | }) 37 | 38 | var _ = SynchronizedAfterSuite(func() { 39 | By("Tearing down the test environment") 40 | gexec.KillAndWait(5 * time.Second) 41 | }, func() { 42 | // NOSONAR ignore this noop func 43 | }) 44 | -------------------------------------------------------------------------------- /test/integration/application/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package application 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Application Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR mandatory noop 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/ingress/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ingress 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Ingress Suite") 31 | } 32 | 33 | type Host struct { 34 | Name string `json:"hostname"` 35 | } 36 | 37 | var _ = SynchronizedBeforeSuite(func() { 38 | // NOSONAR mandatory noop 39 | }, func() { 40 | // NOSONAR ignore this noop func 41 | }) 42 | 43 | var _ = SynchronizedAfterSuite(func() { 44 | By("Tearing down the test environment") 45 | gexec.KillAndWait(5 * time.Second) 46 | }, func() { 47 | // NOSONAR ignore this noop func 48 | }) 49 | 50 | func toPointer(s string) *string { 51 | return &s 52 | } 53 | -------------------------------------------------------------------------------- /test/integration/managementcontext/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package managementcontext 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Management Context Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR ignore this noop func 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/notification/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package notification 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestNotifications(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Notification Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR mandatory noop 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/secret/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package secret 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Secret Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR ignore this noop func 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/sharedpolicygroups/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package sharedpolicygroups 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "SharedPolicyGroup Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR ignore this noop func 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/usecase/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package usecase 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Use Cases Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR mandatory noop 38 | }) 39 | -------------------------------------------------------------------------------- /test/integration/webhook/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package webhook 16 | 17 | import ( 18 | "testing" 19 | "time" 20 | 21 | "github.com/onsi/gomega/gexec" 22 | 23 | . "github.com/onsi/ginkgo/v2" 24 | . "github.com/onsi/gomega" 25 | //+kubebuilder:scaffold:imports 26 | ) 27 | 28 | func TestResources(t *testing.T) { 29 | RegisterFailHandler(Fail) 30 | RunSpecs(t, "Webhook Suite") 31 | } 32 | 33 | var _ = SynchronizedAfterSuite(func() { 34 | By("Tearing down the test environment") 35 | gexec.KillAndWait(5 * time.Second) 36 | }, func() { 37 | // NOSONAR ignore this noop func 38 | }) 39 | -------------------------------------------------------------------------------- /test/internal/integration/labels/labels.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package labels 16 | 17 | import "github.com/onsi/ginkgo/v2/dsl/decorators" 18 | 19 | var WithContext = decorators.Label("integration", "withContext") 20 | var WithoutContext = decorators.Label("integration", "withoutContext") 21 | -------------------------------------------------------------------------------- /test/internal/integration/manager/client.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package manager 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/k8s" 21 | "sigs.k8s.io/controller-runtime/pkg/client" 22 | ) 23 | 24 | func Client() client.Client { 25 | return k8s.GetClient() 26 | } 27 | 28 | func GetLatest[T client.Object](ctx context.Context, obj T) error { 29 | return k8s.GetLatest(ctx, obj) 30 | } 31 | 32 | func Delete[T client.Object](ctx context.Context, obj T) error { 33 | return k8s.Delete(ctx, obj) 34 | } 35 | 36 | func UpdateSafely[T client.Object](ctx context.Context, objNew T) error { 37 | return k8s.UpdateSafely(ctx, objNew) 38 | } 39 | -------------------------------------------------------------------------------- /test/internal/integration/sort/comparators.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package sort 16 | 17 | import ( 18 | "strings" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/api/base" 21 | ) 22 | 23 | type Comparator[E any] func(a, b E) int 24 | 25 | func MembersComparator(a, b *base.Member) int { 26 | return strings.Compare(a.String(), b.String()) 27 | } 28 | -------------------------------------------------------------------------------- /test/unit/admission/mctx/suite_test.go: -------------------------------------------------------------------------------- 1 | package mctx 2 | 3 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | import ( 18 | "testing" 19 | 20 | . "github.com/onsi/ginkgo/v2" 21 | . "github.com/onsi/gomega" 22 | //+kubebuilder:scaffold:imports 23 | ) 24 | 25 | func TestDefaultContext(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecs(t, "Default Context admission hook tests suite") 28 | } 29 | -------------------------------------------------------------------------------- /test/unit/apim/suite_test.go: -------------------------------------------------------------------------------- 1 | package apim_test 2 | 3 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | import ( 18 | "testing" 19 | 20 | . "github.com/onsi/ginkgo/v2" 21 | . "github.com/onsi/gomega" 22 | //+kubebuilder:scaffold:imports 23 | ) 24 | 25 | func TestAPIM(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecs(t, "APIM unit tests suite") 28 | } 29 | -------------------------------------------------------------------------------- /test/unit/ingress/suite_test.go: -------------------------------------------------------------------------------- 1 | package ingress_test 2 | 3 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | import ( 18 | "testing" 19 | 20 | . "github.com/onsi/ginkgo/v2" 21 | . "github.com/onsi/gomega" 22 | //+kubebuilder:scaffold:imports 23 | ) 24 | 25 | func TestIngress(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecs(t, "Ingress unit tests suite") 28 | } 29 | -------------------------------------------------------------------------------- /test/unit/uuid/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Gravitee team (http://gravitee.io) 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package uuid 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/gravitee-io/gravitee-kubernetes-operator/internal/uuid" 21 | . "github.com/onsi/ginkgo/v2" 22 | . "github.com/onsi/gomega" 23 | ) 24 | 25 | func TestUUID(t *testing.T) { 26 | RegisterFailHandler(Fail) 27 | RunSpecs(t, "package uuid") 28 | } 29 | 30 | var _ = Describe("FromStrings", func() { 31 | It("generates a predictable UUID", func() { 32 | firstRun := uuid.FromStrings("foo", "bar") 33 | secondRun := uuid.FromStrings("foo", "bar") 34 | Expect(secondRun).To(Equal(firstRun)) 35 | }) 36 | }) 37 | 38 | var _ = Describe("JavaUUIDFromBytes", func() { 39 | It("generates a predictable UUID same as Java", func() { 40 | firstRun := uuid.JavaUUIDFromBytes("foo") 41 | secondRun := uuid.JavaUUIDFromBytes("foo") 42 | Expect(secondRun).To(Equal(firstRun)) 43 | }) 44 | }) 45 | --------------------------------------------------------------------------------