uffizzi-core 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/README.md +52 -0
- data/Rakefile +31 -0
- data/app/assets/config/uffizzi_core_manifest.js +1 -0
- data/app/assets/stylesheets/uffizzi_core/application.css +15 -0
- data/app/clients/uffizzi_core/amazon_registry_client.rb +18 -0
- data/app/clients/uffizzi_core/azure_registry_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/azure_registry_client.rb +42 -0
- data/app/clients/uffizzi_core/controller_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/controller_client.rb +106 -0
- data/app/clients/uffizzi_core/docker_hub_client/request_result.rb +7 -0
- data/app/clients/uffizzi_core/docker_hub_client.rb +141 -0
- data/app/clients/uffizzi_core/github_container_registry_client/request_result.rb +7 -0
- data/app/clients/uffizzi_core/github_container_registry_client.rb +52 -0
- data/app/clients/uffizzi_core/google_registry_client/request_result.rb +5 -0
- data/app/clients/uffizzi_core/google_registry_client.rb +42 -0
- data/app/contexts/uffizzi_core/base_context.rb +12 -0
- data/app/contexts/uffizzi_core/project_context.rb +13 -0
- data/app/contexts/uffizzi_core/webhooks_context.rb +9 -0
- data/app/controllers/concerns/uffizzi_core/auth_management.rb +23 -0
- data/app/controllers/concerns/uffizzi_core/authorization_concern.rb +38 -0
- data/app/controllers/concerns/uffizzi_core/dependency_injection_concern.rb +19 -0
- data/app/controllers/uffizzi_core/api/cli/v1/account/application_controller.rb +7 -0
- data/app/controllers/uffizzi_core/api/cli/v1/account/credentials_controller.rb +91 -0
- data/app/controllers/uffizzi_core/api/cli/v1/application_controller.rb +5 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/application_controller.rb +11 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/compose_files_controller.rb +93 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/activity_items_controller.rb +36 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/application_controller.rb +7 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers/application_controller.rb +8 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers/logs_controller.rb +27 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/containers_controller.rb +24 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments/events_controller.rb +29 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/deployments_controller.rb +179 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects/secrets_controller.rb +61 -0
- data/app/controllers/uffizzi_core/api/cli/v1/projects_controller.rb +85 -0
- data/app/controllers/uffizzi_core/api/cli/v1/sessions_controller.rb +43 -0
- data/app/controllers/uffizzi_core/application_controller.rb +57 -0
- data/app/errors/uffizzi_core/compose_file/build_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/credential_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/parse_error.rb +4 -0
- data/app/errors/uffizzi_core/compose_file/secrets_error.rb +4 -0
- data/app/errors/uffizzi_core/deployment/image_pull_error.rb +10 -0
- data/app/errors/uffizzi_core/deployment_not_found_error.rb +10 -0
- data/app/forms/uffizzi_core/api/cli/v1/account/credential/check_credential_form.rb +16 -0
- data/app/forms/uffizzi_core/api/cli/v1/account/credential/create_form.rb +26 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/check_credentials_form.rb +21 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/cli_form.rb +22 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/create_form.rb +13 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/template_form.rb +44 -0
- data/app/forms/uffizzi_core/api/cli/v1/compose_file/update_form.rb +9 -0
- data/app/forms/uffizzi_core/api/cli/v1/config_file/create_form.rb +11 -0
- data/app/forms/uffizzi_core/api/cli/v1/deployment/create_form.rb +92 -0
- data/app/forms/uffizzi_core/api/cli/v1/deployment/update_form.rb +90 -0
- data/app/forms/uffizzi_core/api/cli/v1/project/create_form.rb +7 -0
- data/app/forms/uffizzi_core/api/cli/v1/project/update_form.rb +10 -0
- data/app/forms/uffizzi_core/api/cli/v1/secret/bulk_assign_form.rb +39 -0
- data/app/forms/uffizzi_core/api/cli/v1/session_create_form.rb +29 -0
- data/app/forms/uffizzi_core/api/cli/v1/template/create_form.rb +65 -0
- data/app/forms/uffizzi_core/application_form.rb +11 -0
- data/app/forms/uffizzi_core/application_form_without_active_record.rb +17 -0
- data/app/forms/uffizzi_core/mass_assignment_control_concern.rb +22 -0
- data/app/helpers/uffizzi_core/application_helper.rb +6 -0
- data/app/jobs/uffizzi_core/account/create_credential_job.rb +10 -0
- data/app/jobs/uffizzi_core/activity_item/docker/update_digest_job.rb +11 -0
- data/app/jobs/uffizzi_core/application_job.rb +7 -0
- data/app/jobs/uffizzi_core/config_file/apply_job.rb +31 -0
- data/app/jobs/uffizzi_core/credential/docker_hub/create_webhook_job.rb +15 -0
- data/app/jobs/uffizzi_core/deployment/create_credential_job.rb +32 -0
- data/app/jobs/uffizzi_core/deployment/create_credentials_job.rb +17 -0
- data/app/jobs/uffizzi_core/deployment/create_job.rb +15 -0
- data/app/jobs/uffizzi_core/deployment/create_webhooks_job.rb +13 -0
- data/app/jobs/uffizzi_core/deployment/delete_credential_job.rb +13 -0
- data/app/jobs/uffizzi_core/deployment/delete_job.rb +11 -0
- data/app/jobs/uffizzi_core/deployment/deploy_containers_job.rb +27 -0
- data/app/jobs/uffizzi_core/deployment/manage_deploy_activity_item_job.rb +38 -0
- data/app/lib/uffizzi_core/concerns/models/activity_item.rb +39 -0
- data/app/lib/uffizzi_core/concerns/models/credential.rb +65 -0
- data/app/lib/uffizzi_core/concerns/models/repo.rb +33 -0
- data/app/lib/uffizzi_core/rbac/user_access_service.rb +45 -0
- data/app/mailers/uffizzi_core/application_mailer.rb +8 -0
- data/app/models/concerns/uffizzi_core/hashid_concern.rb +25 -0
- data/app/models/concerns/uffizzi_core/state_machine_concern.rb +16 -0
- data/app/models/uffizzi_core/account.rb +83 -0
- data/app/models/uffizzi_core/activity_item/docker.rb +4 -0
- data/app/models/uffizzi_core/activity_item/github.rb +4 -0
- data/app/models/uffizzi_core/activity_item/memory_limit.rb +4 -0
- data/app/models/uffizzi_core/activity_item.rb +53 -0
- data/app/models/uffizzi_core/application_record.rb +7 -0
- data/app/models/uffizzi_core/build.rb +39 -0
- data/app/models/uffizzi_core/comment.rb +16 -0
- data/app/models/uffizzi_core/compose_file.rb +57 -0
- data/app/models/uffizzi_core/config_file.rb +24 -0
- data/app/models/uffizzi_core/container.rb +100 -0
- data/app/models/uffizzi_core/container_config_file.rb +8 -0
- data/app/models/uffizzi_core/continuous_preview.rb +4 -0
- data/app/models/uffizzi_core/coupon.rb +5 -0
- data/app/models/uffizzi_core/credential/amazon.rb +4 -0
- data/app/models/uffizzi_core/credential/azure.rb +4 -0
- data/app/models/uffizzi_core/credential/docker_hub.rb +4 -0
- data/app/models/uffizzi_core/credential/github.rb +4 -0
- data/app/models/uffizzi_core/credential/github_container_registry.rb +4 -0
- data/app/models/uffizzi_core/credential/google.rb +4 -0
- data/app/models/uffizzi_core/credential.rb +61 -0
- data/app/models/uffizzi_core/database.rb +4 -0
- data/app/models/uffizzi_core/database_offering.rb +4 -0
- data/app/models/uffizzi_core/deployment.rb +86 -0
- data/app/models/uffizzi_core/event.rb +13 -0
- data/app/models/uffizzi_core/invitation.rb +27 -0
- data/app/models/uffizzi_core/membership.rb +16 -0
- data/app/models/uffizzi_core/payment.rb +11 -0
- data/app/models/uffizzi_core/price.rb +9 -0
- data/app/models/uffizzi_core/product.rb +11 -0
- data/app/models/uffizzi_core/project.rb +67 -0
- data/app/models/uffizzi_core/rating.rb +20 -0
- data/app/models/uffizzi_core/repo/amazon.rb +4 -0
- data/app/models/uffizzi_core/repo/azure.rb +4 -0
- data/app/models/uffizzi_core/repo/docker_hub.rb +4 -0
- data/app/models/uffizzi_core/repo/github.rb +4 -0
- data/app/models/uffizzi_core/repo/github_container_registry.rb +4 -0
- data/app/models/uffizzi_core/repo/google.rb +4 -0
- data/app/models/uffizzi_core/repo.rb +29 -0
- data/app/models/uffizzi_core/role.rb +17 -0
- data/app/models/uffizzi_core/secret.rb +9 -0
- data/app/models/uffizzi_core/template.rb +19 -0
- data/app/models/uffizzi_core/user.rb +62 -0
- data/app/models/uffizzi_core/user_project.rb +14 -0
- data/app/policies/uffizzi_core/api/cli/v1/account/credentials_policy.rb +19 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/compose_files_policy.rb +15 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/activity_items_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/containers_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments/events_policy.rb +7 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/deployments_policy.rb +27 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects/secrets_policy.rb +15 -0
- data/app/policies/uffizzi_core/api/cli/v1/projects_policy.rb +19 -0
- data/app/policies/uffizzi_core/application_policy.rb +12 -0
- data/app/repositories/uffizzi_core/activity_item_repo.rb +9 -0
- data/app/repositories/uffizzi_core/basic_order_repo.rb +11 -0
- data/app/repositories/uffizzi_core/build_repo.rb +23 -0
- data/app/repositories/uffizzi_core/comment_repo.rb +11 -0
- data/app/repositories/uffizzi_core/compose_file_repo.rb +11 -0
- data/app/repositories/uffizzi_core/config_file_repo.rb +40 -0
- data/app/repositories/uffizzi_core/container_repo.rb +25 -0
- data/app/repositories/uffizzi_core/credential_repo.rb +31 -0
- data/app/repositories/uffizzi_core/deployment_repo.rb +24 -0
- data/app/repositories/uffizzi_core/event_repo.rb +9 -0
- data/app/repositories/uffizzi_core/membership_repo.rb +10 -0
- data/app/repositories/uffizzi_core/price_repo.rb +11 -0
- data/app/repositories/uffizzi_core/product_repo.rb +11 -0
- data/app/repositories/uffizzi_core/project_repo.rb +10 -0
- data/app/repositories/uffizzi_core/repo_repo.rb +10 -0
- data/app/repositories/uffizzi_core/template_repo.rb +87 -0
- data/app/repositories/uffizzi_core/usage_repo.rb +9 -0
- data/app/repositories/uffizzi_core/user_repo.rb +11 -0
- data/app/responders/uffizzi_core/json_responder.rb +13 -0
- data/app/serializers/uffizzi_core/api/cli/v1/account/credential_serializer.rb +9 -0
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer/compose_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer/deployment_serializer.rb +13 -0
- data/app/serializers/uffizzi_core/api/cli/v1/project_serializer.rb +30 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/compose_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/container_serializer.rb +32 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer/user_serializer.rb +11 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployment_serializer.rb +74 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/activity_item_serializer.rb +24 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer/config_file_serializer.rb +6 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer/container_config_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/deployments/container_serializer.rb +30 -0
- data/app/serializers/uffizzi_core/api/cli/v1/projects/secret_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/api/cli/v1/short_project_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/api/cli/v1/user_serializer/account_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/api/cli/v1/user_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/base_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/controller/apply_config_file/config_file_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/controller/create_credential/credential_serializer.rb +19 -0
- data/app/serializers/uffizzi_core/controller/create_deployment/deployment_serializer.rb +5 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer/container_config_file_serializer/config_file_serializer.rb +8 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer/container_config_file_serializer.rb +7 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/container_serializer.rb +70 -0
- data/app/serializers/uffizzi_core/controller/deploy_containers/credential_serializer.rb +5 -0
- data/app/services/uffizzi_core/account_service.rb +21 -0
- data/app/services/uffizzi_core/activity_item_service.rb +88 -0
- data/app/services/uffizzi_core/amazon/credential_service.rb +31 -0
- data/app/services/uffizzi_core/amazon_service.rb +45 -0
- data/app/services/uffizzi_core/azure/credential_service.rb +18 -0
- data/app/services/uffizzi_core/compose_file/builders/config_files_builder_service.rb +31 -0
- data/app/services/uffizzi_core/compose_file/builders/container_builder_service.rb +222 -0
- data/app/services/uffizzi_core/compose_file/builders/docker_repo_builder_service.rb +25 -0
- data/app/services/uffizzi_core/compose_file/builders/template_builder_service.rb +45 -0
- data/app/services/uffizzi_core/compose_file/builders/variables_builder_service.rb +58 -0
- data/app/services/uffizzi_core/compose_file/config_files_service.rb +52 -0
- data/app/services/uffizzi_core/compose_file/config_option_service.rb +41 -0
- data/app/services/uffizzi_core/compose_file/configs_options_service.rb +26 -0
- data/app/services/uffizzi_core/compose_file/container_service.rb +68 -0
- data/app/services/uffizzi_core/compose_file/continuous_preview_options_service.rb +57 -0
- data/app/services/uffizzi_core/compose_file/dependencies_service.rb +56 -0
- data/app/services/uffizzi_core/compose_file/errors_service.rb +46 -0
- data/app/services/uffizzi_core/compose_file/github_dependencies_service.rb +38 -0
- data/app/services/uffizzi_core/compose_file/ingress_options_service.rb +51 -0
- data/app/services/uffizzi_core/compose_file/parsers/services/healthcheck_parser_service.rb +73 -0
- data/app/services/uffizzi_core/compose_file/secrets_options_service.rb +28 -0
- data/app/services/uffizzi_core/compose_file/services_options/command_service.rb +18 -0
- data/app/services/uffizzi_core/compose_file/services_options/configs_service.rb +51 -0
- data/app/services/uffizzi_core/compose_file/services_options/deploy_service.rb +44 -0
- data/app/services/uffizzi_core/compose_file/services_options/entrypoint_service.rb +18 -0
- data/app/services/uffizzi_core/compose_file/services_options/env_file_service.rb +34 -0
- data/app/services/uffizzi_core/compose_file/services_options/environment_service.rb +20 -0
- data/app/services/uffizzi_core/compose_file/services_options/image_service.rb +89 -0
- data/app/services/uffizzi_core/compose_file/services_options/secrets_service.rb +35 -0
- data/app/services/uffizzi_core/compose_file/services_options_service.rb +57 -0
- data/app/services/uffizzi_core/compose_file/template_service.rb +55 -0
- data/app/services/uffizzi_core/compose_file/variables_service.rb +25 -0
- data/app/services/uffizzi_core/compose_file_service.rb +181 -0
- data/app/services/uffizzi_core/container_service.rb +42 -0
- data/app/services/uffizzi_core/controller_service.rb +86 -0
- data/app/services/uffizzi_core/credential_service.rb +44 -0
- data/app/services/uffizzi_core/deployment_service.rb +307 -0
- data/app/services/uffizzi_core/docker_hub/credential_service.rb +15 -0
- data/app/services/uffizzi_core/docker_hub_service.rb +77 -0
- data/app/services/uffizzi_core/github_container_registry/credential_service.rb +24 -0
- data/app/services/uffizzi_core/google/credential_service.rb +18 -0
- data/app/services/uffizzi_core/logs_service.rb +33 -0
- data/app/services/uffizzi_core/manage_activity_items_service.rb +159 -0
- data/app/services/uffizzi_core/project_service.rb +48 -0
- data/app/services/uffizzi_core/repo_service.rb +43 -0
- data/app/services/uffizzi_core/response_service.rb +13 -0
- data/app/services/uffizzi_core/starter_template_service.rb +200 -0
- data/app/services/uffizzi_core/template_service.rb +21 -0
- data/app/services/uffizzi_core/token_service.rb +19 -0
- data/app/services/uffizzi_core/user_access_service.rb +14 -0
- data/app/services/uffizzi_core/user_generator_service.rb +84 -0
- data/app/utils/uffizzi_core/converters.rb +33 -0
- data/app/validators/uffizzi_core/email_validator.rb +9 -0
- data/app/validators/uffizzi_core/environment_variable_list_validator.rb +15 -0
- data/app/validators/uffizzi_core/image_command_args_validator.rb +21 -0
- data/config/initializers/rswag_api.rb +15 -0
- data/config/initializers/rswag_ui.rb +15 -0
- data/config/initializers/swagger_yard.rb +17 -0
- data/config/locales/en.activerecord.yml +23 -0
- data/config/locales/en.yml +66 -0
- data/config/routes.rb +69 -0
- data/db/migrate/20220218121438_create_uffizzi_core_tables.rb +375 -0
- data/db/migrate/20220309110201_remove_secrets_from_projects.rb +7 -0
- data/db/migrate/20220310110150_create_project_secrets.rb +14 -0
- data/db/migrate/20220325113342_add_name_to_uffizzi_containers.rb +7 -0
- data/db/migrate/20220329123323_rename_project_secrets_to_secrets.rb +7 -0
- data/db/migrate/20220329124542_add_resource_to_secrets.rb +7 -0
- data/db/migrate/20220329143241_remove_project_ref_from_secrets.rb +7 -0
- data/db/migrate/20220419074956_add_health_check_to_containers.rb +7 -0
- data/db/migrate/20220525113412_rename_name_to_uffizzi_containers.rb +7 -0
- data/db/seeds.rb +16 -0
- data/lib/tasks/uffizzi_core_tasks.rake +19 -0
- data/lib/uffizzi_core/engine.rb +15 -0
- data/lib/uffizzi_core/version.rb +5 -0
- data/lib/uffizzi_core.rb +61 -0
- data/swagger/v1/swagger.json +1659 -0
- metadata +966 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cfbec5dca0d0caa42919547f48760fe2fda97f6dd381ee1e750db5f1ad70bbd
|
4
|
+
data.tar.gz: bae43f9c9ec6817cbc617cfcfd3ae821fd90df30ecaf10cbacd3f1f7245d1a6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 11c3d8e3ff170103a01a3c1e300feb6c5fd6faa6edce8ba78ed191d027ab94b60c35b4b46ff50cc86f88b62a19001b28b0050a3288e71ae1227c3189e365db92
|
7
|
+
data.tar.gz: f507b9776ff8a0076844449fd771e755bfb721ddcd9fa357f6a0a130586bc0493a50a7a66000908da1cdbc48695f909aa814d48641099e65f7753b621b57c3f5
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Uffizzi Core
|
2
|
+
|
3
|
+
**Uffizzi CLI API, Models, Services and core libraries**
|
4
|
+
|
5
|
+
## Uffizzi Overview
|
6
|
+
|
7
|
+
Uffizzi is the Full-stack Previews Engine that makes it easy for your team to preview code changes before merging—whether frontend, backend or microserivce. Define your full-stack apps with a familiar syntax based on Docker Compose, and Uffizzi will create on-demand test environments when you open pull requests or build new images. Preview URLs are updated when there’s a new commit, so your team can catch issues early, iterate quickly, and accelerate your release cycles.
|
8
|
+
|
9
|
+
## Getting started with Uffizzi
|
10
|
+
|
11
|
+
The fastest and easiest way to get started with Uffizzi is via the fully hosted version available at https://uffizzi.com, which includes free plans for small teams and qualifying open-source projects.
|
12
|
+
|
13
|
+
Alternatively, you can self-host Uffizzi via the open-source repositories available here on GitHub. The remainder of this README is intended for users interested in self-hosting Uffizzi or for those who are just curious about how Uffizzi works.
|
14
|
+
|
15
|
+
## Uffizzi Architecture
|
16
|
+
|
17
|
+
Uffizzi consists of the following components:
|
18
|
+
|
19
|
+
* [Uffizzi App](https://github.com/UffizziCloud/uffizzi_app) - The primary REST API for creating and managing Previews
|
20
|
+
* [Uffizzi Controller](https://github.com/UffizziCloud/uffizzi_controller) - A smart proxy service that handles requests from Uffizzi App to the Kubernetes API
|
21
|
+
* Uffizzi CLI (this repository) - A command-line interface for Uffizzi App
|
22
|
+
* [Uffizzi Dashboard](https://app.uffizzi.com) - A graphical user interface for Uffizzi App, available as a paid service at https://uffizzi.com
|
23
|
+
|
24
|
+
To host Uffizzi yourself, you will also need the following external dependencies:
|
25
|
+
|
26
|
+
* Kubernetes (k8s) cluster
|
27
|
+
* Postgres database
|
28
|
+
* Redis cache
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'uffizzi_core'
|
36
|
+
```
|
37
|
+
|
38
|
+
And then execute:
|
39
|
+
```bash
|
40
|
+
$ bundle
|
41
|
+
```
|
42
|
+
|
43
|
+
Or install it yourself as:
|
44
|
+
```bash
|
45
|
+
$ gem install uffizzi_core
|
46
|
+
```
|
47
|
+
|
48
|
+
## Migrations
|
49
|
+
After adding a new migration, ru the following command:
|
50
|
+
```
|
51
|
+
rake uffizzi_core:install
|
52
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
6
|
+
load 'rails/tasks/engine.rake'
|
7
|
+
|
8
|
+
load 'rails/tasks/statistics.rake'
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'test'
|
16
|
+
t.pattern = 'test/**/*_test.rb'
|
17
|
+
t.verbose = false
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: :test
|
21
|
+
|
22
|
+
namespace :core do
|
23
|
+
desc 'Generate api docs'
|
24
|
+
task generate_docs: :environment do
|
25
|
+
SwaggerYard.register_custom_yard_tags!
|
26
|
+
|
27
|
+
spec = SwaggerYard::Swagger.new
|
28
|
+
|
29
|
+
File.open('swagger/v1/swagger.json', 'w') { |f| f << JSON.pretty_generate(spec.to_h) }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory ../stylesheets/uffizzi_core .css
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::AmazonRegistryClient
|
4
|
+
attr_accessor :client, :token, :registry_url
|
5
|
+
|
6
|
+
def initialize(region:, access_key_id:, secret_access_key:)
|
7
|
+
credentials = Aws::Credentials.new(access_key_id, secret_access_key)
|
8
|
+
@client = Aws::ECR::Client.new(region: region, credentials: credentials)
|
9
|
+
end
|
10
|
+
|
11
|
+
def authorization_token
|
12
|
+
client.get_authorization_token({})
|
13
|
+
end
|
14
|
+
|
15
|
+
def batch_get_image(image:, tag:)
|
16
|
+
client.batch_get_image({ image_ids: [{ image_tag: tag }], repository_name: image })
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::AzureRegistryClient
|
4
|
+
attr_accessor :connection, :token, :registry_url
|
5
|
+
|
6
|
+
def initialize(registry_url:, username:, password:)
|
7
|
+
@registry_url = registry_url
|
8
|
+
@connection = build_connection(registry_url, username, password)
|
9
|
+
@token = oauth2_token&.result&.access_token
|
10
|
+
end
|
11
|
+
|
12
|
+
def manifests(image:, tag:)
|
13
|
+
url = "/v2/#{image}/manifests/#{tag}"
|
14
|
+
response = connection.get(url)
|
15
|
+
|
16
|
+
RequestResult.quiet.new(result: response.body, headers: response.headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
def oauth2_token
|
20
|
+
service = URI.parse(registry_url).hostname
|
21
|
+
url = "/oauth2/token?service=#{service}"
|
22
|
+
|
23
|
+
response = connection.get(url, {})
|
24
|
+
|
25
|
+
RequestResult.new(result: response.body)
|
26
|
+
end
|
27
|
+
|
28
|
+
def authentificated?
|
29
|
+
token.present?
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_connection(registry_url, username, password)
|
35
|
+
Faraday.new(registry_url) do |conn|
|
36
|
+
conn.request(:basic_auth, username, password)
|
37
|
+
conn.request(:json)
|
38
|
+
conn.response(:json)
|
39
|
+
conn.adapter(Faraday.default_adapter)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::ControllerClient
|
4
|
+
attr_accessor :connection
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@connection = build_connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def apply_config_file(deployment_id:, config_file_id:, body:)
|
11
|
+
connection.post("/deployments/#{deployment_id}/config_files/#{config_file_id}", body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def deployment(deployment_id:)
|
15
|
+
get("/deployments/#{deployment_id}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_deployment(deployment_id:, body:)
|
19
|
+
connection.post("/deployments/#{deployment_id}", body)
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_deployment(deployment_id:, body:)
|
23
|
+
connection.put("/deployments/#{deployment_id}", body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_deployment(deployment_id:)
|
27
|
+
connection.delete("/deployments/#{deployment_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def deployment_containers(deployment_id:)
|
31
|
+
get("/deployments/#{deployment_id}/containers")
|
32
|
+
end
|
33
|
+
|
34
|
+
def deploy_containers(deployment_id:, body:)
|
35
|
+
connection.post("/deployments/#{deployment_id}/containers", body)
|
36
|
+
end
|
37
|
+
|
38
|
+
def deployment_containers_metrics(deployment_id:)
|
39
|
+
get("/deployments/#{deployment_id}/containers/metrics")
|
40
|
+
end
|
41
|
+
|
42
|
+
def deployment_container_logs(deployment_id:, container_name:, limit:)
|
43
|
+
get("/deployments/#{deployment_id}/containers/#{container_name}/logs?limit=#{limit}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def deployment_containers_events(deployment_id:)
|
47
|
+
events = get("/deployments/#{deployment_id}/containers/events").result.items
|
48
|
+
pods_events = events.select { |event| event.involved_object.kind == 'Pod' }
|
49
|
+
pods_events.map do |event|
|
50
|
+
{ first_timestamp: event.first_timestamp, last_timestamp: event.last_timestamp, reason: event.reason, message: event.message }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def nodes
|
55
|
+
get('/nodes')
|
56
|
+
end
|
57
|
+
|
58
|
+
def apply_credential(deployment_id:, body:)
|
59
|
+
connection.post("/deployments/#{deployment_id}/credentials", body)
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete_credential(deployment_id:, credential_id:)
|
63
|
+
connection.delete("/deployments/#{deployment_id}/credentials/#{credential_id}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_deployments_usage_metrics_containers(deployment_ids:, begin_at:, end_at:)
|
67
|
+
query_params = {
|
68
|
+
deployment_ids: deployment_ids,
|
69
|
+
begin_at: begin_at,
|
70
|
+
end_at: end_at,
|
71
|
+
}
|
72
|
+
get('/deployments/usage_metrics/containers', query_params)
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def get(url, params = {})
|
78
|
+
response = connection.get(url, params)
|
79
|
+
body = response.body
|
80
|
+
underscored_body = UffizziCore::Converters.deep_underscore_keys(body)
|
81
|
+
|
82
|
+
RequestResult.quiet.new(code: response.status, result: underscored_body)
|
83
|
+
end
|
84
|
+
|
85
|
+
def build_connection
|
86
|
+
controller = Settings.controller
|
87
|
+
login = controller.login
|
88
|
+
password = controller.password
|
89
|
+
url = controller.url
|
90
|
+
connection = controller.connection
|
91
|
+
handled_exceptions = Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
|
92
|
+
|
93
|
+
Faraday.new(url) do |conn|
|
94
|
+
conn.options.timeout = connection.timeout
|
95
|
+
conn.options.open_timeout = connection.open_timeout
|
96
|
+
conn.request(:basic_auth, login, password)
|
97
|
+
conn.request(:json)
|
98
|
+
conn.request(:retry,
|
99
|
+
max: connection.retires_count,
|
100
|
+
interval: connection.next_retry_timeout_seconds,
|
101
|
+
exceptions: handled_exceptions)
|
102
|
+
conn.response(:json)
|
103
|
+
conn.adapter(Faraday.default_adapter)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UffizziCore::DockerHubClient
|
4
|
+
attr_accessor :connection, :jwt, :credential
|
5
|
+
|
6
|
+
BASE_URL = 'https://hub.docker.com'
|
7
|
+
|
8
|
+
def initialize(credential = nil)
|
9
|
+
@connection = build_connection
|
10
|
+
@credential = credential
|
11
|
+
return unless credential
|
12
|
+
|
13
|
+
@jwt = authentificate
|
14
|
+
end
|
15
|
+
|
16
|
+
def authentificate
|
17
|
+
params = { username: credential.username, password: credential.password }
|
18
|
+
url = "#{BASE_URL}/v2/users/login/"
|
19
|
+
response = connection.post(url, params)
|
20
|
+
request_result = RequestResult.new(result: response.body)
|
21
|
+
request_result.result.token
|
22
|
+
rescue NoMethodError
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def public_images(q:, page: 1, per_page: 25)
|
27
|
+
url = "#{BASE_URL}/api/content/v1/products/search"
|
28
|
+
params = { page_size: per_page, q: q, type: :image, page: page }
|
29
|
+
response = connection.get(url, params) do |request|
|
30
|
+
request.headers['Search-Version'] = 'v3'
|
31
|
+
end
|
32
|
+
RequestResult.new(result: response.body)
|
33
|
+
end
|
34
|
+
|
35
|
+
def private_images(account:, page: 1, per_page: 25)
|
36
|
+
raise NotAuthorizedError if !authentificated? || account.empty?
|
37
|
+
|
38
|
+
url = BASE_URL + "/v2/repositories/#{account}/"
|
39
|
+
params = { page_size: per_page, page: page }
|
40
|
+
response = connection.get(url, params) do |request|
|
41
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
42
|
+
end
|
43
|
+
RequestResult.new(result: response.body)
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_webhooks(slug:, registry:)
|
47
|
+
url = BASE_URL + "/v2/repositories/#{slug}/webhook_pipeline/"
|
48
|
+
|
49
|
+
response = connection.get(url, { registry: registry, page_size: 100 }) do |request|
|
50
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
51
|
+
end
|
52
|
+
|
53
|
+
RequestResult.new(status: response.status, result: response.body)
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_webhook(slug:, name:, expect_final_callback:, webhooks:)
|
57
|
+
raise NotAuthorizedError if !authentificated?
|
58
|
+
|
59
|
+
url = BASE_URL + "/v2/repositories/#{slug}/webhook_pipeline/"
|
60
|
+
|
61
|
+
params = {
|
62
|
+
name: name,
|
63
|
+
expect_final_callback: expect_final_callback,
|
64
|
+
webhooks: webhooks,
|
65
|
+
}
|
66
|
+
|
67
|
+
response = connection.post(url, params) do |request|
|
68
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
69
|
+
end
|
70
|
+
|
71
|
+
RequestResult.new(status: response.status, result: response.body)
|
72
|
+
end
|
73
|
+
|
74
|
+
def accounts
|
75
|
+
raise NotAuthorizedError if !authentificated?
|
76
|
+
|
77
|
+
url = "#{BASE_URL}/v2/repositories/namespaces/"
|
78
|
+
response = connection.get(url) do |request|
|
79
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
80
|
+
end
|
81
|
+
RequestResult.new(result: response.body)
|
82
|
+
end
|
83
|
+
|
84
|
+
def metadata(namespace:, image:)
|
85
|
+
url = BASE_URL + "/v2/repositories/#{namespace}/#{image}/"
|
86
|
+
response = connection.get(url) do |request|
|
87
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
88
|
+
end
|
89
|
+
RequestResult.quiet.new(result: response.body)
|
90
|
+
end
|
91
|
+
|
92
|
+
def tags(namespace:, image:, q: '', page: 1, per_page: 10)
|
93
|
+
url = BASE_URL + "/v2/repositories/#{namespace}/#{image}/tags"
|
94
|
+
params = { page_size: per_page, page: page, name: q }
|
95
|
+
response = connection.get(url, params) do |request|
|
96
|
+
request.headers['Authorization'] = "JWT #{jwt}"
|
97
|
+
end
|
98
|
+
RequestResult.quiet.new(result: response.body)
|
99
|
+
end
|
100
|
+
|
101
|
+
def digest(image:, tag:, token:)
|
102
|
+
url = "https://index.docker.io/v2/#{image}/manifests/#{tag}"
|
103
|
+
response = connection.get(url) do |request|
|
104
|
+
request.headers['Accept'] = 'application/vnd.docker.distribution.manifest.v2+json'
|
105
|
+
request.headers['Authorization'] = "Bearer #{token}"
|
106
|
+
end
|
107
|
+
|
108
|
+
RequestResult.quiet.new(result: response.body, headers: response.headers)
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_token(repository)
|
112
|
+
params = { username: credential.username, password: credential.password }
|
113
|
+
url = "https://auth.docker.io/token?service=registry.docker.io&scope=repository:#{repository}:pull"
|
114
|
+
response = connection.get(url, params)
|
115
|
+
RequestResult.new(result: response.body)
|
116
|
+
end
|
117
|
+
|
118
|
+
def send_webhook_answer(url, params)
|
119
|
+
conn = Faraday.new do |c|
|
120
|
+
c.request(:json)
|
121
|
+
c.adapter(Faraday.default_adapter)
|
122
|
+
end
|
123
|
+
response = conn.post(url, params)
|
124
|
+
|
125
|
+
RequestResult.quiet.new(result: response.body)
|
126
|
+
end
|
127
|
+
|
128
|
+
def authentificated?
|
129
|
+
jwt.present?
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def build_connection
|
135
|
+
Faraday.new do |conn|
|
136
|
+
conn.request(:json)
|
137
|
+
conn.response(:json)
|
138
|
+
conn.adapter(Faraday.default_adapter)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|