From e952986b854690bf5fb1738fa7239bfa3782828e Mon Sep 17 00:00:00 2001 From: ajanikow Date: Wed, 23 Oct 2019 16:31:31 +0000 Subject: [PATCH] Change version to V1 --- Makefile | 10 +- .../templates/backup-policy.yaml | 9 +- chart/kube-arangodb-crd/templates/backup.yaml | 11 +- .../templates/deployment-replications.yaml | 9 +- .../templates/deployment.yaml | 9 +- go.mod | 2 +- pkg/apis/backup/definitions.go | 41 + pkg/apis/backup/v1/backup.go | 60 ++ pkg/apis/backup/v1/backup_policy.go | 81 ++ pkg/apis/backup/v1/backup_policy_spec.go | 41 + pkg/apis/backup/v1/backup_policy_status.go | 32 + pkg/apis/backup/v1/backup_policy_validate.go | 48 + pkg/apis/backup/v1/backup_spec.go | 58 + pkg/apis/backup/v1/backup_state.go | 108 ++ pkg/apis/backup/v1/backup_status.go | 97 ++ pkg/apis/backup/v1/backup_validate.go | 81 ++ pkg/apis/backup/v1/doc.go | 25 + pkg/apis/backup/v1/register.go | 59 ++ pkg/apis/backup/v1/zz_generated.deepcopy.go | 426 ++++++++ pkg/apis/backup/v1alpha/backup.go | 3 +- pkg/apis/backup/v1alpha/backup_policy.go | 2 +- pkg/apis/backup/v1alpha/register.go | 17 +- pkg/apis/deployment/definitions.go | 35 + pkg/apis/deployment/v1/authentication_spec.go | 93 ++ .../deployment/v1/authentication_spec_test.go | 105 ++ pkg/apis/deployment/v1/bootstrap.go | 136 +++ pkg/apis/deployment/v1/chaos_spec.go | 91 ++ pkg/apis/deployment/v1/conditions.go | 187 ++++ pkg/apis/deployment/v1/conditions_test.go | 99 ++ pkg/apis/deployment/v1/deployment.go | 93 ++ .../deployment/v1/deployment_backup_status.go | 50 + pkg/apis/deployment/v1/deployment_mode.go | 104 ++ .../deployment/v1/deployment_mode_test.go | 68 ++ pkg/apis/deployment/v1/deployment_phase.go | 42 + .../deployment/v1/deployment_phase_test.go | 35 + pkg/apis/deployment/v1/deployment_spec.go | 404 +++++++ .../deployment/v1/deployment_spec_test.go | 124 +++ pkg/apis/deployment/v1/deployment_status.go | 95 ++ .../v1/deployment_status_members.go | 265 +++++ pkg/apis/deployment/v1/doc.go | 25 + pkg/apis/deployment/v1/duration.go | 81 ++ pkg/apis/deployment/v1/environment.go | 77 ++ pkg/apis/deployment/v1/environment_test.go | 41 + pkg/apis/deployment/v1/errors.go | 53 + .../deployment/v1/external_access_spec.go | 122 +++ .../deployment/v1/external_access_type.go | 95 ++ pkg/apis/deployment/v1/image_info.go | 108 ++ pkg/apis/deployment/v1/image_info_test.go | 50 + pkg/apis/deployment/v1/license_spec.go | 59 ++ pkg/apis/deployment/v1/license_spec_test.go | 15 + pkg/apis/deployment/v1/member_phase.go | 57 + pkg/apis/deployment/v1/member_status.go | 131 +++ pkg/apis/deployment/v1/member_status_list.go | 206 ++++ .../deployment/v1/member_status_list_test.go | 91 ++ pkg/apis/deployment/v1/member_status_test.go | 74 ++ pkg/apis/deployment/v1/metrics_spec.go | 105 ++ pkg/apis/deployment/v1/monitoring_spec.go | 62 ++ .../deployment/v1/monitoring_spec_test.go | 56 + pkg/apis/deployment/v1/percent.go | 62 ++ pkg/apis/deployment/v1/plan.go | 136 +++ pkg/apis/deployment/v1/register.go | 56 + pkg/apis/deployment/v1/rocksdb_spec.go | 88 ++ pkg/apis/deployment/v1/rocksdb_spec_test.go | 97 ++ pkg/apis/deployment/v1/secret_hashes.go | 88 ++ pkg/apis/deployment/v1/secret_hashes_test.go | 164 +++ pkg/apis/deployment/v1/server_group.go | 142 +++ pkg/apis/deployment/v1/server_group_spec.go | 341 ++++++ .../deployment/v1/server_group_spec_test.go | 133 +++ pkg/apis/deployment/v1/server_group_test.go | 65 ++ pkg/apis/deployment/v1/storage_engine.go | 80 ++ pkg/apis/deployment/v1/storage_engine_test.go | 41 + .../deployment/v1/sync_authentication_spec.go | 87 ++ .../v1/sync_external_access_spec.go | 102 ++ pkg/apis/deployment/v1/sync_spec.go | 116 ++ pkg/apis/deployment/v1/sync_spec_test.go | 105 ++ pkg/apis/deployment/v1/tls_spec.go | 128 +++ pkg/apis/deployment/v1/tls_spec_test.go | 66 ++ .../deployment/v1/zz_generated.deepcopy.go | 996 ++++++++++++++++++ pkg/apis/deployment/v1alpha/deployment.go | 3 +- pkg/apis/deployment/v1alpha/register.go | 11 +- pkg/apis/replication/definitions.go | 34 + pkg/apis/replication/v1/collection_status.go | 32 + pkg/apis/replication/v1/conditions.go | 131 +++ pkg/apis/replication/v1/conditions_test.go | 95 ++ pkg/apis/replication/v1/database_status.go | 32 + pkg/apis/replication/v1/doc.go | 25 + .../v1/endpoint_authentication_spec.go | 89 ++ pkg/apis/replication/v1/endpoint_spec.go | 111 ++ pkg/apis/replication/v1/endpoint_status.go | 30 + pkg/apis/replication/v1/endpoint_tls_spec.go | 72 ++ pkg/apis/replication/v1/errors.go | 37 + pkg/apis/replication/v1/register.go | 57 + pkg/apis/replication/v1/replication.go | 64 ++ pkg/apis/replication/v1/replication_phase.go | 39 + pkg/apis/replication/v1/replication_spec.go | 68 ++ pkg/apis/replication/v1/replication_status.go | 44 + pkg/apis/replication/v1/shard_status.go | 28 + .../replication/v1/zz_generated.deepcopy.go | 331 ++++++ pkg/apis/replication/v1alpha/register.go | 10 +- pkg/apis/replication/v1alpha/replication.go | 3 +- .../handlers/arango/backup/arango_client.go | 6 +- .../arango/backup/arango_client_impl.go | 4 +- .../arango/backup/arango_client_mock_test.go | 6 +- .../arango/backup/backup_suite_test.go | 36 +- pkg/backup/handlers/arango/backup/errors.go | 10 +- .../handlers/arango/backup/finalizer.go | 6 +- .../handlers/arango/backup/finalizer_test.go | 2 +- .../handlers/arango/backup/flow_test.go | 2 +- pkg/backup/handlers/arango/backup/handler.go | 39 +- .../handlers/arango/backup/lifecycle.go | 6 +- pkg/backup/handlers/arango/backup/register.go | 18 +- pkg/backup/handlers/arango/backup/state.go | 2 +- .../handlers/arango/backup/state_create.go | 4 +- .../arango/backup/state_create_test.go | 2 +- .../handlers/arango/backup/state_deleted.go | 2 +- .../arango/backup/state_deleted_test.go | 2 +- .../handlers/arango/backup/state_download.go | 2 +- .../arango/backup/state_download_test.go | 4 +- .../arango/backup/state_downloaderror.go | 2 +- .../arango/backup/state_downloaderror_test.go | 2 +- .../arango/backup/state_downloading.go | 8 +- .../arango/backup/state_downloading_test.go | 4 +- .../handlers/arango/backup/state_failed.go | 2 +- .../arango/backup/state_failed_test.go | 2 +- .../handlers/arango/backup/state_none.go | 2 +- .../handlers/arango/backup/state_none_test.go | 2 +- .../handlers/arango/backup/state_pending.go | 4 +- .../arango/backup/state_pending_test.go | 6 +- .../handlers/arango/backup/state_ready.go | 4 +- .../arango/backup/state_ready_test.go | 6 +- .../handlers/arango/backup/state_scheduled.go | 2 +- .../arango/backup/state_scheduled_test.go | 2 +- .../arango/backup/state_unavailable.go | 2 +- .../arango/backup/state_unavailable_test.go | 2 +- .../handlers/arango/backup/state_upload.go | 2 +- .../arango/backup/state_upload_test.go | 2 +- .../arango/backup/state_uploaderror.go | 2 +- .../arango/backup/state_uploaderror_test.go | 2 +- .../handlers/arango/backup/state_uploading.go | 4 +- .../arango/backup/state_uploading_test.go | 2 +- pkg/backup/handlers/arango/backup/status.go | 10 +- pkg/backup/handlers/arango/backup/util.go | 4 +- pkg/backup/handlers/arango/policy/handler.go | 20 +- .../arango/policy/handler_scheduler_test.go | 4 +- .../arango/policy/handler_suite_test.go | 38 +- .../handlers/arango/policy/lifecycle.go | 6 +- pkg/backup/handlers/arango/policy/register.go | 18 +- pkg/deployment/backup/handler.go | 4 +- pkg/deployment/bootstrap.go | 2 +- pkg/deployment/chaos/context.go | 2 +- pkg/deployment/client_cache.go | 2 +- pkg/deployment/cluster_scaling_integration.go | 4 +- pkg/deployment/context_impl.go | 6 +- pkg/deployment/deployment.go | 12 +- pkg/deployment/deployment_finalizers.go | 6 +- pkg/deployment/deployment_inspector.go | 4 +- pkg/deployment/images.go | 2 +- pkg/deployment/members.go | 2 +- pkg/deployment/reconcile/action_add_member.go | 2 +- .../reconcile/action_cleanout_member.go | 2 +- pkg/deployment/reconcile/action_context.go | 2 +- .../reconcile/action_remove_member.go | 2 +- .../action_renew_tls_ca_certificate.go | 2 +- .../reconcile/action_renew_tls_certificate.go | 2 +- .../reconcile/action_rotate_member.go | 2 +- .../reconcile/action_shutdown_member.go | 2 +- .../reconcile/action_upgrade_current_image.go | 2 +- .../reconcile/action_upgrade_member.go | 2 +- .../reconcile/action_wait_for_member_up.go | 2 +- pkg/deployment/reconcile/context.go | 2 +- pkg/deployment/reconcile/plan_builder.go | 2 +- .../reconcile/plan_builder_context.go | 2 +- .../reconcile/plan_builder_storage.go | 2 +- pkg/deployment/reconcile/plan_builder_test.go | 2 +- pkg/deployment/reconcile/plan_builder_tls.go | 2 +- pkg/deployment/reconcile/plan_executor.go | 2 +- pkg/deployment/reconcile/reconciler.go | 2 +- pkg/deployment/resilience/context.go | 2 +- pkg/deployment/resilience/member_failure.go | 2 +- .../resources/certificates_client_auth.go | 2 +- pkg/deployment/resources/certificates_tls.go | 2 +- pkg/deployment/resources/context.go | 2 +- pkg/deployment/resources/deployment_health.go | 2 +- pkg/deployment/resources/member_cleanup.go | 2 +- pkg/deployment/resources/pdbs.go | 2 +- pkg/deployment/resources/pod_cleanup.go | 2 +- pkg/deployment/resources/pod_creator.go | 2 +- .../resources/pod_creator_agent_args_test.go | 2 +- .../pod_creator_coordinator_args_test.go | 2 +- .../pod_creator_dbserver_args_test.go | 2 +- .../resources/pod_creator_single_args_test.go | 2 +- pkg/deployment/resources/pod_finalizers.go | 2 +- pkg/deployment/resources/pod_inspector.go | 2 +- pkg/deployment/resources/pod_termination.go | 2 +- pkg/deployment/resources/pvc_finalizers.go | 2 +- pkg/deployment/resources/pvcs.go | 2 +- pkg/deployment/resources/secret_hashes.go | 2 +- pkg/deployment/resources/secrets.go | 2 +- pkg/deployment/resources/servicemonitor.go | 4 +- pkg/deployment/resources/services.go | 2 +- pkg/deployment/server_api.go | 2 +- pkg/deployment/server_member_api.go | 2 +- .../clientset/versioned/clientset.go | 42 + .../versioned/fake/clientset_generated.go | 21 + .../clientset/versioned/fake/register.go | 6 + .../clientset/versioned/scheme/register.go | 6 + .../versioned/typed/backup/v1/arangobackup.go | 195 ++++ .../typed/backup/v1/arangobackuppolicy.go | 195 ++++ .../typed/backup/v1/backup_client.go | 99 ++ .../versioned/typed/backup/v1/doc.go | 24 + .../versioned/typed/backup/v1/fake/doc.go | 24 + .../typed/backup/v1/fake/fake_arangobackup.go | 144 +++ .../backup/v1/fake/fake_arangobackuppolicy.go | 144 +++ .../backup/v1/fake/fake_backup_client.go | 48 + .../typed/backup/v1/generated_expansion.go | 27 + .../typed/deployment/v1/arangodeployment.go | 195 ++++ .../typed/deployment/v1/deployment_client.go | 94 ++ .../versioned/typed/deployment/v1/doc.go | 24 + .../versioned/typed/deployment/v1/fake/doc.go | 24 + .../v1/fake/fake_arangodeployment.go | 144 +++ .../v1/fake/fake_deployment_client.go | 44 + .../deployment/v1/generated_expansion.go | 25 + .../v1/arangodeploymentreplication.go | 195 ++++ .../versioned/typed/replication/v1/doc.go | 24 + .../typed/replication/v1/fake/doc.go | 24 + .../fake/fake_arangodeploymentreplication.go | 144 +++ .../v1/fake/fake_replication_client.go | 44 + .../replication/v1/generated_expansion.go | 25 + .../replication/v1/replication_client.go | 94 ++ .../externalversions/backup/interface.go | 8 + .../backup/v1/arangobackup.go | 93 ++ .../backup/v1/arangobackuppolicy.go | 93 ++ .../externalversions/backup/v1/interface.go | 56 + .../externalversions/deployment/interface.go | 8 + .../deployment/v1/arangodeployment.go | 93 ++ .../deployment/v1/interface.go | 49 + .../informers/externalversions/generic.go | 19 +- .../externalversions/replication/interface.go | 8 + .../v1/arangodeploymentreplication.go | 93 ++ .../replication/v1/interface.go | 49 + .../listers/backup/v1/arangobackup.go | 98 ++ .../listers/backup/v1/arangobackuppolicy.go | 98 ++ .../listers/backup/v1/expansion_generated.go | 39 + .../listers/deployment/v1/arangodeployment.go | 98 ++ .../deployment/v1/expansion_generated.go | 31 + .../v1/arangodeploymentreplication.go | 98 ++ .../replication/v1/expansion_generated.go | 31 + pkg/operator/crd.go | 12 +- pkg/operator/operator.go | 4 +- pkg/operator/operator_deployment.go | 7 +- .../operator_deployment_relication.go | 7 +- pkg/replication/deployment_replication.go | 10 +- pkg/replication/finalizers.go | 6 +- pkg/replication/server_api.go | 2 +- pkg/replication/server_endpoint_api.go | 2 +- pkg/replication/sync_client.go | 6 +- pkg/replication/sync_inspector.go | 2 +- pkg/server/handlers_deployment.go | 2 +- pkg/util/arangod/client.go | 2 +- pkg/util/k8sutil/test/events_test.go | 2 +- tests/auth_test.go | 14 +- tests/backup_test.go | 18 +- tests/change_args_test.go | 6 +- tests/cursor_test.go | 8 +- tests/deployments_test.go | 8 +- tests/environments_test.go | 4 +- tests/immutable_test.go | 4 +- tests/load_balancer_source_ranges_test.go | 4 +- tests/load_balancer_test.go | 4 +- tests/member_resilience_test.go | 20 +- tests/metrics_test.go | 4 +- tests/operator_upgrade_test.go | 4 +- tests/pc_test.go | 6 +- tests/pdb_test.go | 4 +- tests/persistent_volumes_test.go | 8 +- tests/predicates.go | 2 +- tests/resilience_test.go | 18 +- tests/resources_test.go | 4 +- tests/rocksdb_encryption_test.go | 4 +- tests/scale_test.go | 8 +- tests/secret_hashes_test.go | 6 +- tests/service_account_test.go | 10 +- tests/sidecar_test.go | 4 +- tests/simple_test.go | 10 +- tests/sync/main.go | 20 +- tests/sync_test.go | 12 +- tests/test_util.go | 22 +- tests/upgrade_test.go | 4 +- tests/version_test.go | 4 +- 289 files changed, 12681 insertions(+), 421 deletions(-) create mode 100644 pkg/apis/backup/definitions.go create mode 100644 pkg/apis/backup/v1/backup.go create mode 100644 pkg/apis/backup/v1/backup_policy.go create mode 100644 pkg/apis/backup/v1/backup_policy_spec.go create mode 100644 pkg/apis/backup/v1/backup_policy_status.go create mode 100644 pkg/apis/backup/v1/backup_policy_validate.go create mode 100644 pkg/apis/backup/v1/backup_spec.go create mode 100644 pkg/apis/backup/v1/backup_state.go create mode 100644 pkg/apis/backup/v1/backup_status.go create mode 100644 pkg/apis/backup/v1/backup_validate.go create mode 100644 pkg/apis/backup/v1/doc.go create mode 100644 pkg/apis/backup/v1/register.go create mode 100644 pkg/apis/backup/v1/zz_generated.deepcopy.go create mode 100644 pkg/apis/deployment/definitions.go create mode 100644 pkg/apis/deployment/v1/authentication_spec.go create mode 100644 pkg/apis/deployment/v1/authentication_spec_test.go create mode 100644 pkg/apis/deployment/v1/bootstrap.go create mode 100644 pkg/apis/deployment/v1/chaos_spec.go create mode 100644 pkg/apis/deployment/v1/conditions.go create mode 100644 pkg/apis/deployment/v1/conditions_test.go create mode 100644 pkg/apis/deployment/v1/deployment.go create mode 100644 pkg/apis/deployment/v1/deployment_backup_status.go create mode 100644 pkg/apis/deployment/v1/deployment_mode.go create mode 100644 pkg/apis/deployment/v1/deployment_mode_test.go create mode 100644 pkg/apis/deployment/v1/deployment_phase.go create mode 100644 pkg/apis/deployment/v1/deployment_phase_test.go create mode 100644 pkg/apis/deployment/v1/deployment_spec.go create mode 100644 pkg/apis/deployment/v1/deployment_spec_test.go create mode 100644 pkg/apis/deployment/v1/deployment_status.go create mode 100644 pkg/apis/deployment/v1/deployment_status_members.go create mode 100644 pkg/apis/deployment/v1/doc.go create mode 100644 pkg/apis/deployment/v1/duration.go create mode 100644 pkg/apis/deployment/v1/environment.go create mode 100644 pkg/apis/deployment/v1/environment_test.go create mode 100644 pkg/apis/deployment/v1/errors.go create mode 100644 pkg/apis/deployment/v1/external_access_spec.go create mode 100644 pkg/apis/deployment/v1/external_access_type.go create mode 100644 pkg/apis/deployment/v1/image_info.go create mode 100644 pkg/apis/deployment/v1/image_info_test.go create mode 100644 pkg/apis/deployment/v1/license_spec.go create mode 100644 pkg/apis/deployment/v1/license_spec_test.go create mode 100644 pkg/apis/deployment/v1/member_phase.go create mode 100644 pkg/apis/deployment/v1/member_status.go create mode 100644 pkg/apis/deployment/v1/member_status_list.go create mode 100644 pkg/apis/deployment/v1/member_status_list_test.go create mode 100644 pkg/apis/deployment/v1/member_status_test.go create mode 100644 pkg/apis/deployment/v1/metrics_spec.go create mode 100644 pkg/apis/deployment/v1/monitoring_spec.go create mode 100644 pkg/apis/deployment/v1/monitoring_spec_test.go create mode 100644 pkg/apis/deployment/v1/percent.go create mode 100644 pkg/apis/deployment/v1/plan.go create mode 100644 pkg/apis/deployment/v1/register.go create mode 100644 pkg/apis/deployment/v1/rocksdb_spec.go create mode 100644 pkg/apis/deployment/v1/rocksdb_spec_test.go create mode 100644 pkg/apis/deployment/v1/secret_hashes.go create mode 100644 pkg/apis/deployment/v1/secret_hashes_test.go create mode 100644 pkg/apis/deployment/v1/server_group.go create mode 100644 pkg/apis/deployment/v1/server_group_spec.go create mode 100644 pkg/apis/deployment/v1/server_group_spec_test.go create mode 100644 pkg/apis/deployment/v1/server_group_test.go create mode 100644 pkg/apis/deployment/v1/storage_engine.go create mode 100644 pkg/apis/deployment/v1/storage_engine_test.go create mode 100644 pkg/apis/deployment/v1/sync_authentication_spec.go create mode 100644 pkg/apis/deployment/v1/sync_external_access_spec.go create mode 100644 pkg/apis/deployment/v1/sync_spec.go create mode 100644 pkg/apis/deployment/v1/sync_spec_test.go create mode 100644 pkg/apis/deployment/v1/tls_spec.go create mode 100644 pkg/apis/deployment/v1/tls_spec_test.go create mode 100644 pkg/apis/deployment/v1/zz_generated.deepcopy.go create mode 100644 pkg/apis/replication/definitions.go create mode 100644 pkg/apis/replication/v1/collection_status.go create mode 100644 pkg/apis/replication/v1/conditions.go create mode 100644 pkg/apis/replication/v1/conditions_test.go create mode 100644 pkg/apis/replication/v1/database_status.go create mode 100644 pkg/apis/replication/v1/doc.go create mode 100644 pkg/apis/replication/v1/endpoint_authentication_spec.go create mode 100644 pkg/apis/replication/v1/endpoint_spec.go create mode 100644 pkg/apis/replication/v1/endpoint_status.go create mode 100644 pkg/apis/replication/v1/endpoint_tls_spec.go create mode 100644 pkg/apis/replication/v1/errors.go create mode 100644 pkg/apis/replication/v1/register.go create mode 100644 pkg/apis/replication/v1/replication.go create mode 100644 pkg/apis/replication/v1/replication_phase.go create mode 100644 pkg/apis/replication/v1/replication_spec.go create mode 100644 pkg/apis/replication/v1/replication_status.go create mode 100644 pkg/apis/replication/v1/shard_status.go create mode 100644 pkg/apis/replication/v1/zz_generated.deepcopy.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/arangobackup.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/arangobackuppolicy.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/backup_client.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackup.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackuppolicy.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_backup_client.go create mode 100644 pkg/generated/clientset/versioned/typed/backup/v1/generated_expansion.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/arangodeployment.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/deployment_client.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_arangodeployment.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_deployment_client.go create mode 100644 pkg/generated/clientset/versioned/typed/deployment/v1/generated_expansion.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/arangodeploymentreplication.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_arangodeploymentreplication.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_replication_client.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/generated_expansion.go create mode 100644 pkg/generated/clientset/versioned/typed/replication/v1/replication_client.go create mode 100644 pkg/generated/informers/externalversions/backup/v1/arangobackup.go create mode 100644 pkg/generated/informers/externalversions/backup/v1/arangobackuppolicy.go create mode 100644 pkg/generated/informers/externalversions/backup/v1/interface.go create mode 100644 pkg/generated/informers/externalversions/deployment/v1/arangodeployment.go create mode 100644 pkg/generated/informers/externalversions/deployment/v1/interface.go create mode 100644 pkg/generated/informers/externalversions/replication/v1/arangodeploymentreplication.go create mode 100644 pkg/generated/informers/externalversions/replication/v1/interface.go create mode 100644 pkg/generated/listers/backup/v1/arangobackup.go create mode 100644 pkg/generated/listers/backup/v1/arangobackuppolicy.go create mode 100644 pkg/generated/listers/backup/v1/expansion_generated.go create mode 100644 pkg/generated/listers/deployment/v1/arangodeployment.go create mode 100644 pkg/generated/listers/deployment/v1/expansion_generated.go create mode 100644 pkg/generated/listers/replication/v1/arangodeploymentreplication.go create mode 100644 pkg/generated/listers/replication/v1/expansion_generated.go diff --git a/Makefile b/Makefile index 2cde63e8d..7e7b66bd7 100644 --- a/Makefile +++ b/Makefile @@ -196,7 +196,7 @@ update-generated: "all" \ "github.com/arangodb/kube-arangodb/pkg/generated" \ "github.com/arangodb/kube-arangodb/pkg/apis" \ - "deployment:v1alpha replication:v1alpha storage:v1alpha backup:v1alpha" \ + "deployment:v1alpha deployment:v1 replication:v1alpha replication:v1 storage:v1alpha backup:v1alpha backup:v1" \ --go-header-file "./tools/codegen/boilerplate.go.txt" \ $(VERIFYARGS) @@ -316,10 +316,10 @@ manifests: helm manifests-crd manifests-operator manifests-test chart-crd chart- .PHONY: run-unit-tests run-unit-tests: $(SOURCES) go test $(TESTVERBOSEOPTIONS) \ - $(REPOPATH)/pkg/apis/backup/v1alpha \ - $(REPOPATH)/pkg/apis/deployment/v1alpha \ - $(REPOPATH)/pkg/apis/replication/v1alpha \ - $(REPOPATH)/pkg/apis/storage/v1alpha \ + $(REPOPATH)/pkg/apis/backup/... \ + $(REPOPATH)/pkg/apis/deployment/... \ + $(REPOPATH)/pkg/apis/replication/... \ + $(REPOPATH)/pkg/apis/storage/... \ $(REPOPATH)/pkg/deployment/... \ $(REPOPATH)/pkg/storage \ $(REPOPATH)/pkg/util/k8sutil \ diff --git a/chart/kube-arangodb-crd/templates/backup-policy.yaml b/chart/kube-arangodb-crd/templates/backup-policy.yaml index cd6cb559a..34b6a829d 100644 --- a/chart/kube-arangodb-crd/templates/backup-policy.yaml +++ b/chart/kube-arangodb-crd/templates/backup-policy.yaml @@ -33,6 +33,13 @@ spec: - arangobp singular: arangobackuppolicy scope: Namespaced - version: v1alpha subresources: status: {} + version: v1 + versions: + - name: v1 + served: true + storage: true + - name: v1alpha + served: true + storage: false diff --git a/chart/kube-arangodb-crd/templates/backup.yaml b/chart/kube-arangodb-crd/templates/backup.yaml index 2210da01d..904fd9519 100644 --- a/chart/kube-arangodb-crd/templates/backup.yaml +++ b/chart/kube-arangodb-crd/templates/backup.yaml @@ -53,6 +53,13 @@ spec: - arangobackup singular: arangobackup scope: Namespaced - version: v1alpha subresources: - status: {} \ No newline at end of file + status: {} + version: v1 + versions: + - name: v1 + served: true + storage: true + - name: v1alpha + served: true + storage: false \ No newline at end of file diff --git a/chart/kube-arangodb-crd/templates/deployment-replications.yaml b/chart/kube-arangodb-crd/templates/deployment-replications.yaml index 2e7120d84..597bc981a 100644 --- a/chart/kube-arangodb-crd/templates/deployment-replications.yaml +++ b/chart/kube-arangodb-crd/templates/deployment-replications.yaml @@ -18,4 +18,11 @@ spec: - arangorepl singular: arangodeploymentreplication scope: Namespaced - version: v1alpha \ No newline at end of file + version: v1 + versions: + - name: v1 + served: true + storage: true + - name: v1alpha + served: true + storage: false \ No newline at end of file diff --git a/chart/kube-arangodb-crd/templates/deployment.yaml b/chart/kube-arangodb-crd/templates/deployment.yaml index 53580172d..d9fe646d1 100644 --- a/chart/kube-arangodb-crd/templates/deployment.yaml +++ b/chart/kube-arangodb-crd/templates/deployment.yaml @@ -19,4 +19,11 @@ spec: - arango singular: arangodeployment scope: Namespaced - version: v1alpha \ No newline at end of file + version: v1 + versions: + - name: v1 + served: true + storage: true + - name: v1alpha + served: true + storage: false \ No newline at end of file diff --git a/go.mod b/go.mod index 41695ed25..3df06c872 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ replace ( k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d k8s.io/code-generator => ./deps/k8s.io/code-generator - ) require ( @@ -61,6 +60,7 @@ require ( github.com/jonboulle/clockwork v0.1.0 // indirect github.com/juju/errgo v0.0.0-20140925100237-08cceb5d0b53 // indirect github.com/julienschmidt/httprouter v1.2.0 + github.com/magiconair/properties v1.8.0 github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227 // indirect github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect github.com/mattn/go-colorable v0.1.1 // indirect diff --git a/pkg/apis/backup/definitions.go b/pkg/apis/backup/definitions.go new file mode 100644 index 000000000..452d1b08d --- /dev/null +++ b/pkg/apis/backup/definitions.go @@ -0,0 +1,41 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package backup + +const ( + ArangoBackupCRDName = ArangoBackupResourcePlural + "." + ArangoBackupGroupName + ArangoBackupResourceKind = "ArangoBackup" + ArangoBackupResourcePlural = "arangobackups" + + ArangoBackupPolicyCRDName = ArangoBackupPolicyResourcePlural + "." + ArangoBackupGroupName + ArangoBackupPolicyResourceKind = "ArangoBackupPolicy" + ArangoBackupPolicyResourcePlural = "arangobackuppolicies" + + ArangoBackupGroupName = "backup.arangodb.com" +) + +var ( + ArangoBackupShortNames = []string{"arangobackup"} + + ArangoBackupPolicyShortNames = []string{"arangobackuppolicy"} +) \ No newline at end of file diff --git a/pkg/apis/backup/v1/backup.go b/pkg/apis/backup/v1/backup.go new file mode 100644 index 000000000..9cdbf7a54 --- /dev/null +++ b/pkg/apis/backup/v1/backup.go @@ -0,0 +1,60 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + FinalizerArangoBackup = backup.ArangoBackupCRDName + "/cleanup" +) + +var ( + FinalizersArangoBackup = []string{ + FinalizerArangoBackup, + } +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoBackupList is a list of ArangoDB backups. +type ArangoBackupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []ArangoBackup `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoBackup contains definition and status of the ArangoDB Backup. +type ArangoBackup struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ArangoBackupSpec `json:"spec"` + Status ArangoBackupStatus `json:"status"` +} diff --git a/pkg/apis/backup/v1/backup_policy.go b/pkg/apis/backup/v1/backup_policy.go new file mode 100644 index 000000000..3980130c0 --- /dev/null +++ b/pkg/apis/backup/v1/backup_policy.go @@ -0,0 +1,81 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + "fmt" + + deployment "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + + "github.com/arangodb/kube-arangodb/pkg/backup/utils" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoBackupPolicyList is a list of ArangoDB backup policy. +type ArangoBackupPolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []ArangoBackupPolicy `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoBackupPolicy contains definition and status of the ArangoDB Backup Policy. +type ArangoBackupPolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ArangoBackupPolicySpec `json:"spec"` + Status ArangoBackupPolicyStatus `json:"status"` +} + +func (a *ArangoBackupPolicy) NewBackup(d *deployment.ArangoDeployment) *ArangoBackup { + policyName := a.Name + + spec := &ArangoBackupSpec{ + Deployment: ArangoBackupSpecDeployment{ + Name: d.Name, + }, + Upload: a.Spec.BackupTemplate.Upload.DeepCopy(), + Options: a.Spec.BackupTemplate.Options.DeepCopy(), + PolicyName: &policyName, + } + + return &ArangoBackup{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%s-%s", d.Name, utils.RandomString(8)), + Namespace: a.Namespace, + + Labels: d.Labels, + + Finalizers: []string{ + FinalizerArangoBackup, + }, + }, + Spec: *spec, + } +} diff --git a/pkg/apis/backup/v1/backup_policy_spec.go b/pkg/apis/backup/v1/backup_policy_spec.go new file mode 100644 index 000000000..02b2c1056 --- /dev/null +++ b/pkg/apis/backup/v1/backup_policy_spec.go @@ -0,0 +1,41 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type ArangoBackupPolicySpec struct { + Schedule string `json:"schedule"` + + DeploymentSelector *meta.LabelSelector `json:"selector,omitempty"` + + BackupTemplate ArangoBackupTemplate `json:"template"` +} + +type ArangoBackupTemplate struct { + Options *ArangoBackupSpecOptions `json:"options,omitempty"` + + Upload *ArangoBackupSpecOperation `json:"upload,omitempty"` +} diff --git a/pkg/apis/backup/v1/backup_policy_status.go b/pkg/apis/backup/v1/backup_policy_status.go new file mode 100644 index 000000000..b357fbf3f --- /dev/null +++ b/pkg/apis/backup/v1/backup_policy_status.go @@ -0,0 +1,32 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type ArangoBackupPolicyStatus struct { + Scheduled meta.Time `json:"scheduled,omitempty"` + Message string `json:"message,omitempty"` +} diff --git a/pkg/apis/backup/v1/backup_policy_validate.go b/pkg/apis/backup/v1/backup_policy_validate.go new file mode 100644 index 000000000..9daab720d --- /dev/null +++ b/pkg/apis/backup/v1/backup_policy_validate.go @@ -0,0 +1,48 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + "fmt" + "time" + + "github.com/robfig/cron" +) + +func (a *ArangoBackupPolicy) Validate() error { + if err := a.Spec.Validate(); err != nil { + return err + } + + return nil +} + +func (a *ArangoBackupPolicySpec) Validate() error { + if expr, err := cron.ParseStandard(a.Schedule); err != nil { + return fmt.Errorf("error while parsing expr: %s", err.Error()) + } else if expr.Next(time.Now()).IsZero() { + return fmt.Errorf("invalid schedule format") + } + + return nil +} diff --git a/pkg/apis/backup/v1/backup_spec.go b/pkg/apis/backup/v1/backup_spec.go new file mode 100644 index 000000000..91768954c --- /dev/null +++ b/pkg/apis/backup/v1/backup_spec.go @@ -0,0 +1,58 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +type ArangoBackupSpec struct { + // Deployment + Deployment ArangoBackupSpecDeployment `json:"deployment,omitempty"` + + Options *ArangoBackupSpecOptions `json:"options,omitempty"` + + // Download + Download *ArangoBackupSpecDownload `json:"download,omitempty"` + + // Upload + Upload *ArangoBackupSpecOperation `json:"upload,omitempty"` + + PolicyName *string `json:"policyName,omitempty"` +} + +type ArangoBackupSpecDeployment struct { + Name string `json:"name,omitempty"` +} + +type ArangoBackupSpecOptions struct { + Timeout *float32 `json:"timeout,omitempty"` + AllowInconsistent *bool `json:"allowInconsistent,omitempty"` +} + +type ArangoBackupSpecOperation struct { + RepositoryURL string `json:"repositoryURL"` + CredentialsSecretName string `json:"credentialsSecretName,omitempty"` +} + +type ArangoBackupSpecDownload struct { + ArangoBackupSpecOperation `json:",inline"` + + ID string `json:"id"` +} diff --git a/pkg/apis/backup/v1/backup_state.go b/pkg/apis/backup/v1/backup_state.go new file mode 100644 index 000000000..b0096c36f --- /dev/null +++ b/pkg/apis/backup/v1/backup_state.go @@ -0,0 +1,108 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/backup/state" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ArangoBackupStateNone state.State = "" + ArangoBackupStatePending state.State = "Pending" + ArangoBackupStateScheduled state.State = "Scheduled" + ArangoBackupStateDownload state.State = "Download" + ArangoBackupStateDownloadError state.State = "DownloadError" + ArangoBackupStateDownloading state.State = "Downloading" + ArangoBackupStateCreate state.State = "Create" + ArangoBackupStateUpload state.State = "Upload" + ArangoBackupStateUploading state.State = "Uploading" + ArangoBackupStateUploadError state.State = "UploadError" + ArangoBackupStateReady state.State = "Ready" + ArangoBackupStateDeleted state.State = "Deleted" + ArangoBackupStateFailed state.State = "Failed" + ArangoBackupStateUnavailable state.State = "Unavailable" +) + +var ArangoBackupStateMap = state.Map{ + ArangoBackupStateNone: {ArangoBackupStatePending}, + ArangoBackupStatePending: {ArangoBackupStateScheduled, ArangoBackupStateFailed}, + ArangoBackupStateScheduled: {ArangoBackupStateDownload, ArangoBackupStateCreate, ArangoBackupStateFailed}, + ArangoBackupStateDownload: {ArangoBackupStateDownloading, ArangoBackupStateFailed, ArangoBackupStateDownloadError}, + ArangoBackupStateDownloading: {ArangoBackupStateReady, ArangoBackupStateFailed, ArangoBackupStateDownloadError}, + ArangoBackupStateDownloadError: {ArangoBackupStatePending, ArangoBackupStateFailed}, + ArangoBackupStateCreate: {ArangoBackupStateReady, ArangoBackupStateFailed}, + ArangoBackupStateUpload: {ArangoBackupStateUploading, ArangoBackupStateFailed, ArangoBackupStateDeleted, ArangoBackupStateUploadError}, + ArangoBackupStateUploading: {ArangoBackupStateReady, ArangoBackupStateFailed, ArangoBackupStateUploadError}, + ArangoBackupStateUploadError: {ArangoBackupStateFailed, ArangoBackupStateReady}, + ArangoBackupStateReady: {ArangoBackupStateDeleted, ArangoBackupStateFailed, ArangoBackupStateUpload, ArangoBackupStateUnavailable}, + ArangoBackupStateDeleted: {ArangoBackupStateFailed, ArangoBackupStateReady}, + ArangoBackupStateFailed: {ArangoBackupStatePending}, + ArangoBackupStateUnavailable: {ArangoBackupStateReady, ArangoBackupStateDeleted, ArangoBackupStateFailed}, +} + +type ArangoBackupState struct { + // State holds the current high level state of the backup + State state.State `json:"state"` + + Time meta.Time `json:"time"` + + // Message for the state this object is in. + Message string `json:"message,omitempty"` + + // Progress for the operation + Progress *ArangoBackupProgress `json:"progress,omitempty"` +} + +func (a *ArangoBackupState) Equal(b *ArangoBackupState) bool { + if a == b { + return true + } + + if a == nil && b != nil || a != nil && b == nil { + return false + } + + return a.State == b.State && + a.Time.Equal(&b.Time) && + a.Message == b.Message && + a.Progress.Equal(b.Progress) +} + +type ArangoBackupProgress struct { + JobID string `json:"jobID"` + Progress string `json:"progress"` +} + +func (a *ArangoBackupProgress) Equal(b *ArangoBackupProgress) bool { + if a == b { + return true + } + + if a == nil && b != nil || a != nil && b == nil { + return false + } + + return a.JobID == b.JobID && + a.Progress == b.Progress +} diff --git a/pkg/apis/backup/v1/backup_status.go b/pkg/apis/backup/v1/backup_status.go new file mode 100644 index 000000000..7b2a68849 --- /dev/null +++ b/pkg/apis/backup/v1/backup_status.go @@ -0,0 +1,97 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ArangoBackupStatus contains the status part of +// an ArangoBackup. +type ArangoBackupStatus struct { + ArangoBackupState `json:",inline"` + Backup *ArangoBackupDetails `json:"backup,omitempty"` + Available bool `json:"available"` +} + +func (a *ArangoBackupStatus) Equal(b *ArangoBackupStatus) bool { + if a == b { + return true + } + + if a == nil && b != nil || a != nil && b == nil { + return false + } + + return a.ArangoBackupState.Equal(&b.ArangoBackupState) && + a.Backup.Equal(b.Backup) && + a.Available == b.Available +} + +type ArangoBackupDetails struct { + ID string `json:"id"` + Version string `json:"version"` + PotentiallyInconsistent *bool `json:"potentiallyInconsistent,omitempty"` + SizeInBytes uint64 `json:"sizeInBytes,omitempty"` + NumberOfDBServers uint `json:"numberOfDBServers,omitempty"` + Uploaded *bool `json:"uploaded,omitempty"` + Downloaded *bool `json:"downloaded,omitempty"` + Imported *bool `json:"imported,omitempty"` + CreationTimestamp meta.Time `json:"createdAt"` +} + +func (a *ArangoBackupDetails) Equal(b *ArangoBackupDetails) bool { + if a == b { + return true + } + + if a == nil && b != nil || a != nil && b == nil { + return false + } + + return a.ID == b.ID && + a.Version == b.Version && + a.SizeInBytes == b.SizeInBytes && + a.NumberOfDBServers == b.NumberOfDBServers && + a.CreationTimestamp.Equal(&b.CreationTimestamp) && + compareBoolPointer(a.PotentiallyInconsistent, b.PotentiallyInconsistent) && + compareBoolPointer(a.Uploaded, b.Uploaded) && + compareBoolPointer(a.Downloaded, b.Downloaded) && + compareBoolPointer(a.Imported, b.Imported) +} + +func compareBoolPointer(a, b * bool) bool { + if a == nil && b != nil || a != nil && b == nil { + return false + } + + if a == b { + return true + } + + if *a == *b { + return true + } + + return false +} \ No newline at end of file diff --git a/pkg/apis/backup/v1/backup_validate.go b/pkg/apis/backup/v1/backup_validate.go new file mode 100644 index 000000000..86d658408 --- /dev/null +++ b/pkg/apis/backup/v1/backup_validate.go @@ -0,0 +1,81 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import "fmt" + +func (a *ArangoBackup) Validate() error { + if err := a.Spec.Validate(); err != nil { + return err + } + + if err := a.Status.Validate(); err != nil { + return err + } + + return nil +} + +func (a *ArangoBackupSpec) Validate() error { + if a.Deployment.Name == "" { + return fmt.Errorf("deployment name can not be empty") + } + + if a.Download != nil { + if err := a.Download.Validate(); err != nil { + return err + } + } + + if a.Upload != nil { + if err := a.Upload.Validate(); err != nil { + return err + } + } + + return nil +} + +func (a *ArangoBackupSpecOperation) Validate() error { + if a.RepositoryURL == "" { + return fmt.Errorf("RepositoryURL can not be empty") + } + + return nil +} + +func (a *ArangoBackupSpecDownload) Validate() error { + if a.ID == "" { + return fmt.Errorf("ID can not be empty") + } + + return a.ArangoBackupSpecOperation.Validate() +} + +func (a *ArangoBackupStatus) Validate() error { + if err := ArangoBackupStateMap.Exists(a.ArangoBackupState.State); err != nil { + return err + } + + return nil +} diff --git a/pkg/apis/backup/v1/doc.go b/pkg/apis/backup/v1/doc.go new file mode 100644 index 000000000..6e9a96fe2 --- /dev/null +++ b/pkg/apis/backup/v1/doc.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +// +k8s:deepcopy-gen=package +// +groupName=backup.arangodb.com +package v1 diff --git a/pkg/apis/backup/v1/register.go b/pkg/apis/backup/v1/register.go new file mode 100644 index 000000000..5bdcfafb1 --- /dev/null +++ b/pkg/apis/backup/v1/register.go @@ -0,0 +1,59 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + ArangoBackupVersion = "v1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + + SchemeGroupVersion = schema.GroupVersion{Group: backup.ArangoBackupGroupName, Version: ArangoBackupVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion, + &ArangoBackup{}, + &ArangoBackupList{}, + &ArangoBackupPolicy{}, + &ArangoBackupPolicyList{}, + ) + metav1.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/backup/v1/zz_generated.deepcopy.go b/pkg/apis/backup/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..abde0a62c --- /dev/null +++ b/pkg/apis/backup/v1/zz_generated.deepcopy.go @@ -0,0 +1,426 @@ +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackup) DeepCopyInto(out *ArangoBackup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackup. +func (in *ArangoBackup) DeepCopy() *ArangoBackup { + if in == nil { + return nil + } + out := new(ArangoBackup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoBackup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupDetails) DeepCopyInto(out *ArangoBackupDetails) { + *out = *in + if in.PotentiallyInconsistent != nil { + in, out := &in.PotentiallyInconsistent, &out.PotentiallyInconsistent + *out = new(bool) + **out = **in + } + if in.Uploaded != nil { + in, out := &in.Uploaded, &out.Uploaded + *out = new(bool) + **out = **in + } + if in.Downloaded != nil { + in, out := &in.Downloaded, &out.Downloaded + *out = new(bool) + **out = **in + } + if in.Imported != nil { + in, out := &in.Imported, &out.Imported + *out = new(bool) + **out = **in + } + in.CreationTimestamp.DeepCopyInto(&out.CreationTimestamp) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupDetails. +func (in *ArangoBackupDetails) DeepCopy() *ArangoBackupDetails { + if in == nil { + return nil + } + out := new(ArangoBackupDetails) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupList) DeepCopyInto(out *ArangoBackupList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ArangoBackup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupList. +func (in *ArangoBackupList) DeepCopy() *ArangoBackupList { + if in == nil { + return nil + } + out := new(ArangoBackupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoBackupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupPolicy) DeepCopyInto(out *ArangoBackupPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupPolicy. +func (in *ArangoBackupPolicy) DeepCopy() *ArangoBackupPolicy { + if in == nil { + return nil + } + out := new(ArangoBackupPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoBackupPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupPolicyList) DeepCopyInto(out *ArangoBackupPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ArangoBackupPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupPolicyList. +func (in *ArangoBackupPolicyList) DeepCopy() *ArangoBackupPolicyList { + if in == nil { + return nil + } + out := new(ArangoBackupPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoBackupPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupPolicySpec) DeepCopyInto(out *ArangoBackupPolicySpec) { + *out = *in + if in.DeploymentSelector != nil { + in, out := &in.DeploymentSelector, &out.DeploymentSelector + *out = new(metav1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.BackupTemplate.DeepCopyInto(&out.BackupTemplate) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupPolicySpec. +func (in *ArangoBackupPolicySpec) DeepCopy() *ArangoBackupPolicySpec { + if in == nil { + return nil + } + out := new(ArangoBackupPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupPolicyStatus) DeepCopyInto(out *ArangoBackupPolicyStatus) { + *out = *in + in.Scheduled.DeepCopyInto(&out.Scheduled) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupPolicyStatus. +func (in *ArangoBackupPolicyStatus) DeepCopy() *ArangoBackupPolicyStatus { + if in == nil { + return nil + } + out := new(ArangoBackupPolicyStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupProgress) DeepCopyInto(out *ArangoBackupProgress) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupProgress. +func (in *ArangoBackupProgress) DeepCopy() *ArangoBackupProgress { + if in == nil { + return nil + } + out := new(ArangoBackupProgress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupSpec) DeepCopyInto(out *ArangoBackupSpec) { + *out = *in + out.Deployment = in.Deployment + if in.Options != nil { + in, out := &in.Options, &out.Options + *out = new(ArangoBackupSpecOptions) + (*in).DeepCopyInto(*out) + } + if in.Download != nil { + in, out := &in.Download, &out.Download + *out = new(ArangoBackupSpecDownload) + **out = **in + } + if in.Upload != nil { + in, out := &in.Upload, &out.Upload + *out = new(ArangoBackupSpecOperation) + **out = **in + } + if in.PolicyName != nil { + in, out := &in.PolicyName, &out.PolicyName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupSpec. +func (in *ArangoBackupSpec) DeepCopy() *ArangoBackupSpec { + if in == nil { + return nil + } + out := new(ArangoBackupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupSpecDeployment) DeepCopyInto(out *ArangoBackupSpecDeployment) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupSpecDeployment. +func (in *ArangoBackupSpecDeployment) DeepCopy() *ArangoBackupSpecDeployment { + if in == nil { + return nil + } + out := new(ArangoBackupSpecDeployment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupSpecDownload) DeepCopyInto(out *ArangoBackupSpecDownload) { + *out = *in + out.ArangoBackupSpecOperation = in.ArangoBackupSpecOperation + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupSpecDownload. +func (in *ArangoBackupSpecDownload) DeepCopy() *ArangoBackupSpecDownload { + if in == nil { + return nil + } + out := new(ArangoBackupSpecDownload) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupSpecOperation) DeepCopyInto(out *ArangoBackupSpecOperation) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupSpecOperation. +func (in *ArangoBackupSpecOperation) DeepCopy() *ArangoBackupSpecOperation { + if in == nil { + return nil + } + out := new(ArangoBackupSpecOperation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupSpecOptions) DeepCopyInto(out *ArangoBackupSpecOptions) { + *out = *in + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(float32) + **out = **in + } + if in.AllowInconsistent != nil { + in, out := &in.AllowInconsistent, &out.AllowInconsistent + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupSpecOptions. +func (in *ArangoBackupSpecOptions) DeepCopy() *ArangoBackupSpecOptions { + if in == nil { + return nil + } + out := new(ArangoBackupSpecOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupState) DeepCopyInto(out *ArangoBackupState) { + *out = *in + in.Time.DeepCopyInto(&out.Time) + if in.Progress != nil { + in, out := &in.Progress, &out.Progress + *out = new(ArangoBackupProgress) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupState. +func (in *ArangoBackupState) DeepCopy() *ArangoBackupState { + if in == nil { + return nil + } + out := new(ArangoBackupState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupStatus) DeepCopyInto(out *ArangoBackupStatus) { + *out = *in + in.ArangoBackupState.DeepCopyInto(&out.ArangoBackupState) + if in.Backup != nil { + in, out := &in.Backup, &out.Backup + *out = new(ArangoBackupDetails) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupStatus. +func (in *ArangoBackupStatus) DeepCopy() *ArangoBackupStatus { + if in == nil { + return nil + } + out := new(ArangoBackupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoBackupTemplate) DeepCopyInto(out *ArangoBackupTemplate) { + *out = *in + if in.Options != nil { + in, out := &in.Options, &out.Options + *out = new(ArangoBackupSpecOptions) + (*in).DeepCopyInto(*out) + } + if in.Upload != nil { + in, out := &in.Upload, &out.Upload + *out = new(ArangoBackupSpecOperation) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoBackupTemplate. +func (in *ArangoBackupTemplate) DeepCopy() *ArangoBackupTemplate { + if in == nil { + return nil + } + out := new(ArangoBackupTemplate) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/backup/v1alpha/backup.go b/pkg/apis/backup/v1alpha/backup.go index 06c9db2cd..5e5b411e9 100644 --- a/pkg/apis/backup/v1alpha/backup.go +++ b/pkg/apis/backup/v1alpha/backup.go @@ -23,11 +23,12 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( - FinalizerArangoBackup = ArangoBackupCRDName + "/cleanup" + FinalizerArangoBackup = backup.ArangoBackupCRDName + "/cleanup" ) var ( diff --git a/pkg/apis/backup/v1alpha/backup_policy.go b/pkg/apis/backup/v1alpha/backup_policy.go index 9329ad48c..27f747bcb 100644 --- a/pkg/apis/backup/v1alpha/backup_policy.go +++ b/pkg/apis/backup/v1alpha/backup_policy.go @@ -25,7 +25,7 @@ package v1alpha import ( "fmt" - deployment "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + deployment "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/backup/utils" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/backup/v1alpha/register.go b/pkg/apis/backup/v1alpha/register.go index a324d977e..22b975c78 100644 --- a/pkg/apis/backup/v1alpha/register.go +++ b/pkg/apis/backup/v1alpha/register.go @@ -23,32 +23,21 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) const ( - ArangoBackupCRDName = ArangoBackupResourcePlural + "." + groupName - ArangoBackupResourceKind = "ArangoBackup" - ArangoBackupResourcePlural = "arangobackups" - - ArangoBackupPolicyCRDName = ArangoBackupPolicyResourcePlural + "." + groupName - ArangoBackupPolicyResourceKind = "ArangoBackupPolicy" - ArangoBackupPolicyResourcePlural = "arangobackuppolicies" - - groupName = "backup.arangodb.com" + ArangoBackupVersion = "v1alpha" ) var ( SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) AddToScheme = SchemeBuilder.AddToScheme - SchemeGroupVersion = schema.GroupVersion{Group: groupName, Version: "v1alpha"} - - ArangoBackupShortNames = []string{"arangobackup"} - - ArangoBackupPolicyShortNames = []string{"arangobackuppolicy"} + SchemeGroupVersion = schema.GroupVersion{Group: backup.ArangoBackupGroupName, Version: ArangoBackupVersion} ) // Resource gets an ArangoCluster GroupResource for a specified resource diff --git a/pkg/apis/deployment/definitions.go b/pkg/apis/deployment/definitions.go new file mode 100644 index 000000000..55cc3a203 --- /dev/null +++ b/pkg/apis/deployment/definitions.go @@ -0,0 +1,35 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package deployment + +const ( + ArangoDeploymentCRDName = ArangoDeploymentResourcePlural + "." + ArangoDeploymentGroupName + ArangoDeploymentResourceKind = "ArangoDeployment" + ArangoDeploymentResourcePlural = "arangodeployments" + + ArangoDeploymentGroupName = "database.arangodb.com" +) + +var ( + ArangoDeploymentShortNames = []string{"arangodb", "arango"} +) \ No newline at end of file diff --git a/pkg/apis/deployment/v1/authentication_spec.go b/pkg/apis/deployment/v1/authentication_spec.go new file mode 100644 index 000000000..f07ddff3b --- /dev/null +++ b/pkg/apis/deployment/v1/authentication_spec.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// AuthenticationSpec holds authentication specific configuration settings +type AuthenticationSpec struct { + JWTSecretName *string `json:"jwtSecretName,omitempty"` +} + +const ( + // JWTSecretNameDisabled is the value of JWTSecretName to use for disabling authentication. + JWTSecretNameDisabled = "None" +) + +// GetJWTSecretName returns the value of jwtSecretName. +func (s AuthenticationSpec) GetJWTSecretName() string { + return util.StringOrDefault(s.JWTSecretName) +} + +// IsAuthenticated returns true if authentication is enabled. +// Returns false other (when JWTSecretName == "None"). +func (s AuthenticationSpec) IsAuthenticated() bool { + return s.GetJWTSecretName() != JWTSecretNameDisabled +} + +// Validate the given spec +func (s AuthenticationSpec) Validate(required bool) error { + if required && !s.IsAuthenticated() { + return maskAny(errors.Wrap(ValidationError, "JWT secret is required")) + } + if s.IsAuthenticated() { + if err := k8sutil.ValidateResourceName(s.GetJWTSecretName()); err != nil { + return maskAny(err) + } + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *AuthenticationSpec) SetDefaults(defaultJWTSecretName string) { + if s.GetJWTSecretName() == "" { + // Note that we don't check for nil here, since even a specified, but empty + // string should result in the default value. + s.JWTSecretName = util.NewString(defaultJWTSecretName) + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *AuthenticationSpec) SetDefaultsFrom(source AuthenticationSpec) { + if s.JWTSecretName == nil { + s.JWTSecretName = util.NewStringOrNil(source.JWTSecretName) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s AuthenticationSpec) ResetImmutableFields(fieldPrefix string, target *AuthenticationSpec) []string { + var resetFields []string + if s.IsAuthenticated() != target.IsAuthenticated() { + // Note: You can change the name, but not from empty to non-empty (or reverse). + target.JWTSecretName = util.NewStringOrNil(s.JWTSecretName) + resetFields = append(resetFields, fieldPrefix+".jwtSecretName") + } + return resetFields +} diff --git a/pkg/apis/deployment/v1/authentication_spec_test.go b/pkg/apis/deployment/v1/authentication_spec_test.go new file mode 100644 index 000000000..376533c5b --- /dev/null +++ b/pkg/apis/deployment/v1/authentication_spec_test.go @@ -0,0 +1,105 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestAuthenticationSpecValidate(t *testing.T) { + // Valid + assert.Nil(t, AuthenticationSpec{JWTSecretName: util.NewString("None")}.Validate(false)) + assert.Nil(t, AuthenticationSpec{JWTSecretName: util.NewString("foo")}.Validate(false)) + assert.Nil(t, AuthenticationSpec{JWTSecretName: util.NewString("foo")}.Validate(true)) + + // Not valid + assert.Error(t, AuthenticationSpec{JWTSecretName: util.NewString("Foo")}.Validate(false)) +} + +func TestAuthenticationSpecIsAuthenticated(t *testing.T) { + assert.False(t, AuthenticationSpec{JWTSecretName: util.NewString("None")}.IsAuthenticated()) + assert.True(t, AuthenticationSpec{JWTSecretName: util.NewString("foo")}.IsAuthenticated()) + assert.True(t, AuthenticationSpec{JWTSecretName: util.NewString("")}.IsAuthenticated()) +} + +func TestAuthenticationSpecSetDefaults(t *testing.T) { + def := func(spec AuthenticationSpec) AuthenticationSpec { + spec.SetDefaults("test-jwt") + return spec + } + + assert.Equal(t, "test-jwt", def(AuthenticationSpec{}).GetJWTSecretName()) + assert.Equal(t, "foo", def(AuthenticationSpec{JWTSecretName: util.NewString("foo")}).GetJWTSecretName()) +} + +func TestAuthenticationSpecResetImmutableFields(t *testing.T) { + tests := []struct { + Original AuthenticationSpec + Target AuthenticationSpec + Expected AuthenticationSpec + Result []string + }{ + // Valid "changes" + { + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + nil, + }, + { + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + nil, + }, + { + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo2")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo2")}, + nil, + }, + + // Invalid changes + { + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + []string{"test.jwtSecretName"}, + }, + { + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + AuthenticationSpec{JWTSecretName: util.NewString("foo")}, + AuthenticationSpec{JWTSecretName: util.NewString("None")}, + []string{"test.jwtSecretName"}, + }, + } + + for _, test := range tests { + result := test.Original.ResetImmutableFields("test", &test.Target) + assert.Equal(t, test.Result, result) + assert.Equal(t, test.Expected, test.Target) + } +} diff --git a/pkg/apis/deployment/v1/bootstrap.go b/pkg/apis/deployment/v1/bootstrap.go new file mode 100644 index 000000000..637f009c8 --- /dev/null +++ b/pkg/apis/deployment/v1/bootstrap.go @@ -0,0 +1,136 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1 + +import ( + "fmt" + + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +const ( + // UserNameRoot root user name + UserNameRoot = "root" +) + +// PasswordSecretName contains user password secret name +type PasswordSecretName string + +const ( + // PasswordSecretNameNone is magic value for no action + PasswordSecretNameNone PasswordSecretName = "None" + // PasswordSecretNameAuto is magic value for autogenerate name + PasswordSecretNameAuto PasswordSecretName = "Auto" +) + +// PasswordSecretNameList is a map from username to secretnames +type PasswordSecretNameList map[string]PasswordSecretName + +// BootstrapSpec contains information for cluster bootstrapping +type BootstrapSpec struct { + // PasswordSecretNames contains a map of username to password-secret-name + PasswordSecretNames PasswordSecretNameList `json:"passwordSecretNames,omitempty"` +} + +// IsNone returns true if p is None or p is empty +func (p PasswordSecretName) IsNone() bool { + return p == PasswordSecretNameNone || p == "" +} + +// IsAuto returns true if p is Auto +func (p PasswordSecretName) IsAuto() bool { + return p == PasswordSecretNameAuto +} + +// GetSecretName returns the secret name given by the specs. Or None if not set. +func (s PasswordSecretNameList) GetSecretName(user string) PasswordSecretName { + if s != nil { + if secretname, ok := s[user]; ok { + return secretname + } + } + return PasswordSecretNameNone +} + +// getSecretNameForUserPassword returns the default secret name for the given user +func getSecretNameForUserPassword(deploymentname, username string) PasswordSecretName { + return PasswordSecretName(k8sutil.FixupResourceName(deploymentname + "-" + username + "-password")) +} + +// Validate the specification. +func (b *BootstrapSpec) Validate() error { + for username, secretname := range b.PasswordSecretNames { + // Remove this restriction as soon as we can bootstrap databases + if username != UserNameRoot { + return fmt.Errorf("only username `root` allowed in passwordSecretNames") + } + + if secretname.IsNone() { + if username != UserNameRoot { + return fmt.Errorf("magic value None not allowed for %s", username) + } + } else { + if err := k8sutil.ValidateResourceName(string(secretname)); err != nil { + return maskAny(err) + } + } + } + + return nil +} + +// SetDefaults fills in default values when a field is not specified. +func (b *BootstrapSpec) SetDefaults(deploymentname string) { + if b.PasswordSecretNames == nil { + b.PasswordSecretNames = make(map[string]PasswordSecretName) + } + + // If root is not set init with Auto + if _, ok := b.PasswordSecretNames[UserNameRoot]; !ok { + b.PasswordSecretNames[UserNameRoot] = PasswordSecretNameNone + } + + // Replace Auto with generated secret name + for user, secretname := range b.PasswordSecretNames { + if secretname.IsAuto() { + b.PasswordSecretNames[user] = getSecretNameForUserPassword(deploymentname, user) + } + } +} + +// NewPasswordSecretNameListOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewPasswordSecretNameListOrNil(list PasswordSecretNameList) PasswordSecretNameList { + if list == nil { + return nil + } + var newList = make(PasswordSecretNameList) + for k, v := range list { + newList[k] = v + } + return newList +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (b *BootstrapSpec) SetDefaultsFrom(source BootstrapSpec) { + if b.PasswordSecretNames == nil { + b.PasswordSecretNames = NewPasswordSecretNameListOrNil(source.PasswordSecretNames) + } +} diff --git a/pkg/apis/deployment/v1/chaos_spec.go b/pkg/apis/deployment/v1/chaos_spec.go new file mode 100644 index 000000000..c86541dd9 --- /dev/null +++ b/pkg/apis/deployment/v1/chaos_spec.go @@ -0,0 +1,91 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + time "time" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/pkg/errors" +) + +// ChaosSpec holds configuration for the deployment chaos monkey. +type ChaosSpec struct { + // Enabled switches the chaos monkey for a deployment on or off. + Enabled *bool `json:"enabled,omitempty"` + // Interval is the time between events + Interval *time.Duration `json:"interval,omitempty"` + // KillPodProbability is the chance of a pod being killed during an event + KillPodProbability *Percent `json:"kill-pod-probability,omitempty"` +} + +// IsEnabled returns the value of enabled. +func (s ChaosSpec) IsEnabled() bool { + return util.BoolOrDefault(s.Enabled) +} + +// GetInterval returns the value of interval. +func (s ChaosSpec) GetInterval() time.Duration { + return util.DurationOrDefault(s.Interval) +} + +// GetKillPodProbability returns the value of kill-pod-probability. +func (s ChaosSpec) GetKillPodProbability() Percent { + return PercentOrDefault(s.KillPodProbability) +} + +// Validate the given spec +func (s ChaosSpec) Validate() error { + if s.IsEnabled() { + if s.GetInterval() <= 0 { + return maskAny(errors.Wrapf(ValidationError, "Interval must be > 0")) + } + if err := s.GetKillPodProbability().Validate(); err != nil { + return maskAny(err) + } + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *ChaosSpec) SetDefaults() { + if s.GetInterval() == 0 { + s.Interval = util.NewDuration(time.Minute) + } + if s.GetKillPodProbability() == 0 { + s.KillPodProbability = NewPercent(50) + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *ChaosSpec) SetDefaultsFrom(source ChaosSpec) { + if s.Enabled == nil { + s.Enabled = util.NewBoolOrNil(source.Enabled) + } + if s.Interval == nil { + s.Interval = util.NewDurationOrNil(source.Interval) + } + if s.KillPodProbability == nil { + s.KillPodProbability = NewPercentOrNil(source.KillPodProbability) + } +} diff --git a/pkg/apis/deployment/v1/conditions.go b/pkg/apis/deployment/v1/conditions.go new file mode 100644 index 000000000..e6b0c20e9 --- /dev/null +++ b/pkg/apis/deployment/v1/conditions.go @@ -0,0 +1,187 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ConditionType is a strongly typed condition name +type ConditionType string + +const ( + // ConditionTypeReady indicates that the member or entire deployment is ready and running normally. + ConditionTypeReady ConditionType = "Ready" + // ConditionTypeTerminated indicates that the member has terminated and will not restart. + ConditionTypeTerminated ConditionType = "Terminated" + // ConditionTypeAutoUpgrade indicates that the member has to be started with `--database.auto-upgrade` once. + ConditionTypeAutoUpgrade ConditionType = "AutoUpgrade" + // ConditionTypeCleanedOut indicates that the member (dbserver) has been cleaned out. + // Always check in combination with ConditionTypeTerminated. + ConditionTypeCleanedOut ConditionType = "CleanedOut" + // ConditionTypeAgentRecoveryNeeded indicates that the member (agent) will no + // longer recover from its current volume and there has to be rebuild + // using the recovery procedure. + ConditionTypeAgentRecoveryNeeded ConditionType = "AgentRecoveryNeeded" + // ConditionTypePodSchedulingFailure indicates that one or more pods belonging to the deployment cannot be schedule. + ConditionTypePodSchedulingFailure ConditionType = "PodSchedulingFailure" + // ConditionTypeSecretsChanged indicates that the value of one of more secrets used by + // the deployment have changed. Once that is the case, the operator will no longer + // touch the deployment, until the original secrets have been restored. + ConditionTypeSecretsChanged ConditionType = "SecretsChanged" + // ConditionTypeMemberOfCluster indicates that the member is a known member of the ArangoDB cluster. + ConditionTypeMemberOfCluster ConditionType = "MemberOfCluster" + // ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed. + ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted" + // ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully. + ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded" + // ConditionTypeTerminating indicates that the member is terminating but not yet terminated. + ConditionTypeTerminating ConditionType = "Terminating" +) + +// Condition represents one current condition of a deployment or deployment member. +// A condition might not show up if it is not happening. +// For example, if a cluster is not upgrading, the Upgrading condition would not show up. +type Condition struct { + // Type of condition. + Type ConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status v1.ConditionStatus `json:"status"` + // The last time this condition was updated. + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the condition transitioned from one status to another. + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // The reason for the condition's last transition. + Reason string `json:"reason,omitempty"` + // A human readable message indicating details about the transition. + Message string `json:"message,omitempty"` +} + +// ConditionList is a list of conditions. +// Each type is allowed only once. +type ConditionList []Condition + +// Equal checks for equality +func (list ConditionList) Equal(other ConditionList) bool { + if len(list) != len(other) { + return false + } + + for i := 0; i < len(list); i++ { + c, found := other.Get(list[i].Type) + if !found { + return false + } + + if !list[i].Equal(c) { + return false + } + } + + return true +} + +// Equal checks for equality +func (c Condition) Equal(other Condition) bool { + return c.Type == other.Type && + c.Status == other.Status && + util.TimeCompareEqual(c.LastUpdateTime, other.LastUpdateTime) && + util.TimeCompareEqual(c.LastTransitionTime, other.LastTransitionTime) && + c.Reason == other.Reason && + c.Message == other.Message +} + +// IsTrue return true when a condition with given type exists and its status is `True`. +func (list ConditionList) IsTrue(conditionType ConditionType) bool { + c, found := list.Get(conditionType) + return found && c.Status == v1.ConditionTrue +} + +// Get a condition by type. +// Returns true if found, false if not found. +func (list ConditionList) Get(conditionType ConditionType) (Condition, bool) { + for _, x := range list { + if x.Type == conditionType { + return x, true + } + } + // Not found + return Condition{}, false +} + +// Update the condition, replacing an old condition with same type (if any) +// Returns true when changes were made, false otherwise. +func (list *ConditionList) Update(conditionType ConditionType, status bool, reason, message string) bool { + src := *list + statusX := v1.ConditionFalse + if status { + statusX = v1.ConditionTrue + } + for i, x := range src { + if x.Type == conditionType { + if x.Status != statusX { + // Transition to another status + src[i].Status = statusX + now := metav1.Now() + src[i].LastTransitionTime = now + src[i].LastUpdateTime = now + src[i].Reason = reason + src[i].Message = message + } else if x.Reason != reason || x.Message != message { + src[i].LastUpdateTime = metav1.Now() + src[i].Reason = reason + src[i].Message = message + } else { + return false + } + return true + } + } + // Not found + now := metav1.Now() + *list = append(src, Condition{ + Type: conditionType, + LastUpdateTime: now, + LastTransitionTime: now, + Status: statusX, + Reason: reason, + Message: message, + }) + return true +} + +// Remove the condition with given type. +// Returns true if removed, or false if not found. +func (list *ConditionList) Remove(conditionType ConditionType) bool { + src := *list + for i, x := range src { + if x.Type == conditionType { + *list = append(src[:i], src[i+1:]...) + return true + } + } + // Not found + return false +} diff --git a/pkg/apis/deployment/v1/conditions_test.go b/pkg/apis/deployment/v1/conditions_test.go new file mode 100644 index 000000000..3e4dcabdd --- /dev/null +++ b/pkg/apis/deployment/v1/conditions_test.go @@ -0,0 +1,99 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestConditionListIsTrue(t *testing.T) { + assert.False(t, ConditionList{}.IsTrue(ConditionTypeReady)) + + cl := ConditionList{} + cl.Update(ConditionTypeReady, true, "test", "msg") + assert.True(t, cl.IsTrue(ConditionTypeReady)) + assert.False(t, cl.IsTrue(ConditionTypeTerminated)) + + cl.Update(ConditionTypeReady, false, "test", "msg") + assert.False(t, cl.IsTrue(ConditionTypeReady)) + + cl.Remove(ConditionTypeReady) + assert.False(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 0, len(cl)) +} + +func TestConditionListGet(t *testing.T) { + conv := func(c Condition, b bool) []interface{} { + return []interface{}{c, b} + } + + cl := ConditionList{} + assert.EqualValues(t, conv(Condition{}, false), conv(cl.Get(ConditionTypeReady))) + cl.Update(ConditionTypeReady, false, "test", "msg") + assert.EqualValues(t, conv(cl[0], true), conv(cl.Get(ConditionTypeReady))) +} + +func TestConditionListUpdate(t *testing.T) { + cl := ConditionList{} + assert.Equal(t, 0, len(cl)) + + assert.True(t, cl.Update(ConditionTypeReady, true, "test", "msg")) + assert.True(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.False(t, cl.Update(ConditionTypeReady, true, "test", "msg")) + assert.True(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeReady, false, "test", "msg")) + assert.False(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeReady, false, "test2", "msg")) + assert.False(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeReady, false, "test2", "msg2")) + assert.False(t, cl.IsTrue(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) +} + +func TestConditionListRemove(t *testing.T) { + cl := ConditionList{} + assert.Equal(t, 0, len(cl)) + + cl.Update(ConditionTypeReady, true, "test", "msg") + cl.Update(ConditionTypeTerminated, false, "test", "msg") + assert.Equal(t, 2, len(cl)) + + assert.True(t, cl.Remove(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.False(t, cl.Remove(ConditionTypeReady)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Remove(ConditionTypeTerminated)) + assert.Equal(t, 0, len(cl)) +} diff --git a/pkg/apis/deployment/v1/deployment.go b/pkg/apis/deployment/v1/deployment.go new file mode 100644 index 000000000..5be4092a5 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoDeploymentList is a list of ArangoDB clusters. +type ArangoDeploymentList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata + metav1.ListMeta `json:"metadata,omitempty"` + Items []ArangoDeployment `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoDeployment contains the entire Kubernetes info for an ArangoDB database deployment. +type ArangoDeployment struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec DeploymentSpec `json:"spec"` + Status DeploymentStatus `json:"status"` +} + +// AsOwner creates an OwnerReference for the given deployment +func (d *ArangoDeployment) AsOwner() metav1.OwnerReference { + trueVar := true + return metav1.OwnerReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: deployment.ArangoDeploymentResourceKind, + Name: d.Name, + UID: d.UID, + Controller: &trueVar, + // For now BlockOwnerDeletion does not work on OpenShift, so we leave it out. + //BlockOwnerDeletion: &trueVar, + } +} + +// ForeachServerGroup calls the given callback for all server groups. +// If the callback returns an error, this error is returned and no other server +// groups are processed. +// Groups are processed in this order: agents, single, dbservers, coordinators, syncmasters, syncworkers +func (d *ArangoDeployment) ForeachServerGroup(cb func(group ServerGroup, spec ServerGroupSpec, status *MemberStatusList) error, status *DeploymentStatus) error { + if status == nil { + status = &d.Status + } + if err := cb(ServerGroupAgents, d.Spec.Agents, &status.Members.Agents); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupSingle, d.Spec.Single, &status.Members.Single); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupDBServers, d.Spec.DBServers, &status.Members.DBServers); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupCoordinators, d.Spec.Coordinators, &status.Members.Coordinators); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupSyncMasters, d.Spec.SyncMasters, &status.Members.SyncMasters); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupSyncWorkers, d.Spec.SyncWorkers, &status.Members.SyncWorkers); err != nil { + return maskAny(err) + } + return nil +} diff --git a/pkg/apis/deployment/v1/deployment_backup_status.go b/pkg/apis/deployment/v1/deployment_backup_status.go new file mode 100644 index 000000000..9af2aefbc --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_backup_status.go @@ -0,0 +1,50 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Lars Maier +// +package v1 + +type DeploymentRestoreState string + +const ( + DeploymentRestoreStateRestoring DeploymentRestoreState = "Restoring" + DeploymentRestoreStateRestored DeploymentRestoreState = "Restored" + DeploymentRestoreStateRestoreFailed DeploymentRestoreState = "RestoreFailed" +) + +type DeploymentRestoreResult struct { + RequestedFrom string `json:"requestedFrom"` + State DeploymentRestoreState `json:"state"` + Message string `json:"message,omitempty"` +} + +func (dr *DeploymentRestoreResult) Equal(other *DeploymentRestoreResult) bool { + if dr == nil { + return other == nil + } + + if other == nil { + return false + } + + return dr.RequestedFrom == other.RequestedFrom && + dr.Message == other.Message && + dr.State == other.State +} diff --git a/pkg/apis/deployment/v1/deployment_mode.go b/pkg/apis/deployment/v1/deployment_mode.go new file mode 100644 index 000000000..8949b9391 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_mode.go @@ -0,0 +1,104 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" +) + +// DeploymentMode specifies the type of ArangoDB deployment to create. +type DeploymentMode string + +const ( + // DeploymentModeSingle yields a single server + DeploymentModeSingle DeploymentMode = "Single" + // DeploymentModeActiveFailover yields an agency and a active-failover server pair + DeploymentModeActiveFailover DeploymentMode = "ActiveFailover" + // DeploymentModeCluster yields an full cluster (agency, dbservers & coordinators) + DeploymentModeCluster DeploymentMode = "Cluster" +) + +// Validate the mode. +// Return errors when validation fails, nil on success. +func (m DeploymentMode) Validate() error { + switch m { + case DeploymentModeSingle, DeploymentModeActiveFailover, DeploymentModeCluster: + return nil + default: + return maskAny(errors.Wrapf(ValidationError, "Unknown deployment mode: '%s'", string(m))) + } +} + +// HasSingleServers returns true when the given mode is "Single" or "ActiveFailover". +func (m DeploymentMode) HasSingleServers() bool { + return m == DeploymentModeSingle || m == DeploymentModeActiveFailover +} + +// HasAgents returns true when the given mode is "ActiveFailover" or "Cluster". +func (m DeploymentMode) HasAgents() bool { + return m == DeploymentModeActiveFailover || m == DeploymentModeCluster +} + +// HasDBServers returns true when the given mode is "Cluster". +func (m DeploymentMode) HasDBServers() bool { + return m == DeploymentModeCluster +} + +// HasCoordinators returns true when the given mode is "Cluster". +func (m DeploymentMode) HasCoordinators() bool { + return m == DeploymentModeCluster +} + +// SupportsSync returns true when the given mode supports dc2dc replication. +func (m DeploymentMode) SupportsSync() bool { + return m == DeploymentModeCluster +} + +// IsCluster returns true if the deployment mode is cluster +func (m DeploymentMode) IsCluster() bool { + return m == DeploymentModeCluster +} + +// NewMode returns a reference to a string with given value. +func NewMode(input DeploymentMode) *DeploymentMode { + return &input +} + +// NewModeOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewModeOrNil(input *DeploymentMode) *DeploymentMode { + if input == nil { + return nil + } + return NewMode(*input) +} + +// ModeOrDefault returns the default value (or empty string) if input is nil, otherwise returns the referenced value. +func ModeOrDefault(input *DeploymentMode, defaultValue ...DeploymentMode) DeploymentMode { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + return *input +} diff --git a/pkg/apis/deployment/v1/deployment_mode_test.go b/pkg/apis/deployment/v1/deployment_mode_test.go new file mode 100644 index 000000000..46b556cf2 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_mode_test.go @@ -0,0 +1,68 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDeploymentModeValidate(t *testing.T) { + // Valid + assert.Nil(t, DeploymentMode("Single").Validate()) + assert.Nil(t, DeploymentMode("ActiveFailover").Validate()) + assert.Nil(t, DeploymentMode("Cluster").Validate()) + + // Not valid + assert.Error(t, DeploymentMode("").Validate()) + assert.Error(t, DeploymentMode(" cluster").Validate()) + assert.Error(t, DeploymentMode("singles").Validate()) + assert.Error(t, DeploymentMode("single").Validate()) + assert.Error(t, DeploymentMode("activefailover").Validate()) + assert.Error(t, DeploymentMode("cluster").Validate()) +} + +func TestDeploymentModeHasX(t *testing.T) { + assert.True(t, DeploymentModeSingle.HasSingleServers()) + assert.True(t, DeploymentModeActiveFailover.HasSingleServers()) + assert.False(t, DeploymentModeCluster.HasSingleServers()) + + assert.False(t, DeploymentModeSingle.HasAgents()) + assert.True(t, DeploymentModeActiveFailover.HasAgents()) + assert.True(t, DeploymentModeCluster.HasAgents()) + + assert.False(t, DeploymentModeSingle.HasDBServers()) + assert.False(t, DeploymentModeActiveFailover.HasDBServers()) + assert.True(t, DeploymentModeCluster.HasDBServers()) + + assert.False(t, DeploymentModeSingle.HasCoordinators()) + assert.False(t, DeploymentModeActiveFailover.HasCoordinators()) + assert.True(t, DeploymentModeCluster.HasCoordinators()) +} + +func TestDeploymentModeSupportsSync(t *testing.T) { + assert.False(t, DeploymentModeSingle.SupportsSync()) + assert.False(t, DeploymentModeActiveFailover.SupportsSync()) + assert.True(t, DeploymentModeCluster.SupportsSync()) +} diff --git a/pkg/apis/deployment/v1/deployment_phase.go b/pkg/apis/deployment/v1/deployment_phase.go new file mode 100644 index 000000000..e6301e342 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_phase.go @@ -0,0 +1,42 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// DeploymentPhase is a strongly typed lifetime phase of a deployment +type DeploymentPhase string + +const ( + // DeploymentPhaseNone indicates that the phase is not set yet + DeploymentPhaseNone DeploymentPhase = "" + // DeploymentPhaseRunning indicates that the deployment is under control of the + // ArangoDeployment operator. + DeploymentPhaseRunning DeploymentPhase = "Running" + // DeploymentPhaseFailed indicates that a deployment is in a failed state + // from which automatic recovery is impossible. Inspect `Reason` for more info. + DeploymentPhaseFailed DeploymentPhase = "Failed" +) + +// IsFailed returns true if given state is DeploymentStateFailed +func (cs DeploymentPhase) IsFailed() bool { + return cs == DeploymentPhaseFailed +} diff --git a/pkg/apis/deployment/v1/deployment_phase_test.go b/pkg/apis/deployment/v1/deployment_phase_test.go new file mode 100644 index 000000000..8bd49a8fd --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_phase_test.go @@ -0,0 +1,35 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDeploymentPhaseIsFailed(t *testing.T) { + assert.False(t, DeploymentPhaseNone.IsFailed()) + assert.True(t, DeploymentPhaseFailed.IsFailed()) + assert.False(t, DeploymentPhaseRunning.IsFailed()) +} diff --git a/pkg/apis/deployment/v1/deployment_spec.go b/pkg/apis/deployment/v1/deployment_spec.go new file mode 100644 index 000000000..701fc9726 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_spec.go @@ -0,0 +1,404 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "reflect" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" +) + +const ( + defaultImage = "arangodb/arangodb:latest" +) + +// validatePullPolicy the image pull policy. +// Return errors when validation fails, nil on success. +func validatePullPolicy(v v1.PullPolicy) error { + switch v { + case "", v1.PullAlways, v1.PullNever, v1.PullIfNotPresent: + return nil + default: + return maskAny(errors.Wrapf(ValidationError, "Unknown pull policy: '%s'", string(v))) + } +} + +// DeploymentSpec contains the spec part of a ArangoDeployment resource. +type DeploymentSpec struct { + Mode *DeploymentMode `json:"mode,omitempty"` + Environment *Environment `json:"environment,omitempty"` + StorageEngine *StorageEngine `json:"storageEngine,omitempty"` + Image *string `json:"image,omitempty"` + ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"` + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"` + DisableIPv6 *bool `json:"disableIPv6,omitempty"` + + NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"` + + RestoreFrom *string `json:"restoreFrom,omitempty"` + + ExternalAccess ExternalAccessSpec `json:"externalAccess"` + RocksDB RocksDBSpec `json:"rocksdb"` + Authentication AuthenticationSpec `json:"auth"` + TLS TLSSpec `json:"tls"` + Sync SyncSpec `json:"sync"` + License LicenseSpec `json:"license"` + Metrics MetricsSpec `json:"metrics"` + + Single ServerGroupSpec `json:"single"` + Agents ServerGroupSpec `json:"agents"` + DBServers ServerGroupSpec `json:"dbservers"` + Coordinators ServerGroupSpec `json:"coordinators"` + SyncMasters ServerGroupSpec `json:"syncmasters"` + SyncWorkers ServerGroupSpec `json:"syncworkers"` + + Chaos ChaosSpec `json:"chaos"` + + Bootstrap BootstrapSpec `json:"bootstrap,omitempty"` +} + +// GetRestoreFrom returns the restore from string or empty string if not set +func (s *DeploymentSpec) GetRestoreFrom() string { + return util.StringOrDefault(s.RestoreFrom) +} + +// HasRestoreFrom returns true if RestoreFrom is set +func (s *DeploymentSpec) HasRestoreFrom() bool { + return s.RestoreFrom != nil +} + +// Equal compares two DeploymentSpec +func (s *DeploymentSpec) Equal(other *DeploymentSpec) bool { + return reflect.DeepEqual(s, other) +} + +// GetMode returns the value of mode. +func (s DeploymentSpec) GetMode() DeploymentMode { + return ModeOrDefault(s.Mode) +} + +// GetEnvironment returns the value of environment. +func (s DeploymentSpec) GetEnvironment() Environment { + return EnvironmentOrDefault(s.Environment) +} + +// GetStorageEngine returns the value of storageEngine. +func (s DeploymentSpec) GetStorageEngine() StorageEngine { + return StorageEngineOrDefault(s.StorageEngine) +} + +// GetImage returns the value of image. +func (s DeploymentSpec) GetImage() string { + return util.StringOrDefault(s.Image) +} + +// GetSyncImage returns, if set, Sync.Image or the default image. +func (s DeploymentSpec) GetSyncImage() string { + if s.Sync.HasSyncImage() { + return s.Sync.GetSyncImage() + } + return s.GetImage() +} + +// GetImagePullPolicy returns the value of imagePullPolicy. +func (s DeploymentSpec) GetImagePullPolicy() v1.PullPolicy { + return util.PullPolicyOrDefault(s.ImagePullPolicy) +} + +// IsDowntimeAllowed returns the value of downtimeAllowed. +func (s DeploymentSpec) IsDowntimeAllowed() bool { + return util.BoolOrDefault(s.DowntimeAllowed) +} + +// IsDisableIPv6 returns the value of disableIPv6. +func (s DeploymentSpec) IsDisableIPv6() bool { + return util.BoolOrDefault(s.DisableIPv6) +} + +// IsNetworkAttachedVolumes returns the value of networkAttachedVolumes, default false +func (s DeploymentSpec) IsNetworkAttachedVolumes() bool { + return util.BoolOrDefault(s.NetworkAttachedVolumes, false) +} + +// GetListenAddr returns "[::]" or "0.0.0.0" depending on IsDisableIPv6 +func (s DeploymentSpec) GetListenAddr() string { + if s.IsDisableIPv6() { + return "0.0.0.0" + } + return "[::]" +} + +// IsAuthenticated returns true when authentication is enabled +func (s DeploymentSpec) IsAuthenticated() bool { + return s.Authentication.IsAuthenticated() +} + +// IsSecure returns true when SSL is enabled +func (s DeploymentSpec) IsSecure() bool { + return s.TLS.IsSecure() +} + +// GetServerGroupSpec returns the server group spec (from this +// deployment spec) for the given group. +func (s DeploymentSpec) GetServerGroupSpec(group ServerGroup) ServerGroupSpec { + switch group { + case ServerGroupSingle: + return s.Single + case ServerGroupAgents: + return s.Agents + case ServerGroupDBServers: + return s.DBServers + case ServerGroupCoordinators: + return s.Coordinators + case ServerGroupSyncMasters: + return s.SyncMasters + case ServerGroupSyncWorkers: + return s.SyncWorkers + default: + return ServerGroupSpec{} + } +} + +// UpdateServerGroupSpec returns the server group spec (from this +// deployment spec) for the given group. +func (s *DeploymentSpec) UpdateServerGroupSpec(group ServerGroup, gspec ServerGroupSpec) { + switch group { + case ServerGroupSingle: + s.Single = gspec + case ServerGroupAgents: + s.Agents = gspec + case ServerGroupDBServers: + s.DBServers = gspec + case ServerGroupCoordinators: + s.Coordinators = gspec + case ServerGroupSyncMasters: + s.SyncMasters = gspec + case ServerGroupSyncWorkers: + s.SyncWorkers = gspec + } +} + +// SetDefaults fills in default values when a field is not specified. +func (s *DeploymentSpec) SetDefaults(deploymentName string) { + if s.GetMode() == "" { + s.Mode = NewMode(DeploymentModeCluster) + } + if s.GetEnvironment() == "" { + s.Environment = NewEnvironment(EnvironmentDevelopment) + } + if s.GetStorageEngine() == "" { + s.StorageEngine = NewStorageEngine(StorageEngineRocksDB) + } + if s.GetImage() == "" && s.IsDevelopment() { + s.Image = util.NewString(defaultImage) + } + if s.GetImagePullPolicy() == "" { + s.ImagePullPolicy = util.NewPullPolicy(v1.PullIfNotPresent) + } + s.ExternalAccess.SetDefaults() + s.RocksDB.SetDefaults() + s.Authentication.SetDefaults(deploymentName + "-jwt") + s.TLS.SetDefaults(deploymentName + "-ca") + s.Sync.SetDefaults(deploymentName+"-sync-jwt", deploymentName+"-sync-client-auth-ca", deploymentName+"-sync-ca", deploymentName+"-sync-mt") + s.Single.SetDefaults(ServerGroupSingle, s.GetMode().HasSingleServers(), s.GetMode()) + s.Agents.SetDefaults(ServerGroupAgents, s.GetMode().HasAgents(), s.GetMode()) + s.DBServers.SetDefaults(ServerGroupDBServers, s.GetMode().HasDBServers(), s.GetMode()) + s.Coordinators.SetDefaults(ServerGroupCoordinators, s.GetMode().HasCoordinators(), s.GetMode()) + s.SyncMasters.SetDefaults(ServerGroupSyncMasters, s.Sync.IsEnabled(), s.GetMode()) + s.SyncWorkers.SetDefaults(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode()) + s.Metrics.SetDefaults(deploymentName+"-exporter-jwt-token", s.Authentication.IsAuthenticated()) + s.Chaos.SetDefaults() + s.Bootstrap.SetDefaults(deploymentName) +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) { + if s.Mode == nil { + s.Mode = NewModeOrNil(source.Mode) + } + if s.Environment == nil { + s.Environment = NewEnvironmentOrNil(source.Environment) + } + if s.StorageEngine == nil { + s.StorageEngine = NewStorageEngineOrNil(source.StorageEngine) + } + if s.Image == nil { + s.Image = util.NewStringOrNil(source.Image) + } + if s.ImagePullPolicy == nil { + s.ImagePullPolicy = util.NewPullPolicyOrNil(source.ImagePullPolicy) + } + if s.DowntimeAllowed == nil { + s.DowntimeAllowed = util.NewBoolOrNil(source.DowntimeAllowed) + } + if s.DisableIPv6 == nil { + s.DisableIPv6 = util.NewBoolOrNil(source.DisableIPv6) + } + s.License.SetDefaultsFrom(source.License) + s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess) + s.RocksDB.SetDefaultsFrom(source.RocksDB) + s.Authentication.SetDefaultsFrom(source.Authentication) + s.TLS.SetDefaultsFrom(source.TLS) + s.Sync.SetDefaultsFrom(source.Sync) + s.Single.SetDefaultsFrom(source.Single) + s.Agents.SetDefaultsFrom(source.Agents) + s.DBServers.SetDefaultsFrom(source.DBServers) + s.Coordinators.SetDefaultsFrom(source.Coordinators) + s.SyncMasters.SetDefaultsFrom(source.SyncMasters) + s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers) + s.Metrics.SetDefaultsFrom(source.Metrics) + s.Chaos.SetDefaultsFrom(source.Chaos) + s.Bootstrap.SetDefaultsFrom(source.Bootstrap) +} + +// Validate the specification. +// Return errors when validation fails, nil on success. +func (s *DeploymentSpec) Validate() error { + if err := s.GetMode().Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.mode")) + } + if err := s.GetEnvironment().Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.environment")) + } + if err := s.GetStorageEngine().Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.storageEngine")) + } + if err := validatePullPolicy(s.GetImagePullPolicy()); err != nil { + return maskAny(errors.Wrap(err, "spec.imagePullPolicy")) + } + if s.GetImage() == "" { + return maskAny(errors.Wrapf(ValidationError, "spec.image must be set")) + } + if err := s.ExternalAccess.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.externalAccess")) + } + if err := s.RocksDB.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.rocksdb")) + } + if err := s.Authentication.Validate(false); err != nil { + return maskAny(errors.Wrap(err, "spec.auth")) + } + if err := s.TLS.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.tls")) + } + if err := s.Sync.Validate(s.GetMode()); err != nil { + return maskAny(errors.Wrap(err, "spec.sync")) + } + if err := s.Single.Validate(ServerGroupSingle, s.GetMode().HasSingleServers(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.Agents.Validate(ServerGroupAgents, s.GetMode().HasAgents(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.DBServers.Validate(ServerGroupDBServers, s.GetMode().HasDBServers(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.Coordinators.Validate(ServerGroupCoordinators, s.GetMode().HasCoordinators(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.SyncMasters.Validate(ServerGroupSyncMasters, s.Sync.IsEnabled(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.SyncWorkers.Validate(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode(), s.GetEnvironment()); err != nil { + return maskAny(err) + } + if err := s.Metrics.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.metrics")) + } + if err := s.Chaos.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.chaos")) + } + if err := s.License.Validate(); err != nil { + return maskAny(errors.Wrap(err, "spec.licenseKey")) + } + if err := s.Bootstrap.Validate(); err != nil { + return maskAny(err) + } + return nil +} + +// IsDevelopment returns true when the spec contains a Development environment. +func (s DeploymentSpec) IsDevelopment() bool { + return s.GetEnvironment() == EnvironmentDevelopment +} + +// IsProduction returns true when the spec contains a Production environment. +func (s DeploymentSpec) IsProduction() bool { + return s.GetEnvironment() == EnvironmentProduction +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to `spec.`. +func (s DeploymentSpec) ResetImmutableFields(target *DeploymentSpec) []string { + var resetFields []string + if s.GetMode() != target.GetMode() { + target.Mode = NewModeOrNil(s.Mode) + resetFields = append(resetFields, "mode") + } + if s.GetStorageEngine() != target.GetStorageEngine() { + target.StorageEngine = NewStorageEngineOrNil(s.StorageEngine) + resetFields = append(resetFields, "storageEngine") + } + if s.IsDisableIPv6() != target.IsDisableIPv6() { + target.DisableIPv6 = util.NewBoolOrNil(s.DisableIPv6) + resetFields = append(resetFields, "disableIPv6") + } + if l := s.ExternalAccess.ResetImmutableFields("externalAccess", &target.ExternalAccess); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.RocksDB.ResetImmutableFields("rocksdb", &target.RocksDB); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Authentication.ResetImmutableFields("auth", &target.Authentication); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Sync.ResetImmutableFields("sync", &target.Sync); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Single.ResetImmutableFields(ServerGroupSingle, "single", &target.Single); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Agents.ResetImmutableFields(ServerGroupAgents, "agents", &target.Agents); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.DBServers.ResetImmutableFields(ServerGroupDBServers, "dbservers", &target.DBServers); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Coordinators.ResetImmutableFields(ServerGroupCoordinators, "coordinators", &target.Coordinators); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.SyncMasters.ResetImmutableFields(ServerGroupSyncMasters, "syncmasters", &target.SyncMasters); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.SyncWorkers.ResetImmutableFields(ServerGroupSyncWorkers, "syncworkers", &target.SyncWorkers); l != nil { + resetFields = append(resetFields, l...) + } + if l := s.Metrics.ResetImmutableFields("metrics", &target.Metrics); l != nil { + resetFields = append(resetFields, l...) + } + return resetFields +} diff --git a/pkg/apis/deployment/v1/deployment_spec_test.go b/pkg/apis/deployment/v1/deployment_spec_test.go new file mode 100644 index 000000000..025474f37 --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_spec_test.go @@ -0,0 +1,124 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" +) + +func TestDeploymentSpecValidate(t *testing.T) { + // TODO +} + +func TestDeploymentSpecSetDefaults(t *testing.T) { + def := func(spec DeploymentSpec) DeploymentSpec { + spec.SetDefaults("test") + return spec + } + + assert.Equal(t, "arangodb/arangodb:latest", def(DeploymentSpec{}).GetImage()) +} + +func TestDeploymentSpecResetImmutableFields(t *testing.T) { + tests := []struct { + Original DeploymentSpec + Target DeploymentSpec + Expected DeploymentSpec + ApplyDefaults bool + Result []string + }{ + // Valid "changes" + { + DeploymentSpec{Image: util.NewString("foo")}, + DeploymentSpec{Image: util.NewString("foo2")}, + DeploymentSpec{Image: util.NewString("foo2")}, + false, + nil, + }, + { + DeploymentSpec{Image: util.NewString("foo")}, + DeploymentSpec{Image: util.NewString("foo2")}, + DeploymentSpec{Image: util.NewString("foo2")}, + true, + nil, + }, + { + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullAlways)}, + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)}, + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)}, + false, + nil, + }, + { + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullAlways)}, + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)}, + DeploymentSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)}, + true, + nil, + }, + + // Invalid changes + { + DeploymentSpec{Mode: NewMode(DeploymentModeSingle)}, + DeploymentSpec{Mode: NewMode(DeploymentModeCluster)}, + DeploymentSpec{Mode: NewMode(DeploymentModeSingle)}, + false, + []string{"mode"}, + }, + { + DeploymentSpec{Mode: NewMode(DeploymentModeSingle)}, + DeploymentSpec{Mode: NewMode(DeploymentModeCluster)}, + DeploymentSpec{Mode: NewMode(DeploymentModeSingle)}, + true, + []string{"mode", "agents.count"}, + }, + { + DeploymentSpec{DisableIPv6: util.NewBool(false)}, + DeploymentSpec{DisableIPv6: util.NewBool(true)}, + DeploymentSpec{DisableIPv6: util.NewBool(false)}, + false, + []string{"disableIPv6"}, + }, + } + + for _, test := range tests { + if test.ApplyDefaults { + test.Original.SetDefaults("foo") + test.Expected.SetDefaults("foo") + test.Target.SetDefaultsFrom(test.Original) + test.Target.SetDefaults("foo") + } + result := test.Original.ResetImmutableFields(&test.Target) + if test.ApplyDefaults { + if len(result) > 0 { + test.Target.SetDefaults("foo") + } + } + assert.Equal(t, test.Result, result) + assert.Equal(t, test.Expected, test.Target) + } +} diff --git a/pkg/apis/deployment/v1/deployment_status.go b/pkg/apis/deployment/v1/deployment_status.go new file mode 100644 index 000000000..250c8ad3d --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_status.go @@ -0,0 +1,95 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" +) + +// DeploymentStatus contains the status part of a Cluster resource. +type DeploymentStatus struct { + // Phase holds the current lifetime phase of the deployment + Phase DeploymentPhase `json:"phase"` + // Reason contains a human readable reason for reaching the current state (can be empty) + Reason string `json:"reason,omitempty"` // Reason for current state + + // ServiceName holds the name of the Service a client can use (inside the k8s cluster) + // to access ArangoDB. + ServiceName string `json:"serviceName,omitempty"` + // SyncServiceName holds the name of the Service a client can use (inside the k8s cluster) + // to access syncmasters (only set when dc2dc synchronization is enabled). + SyncServiceName string `json:"syncServiceName,omitempty"` + + ExporterServiceName string `json:"exporterServiceName,omitempty"` + + ExporterServiceMonitorName string `json:"exporterServiceMonitorName,omitempty"` + + Restore *DeploymentRestoreResult `json:"restore,omitempty"` + + // Images holds a list of ArangoDB images with their ID and ArangoDB version. + Images ImageInfoList `json:"arangodb-images,omitempty"` + // Image that is currently being used when new pods are created + CurrentImage *ImageInfo `json:"current-image,omitempty"` + + // Members holds the status for all members in all server groups + Members DeploymentStatusMembers `json:"members"` + + // Conditions specific to the entire deployment + Conditions ConditionList `json:"conditions,omitempty"` + + // Plan to update this deployment + Plan Plan `json:"plan,omitempty"` + + // AcceptedSpec contains the last specification that was accepted by the operator. + AcceptedSpec *DeploymentSpec `json:"accepted-spec,omitempty"` + + // SecretHashes keeps a sha256 hash of secret values, so we can + // detect changes in secret values. + SecretHashes *SecretHashes `json:"secret-hashes,omitempty"` + + // ForceStatusReload if set to true forces a reload of the status from the custom resource. + ForceStatusReload *bool `json:"force-status-reload,omitempty"` +} + +// Equal checks for equality +func (ds *DeploymentStatus) Equal(other DeploymentStatus) bool { + return ds.Phase == other.Phase && + ds.Reason == other.Reason && + ds.ServiceName == other.ServiceName && + ds.SyncServiceName == other.SyncServiceName && + ds.ExporterServiceName == other.ExporterServiceName && + ds.ExporterServiceMonitorName == other.ExporterServiceMonitorName && + ds.Images.Equal(other.Images) && + ds.Restore.Equal(other.Restore) && + ds.CurrentImage.Equal(other.CurrentImage) && + ds.Members.Equal(other.Members) && + ds.Conditions.Equal(other.Conditions) && + ds.Plan.Equal(other.Plan) && + ds.AcceptedSpec.Equal(other.AcceptedSpec) && + ds.SecretHashes.Equal(other.SecretHashes) +} + +// IsForceReload returns true if ForceStatusReload is set to true +func (ds *DeploymentStatus) IsForceReload() bool { + return util.BoolOrDefault(ds.ForceStatusReload, false) +} diff --git a/pkg/apis/deployment/v1/deployment_status_members.go b/pkg/apis/deployment/v1/deployment_status_members.go new file mode 100644 index 000000000..8a8dd099b --- /dev/null +++ b/pkg/apis/deployment/v1/deployment_status_members.go @@ -0,0 +1,265 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" +) + +// DeploymentStatusMembers holds the member status of all server groups +type DeploymentStatusMembers struct { + Single MemberStatusList `json:"single,omitempty"` + Agents MemberStatusList `json:"agents,omitempty"` + DBServers MemberStatusList `json:"dbservers,omitempty"` + Coordinators MemberStatusList `json:"coordinators,omitempty"` + SyncMasters MemberStatusList `json:"syncmasters,omitempty"` + SyncWorkers MemberStatusList `json:"syncworkers,omitempty"` +} + +// Equal checks for equality +func (ds DeploymentStatusMembers) Equal(other DeploymentStatusMembers) bool { + return ds.Single.Equal(other.Single) && + ds.Agents.Equal(other.Agents) && + ds.DBServers.Equal(other.DBServers) && + ds.Coordinators.Equal(other.Coordinators) && + ds.SyncMasters.Equal(other.SyncMasters) && + ds.SyncWorkers.Equal(other.SyncWorkers) +} + +// ContainsID returns true if the given set of members contains a member with given ID. +func (ds DeploymentStatusMembers) ContainsID(id string) bool { + return ds.Single.ContainsID(id) || + ds.Agents.ContainsID(id) || + ds.DBServers.ContainsID(id) || + ds.Coordinators.ContainsID(id) || + ds.SyncMasters.ContainsID(id) || + ds.SyncWorkers.ContainsID(id) +} + +// ElementByID returns the element in the given list that has the given ID and true. +// If no such element exists, false is returned. +func (ds DeploymentStatusMembers) ElementByID(id string) (MemberStatus, ServerGroup, bool) { + if result, found := ds.Single.ElementByID(id); found { + return result, ServerGroupSingle, true + } + if result, found := ds.Agents.ElementByID(id); found { + return result, ServerGroupAgents, true + } + if result, found := ds.DBServers.ElementByID(id); found { + return result, ServerGroupDBServers, true + } + if result, found := ds.Coordinators.ElementByID(id); found { + return result, ServerGroupCoordinators, true + } + if result, found := ds.SyncMasters.ElementByID(id); found { + return result, ServerGroupSyncMasters, true + } + if result, found := ds.SyncWorkers.ElementByID(id); found { + return result, ServerGroupSyncWorkers, true + } + return MemberStatus{}, 0, false +} + +// ForeachServerGroup calls the given callback for all server groups. +// If the callback returns an error, this error is returned and the callback is +// not called for the remaining groups. +func (ds DeploymentStatusMembers) ForeachServerGroup(cb func(group ServerGroup, list MemberStatusList) error) error { + if err := cb(ServerGroupSingle, ds.Single); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupAgents, ds.Agents); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupDBServers, ds.DBServers); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupCoordinators, ds.Coordinators); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupSyncMasters, ds.SyncMasters); err != nil { + return maskAny(err) + } + if err := cb(ServerGroupSyncWorkers, ds.SyncWorkers); err != nil { + return maskAny(err) + } + return nil +} + +// MemberStatusByPodName returns a reference to the element in the given set of lists that has the given pod name. +// If no such element exists, nil is returned. +func (ds DeploymentStatusMembers) MemberStatusByPodName(podName string) (MemberStatus, ServerGroup, bool) { + if result, found := ds.Single.ElementByPodName(podName); found { + return result, ServerGroupSingle, true + } + if result, found := ds.Agents.ElementByPodName(podName); found { + return result, ServerGroupAgents, true + } + if result, found := ds.DBServers.ElementByPodName(podName); found { + return result, ServerGroupDBServers, true + } + if result, found := ds.Coordinators.ElementByPodName(podName); found { + return result, ServerGroupCoordinators, true + } + if result, found := ds.SyncMasters.ElementByPodName(podName); found { + return result, ServerGroupSyncMasters, true + } + if result, found := ds.SyncWorkers.ElementByPodName(podName); found { + return result, ServerGroupSyncWorkers, true + } + return MemberStatus{}, 0, false +} + +// MemberStatusByPVCName returns a reference to the element in the given set of lists that has the given PVC name. +// If no such element exists, nil is returned. +func (ds DeploymentStatusMembers) MemberStatusByPVCName(pvcName string) (MemberStatus, ServerGroup, bool) { + if result, found := ds.Single.ElementByPVCName(pvcName); found { + return result, ServerGroupSingle, true + } + if result, found := ds.Agents.ElementByPVCName(pvcName); found { + return result, ServerGroupAgents, true + } + if result, found := ds.DBServers.ElementByPVCName(pvcName); found { + return result, ServerGroupDBServers, true + } + // Note: Other server groups do not have PVC's so we can skip them. + return MemberStatus{}, 0, false +} + +// Add adds the given status in the given group. +func (ds *DeploymentStatusMembers) Add(status MemberStatus, group ServerGroup) error { + var err error + switch group { + case ServerGroupSingle: + err = ds.Single.add(status) + case ServerGroupAgents: + err = ds.Agents.add(status) + case ServerGroupDBServers: + err = ds.DBServers.add(status) + case ServerGroupCoordinators: + err = ds.Coordinators.add(status) + case ServerGroupSyncMasters: + err = ds.SyncMasters.add(status) + case ServerGroupSyncWorkers: + err = ds.SyncWorkers.add(status) + default: + return maskAny(errors.Wrapf(NotFoundError, "ServerGroup %d is not known", group)) + } + if err != nil { + return maskAny(err) + } + return nil +} + +// Update updates the given status in the given group. +func (ds *DeploymentStatusMembers) Update(status MemberStatus, group ServerGroup) error { + var err error + switch group { + case ServerGroupSingle: + err = ds.Single.update(status) + case ServerGroupAgents: + err = ds.Agents.update(status) + case ServerGroupDBServers: + err = ds.DBServers.update(status) + case ServerGroupCoordinators: + err = ds.Coordinators.update(status) + case ServerGroupSyncMasters: + err = ds.SyncMasters.update(status) + case ServerGroupSyncWorkers: + err = ds.SyncWorkers.update(status) + default: + return maskAny(errors.Wrapf(NotFoundError, "ServerGroup %d is not known", group)) + } + if err != nil { + return maskAny(err) + } + return nil +} + +// RemoveByID a member with given ID from the given group. +// Returns a NotFoundError if the ID of the given member or group cannot be found. +func (ds *DeploymentStatusMembers) RemoveByID(id string, group ServerGroup) error { + var err error + switch group { + case ServerGroupSingle: + err = ds.Single.removeByID(id) + case ServerGroupAgents: + err = ds.Agents.removeByID(id) + case ServerGroupDBServers: + err = ds.DBServers.removeByID(id) + case ServerGroupCoordinators: + err = ds.Coordinators.removeByID(id) + case ServerGroupSyncMasters: + err = ds.SyncMasters.removeByID(id) + case ServerGroupSyncWorkers: + err = ds.SyncWorkers.removeByID(id) + default: + return maskAny(errors.Wrapf(NotFoundError, "ServerGroup %d is not known", group)) + } + if err != nil { + return maskAny(err) + } + return nil +} + +// AllMembersReady returns true when all members, that must be ready for the given mode, are in the Ready state. +func (ds DeploymentStatusMembers) AllMembersReady(mode DeploymentMode, syncEnabled bool) bool { + syncReady := func() bool { + if syncEnabled { + return ds.SyncMasters.AllMembersReady() && ds.SyncWorkers.AllMembersReady() + } + return true + } + switch mode { + case DeploymentModeSingle: + return ds.Single.MembersReady() > 0 + case DeploymentModeActiveFailover: + return ds.Agents.AllMembersReady() && ds.Single.MembersReady() > 0 + case DeploymentModeCluster: + return ds.Agents.AllMembersReady() && + ds.DBServers.AllMembersReady() && + ds.Coordinators.AllMembersReady() && + syncReady() + default: + return false + } +} + +// MembersOfGroup returns the member list of the given group +func (ds DeploymentStatusMembers) MembersOfGroup(group ServerGroup) MemberStatusList { + switch group { + case ServerGroupSingle: + return ds.Single + case ServerGroupAgents: + return ds.Agents + case ServerGroupDBServers: + return ds.DBServers + case ServerGroupCoordinators: + return ds.Coordinators + case ServerGroupSyncMasters: + return ds.SyncMasters + case ServerGroupSyncWorkers: + return ds.SyncWorkers + default: + return MemberStatusList{} + } +} diff --git a/pkg/apis/deployment/v1/doc.go b/pkg/apis/deployment/v1/doc.go new file mode 100644 index 000000000..80ddbb639 --- /dev/null +++ b/pkg/apis/deployment/v1/doc.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +// +k8s:deepcopy-gen=package +// +groupName=database.arangodb.com +package v1 diff --git a/pkg/apis/deployment/v1/duration.go b/pkg/apis/deployment/v1/duration.go new file mode 100644 index 000000000..929ca977c --- /dev/null +++ b/pkg/apis/deployment/v1/duration.go @@ -0,0 +1,81 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "time" + + "github.com/pkg/errors" +) + +// Duration is a period of time, specified in go time.Duration format. +// This is intended to allow human friendly TTL's to be specified. +type Duration string + +// Validate the duration. +// Return errors when validation fails, nil on success. +func (d Duration) Validate() error { + if d != "" { + if _, err := time.ParseDuration(string(d)); err != nil { + return maskAny(errors.Wrapf(ValidationError, "Invalid duration: '%s': %s", string(d), err.Error())) + } + } + return nil +} + +// AsDuration parses the duration to a time.Duration value. +// In case of a parse error, 0 is returned. +func (d Duration) AsDuration() time.Duration { + if d == "" { + return 0 + } + result, err := time.ParseDuration(string(d)) + if err != nil { + return 0 + } + return result +} + +// NewDuration returns a reference to a Duration with given value. +func NewDuration(input Duration) *Duration { + return &input +} + +// NewDurationOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewDurationOrNil(input *Duration) *Duration { + if input == nil { + return nil + } + return NewDuration(*input) +} + +// DurationOrDefault returns the default value (or empty string) if input is nil, otherwise returns the referenced value. +func DurationOrDefault(input *Duration, defaultValue ...Duration) Duration { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + return *input +} diff --git a/pkg/apis/deployment/v1/environment.go b/pkg/apis/deployment/v1/environment.go new file mode 100644 index 000000000..b508c0710 --- /dev/null +++ b/pkg/apis/deployment/v1/environment.go @@ -0,0 +1,77 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" +) + +// Environment in which to run the cluster +type Environment string + +const ( + // EnvironmentDevelopment yields a cluster optimized for development + EnvironmentDevelopment Environment = "Development" + // EnvironmentProduction yields a cluster optimized for production + EnvironmentProduction Environment = "Production" +) + +// Validate the environment. +// Return errors when validation fails, nil on success. +func (e Environment) Validate() error { + switch e { + case EnvironmentDevelopment, EnvironmentProduction: + return nil + default: + return maskAny(errors.Wrapf(ValidationError, "Unknown environment: '%s'", string(e))) + } +} + +// IsProduction returns true when the given environment is a production environment. +func (e Environment) IsProduction() bool { + return e == EnvironmentProduction +} + +// NewEnvironment returns a reference to a string with given value. +func NewEnvironment(input Environment) *Environment { + return &input +} + +// NewEnvironmentOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewEnvironmentOrNil(input *Environment) *Environment { + if input == nil { + return nil + } + return NewEnvironment(*input) +} + +// EnvironmentOrDefault returns the default value (or empty string) if input is nil, otherwise returns the referenced value. +func EnvironmentOrDefault(input *Environment, defaultValue ...Environment) Environment { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + return *input +} diff --git a/pkg/apis/deployment/v1/environment_test.go b/pkg/apis/deployment/v1/environment_test.go new file mode 100644 index 000000000..92cfd49bc --- /dev/null +++ b/pkg/apis/deployment/v1/environment_test.go @@ -0,0 +1,41 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestEnvironmentValidate(t *testing.T) { + // Valid + assert.Nil(t, Environment("Development").Validate()) + assert.Nil(t, Environment("Production").Validate()) + + // Not valid + assert.Error(t, Environment("").Validate()) + assert.Error(t, Environment(" development").Validate()) + assert.Error(t, Environment("development").Validate()) + assert.Error(t, Environment("production").Validate()) +} diff --git a/pkg/apis/deployment/v1/errors.go b/pkg/apis/deployment/v1/errors.go new file mode 100644 index 000000000..ca292cf1a --- /dev/null +++ b/pkg/apis/deployment/v1/errors.go @@ -0,0 +1,53 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import "github.com/pkg/errors" + +var ( + // ValidationError indicates a validation failure + ValidationError = errors.New("validation failed") + + // AlreadyExistsError indicates an object that already exists + AlreadyExistsError = errors.New("already exists") + + // NotFoundError indicates an object that cannot be found + NotFoundError = errors.New("not found") + + maskAny = errors.WithStack +) + +// IsValidation return true when the given error is or is caused by a ValidationError. +func IsValidation(err error) bool { + return errors.Cause(err) == ValidationError +} + +// IsAlreadyExists return true when the given error is or is caused by a AlreadyExistsError. +func IsAlreadyExists(err error) bool { + return errors.Cause(err) == AlreadyExistsError +} + +// IsNotFound return true when the given error is or is caused by a NotFoundError. +func IsNotFound(err error) bool { + return errors.Cause(err) == NotFoundError +} diff --git a/pkg/apis/deployment/v1/external_access_spec.go b/pkg/apis/deployment/v1/external_access_spec.go new file mode 100644 index 000000000..08655e6cb --- /dev/null +++ b/pkg/apis/deployment/v1/external_access_spec.go @@ -0,0 +1,122 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "fmt" + "net" + "net/url" + + "github.com/arangodb/kube-arangodb/pkg/util" +) + +// ExternalAccessSpec holds configuration for the external access provided for the deployment. +type ExternalAccessSpec struct { + // Type of external access + Type *ExternalAccessType `json:"type,omitempty"` + // Optional port used in case of Auto or NodePort type. + NodePort *int `json:"nodePort,omitempty"` + // Optional IP used to configure a load-balancer on, in case of Auto or LoadBalancer type. + LoadBalancerIP *string `json:"loadBalancerIP,omitempty"` + // If specified and supported by the platform, this will restrict traffic through the cloud-provider + // load-balancer will be restricted to the specified client IPs. This field will be ignored if the + // cloud-provider does not support the feature. + // More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/ + LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"` + // Advertised Endpoint is passed to the coordinators/single servers for advertising a specific endpoint + AdvertisedEndpoint *string `json:"advertisedEndpoint,omitempty"` +} + +// GetType returns the value of type. +func (s ExternalAccessSpec) GetType() ExternalAccessType { + return ExternalAccessTypeOrDefault(s.Type, ExternalAccessTypeAuto) +} + +// GetNodePort returns the value of nodePort. +func (s ExternalAccessSpec) GetNodePort() int { + return util.IntOrDefault(s.NodePort) +} + +// GetLoadBalancerIP returns the value of loadBalancerIP. +func (s ExternalAccessSpec) GetLoadBalancerIP() string { + return util.StringOrDefault(s.LoadBalancerIP) +} + +// GetAdvertisedEndpoint returns the advertised endpoint or empty string if none was specified +func (s ExternalAccessSpec) GetAdvertisedEndpoint() string { + return util.StringOrDefault(s.AdvertisedEndpoint) +} + +// HasAdvertisedEndpoint return whether an advertised endpoint was specified or not +func (s ExternalAccessSpec) HasAdvertisedEndpoint() bool { + return s.AdvertisedEndpoint != nil +} + +// Validate the given spec +func (s ExternalAccessSpec) Validate() error { + if err := s.GetType().Validate(); err != nil { + return maskAny(err) + } + if s.AdvertisedEndpoint != nil { + ep := s.GetAdvertisedEndpoint() + if _, err := url.Parse(ep); err != nil { + return maskAny(fmt.Errorf("Failed to parse advertised endpoint '%s': %s", ep, err)) + } + } + for _, x := range s.LoadBalancerSourceRanges { + if _, _, err := net.ParseCIDR(x); err != nil { + return maskAny(fmt.Errorf("Failed to parse loadbalancer source range '%s': %s", x, err)) + } + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *ExternalAccessSpec) SetDefaults() { +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *ExternalAccessSpec) SetDefaultsFrom(source ExternalAccessSpec) { + if s.Type == nil { + s.Type = NewExternalAccessTypeOrNil(source.Type) + } + if s.NodePort == nil { + s.NodePort = util.NewIntOrNil(source.NodePort) + } + if s.LoadBalancerIP == nil { + s.LoadBalancerIP = util.NewStringOrNil(source.LoadBalancerIP) + } + if s.LoadBalancerSourceRanges == nil && len(source.LoadBalancerSourceRanges) > 0 { + s.LoadBalancerSourceRanges = append([]string{}, source.LoadBalancerSourceRanges...) + } + if s.AdvertisedEndpoint == nil { + s.AdvertisedEndpoint = source.AdvertisedEndpoint + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s ExternalAccessSpec) ResetImmutableFields(fieldPrefix string, target *ExternalAccessSpec) []string { + return nil +} diff --git a/pkg/apis/deployment/v1/external_access_type.go b/pkg/apis/deployment/v1/external_access_type.go new file mode 100644 index 000000000..278123f15 --- /dev/null +++ b/pkg/apis/deployment/v1/external_access_type.go @@ -0,0 +1,95 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" +) + +// ExternalAccessType specifies the type of external access provides for the deployment +type ExternalAccessType string + +const ( + // ExternalAccessTypeNone yields a cluster with no external access + ExternalAccessTypeNone ExternalAccessType = "None" + // ExternalAccessTypeAuto yields a cluster with an automatic selection for external access + ExternalAccessTypeAuto ExternalAccessType = "Auto" + // ExternalAccessTypeLoadBalancer yields a cluster with a service of type `LoadBalancer` to provide external access + ExternalAccessTypeLoadBalancer ExternalAccessType = "LoadBalancer" + // ExternalAccessTypeNodePort yields a cluster with a service of type `NodePort` to provide external access + ExternalAccessTypeNodePort ExternalAccessType = "NodePort" +) + +func (t ExternalAccessType) IsNone() bool { return t == ExternalAccessTypeNone } +func (t ExternalAccessType) IsAuto() bool { return t == ExternalAccessTypeAuto } +func (t ExternalAccessType) IsLoadBalancer() bool { return t == ExternalAccessTypeLoadBalancer } +func (t ExternalAccessType) IsNodePort() bool { return t == ExternalAccessTypeNodePort } + +// AsServiceType returns the k8s ServiceType for this ExternalAccessType. +// If type is "Auto", ServiceTypeLoadBalancer is returned. +func (t ExternalAccessType) AsServiceType() v1.ServiceType { + switch t { + case ExternalAccessTypeLoadBalancer, ExternalAccessTypeAuto: + return v1.ServiceTypeLoadBalancer + case ExternalAccessTypeNodePort: + return v1.ServiceTypeNodePort + default: + return "" + } +} + +// Validate the type. +// Return errors when validation fails, nil on success. +func (t ExternalAccessType) Validate() error { + switch t { + case ExternalAccessTypeNone, ExternalAccessTypeAuto, ExternalAccessTypeLoadBalancer, ExternalAccessTypeNodePort: + return nil + default: + return maskAny(errors.Wrapf(ValidationError, "Unknown external access type: '%s'", string(t))) + } +} + +// NewExternalAccessType returns a reference to a string with given value. +func NewExternalAccessType(input ExternalAccessType) *ExternalAccessType { + return &input +} + +// NewExternalAccessTypeOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewExternalAccessTypeOrNil(input *ExternalAccessType) *ExternalAccessType { + if input == nil { + return nil + } + return NewExternalAccessType(*input) +} + +// ExternalAccessTypeOrDefault returns the default value (or empty string) if input is nil, otherwise returns the referenced value. +func ExternalAccessTypeOrDefault(input *ExternalAccessType, defaultValue ...ExternalAccessType) ExternalAccessType { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + return *input +} diff --git a/pkg/apis/deployment/v1/image_info.go b/pkg/apis/deployment/v1/image_info.go new file mode 100644 index 000000000..38d306806 --- /dev/null +++ b/pkg/apis/deployment/v1/image_info.go @@ -0,0 +1,108 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import driver "github.com/arangodb/go-driver" + +// ImageInfo contains an ID of an image and the ArangoDB version inside the image. +type ImageInfo struct { + Image string `json:"image"` // Human provided name of the image + ImageID string `json:"image-id,omitempty"` // Unique ID (with SHA256) of the image + ArangoDBVersion driver.Version `json:"arangodb-version,omitempty"` // ArangoDB version within the image + Enterprise bool `json:"enterprise,omitempty"` // If set, this is an enterprise image +} + +// ImageInfoList is a list of image infos +type ImageInfoList []ImageInfo + +// GetByImage returns the info in the given list for the image with given name. +// If not found, false is returned. +func (l ImageInfoList) GetByImage(image string) (ImageInfo, bool) { + for _, x := range l { + if x.Image == image { + return x, true + } + } + return ImageInfo{}, false +} + +// GetByImageID returns the info in the given list for the image with given id. +// If not found, false is returned. +func (l ImageInfoList) GetByImageID(imageID string) (ImageInfo, bool) { + for _, x := range l { + if x.ImageID == imageID { + return x, true + } + } + return ImageInfo{}, false +} + +// AddOrUpdate adds the given info to the given list, if its image does not exist +// in the list. If the image does exist in the list, its entry is replaced by the given info. +// If not found, false is returned. +func (l *ImageInfoList) AddOrUpdate(info ImageInfo) { + // Look for existing entry + for i, x := range *l { + if x.Image == info.Image { + (*l)[i] = info + return + } + } + // No existing entry found, add it + *l = append(*l, info) +} + +// Equal compares to ImageInfo +func (i *ImageInfo) Equal(other *ImageInfo) bool { + if i == nil || other == nil { + return false + } else if i == other { + return true + } + + return i.ArangoDBVersion == other.ArangoDBVersion && + i.Enterprise == other.Enterprise && + i.Image == other.Image && + i.ImageID == other.ImageID +} + +// Equal compares to ImageInfoList +func (l ImageInfoList) Equal(other ImageInfoList) bool { + if len(l) != len(other) { + return false + } + + for i := 0; i < len(l); i++ { + ii, found := l.GetByImageID(l[i].ImageID) + + if !found { + return false + } + + if !l[i].Equal(&ii) { + return false + } + } + + return true +} diff --git a/pkg/apis/deployment/v1/image_info_test.go b/pkg/apis/deployment/v1/image_info_test.go new file mode 100644 index 000000000..8ecacc9c7 --- /dev/null +++ b/pkg/apis/deployment/v1/image_info_test.go @@ -0,0 +1,50 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestImageInfoList(t *testing.T) { + var list ImageInfoList + + _, found := list.GetByImage("notfound") + assert.False(t, found) + _, found = list.GetByImageID("id-notfound") + assert.False(t, found) + + list.AddOrUpdate(ImageInfo{ + Image: "foo", + ImageID: "foo-ID", + ArangoDBVersion: "1.3.4", + }) + assert.Len(t, list, 1) + + _, found = list.GetByImage("foo") + assert.True(t, found) + _, found = list.GetByImageID("foo-ID") + assert.True(t, found) +} diff --git a/pkg/apis/deployment/v1/license_spec.go b/pkg/apis/deployment/v1/license_spec.go new file mode 100644 index 000000000..ac9d75d5b --- /dev/null +++ b/pkg/apis/deployment/v1/license_spec.go @@ -0,0 +1,59 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// LicenseSpec holds the license related information +type LicenseSpec struct { + SecretName *string `json:"secretName,omitempty"` +} + +// HasSecretName returns true if a license key secret name was set +func (s LicenseSpec) HasSecretName() bool { + return s.SecretName != nil +} + +// GetSecretName returns the license key if set. Empty string otherwise. +func (s LicenseSpec) GetSecretName() string { + return util.StringOrDefault(s.SecretName) +} + +// Validate validates the LicenseSpec +func (s LicenseSpec) Validate() error { + if s.HasSecretName() { + if err := k8sutil.ValidateResourceName(s.GetSecretName()); err != nil { + return err + } + } + + return nil +} + +// SetDefaultsFrom fills all values not set in s with values from other +func (s LicenseSpec) SetDefaultsFrom(other LicenseSpec) { + if !s.HasSecretName() { + s.SecretName = util.NewStringOrNil(other.SecretName) + } +} diff --git a/pkg/apis/deployment/v1/license_spec_test.go b/pkg/apis/deployment/v1/license_spec_test.go new file mode 100644 index 000000000..acef3c074 --- /dev/null +++ b/pkg/apis/deployment/v1/license_spec_test.go @@ -0,0 +1,15 @@ +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestLicenseSpecValidation(t *testing.T) { + assert.Nil(t, LicenseSpec{SecretName: nil}.Validate()) + assert.Nil(t, LicenseSpec{SecretName: util.NewString("some-name")}.Validate()) + + assert.Error(t, LicenseSpec{SecretName: util.NewString("@@")}.Validate()) +} diff --git a/pkg/apis/deployment/v1/member_phase.go b/pkg/apis/deployment/v1/member_phase.go new file mode 100644 index 000000000..39a58cb9e --- /dev/null +++ b/pkg/apis/deployment/v1/member_phase.go @@ -0,0 +1,57 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// MemberPhase is a strongly typed lifetime phase of a deployment member +type MemberPhase string + +const ( + // MemberPhaseNone indicates that the state is not set yet + MemberPhaseNone MemberPhase = "" + // MemberPhaseCreated indicates that all resources needed for the member have been created + MemberPhaseCreated MemberPhase = "Created" + // MemberPhaseFailed indicates that the member is gone beyond hope of recovery. It must be replaced with a new member. + MemberPhaseFailed MemberPhase = "Failed" + // MemberPhaseCleanOut indicates that a dbserver is in the process of being cleaned out + MemberPhaseCleanOut MemberPhase = "CleanOut" + // MemberPhaseDrain indicates that a dbserver is in the process of being cleaned out as result of draining a node + MemberPhaseDrain MemberPhase = "Drain" + // MemberPhaseResign indicates that a dbserver is in the process of resigning for a shutdown + MemberPhaseResign MemberPhase = "Resign" + // MemberPhaseShuttingDown indicates that a member is shutting down + MemberPhaseShuttingDown MemberPhase = "ShuttingDown" + // MemberPhaseRotating indicates that a member is being rotated + MemberPhaseRotating MemberPhase = "Rotating" + // MemberPhaseUpgrading indicates that a member is in the process of upgrading its database data format + MemberPhaseUpgrading MemberPhase = "Upgrading" +) + +// IsFailed returns true when given phase == "Failed" +func (p MemberPhase) IsFailed() bool { + return p == MemberPhaseFailed +} + +// IsCreatedOrDrain returns true when given phase is MemberPhaseCreated or MemberPhaseDrain +func (p MemberPhase) IsCreatedOrDrain() bool { + return p == MemberPhaseCreated || p == MemberPhaseDrain +} diff --git a/pkg/apis/deployment/v1/member_status.go b/pkg/apis/deployment/v1/member_status.go new file mode 100644 index 000000000..fc05842e9 --- /dev/null +++ b/pkg/apis/deployment/v1/member_status.go @@ -0,0 +1,131 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "reflect" + "time" + + driver "github.com/arangodb/go-driver" + "github.com/arangodb/kube-arangodb/pkg/util" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// MemberStatus holds the current status of a single member (server) +type MemberStatus struct { + // ID holds the unique ID of the member. + // This id is also used within the ArangoDB cluster to identify this server. + ID string `json:"id"` + // Phase holds the current lifetime phase of this member + Phase MemberPhase `json:"phase"` + // CreatedAt holds the creation timestamp of this member. + CreatedAt metav1.Time `json:"created-at"` + // PersistentVolumeClaimName holds the name of the persistent volume claim used for this member (if any). + PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"` + // PodName holds the name of the Pod that currently runs this member + PodName string `json:"podName,omitempty"` + // Conditions specific to this member + Conditions ConditionList `json:"conditions,omitempty"` + // RecentTerminatons holds the times when this member was recently terminated. + // First entry is the oldest. (do not add omitempty, since we want to be able to switch from a list to an empty list) + RecentTerminations []metav1.Time `json:"recent-terminations"` + // IsInitialized is set after the very first time a pod was created for this member. + // After that, DBServers must have a UUID field or fail. + IsInitialized bool `json:"initialized"` + // CleanoutJobID holds the ID of the agency job for cleaning out this server + CleanoutJobID string `json:"cleanout-job-id,omitempty"` + // SideCarSpecs contains list of specifications specified for side cars + SideCarSpecs map[string]v1.Container `json:"sidecars-specs,omitempty"` + // ArangoVersion holds the ArangoDB version in member + ArangoVersion driver.Version `json:"arango-version,omitempty"` + // ImageId holds the members ArangoDB image ID + ImageID string `json:"image-id,omitempty"` +} + +// Equal checks for equality +func (s MemberStatus) Equal(other MemberStatus) bool { + return s.ID == other.ID && + s.Phase == other.Phase && + util.TimeCompareEqual(s.CreatedAt, other.CreatedAt) && + s.PersistentVolumeClaimName == other.PersistentVolumeClaimName && + s.PodName == other.PodName && + s.Conditions.Equal(other.Conditions) && + s.IsInitialized == other.IsInitialized && + s.CleanoutJobID == other.CleanoutJobID && + reflect.DeepEqual(s.SideCarSpecs, other.SideCarSpecs) && + s.ArangoVersion == other.ArangoVersion && + s.ImageID == other.ImageID +} + +// Age returns the duration since the creation timestamp of this member. +func (s MemberStatus) Age() time.Duration { + return time.Since(s.CreatedAt.Time) +} + +// RemoveTerminationsBefore removes all recent terminations before the given timestamp. +// It returns the number of terminations that have been removed. +func (s *MemberStatus) RemoveTerminationsBefore(timestamp time.Time) int { + removed := 0 + for { + if len(s.RecentTerminations) == 0 { + // Nothing left + return removed + } + if s.RecentTerminations[0].Time.Before(timestamp) { + // Let's remove it + s.RecentTerminations = s.RecentTerminations[1:] + removed++ + } else { + // First (oldest) is not before given timestamp, we're done + return removed + } + } +} + +// RecentTerminationsSince returns the number of terminations since the given timestamp. +func (s MemberStatus) RecentTerminationsSince(timestamp time.Time) int { + count := 0 + for idx := len(s.RecentTerminations) - 1; idx >= 0; idx-- { + if s.RecentTerminations[idx].Time.Before(timestamp) { + // This termination is before the timestamp, so we're done + return count + } + count++ + } + return count +} + +// IsNotReadySince returns true when the given member has not been ready since the given timestamp. +// That means it: +// - A) Was created before timestamp and never reached a ready state or +// - B) The Ready condition is set to false, and last transision is before timestamp +func (s MemberStatus) IsNotReadySince(timestamp time.Time) bool { + cond, found := s.Conditions.Get(ConditionTypeReady) + if found { + // B + return cond.Status != v1.ConditionTrue && cond.LastTransitionTime.Time.Before(timestamp) + } + // A + return s.CreatedAt.Time.Before(timestamp) +} diff --git a/pkg/apis/deployment/v1/member_status_list.go b/pkg/apis/deployment/v1/member_status_list.go new file mode 100644 index 000000000..65bc3d36b --- /dev/null +++ b/pkg/apis/deployment/v1/member_status_list.go @@ -0,0 +1,206 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "math/rand" + "sort" + "time" + + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" +) + +// MemberStatusList is a list of MemberStatus entries +type MemberStatusList []MemberStatus + +// Equal checks for equality +func (l MemberStatusList) Equal(other MemberStatusList) bool { + if len(l) != len(other) { + return false + } + + for i := 0; i < len(l); i++ { + o, found := other.ElementByID(l[i].ID) + if !found { + return false + } + + if !l[i].Equal(o) { + return false + } + } + + return true +} + +// ContainsID returns true if the given list contains a member with given ID. +func (l MemberStatusList) ContainsID(id string) bool { + for _, x := range l { + if x.ID == id { + return true + } + } + return false +} + +// ElementByID returns the element in the given list that has the given ID and true. +// If no such element exists, false is returned. +func (l MemberStatusList) ElementByID(id string) (MemberStatus, bool) { + for i, x := range l { + if x.ID == id { + return l[i], true + } + } + return MemberStatus{}, false +} + +// ElementByPodName returns the element in the given list that has the given pod name and true. +// If no such element exists, an empty element and false is returned. +func (l MemberStatusList) ElementByPodName(podName string) (MemberStatus, bool) { + for i, x := range l { + if x.PodName == podName { + return l[i], true + } + } + return MemberStatus{}, false +} + +// ElementByPVCName returns the element in the given list that has the given PVC name and true. +// If no such element exists, an empty element and false is returned. +func (l MemberStatusList) ElementByPVCName(pvcName string) (MemberStatus, bool) { + for i, x := range l { + if x.PersistentVolumeClaimName == pvcName { + return l[i], true + } + } + return MemberStatus{}, false +} + +// Add a member to the list. +// Returns an AlreadyExistsError if the ID of the given member already exists. +func (l *MemberStatusList) add(m MemberStatus) error { + src := *l + for _, x := range src { + if x.ID == m.ID { + return maskAny(errors.Wrapf(AlreadyExistsError, "Member '%s' already exists", m.ID)) + } + } + newList := append(src, m) + sort.Slice(newList, func(i, j int) bool { return newList[i].ID < newList[j].ID }) + *l = newList + return nil +} + +// Update a member in the list. +// Returns a NotFoundError if the ID of the given member cannot be found. +func (l MemberStatusList) update(m MemberStatus) error { + for i, x := range l { + if x.ID == m.ID { + l[i] = m + return nil + } + } + return maskAny(errors.Wrapf(NotFoundError, "Member '%s' is not a member", m.ID)) +} + +// RemoveByID a member with given ID from the list. +// Returns a NotFoundError if the ID of the given member cannot be found. +func (l *MemberStatusList) removeByID(id string) error { + src := *l + for i, x := range src { + if x.ID == id { + *l = append(src[:i], src[i+1:]...) + return nil + } + } + return maskAny(errors.Wrapf(NotFoundError, "Member '%s' is not a member", id)) +} + +// SelectMemberToRemove selects a member from the given list that should +// be removed in a scale down action. +// Returns an error if the list is empty. +func (l MemberStatusList) SelectMemberToRemove() (MemberStatus, error) { + if len(l) > 0 { + // Try to find a not ready member + for _, m := range l { + if m.Phase == MemberPhaseNone { + return m, nil + } + } + for _, m := range l { + if !m.Conditions.IsTrue(ConditionTypeReady) { + return m, nil + } + } + // Pick a random member that is in created state + perm := rand.Perm(len(l)) + for _, idx := range perm { + m := l[idx] + if m.Phase == MemberPhaseCreated { + return m, nil + } + } + } + return MemberStatus{}, maskAny(errors.Wrap(NotFoundError, "No member available for removal")) +} + +// MembersReady returns the number of members that are in the Ready state. +func (l MemberStatusList) MembersReady() int { + readyCount := 0 + for _, x := range l { + if x.Conditions.IsTrue(ConditionTypeReady) { + readyCount++ + } + } + return readyCount +} + +// AllMembersReady returns the true if all members are in the Ready state. +func (l MemberStatusList) AllMembersReady() bool { + return len(l) == l.MembersReady() +} + +// AllConditionTrueSince returns true if all members satisfy the condition since the given period +func (l MemberStatusList) AllConditionTrueSince(cond ConditionType, status v1.ConditionStatus, period time.Duration) bool { + for _, x := range l { + if c, ok := x.Conditions.Get(cond); ok { + if c.Status == status && c.LastTransitionTime.Time.Add(period).Before(time.Now()) { + continue + } + } + return false + } + + return true +} + +// AllFailed returns true if all members are failed +func (l MemberStatusList) AllFailed() bool { + for _, x := range l { + if !x.Phase.IsFailed() { + return false + } + } + return true +} diff --git a/pkg/apis/deployment/v1/member_status_list_test.go b/pkg/apis/deployment/v1/member_status_list_test.go new file mode 100644 index 000000000..5275d0c67 --- /dev/null +++ b/pkg/apis/deployment/v1/member_status_list_test.go @@ -0,0 +1,91 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// TestMemberStatusList tests modifying a MemberStatusList. +func TestMemberStatusList(t *testing.T) { + list := &MemberStatusList{} + m1 := MemberStatus{ID: "m1"} + m2 := MemberStatus{ID: "m2"} + m3 := MemberStatus{ID: "m3"} + assert.Equal(t, 0, len(*list)) + + assert.NoError(t, list.add(m1)) + assert.Equal(t, 1, len(*list)) + + assert.NoError(t, list.add(m2)) + assert.NoError(t, list.add(m3)) + assert.Equal(t, 3, len(*list)) + + assert.Error(t, list.add(m2)) + assert.Equal(t, 3, len(*list)) + + assert.NoError(t, list.removeByID(m3.ID)) + assert.Equal(t, 2, len(*list)) + assert.False(t, list.ContainsID(m3.ID)) + assert.Equal(t, m1.ID, (*list)[0].ID) + assert.Equal(t, m2.ID, (*list)[1].ID) + + m2.PodName = "foo" + assert.NoError(t, list.update(m2)) + assert.Equal(t, 2, len(*list)) + assert.True(t, list.ContainsID(m2.ID)) + x, found := list.ElementByPodName("foo") + assert.True(t, found) + assert.Equal(t, "foo", x.PodName) + assert.Equal(t, m2.ID, x.ID) + + assert.NoError(t, list.add(m3)) + assert.Equal(t, 3, len(*list)) + assert.Equal(t, m1.ID, (*list)[0].ID) + assert.Equal(t, m2.ID, (*list)[1].ID) + assert.Equal(t, m3.ID, (*list)[2].ID) + + list2 := &MemberStatusList{m3, m2, m1} + assert.True(t, list.Equal(*list2)) + assert.True(t, list2.Equal(*list)) + + list3 := &MemberStatusList{m3, m1} + assert.False(t, list.Equal(*list3)) + assert.False(t, list3.Equal(*list)) + + list4 := MemberStatusList{m3, m2, m1} + list4[1].Phase = "something-else" + assert.False(t, list.Equal(list4)) + assert.False(t, list4.Equal(*list)) + + m4 := MemberStatus{ID: "m4"} + list5 := &MemberStatusList{m1, m2, m4} + assert.False(t, list.Equal(*list5)) + assert.False(t, list5.Equal(*list)) + + list6 := &MemberStatusList{m1, m2, m3, m4} + assert.False(t, list.Equal(*list6)) + assert.False(t, list6.Equal(*list)) +} diff --git a/pkg/apis/deployment/v1/member_status_test.go b/pkg/apis/deployment/v1/member_status_test.go new file mode 100644 index 000000000..1920f22bd --- /dev/null +++ b/pkg/apis/deployment/v1/member_status_test.go @@ -0,0 +1,74 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// TestMemberStatusRecentTerminations tests the functions related to MemberStatus.RecentTerminations. +func TestMemberStatusRecentTerminations(t *testing.T) { + relTime := func(delta time.Duration) metav1.Time { + return metav1.Time{Time: time.Now().Add(delta)} + } + + s := MemberStatus{} + assert.Equal(t, 0, s.RecentTerminationsSince(time.Now().Add(-time.Hour))) + assert.Equal(t, 0, s.RemoveTerminationsBefore(time.Now())) + + s.RecentTerminations = []metav1.Time{metav1.Now()} + assert.Equal(t, 1, s.RecentTerminationsSince(time.Now().Add(-time.Minute))) + assert.Equal(t, 0, s.RecentTerminationsSince(time.Now().Add(time.Minute))) + assert.Equal(t, 0, s.RemoveTerminationsBefore(time.Now().Add(-time.Hour))) + + s.RecentTerminations = []metav1.Time{relTime(-time.Hour), relTime(-time.Minute), relTime(time.Minute)} + assert.Equal(t, 3, s.RecentTerminationsSince(time.Now().Add(-time.Hour*2))) + assert.Equal(t, 2, s.RecentTerminationsSince(time.Now().Add(-time.Minute*2))) + assert.Equal(t, 2, s.RemoveTerminationsBefore(time.Now())) + assert.Len(t, s.RecentTerminations, 1) +} + +// TestMemberStatusIsNotReadySince tests the functions related to MemberStatus.IsNotReadySince. +func TestMemberStatusIsNotReadySince(t *testing.T) { + s := MemberStatus{ + CreatedAt: metav1.Now(), + } + assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Hour))) + + s.CreatedAt.Time = time.Now().Add(-time.Hour) + assert.False(t, s.IsNotReadySince(time.Now().Add(-2*time.Hour))) + assert.True(t, s.IsNotReadySince(time.Now().Add(-(time.Hour - time.Minute)))) + + s.CreatedAt = metav1.Now() + s.Conditions.Update(ConditionTypeReady, true, "", "") + assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Minute))) + assert.False(t, s.IsNotReadySince(time.Now().Add(time.Minute))) + + s.Conditions.Update(ConditionTypeReady, false, "", "") + assert.False(t, s.IsNotReadySince(time.Now().Add(-time.Minute))) + assert.True(t, s.IsNotReadySince(time.Now().Add(time.Minute))) +} diff --git a/pkg/apis/deployment/v1/metrics_spec.go b/pkg/apis/deployment/v1/metrics_spec.go new file mode 100644 index 000000000..313b507c2 --- /dev/null +++ b/pkg/apis/deployment/v1/metrics_spec.go @@ -0,0 +1,105 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// MetricsAuthenticationSpec contains spec for authentication with arangodb +type MetricsAuthenticationSpec struct { + // JWTTokenSecretName contains the name of the JWT kubernetes secret used for authentication + JWTTokenSecretName *string `json:"jwtTokenSecretName,omitempty"` +} + +// MetricsSpec contains spec for arangodb exporter +type MetricsSpec struct { + Enabled *bool `json:"enabled,omitempty"` + Image *string `json:"image,omitempty"` + Authentication MetricsAuthenticationSpec `json:"authentication,omitempty"` +} + +// IsEnabled returns whether metrics are enabled or not +func (s *MetricsSpec) IsEnabled() bool { + return util.BoolOrDefault(s.Enabled, false) +} + +// HasImage returns whether a image was specified or not +func (s *MetricsSpec) HasImage() bool { + return s.Image != nil +} + +// GetImage returns the Image or empty string +func (s *MetricsSpec) GetImage() string { + return util.StringOrDefault(s.Image) +} + +// SetDefaults sets default values +func (s *MetricsSpec) SetDefaults(defaultTokenName string, isAuthenticated bool) { + if s.Enabled == nil { + s.Enabled = util.NewBool(false) + } + if s.GetJWTTokenSecretName() == "" { + s.Authentication.JWTTokenSecretName = util.NewString(defaultTokenName) + } +} + +// GetJWTTokenSecretName returns the token secret name or empty string +func (s *MetricsSpec) GetJWTTokenSecretName() string { + return util.StringOrDefault(s.Authentication.JWTTokenSecretName) +} + +// HasJWTTokenSecretName returns true if a secret name was specified +func (s *MetricsSpec) HasJWTTokenSecretName() bool { + return s.Authentication.JWTTokenSecretName != nil +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *MetricsSpec) SetDefaultsFrom(source MetricsSpec) { + if s.Enabled == nil { + s.Enabled = util.NewBoolOrNil(source.Enabled) + } + if s.Image == nil { + s.Image = util.NewStringOrNil(source.Image) + } + if s.Authentication.JWTTokenSecretName == nil { + s.Authentication.JWTTokenSecretName = util.NewStringOrNil(source.Authentication.JWTTokenSecretName) + } +} + +// Validate the given spec +func (s *MetricsSpec) Validate() error { + + if s.HasJWTTokenSecretName() { + if err := k8sutil.ValidateResourceName(s.GetJWTTokenSecretName()); err != nil { + return err + } + } + + return nil +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +func (s MetricsSpec) ResetImmutableFields(fieldPrefix string, target *MetricsSpec) []string { + return nil +} diff --git a/pkg/apis/deployment/v1/monitoring_spec.go b/pkg/apis/deployment/v1/monitoring_spec.go new file mode 100644 index 000000000..415b638a1 --- /dev/null +++ b/pkg/apis/deployment/v1/monitoring_spec.go @@ -0,0 +1,62 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// MonitoringSpec holds monitoring specific configuration settings +type MonitoringSpec struct { + TokenSecretName *string `json:"tokenSecretName,omitempty"` +} + +// GetTokenSecretName returns the value of tokenSecretName. +func (s MonitoringSpec) GetTokenSecretName() string { + return util.StringOrDefault(s.TokenSecretName) +} + +// Validate the given spec +func (s MonitoringSpec) Validate() error { + if err := k8sutil.ValidateOptionalResourceName(s.GetTokenSecretName()); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *MonitoringSpec) SetDefaults(defaultTokenSecretName string) { + if s.GetTokenSecretName() == "" { + // Note that we don't check for nil here, since even a specified, but empty + // string should result in the default value. + s.TokenSecretName = util.NewString(defaultTokenSecretName) + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *MonitoringSpec) SetDefaultsFrom(source MonitoringSpec) { + if s.TokenSecretName == nil { + s.TokenSecretName = util.NewStringOrNil(source.TokenSecretName) + } +} diff --git a/pkg/apis/deployment/v1/monitoring_spec_test.go b/pkg/apis/deployment/v1/monitoring_spec_test.go new file mode 100644 index 000000000..2c5a2214b --- /dev/null +++ b/pkg/apis/deployment/v1/monitoring_spec_test.go @@ -0,0 +1,56 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestMonitoringSpecValidate(t *testing.T) { + // Valid + assert.Nil(t, MonitoringSpec{TokenSecretName: nil}.Validate()) + assert.Nil(t, MonitoringSpec{TokenSecretName: util.NewString("")}.Validate()) + assert.Nil(t, MonitoringSpec{TokenSecretName: util.NewString("foo")}.Validate()) + assert.Nil(t, MonitoringSpec{TokenSecretName: util.NewString("foo")}.Validate()) + + // Not valid + assert.Error(t, MonitoringSpec{TokenSecretName: util.NewString("Foo")}.Validate()) +} + +func TestMonitoringSpecSetDefaults(t *testing.T) { + def := func(spec MonitoringSpec) MonitoringSpec { + spec.SetDefaults("") + return spec + } + def2 := func(spec MonitoringSpec) MonitoringSpec { + spec.SetDefaults("def2") + return spec + } + + assert.Equal(t, "", def(MonitoringSpec{}).GetTokenSecretName()) + assert.Equal(t, "def2", def2(MonitoringSpec{}).GetTokenSecretName()) + assert.Equal(t, "foo", def(MonitoringSpec{TokenSecretName: util.NewString("foo")}).GetTokenSecretName()) +} diff --git a/pkg/apis/deployment/v1/percent.go b/pkg/apis/deployment/v1/percent.go new file mode 100644 index 000000000..523c1d412 --- /dev/null +++ b/pkg/apis/deployment/v1/percent.go @@ -0,0 +1,62 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" +) + +// Percent is a percentage between 0 and 100. +type Percent int + +// Validate the given percentage. +func (p Percent) Validate() error { + if p < 0 || p > 100 { + return maskAny(errors.Wrapf(ValidationError, "Percentage must be between 0 and 100, got %d", int(p))) + } + return nil +} + +// NewPercent returns a reference to a percent with given value. +func NewPercent(input Percent) *Percent { + return &input +} + +// NewPercentOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewPercentOrNil(input *Percent) *Percent { + if input == nil { + return nil + } + return NewPercent(*input) +} + +// PercentOrDefault returns the default value or 0 if input is nil, otherwise returns the referenced value. +func PercentOrDefault(input *Percent, defaultValue ...Percent) Percent { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return 0 + } + return *input +} diff --git a/pkg/apis/deployment/v1/plan.go b/pkg/apis/deployment/v1/plan.go new file mode 100644 index 000000000..d94945870 --- /dev/null +++ b/pkg/apis/deployment/v1/plan.go @@ -0,0 +1,136 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/dchest/uniuri" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ActionType is a strongly typed name for a plan action item +type ActionType string + +const ( + // ActionTypeAddMember causes a member to be added. + ActionTypeAddMember ActionType = "AddMember" + // ActionTypeRemoveMember causes a member to be removed. + ActionTypeRemoveMember ActionType = "RemoveMember" + // ActionTypeCleanOutMember causes a member to be cleaned out (dbserver only). + ActionTypeCleanOutMember ActionType = "CleanOutMember" + // ActionTypeShutdownMember causes a member to be shutdown and removed from the cluster. + ActionTypeShutdownMember ActionType = "ShutdownMember" + // ActionTypeRotateMember causes a member to be shutdown and have it's pod removed. + ActionTypeRotateMember ActionType = "RotateMember" + // ActionTypeUpgradeMember causes a member to be shutdown and have it's pod removed, restarted with AutoUpgrade option, waited until termination and the restarted again. + ActionTypeUpgradeMember ActionType = "UpgradeMember" + // ActionTypeWaitForMemberUp causes the plan to wait until the member is considered "up". + ActionTypeWaitForMemberUp ActionType = "WaitForMemberUp" + // ActionTypeRenewTLSCertificate causes the TLS certificate of a member to be renewed. + ActionTypeRenewTLSCertificate ActionType = "RenewTLSCertificate" + // ActionTypeRenewTLSCACertificate causes the TLS CA certificate of the entire deployment to be renewed. + ActionTypeRenewTLSCACertificate ActionType = "RenewTLSCACertificate" + // ActionTypeSetCurrentImage causes status.CurrentImage to be updated to the image given in the action. + ActionTypeSetCurrentImage ActionType = "SetCurrentImage" +) + +const ( + // MemberIDPreviousAction is used for Action.MemberID when the MemberID + // should be derived from the previous action. + MemberIDPreviousAction = "@previous" +) + +// Action represents a single action to be taken to update a deployment. +type Action struct { + // ID of this action (unique for every action) + ID string `json:"id"` + // Type of action. + Type ActionType `json:"type"` + // ID reference of the member involved in this action (if any) + MemberID string `json:"memberID,omitempty"` + // Group involved in this action + Group ServerGroup `json:"group,omitempty"` + // CreationTime is set the when the action is created. + CreationTime metav1.Time `json:"creationTime"` + // StartTime is set the when the action has been started, but needs to wait to be finished. + StartTime *metav1.Time `json:"startTime,omitempty"` + // Reason for this action + Reason string `json:"reason,omitempty"` + // Image used in can of a SetCurrentImage action. + Image string `json:"image,omitempty"` +} + +// Equal compares two Actions +func (a Action) Equal(other Action) bool { + return a.ID == other.ID && + a.Type == other.Type && + a.MemberID == other.MemberID && + a.Group == other.Group && + util.TimeCompareEqual(a.CreationTime, other.CreationTime) && + util.TimeCompareEqualPointer(a.StartTime, other.StartTime) && + a.Reason == other.Reason && + a.Image == other.Image +} + +// NewAction instantiates a new Action. +func NewAction(actionType ActionType, group ServerGroup, memberID string, reason ...string) Action { + a := Action{ + ID: uniuri.New(), + Type: actionType, + MemberID: memberID, + Group: group, + CreationTime: metav1.Now(), + } + if len(reason) != 0 { + a.Reason = reason[0] + } + return a +} + +// SetImage sets the Image field to the given value and returns the modified +// action. +func (a Action) SetImage(image string) Action { + a.Image = image + return a +} + +// Plan is a list of actions that will be taken to update a deployment. +// Only 1 action is in progress at a time. The operator will wait for that +// action to be completely and then remove the action. +type Plan []Action + +// Equal compares two Plan +func (p Plan) Equal(other Plan) bool { + // For plan the order is relevant! + if len(p) != len(other) { + return false + } + + for i := 0; i < len(p); i++ { + if !p[i].Equal(other[i]) { + return false + } + } + + return true +} diff --git a/pkg/apis/deployment/v1/register.go b/pkg/apis/deployment/v1/register.go new file mode 100644 index 000000000..2e9f412ba --- /dev/null +++ b/pkg/apis/deployment/v1/register.go @@ -0,0 +1,56 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + ArangoDeploymentVersion = "v1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = schema.GroupVersion{Group: deployment.ArangoDeploymentGroupName, Version: ArangoDeploymentVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion, + &ArangoDeployment{}, + &ArangoDeploymentList{}, + ) + metav1.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/deployment/v1/rocksdb_spec.go b/pkg/apis/deployment/v1/rocksdb_spec.go new file mode 100644 index 000000000..a3d6c74b8 --- /dev/null +++ b/pkg/apis/deployment/v1/rocksdb_spec.go @@ -0,0 +1,88 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// RocksDBEncryptionSpec holds rocksdb encryption at rest specific configuration settings +type RocksDBEncryptionSpec struct { + KeySecretName *string `json:"keySecretName,omitempty"` +} + +// GetKeySecretName returns the value of keySecretName. +func (s RocksDBEncryptionSpec) GetKeySecretName() string { + return util.StringOrDefault(s.KeySecretName) +} + +// IsEncrypted returns true when an encryption key secret name is provided, +// false otherwise. +func (s RocksDBEncryptionSpec) IsEncrypted() bool { + return s.GetKeySecretName() != "" +} + +// RocksDBSpec holds rocksdb specific configuration settings +type RocksDBSpec struct { + Encryption RocksDBEncryptionSpec `json:"encryption"` +} + +// IsEncrypted returns true when an encryption key secret name is provided, +// false otherwise. +func (s RocksDBSpec) IsEncrypted() bool { + return s.Encryption.IsEncrypted() +} + +// Validate the given spec +func (s RocksDBSpec) Validate() error { + if err := k8sutil.ValidateOptionalResourceName(s.Encryption.GetKeySecretName()); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *RocksDBSpec) SetDefaults() { + // Nothing needed +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *RocksDBSpec) SetDefaultsFrom(source RocksDBSpec) { + if s.Encryption.KeySecretName == nil { + s.Encryption.KeySecretName = util.NewStringOrNil(source.Encryption.KeySecretName) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s RocksDBSpec) ResetImmutableFields(fieldPrefix string, target *RocksDBSpec) []string { + var resetFields []string + if s.IsEncrypted() != target.IsEncrypted() { + // Note: You can change the name, but not from empty to non-empty (or reverse). + target.Encryption.KeySecretName = util.NewStringOrNil(s.Encryption.KeySecretName) + resetFields = append(resetFields, fieldPrefix+".encryption.keySecretName") + } + return resetFields +} diff --git a/pkg/apis/deployment/v1/rocksdb_spec_test.go b/pkg/apis/deployment/v1/rocksdb_spec_test.go new file mode 100644 index 000000000..288e9d269 --- /dev/null +++ b/pkg/apis/deployment/v1/rocksdb_spec_test.go @@ -0,0 +1,97 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestRocksDBSpecValidate(t *testing.T) { + // Valid + assert.Nil(t, RocksDBSpec{}.Validate()) + assert.Nil(t, RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}.Validate()) + + // Not valid + assert.Error(t, RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("Foo")}}.Validate()) +} + +func TestRocksDBSpecIsEncrypted(t *testing.T) { + assert.False(t, RocksDBSpec{}.IsEncrypted()) + assert.False(t, RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("")}}.IsEncrypted()) + assert.True(t, RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}.IsEncrypted()) +} + +func TestRocksDBSpecSetDefaults(t *testing.T) { + def := func(spec RocksDBSpec) RocksDBSpec { + spec.SetDefaults() + return spec + } + + assert.Equal(t, "", def(RocksDBSpec{}).Encryption.GetKeySecretName()) +} + +func TestRocksDBSpecResetImmutableFields(t *testing.T) { + tests := []struct { + Original RocksDBSpec + Target RocksDBSpec + Expected RocksDBSpec + Result []string + }{ + // Valid "changes" + { + RocksDBSpec{}, + RocksDBSpec{}, + RocksDBSpec{}, + nil, + }, + { + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + nil, + }, + { + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo2")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo2")}}, + nil, + }, + + // Invalid changes + { + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("")}}, + RocksDBSpec{Encryption: RocksDBEncryptionSpec{KeySecretName: util.NewString("foo")}}, + []string{"test.encryption.keySecretName"}, + }, + } + + for _, test := range tests { + result := test.Original.ResetImmutableFields("test", &test.Target) + assert.Equal(t, test.Result, result) + assert.Equal(t, test.Expected, test.Target) + } +} diff --git a/pkg/apis/deployment/v1/secret_hashes.go b/pkg/apis/deployment/v1/secret_hashes.go new file mode 100644 index 000000000..4ff8b3984 --- /dev/null +++ b/pkg/apis/deployment/v1/secret_hashes.go @@ -0,0 +1,88 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// SecretHashes keeps track of the value of secrets +// so we can detect changes. +// For each used secret, a sha256 hash is stored. +type SecretHashes struct { + // AuthJWT contains the hash of the auth.jwtSecretName secret + AuthJWT string `json:"auth-jwt,omitempty"` + // RocksDBEncryptionKey contains the hash of the rocksdb.encryption.keySecretName secret + RocksDBEncryptionKey string `json:"rocksdb-encryption-key,omitempty"` + // TLSCA contains the hash of the tls.caSecretName secret + TLSCA string `json:"tls-ca,omitempty"` + // SyncTLSCA contains the hash of the sync.tls.caSecretName secret + SyncTLSCA string `json:"sync-tls-ca,omitempty"` + // User's map contains hashes for each user + Users map[string]string `json:"users,omitempty"` +} + +// Equal compares two SecretHashes +func (sh *SecretHashes) Equal(other *SecretHashes) bool { + if sh == nil || other == nil { + return false + } else if sh == other { + return true + } + + return sh.AuthJWT == other.AuthJWT && + sh.RocksDBEncryptionKey == other.RocksDBEncryptionKey && + sh.TLSCA == other.TLSCA && + sh.SyncTLSCA == other.SyncTLSCA && + isStringMapEqual(sh.Users, other.Users) +} + +// NewEmptySecretHashes creates new empty structure +func NewEmptySecretHashes() *SecretHashes { + sh := &SecretHashes{} + sh.Users = make(map[string]string) + return sh +} + +func isStringMapEqual(first map[string]string, second map[string]string) bool { + if first == nil && second == nil { + return true + } + + if first == nil || second == nil { + return false + } + + if len(first) != len(second) { + return false + } + + for key, valueF := range first { + valueS, ok := second[key] + if !ok { + return false + } + + if valueF != valueS { + return false + } + } + + return true +} diff --git a/pkg/apis/deployment/v1/secret_hashes_test.go b/pkg/apis/deployment/v1/secret_hashes_test.go new file mode 100644 index 000000000..2918dac1e --- /dev/null +++ b/pkg/apis/deployment/v1/secret_hashes_test.go @@ -0,0 +1,164 @@ +// +// DISCLAIMER +// +// Copyright 2019 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author tomasz@arangodb.con +// + +package v1 + +import ( + "github.com/magiconair/properties/assert" + + "testing" +) + +func TestSecretHashes_Equal(t *testing.T) { + // Arrange + sh := SecretHashes{} + testCases := []struct { + Name string + CompareFrom *SecretHashes + CompareTo *SecretHashes + Expected bool + }{ + { + Name: "Parameter can not be nil", + CompareFrom: &SecretHashes{}, + Expected: false, + }, + { + Name: "The addresses are the same", + CompareFrom: &sh, + CompareTo: &sh, + Expected: true, + }, + { + Name: "JWT token is different", + CompareFrom: &SecretHashes{ + AuthJWT: "1", + }, + CompareTo: &SecretHashes{ + AuthJWT: "2", + }, + Expected: false, + }, + { + Name: "Users are different", + CompareFrom: &SecretHashes{ + Users: map[string]string{ + "root": "", + }, + }, + CompareTo: &SecretHashes{}, + Expected: false, + }, + { + Name: "User's table size is different", + CompareFrom: &SecretHashes{ + Users: map[string]string{ + "root": "", + }, + }, + CompareTo: &SecretHashes{ + Users: map[string]string{ + "root": "", + "user": "", + }, + }, + Expected: false, + }, + { + Name: "User's table has got different users", + CompareFrom: &SecretHashes{ + Users: map[string]string{ + "root": "", + }, + }, + CompareTo: &SecretHashes{ + Users: map[string]string{ + "user": "", + }, + }, + Expected: false, + }, + { + Name: "User's table has got different hashes for users", + CompareFrom: &SecretHashes{ + Users: map[string]string{ + "root": "123", + }, + }, + CompareTo: &SecretHashes{ + Users: map[string]string{ + "root": "1234", + }, + }, + Expected: false, + }, + { + Name: "Secret hashes are the same", + CompareFrom: &SecretHashes{ + AuthJWT: "1", + RocksDBEncryptionKey: "2", + TLSCA: "3", + SyncTLSCA: "4", + Users: map[string]string{ + "root": "123", + }, + }, + CompareTo: &SecretHashes{ + AuthJWT: "1", + RocksDBEncryptionKey: "2", + TLSCA: "3", + SyncTLSCA: "4", + Users: map[string]string{ + "root": "123", + }, + }, + Expected: true, + }, + { + Name: "Secret hashes are the same without users", + CompareFrom: &SecretHashes{ + AuthJWT: "1", + RocksDBEncryptionKey: "2", + TLSCA: "3", + SyncTLSCA: "4", + }, + CompareTo: &SecretHashes{ + AuthJWT: "1", + RocksDBEncryptionKey: "2", + TLSCA: "3", + SyncTLSCA: "4", + }, + Expected: true, + }, + } + + for _, testCase := range testCases { + //nolint:scopelint + t.Run(testCase.Name, func(t *testing.T) { + // Act + expected := testCase.CompareFrom.Equal(testCase.CompareTo) + + // Assert + assert.Equal(t, testCase.Expected, expected) + }) + } +} diff --git a/pkg/apis/deployment/v1/server_group.go b/pkg/apis/deployment/v1/server_group.go new file mode 100644 index 000000000..773cd1199 --- /dev/null +++ b/pkg/apis/deployment/v1/server_group.go @@ -0,0 +1,142 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import time "time" + +type ServerGroup int + +const ( + ServerGroupSingle ServerGroup = 1 + ServerGroupAgents ServerGroup = 2 + ServerGroupDBServers ServerGroup = 3 + ServerGroupCoordinators ServerGroup = 4 + ServerGroupSyncMasters ServerGroup = 5 + ServerGroupSyncWorkers ServerGroup = 6 +) + +var ( + // AllServerGroups contains a constant list of all known server groups + AllServerGroups = []ServerGroup{ + ServerGroupSingle, + ServerGroupAgents, + ServerGroupDBServers, + ServerGroupCoordinators, + ServerGroupSyncMasters, + ServerGroupSyncWorkers, + } +) + +// AsRole returns the "role" value for the given group. +func (g ServerGroup) AsRole() string { + switch g { + case ServerGroupSingle: + return "single" + case ServerGroupAgents: + return "agent" + case ServerGroupDBServers: + return "dbserver" + case ServerGroupCoordinators: + return "coordinator" + case ServerGroupSyncMasters: + return "syncmaster" + case ServerGroupSyncWorkers: + return "syncworker" + default: + return "?" + } +} + +// AsRoleAbbreviated returns the abbreviation of the "role" value for the given group. +func (g ServerGroup) AsRoleAbbreviated() string { + switch g { + case ServerGroupSingle: + return "sngl" + case ServerGroupAgents: + return "agnt" + case ServerGroupDBServers: + return "prmr" + case ServerGroupCoordinators: + return "crdn" + case ServerGroupSyncMasters: + return "syma" + case ServerGroupSyncWorkers: + return "sywo" + default: + return "?" + } +} + +// DefaultTerminationGracePeriod returns the default period between SIGTERM & SIGKILL for a server in the given group. +func (g ServerGroup) DefaultTerminationGracePeriod() time.Duration { + switch g { + case ServerGroupSingle: + return time.Minute + case ServerGroupAgents: + return time.Minute + case ServerGroupDBServers: + return time.Hour + default: + return time.Second * 30 + } +} + +// IsStateless returns true when the groups runs servers without a persistent volume. +func (g ServerGroup) IsStateless() bool { + switch g { + case ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers: + return true + default: + return false + } +} + +// IsArangod returns true when the groups runs servers of type `arangod`. +func (g ServerGroup) IsArangod() bool { + switch g { + case ServerGroupSingle, ServerGroupAgents, ServerGroupDBServers, ServerGroupCoordinators: + return true + default: + return false + } +} + +// IsArangosync returns true when the groups runs servers of type `arangosync`. +func (g ServerGroup) IsArangosync() bool { + switch g { + case ServerGroupSyncMasters, ServerGroupSyncWorkers: + return true + default: + return false + } +} + +// IsExportMetrics return true when the group can be used with the arangodbexporter +func (g ServerGroup) IsExportMetrics() bool { + switch g { + case ServerGroupCoordinators, ServerGroupDBServers, ServerGroupSingle: + return true + default: + return false + } +} diff --git a/pkg/apis/deployment/v1/server_group_spec.go b/pkg/apis/deployment/v1/server_group_spec.go new file mode 100644 index 000000000..853c69152 --- /dev/null +++ b/pkg/apis/deployment/v1/server_group_spec.go @@ -0,0 +1,341 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "math" + "strings" + + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + + "github.com/arangodb/kube-arangodb/pkg/util" + arangod_options "github.com/arangodb/kube-arangodb/pkg/util/arangod/options" + arangosync_options "github.com/arangodb/kube-arangodb/pkg/util/arangosync/options" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// ServerGroupSpec contains the specification for all servers in a specific group (e.g. all agents) +type ServerGroupSpec struct { + // Count holds the requested number of servers + Count *int `json:"count,omitempty"` + // MinCount specifies a lower limit for count + MinCount *int `json:"minCount,omitempty"` + // MaxCount specifies a upper limit for count + MaxCount *int `json:"maxCount,omitempty"` + // Args holds additional commandline arguments + Args []string `json:"args,omitempty"` + // StorageClassName specifies the classname for storage of the servers. + StorageClassName *string `json:"storageClassName,omitempty"` + // Resources holds resource requests & limits + Resources v1.ResourceRequirements `json:"resources,omitempty"` + // Tolerations specifies the tolerations added to Pods in this group. + Tolerations []v1.Toleration `json:"tolerations,omitempty"` + // ServiceAccountName specifies the name of the service account used for Pods in this group. + ServiceAccountName *string `json:"serviceAccountName,omitempty"` + // NodeSelector speficies a set of selectors for nodes + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + // Probes specifies additional behaviour for probes + Probes *ServerGroupProbesSpec `json:"probes,omitempty"` + // PriorityClassName specifies a priority class name + PriorityClassName string `json:"priorityClassName,omitempty"` + // VolumeClaimTemplate specifies a template for volume claims + VolumeClaimTemplate *v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"` + // Sidecars specifies a list of additional containers to be started + Sidecars []v1.Container `json:"sidecars,omitempty"` +} + +// ServerGroupProbesSpec contains specification for probes for pods of the server group +type ServerGroupProbesSpec struct { + // LivenessProbeDisabled if true livenessProbes are disabled + LivenessProbeDisabled *bool `json:"livenessProbeDisabled,omitempty"` + // LivenessProbeDisabled if specified the given probes is used as liveness probe + //LivenessProbeOverride *v1.Probe `json:"LivenessProbeOverride,omitempty"` + // LivenessProbeDisabled if true readinessProbes are disabled + ReadinessProbeDisabled *bool `json:"ReadinessProbeDisabled,omitempty"` + // ReadinessProbeOverride if specified the given probes is used as readiness probe + //ReadinessProbeOverride *v1.Probe `json:"ReadinessProbeOverride,omitempty"` +} + +// // HasLivenessProbeOverride returns true if a livenessprobe override is set +// func (s ServerGroupProbesSpec) HasLivenessProbeOverride() bool { +// return s.LivenessProbeOverride != nil +// } + +// // HasReadinessProbeOverride returns true if a readinessprobe override is set +// func (s ServerGroupProbesSpec) HasReadinessProbeOverride() bool { +// return s.ReadinessProbeOverride != nil +// } + +// GetSidecars returns a list of sidecars the use wish to add +func (s ServerGroupSpec) GetSidecars() []v1.Container { + return s.Sidecars +} + +// IsLivenessProbeDisabled returns true if liveness probes are disabled +func (s ServerGroupProbesSpec) IsLivenessProbeDisabled() bool { + return util.BoolOrDefault(s.LivenessProbeDisabled) +} + +// IsReadinessProbeDisabled returns true if readiness probes are disabled +func (s ServerGroupProbesSpec) IsReadinessProbeDisabled() bool { + return util.BoolOrDefault(s.ReadinessProbeDisabled) +} + +// HasVolumeClaimTemplate returns whether there is a volumeClaimTemplate or not +func (s ServerGroupSpec) HasVolumeClaimTemplate() bool { + return s.VolumeClaimTemplate != nil +} + +// GetVolumeClaimTemplate returns a pointer to a volume claim template or nil if none is specified +func (s ServerGroupSpec) GetVolumeClaimTemplate() *v1.PersistentVolumeClaim { + return s.VolumeClaimTemplate +} + +// GetCount returns the value of count. +func (s ServerGroupSpec) GetCount() int { + return util.IntOrDefault(s.Count) +} + +// GetMinCount returns MinCount or 1 if not set +func (s ServerGroupSpec) GetMinCount() int { + return util.IntOrDefault(s.MinCount, 1) +} + +// GetMaxCount returns MaxCount or +func (s ServerGroupSpec) GetMaxCount() int { + return util.IntOrDefault(s.MaxCount, math.MaxInt32) +} + +// GetNodeSelector returns the selectors for nodes of this group +func (s ServerGroupSpec) GetNodeSelector() map[string]string { + return s.NodeSelector +} + +// GetArgs returns the value of args. +func (s ServerGroupSpec) GetArgs() []string { + return s.Args +} + +// GetStorageClassName returns the value of storageClassName. +func (s ServerGroupSpec) GetStorageClassName() string { + return util.StringOrDefault(s.StorageClassName) +} + +// GetTolerations returns the value of tolerations. +func (s ServerGroupSpec) GetTolerations() []v1.Toleration { + return s.Tolerations +} + +// GetServiceAccountName returns the value of serviceAccountName. +func (s ServerGroupSpec) GetServiceAccountName() string { + return util.StringOrDefault(s.ServiceAccountName) +} + +// HasProbesSpec returns true if Probes is non nil +func (s ServerGroupSpec) HasProbesSpec() bool { + return s.Probes != nil +} + +// GetProbesSpec returns the Probes spec or the nil value if not set +func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec { + if s.HasProbesSpec() { + return *s.Probes + } + return ServerGroupProbesSpec{} +} + +// Validate the given group spec +func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error { + if used { + minCount := 1 + if env == EnvironmentProduction { + // Set validation boundaries for production mode + switch group { + case ServerGroupSingle: + if mode == DeploymentModeActiveFailover { + minCount = 2 + } + case ServerGroupAgents: + minCount = 3 + case ServerGroupDBServers, ServerGroupCoordinators, ServerGroupSyncMasters, ServerGroupSyncWorkers: + minCount = 2 + } + } else { + // Set validation boundaries for development mode + switch group { + case ServerGroupSingle: + if mode == DeploymentModeActiveFailover { + minCount = 2 + } + case ServerGroupDBServers: + minCount = 2 + } + } + if s.GetMinCount() > s.GetMaxCount() { + return maskAny(errors.Wrapf(ValidationError, "Invalid min/maxCount. Min (%d) bigger than Max (%d)", s.GetMinCount(), s.GetMaxCount())) + } + if s.GetCount() < s.GetMinCount() { + return maskAny(errors.Wrapf(ValidationError, "Invalid count value %d. Expected >= %d", s.GetCount(), s.GetMinCount())) + } + if s.GetCount() > s.GetMaxCount() { + return maskAny(errors.Wrapf(ValidationError, "Invalid count value %d. Expected <= %d", s.GetCount(), s.GetMaxCount())) + } + if s.GetCount() < minCount { + return maskAny(errors.Wrapf(ValidationError, "Invalid count value %d. Expected >= %d (implicit minimum; by deployment mode)", s.GetCount(), minCount)) + } + if s.GetCount() > 1 && group == ServerGroupSingle && mode == DeploymentModeSingle { + return maskAny(errors.Wrapf(ValidationError, "Invalid count value %d. Expected 1", s.GetCount())) + } + if name := s.GetServiceAccountName(); name != "" { + if err := k8sutil.ValidateOptionalResourceName(name); err != nil { + return maskAny(errors.Wrapf(ValidationError, "Invalid serviceAccountName: %s", err)) + } + } + if name := s.GetStorageClassName(); name != "" { + if err := k8sutil.ValidateOptionalResourceName(name); err != nil { + return maskAny(errors.Wrapf(ValidationError, "Invalid storageClassName: %s", err)) + } + } + for _, arg := range s.Args { + parts := strings.Split(arg, "=") + optionKey := strings.TrimSpace(parts[0]) + if group.IsArangod() { + if arangod_options.IsCriticalOption(optionKey) { + return maskAny(errors.Wrapf(ValidationError, "Critical option '%s' cannot be overriden", optionKey)) + } + } else if group.IsArangosync() { + if arangosync_options.IsCriticalOption(optionKey) { + return maskAny(errors.Wrapf(ValidationError, "Critical option '%s' cannot be overriden", optionKey)) + } + } + } + } else if s.GetCount() != 0 { + return maskAny(errors.Wrapf(ValidationError, "Invalid count value %d for un-used group. Expected 0", s.GetCount())) + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *ServerGroupSpec) SetDefaults(group ServerGroup, used bool, mode DeploymentMode) { + if s.GetCount() == 0 && used { + switch group { + case ServerGroupSingle: + if mode == DeploymentModeSingle { + s.Count = util.NewInt(1) // Single server + } else { + s.Count = util.NewInt(2) // ActiveFailover + } + default: + s.Count = util.NewInt(3) + } + } else if s.GetCount() > 0 && !used { + s.Count = nil + s.MinCount = nil + s.MaxCount = nil + } + if !s.HasVolumeClaimTemplate() { + if _, found := s.Resources.Requests[v1.ResourceStorage]; !found { + switch group { + case ServerGroupSingle, ServerGroupAgents, ServerGroupDBServers: + volumeMode := v1.PersistentVolumeFilesystem + s.VolumeClaimTemplate = &v1.PersistentVolumeClaim{ + Spec: v1.PersistentVolumeClaimSpec{ + AccessModes: []v1.PersistentVolumeAccessMode{ + v1.ReadWriteOnce, + }, + VolumeMode: &volumeMode, + Resources: v1.ResourceRequirements{ + Requests: v1.ResourceList{ + v1.ResourceStorage: resource.MustParse("8Gi"), + }, + }, + }, + } + } + } + } +} + +// setDefaultsFromResourceList fills unspecified fields with a value from given source spec. +func setDefaultsFromResourceList(s *v1.ResourceList, source v1.ResourceList) { + for k, v := range source { + if *s == nil { + *s = make(v1.ResourceList) + } + if _, found := (*s)[k]; !found { + (*s)[k] = v + } + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *ServerGroupSpec) SetDefaultsFrom(source ServerGroupSpec) { + if s.Count == nil { + s.Count = util.NewIntOrNil(source.Count) + } + if s.MinCount == nil { + s.MinCount = util.NewIntOrNil(source.MinCount) + } + if s.MaxCount == nil { + s.MaxCount = util.NewIntOrNil(source.MaxCount) + } + if s.Args == nil { + s.Args = source.Args + } + if s.StorageClassName == nil { + s.StorageClassName = util.NewStringOrNil(source.StorageClassName) + } + if s.Tolerations == nil { + s.Tolerations = source.Tolerations + } + if s.ServiceAccountName == nil { + s.ServiceAccountName = util.NewStringOrNil(source.ServiceAccountName) + } + if s.NodeSelector == nil { + s.NodeSelector = source.NodeSelector + } + setDefaultsFromResourceList(&s.Resources.Limits, source.Resources.Limits) + setDefaultsFromResourceList(&s.Resources.Requests, source.Resources.Requests) + if s.VolumeClaimTemplate == nil { + s.VolumeClaimTemplate = source.VolumeClaimTemplate.DeepCopy() + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +func (s ServerGroupSpec) ResetImmutableFields(group ServerGroup, fieldPrefix string, target *ServerGroupSpec) []string { + var resetFields []string + if group == ServerGroupAgents { + if s.GetCount() != target.GetCount() { + target.Count = util.NewIntOrNil(s.Count) + resetFields = append(resetFields, fieldPrefix+".count") + } + } + if s.HasVolumeClaimTemplate() != target.HasVolumeClaimTemplate() { + target.VolumeClaimTemplate = s.GetVolumeClaimTemplate() + resetFields = append(resetFields, fieldPrefix+".volumeClaimTemplate") + } + return resetFields +} diff --git a/pkg/apis/deployment/v1/server_group_spec_test.go b/pkg/apis/deployment/v1/server_group_spec_test.go new file mode 100644 index 000000000..3d2d9c9b0 --- /dev/null +++ b/pkg/apis/deployment/v1/server_group_spec_test.go @@ -0,0 +1,133 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestServerGroupSpecValidateCount(t *testing.T) { + // Valid + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupSingle, false, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(3)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(3)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(6)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(3)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(3)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentProduction)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupSyncWorkers, true, DeploymentModeCluster, EnvironmentProduction)) + + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2), MinCount: util.NewInt(2), MaxCount: util.NewInt(5)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1), MaxCount: util.NewInt(5)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(6), MinCount: util.NewInt(2)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(5), MinCount: util.NewInt(5), MaxCount: util.NewInt(5)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + + // Invalid + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupSingle, false, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupSingle, true, DeploymentModeActiveFailover, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(0)}.Validate(ServerGroupSyncWorkers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(-1)}.Validate(ServerGroupSyncWorkers, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupAgents, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(2)}.Validate(ServerGroupAgents, true, DeploymentModeActiveFailover, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupDBServers, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentProduction)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1)}.Validate(ServerGroupSyncWorkers, true, DeploymentModeCluster, EnvironmentProduction)) + + assert.Error(t, ServerGroupSpec{Count: util.NewInt(2), MinCount: util.NewInt(5), MaxCount: util.NewInt(1)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(6), MaxCount: util.NewInt(5)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1), MinCount: util.NewInt(2)}.Validate(ServerGroupCoordinators, true, DeploymentModeCluster, EnvironmentDevelopment)) + +} + +func TestServerGroupSpecDefault(t *testing.T) { + def := func(spec ServerGroupSpec, group ServerGroup, used bool, mode DeploymentMode) ServerGroupSpec { + spec.SetDefaults(group, used, mode) + return spec + } + + assert.Equal(t, 1, def(ServerGroupSpec{}, ServerGroupSingle, true, DeploymentModeSingle).GetCount()) + assert.Equal(t, 2, def(ServerGroupSpec{}, ServerGroupSingle, true, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSingle, false, DeploymentModeCluster).GetCount()) + + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupAgents, false, DeploymentModeSingle).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupAgents, true, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupAgents, true, DeploymentModeCluster).GetCount()) + + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupDBServers, false, DeploymentModeSingle).GetCount()) + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupDBServers, false, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupDBServers, true, DeploymentModeCluster).GetCount()) + + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupCoordinators, false, DeploymentModeSingle).GetCount()) + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupCoordinators, false, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupCoordinators, true, DeploymentModeCluster).GetCount()) + + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSyncMasters, false, DeploymentModeSingle).GetCount()) + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSyncMasters, false, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupSyncMasters, true, DeploymentModeCluster).GetCount()) + + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSyncWorkers, false, DeploymentModeSingle).GetCount()) + assert.Equal(t, 0, def(ServerGroupSpec{}, ServerGroupSyncWorkers, false, DeploymentModeActiveFailover).GetCount()) + assert.Equal(t, 3, def(ServerGroupSpec{}, ServerGroupSyncWorkers, true, DeploymentModeCluster).GetCount()) + + for _, g := range AllServerGroups { + assert.Equal(t, 0, len(def(ServerGroupSpec{}, g, true, DeploymentModeSingle).Args)) + assert.Equal(t, "", def(ServerGroupSpec{}, g, true, DeploymentModeSingle).GetStorageClassName()) + } +} + +func TestServerGroupSpecValidateArgs(t *testing.T) { + // Valid + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{}}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--master.endpoint"}}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{}}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Nil(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--server.authentication=true"}}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) + // Invalid + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--server.authentication=true"}}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--server.authentication", "true"}}.Validate(ServerGroupSingle, true, DeploymentModeSingle, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--master.endpoint=http://something"}}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) + assert.Error(t, ServerGroupSpec{Count: util.NewInt(1), Args: []string{"--mq.type=strange"}}.Validate(ServerGroupSyncMasters, true, DeploymentModeCluster, EnvironmentDevelopment)) +} diff --git a/pkg/apis/deployment/v1/server_group_test.go b/pkg/apis/deployment/v1/server_group_test.go new file mode 100644 index 000000000..b40f0e82e --- /dev/null +++ b/pkg/apis/deployment/v1/server_group_test.go @@ -0,0 +1,65 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestServerGroupAsRole(t *testing.T) { + assert.Equal(t, "single", ServerGroupSingle.AsRole()) + assert.Equal(t, "agent", ServerGroupAgents.AsRole()) + assert.Equal(t, "dbserver", ServerGroupDBServers.AsRole()) + assert.Equal(t, "coordinator", ServerGroupCoordinators.AsRole()) + assert.Equal(t, "syncmaster", ServerGroupSyncMasters.AsRole()) + assert.Equal(t, "syncworker", ServerGroupSyncWorkers.AsRole()) +} + +func TestServerGroupAsRoleAbbreviated(t *testing.T) { + assert.Equal(t, "sngl", ServerGroupSingle.AsRoleAbbreviated()) + assert.Equal(t, "agnt", ServerGroupAgents.AsRoleAbbreviated()) + assert.Equal(t, "prmr", ServerGroupDBServers.AsRoleAbbreviated()) + assert.Equal(t, "crdn", ServerGroupCoordinators.AsRoleAbbreviated()) + assert.Equal(t, "syma", ServerGroupSyncMasters.AsRoleAbbreviated()) + assert.Equal(t, "sywo", ServerGroupSyncWorkers.AsRoleAbbreviated()) +} + +func TestServerGroupIsArangod(t *testing.T) { + assert.True(t, ServerGroupSingle.IsArangod()) + assert.True(t, ServerGroupAgents.IsArangod()) + assert.True(t, ServerGroupDBServers.IsArangod()) + assert.True(t, ServerGroupCoordinators.IsArangod()) + assert.False(t, ServerGroupSyncMasters.IsArangod()) + assert.False(t, ServerGroupSyncWorkers.IsArangod()) +} + +func TestServerGroupIsArangosync(t *testing.T) { + assert.False(t, ServerGroupSingle.IsArangosync()) + assert.False(t, ServerGroupAgents.IsArangosync()) + assert.False(t, ServerGroupDBServers.IsArangosync()) + assert.False(t, ServerGroupCoordinators.IsArangosync()) + assert.True(t, ServerGroupSyncMasters.IsArangosync()) + assert.True(t, ServerGroupSyncWorkers.IsArangosync()) +} diff --git a/pkg/apis/deployment/v1/storage_engine.go b/pkg/apis/deployment/v1/storage_engine.go new file mode 100644 index 000000000..fda1c8167 --- /dev/null +++ b/pkg/apis/deployment/v1/storage_engine.go @@ -0,0 +1,80 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "strings" + + "github.com/pkg/errors" +) + +// StorageEngine specifies the type of storage engine used by the cluster +type StorageEngine string + +const ( + // StorageEngineMMFiles yields a cluster using the mmfiles storage engine + StorageEngineMMFiles StorageEngine = "MMFiles" + // StorageEngineRocksDB yields a cluster using the rocksdb storage engine + StorageEngineRocksDB StorageEngine = "RocksDB" +) + +// Validate the storage engine. +// Return errors when validation fails, nil on success. +func (se StorageEngine) Validate() error { + switch se { + case StorageEngineMMFiles, StorageEngineRocksDB: + return nil + default: + return maskAny(errors.Wrapf(ValidationError, "Unknown storage engine: '%s'", string(se))) + } +} + +// AsArangoArgument returns the value for the given storage engine as it is to be used +// for arangod's --server.storage-engine option. +func (se StorageEngine) AsArangoArgument() string { + return strings.ToLower(string(se)) +} + +// NewStorageEngine returns a reference to a string with given value. +func NewStorageEngine(input StorageEngine) *StorageEngine { + return &input +} + +// NewStorageEngineOrNil returns nil if input is nil, otherwise returns a clone of the given value. +func NewStorageEngineOrNil(input *StorageEngine) *StorageEngine { + if input == nil { + return nil + } + return NewStorageEngine(*input) +} + +// StorageEngineOrDefault returns the default value (or empty string) if input is nil, otherwise returns the referenced value. +func StorageEngineOrDefault(input *StorageEngine, defaultValue ...StorageEngine) StorageEngine { + if input == nil { + if len(defaultValue) > 0 { + return defaultValue[0] + } + return "" + } + return *input +} diff --git a/pkg/apis/deployment/v1/storage_engine_test.go b/pkg/apis/deployment/v1/storage_engine_test.go new file mode 100644 index 000000000..fc87ff927 --- /dev/null +++ b/pkg/apis/deployment/v1/storage_engine_test.go @@ -0,0 +1,41 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestStorageEngineValidate(t *testing.T) { + // Valid + assert.Nil(t, StorageEngine("MMFiles").Validate()) + assert.Nil(t, StorageEngine("RocksDB").Validate()) + + // Not valid + assert.Error(t, StorageEngine("").Validate()) + assert.Error(t, StorageEngine(" mmfiles").Validate()) + assert.Error(t, StorageEngine("mmfiles").Validate()) + assert.Error(t, StorageEngine("rocksdb").Validate()) +} diff --git a/pkg/apis/deployment/v1/sync_authentication_spec.go b/pkg/apis/deployment/v1/sync_authentication_spec.go new file mode 100644 index 000000000..19738a075 --- /dev/null +++ b/pkg/apis/deployment/v1/sync_authentication_spec.go @@ -0,0 +1,87 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// SyncAuthenticationSpec holds dc2dc sync authentication specific configuration settings +type SyncAuthenticationSpec struct { + JWTSecretName *string `json:"jwtSecretName,omitempty"` // JWT secret for sync masters + ClientCASecretName *string `json:"clientCASecretName,omitempty"` // Secret containing client authentication CA +} + +// GetJWTSecretName returns the value of jwtSecretName. +func (s SyncAuthenticationSpec) GetJWTSecretName() string { + return util.StringOrDefault(s.JWTSecretName) +} + +// GetClientCASecretName returns the value of clientCASecretName. +func (s SyncAuthenticationSpec) GetClientCASecretName() string { + return util.StringOrDefault(s.ClientCASecretName) +} + +// Validate the given spec +func (s SyncAuthenticationSpec) Validate() error { + if err := k8sutil.ValidateResourceName(s.GetJWTSecretName()); err != nil { + return maskAny(err) + } + if err := k8sutil.ValidateResourceName(s.GetClientCASecretName()); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *SyncAuthenticationSpec) SetDefaults(defaultJWTSecretName, defaultClientCASecretName string) { + if s.GetJWTSecretName() == "" { + // Note that we don't check for nil here, since even a specified, but empty + // string should result in the default value. + s.JWTSecretName = util.NewString(defaultJWTSecretName) + } + if s.GetClientCASecretName() == "" { + // Note that we don't check for nil here, since even a specified, but empty + // string should result in the default value. + s.ClientCASecretName = util.NewString(defaultClientCASecretName) + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *SyncAuthenticationSpec) SetDefaultsFrom(source SyncAuthenticationSpec) { + if s.JWTSecretName == nil { + s.JWTSecretName = util.NewStringOrNil(source.JWTSecretName) + } + if s.ClientCASecretName == nil { + s.ClientCASecretName = util.NewStringOrNil(source.ClientCASecretName) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s SyncAuthenticationSpec) ResetImmutableFields(fieldPrefix string, target *SyncAuthenticationSpec) []string { + var resetFields []string + return resetFields +} diff --git a/pkg/apis/deployment/v1/sync_external_access_spec.go b/pkg/apis/deployment/v1/sync_external_access_spec.go new file mode 100644 index 000000000..1b1942266 --- /dev/null +++ b/pkg/apis/deployment/v1/sync_external_access_spec.go @@ -0,0 +1,102 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "fmt" + "net" + "net/url" + "strconv" + + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" +) + +// SyncExternalAccessSpec holds configuration for the external access provided for the sync deployment. +type SyncExternalAccessSpec struct { + ExternalAccessSpec + MasterEndpoint []string `json:"masterEndpoint,omitempty"` + AccessPackageSecretNames []string `json:"accessPackageSecretNames,omitempty"` +} + +// GetMasterEndpoint returns the value of masterEndpoint. +func (s SyncExternalAccessSpec) GetMasterEndpoint() []string { + return s.MasterEndpoint +} + +// GetAccessPackageSecretNames returns the value of accessPackageSecretNames. +func (s SyncExternalAccessSpec) GetAccessPackageSecretNames() []string { + return s.AccessPackageSecretNames +} + +// ResolveMasterEndpoint returns the value of `--master.endpoint` option passed to arangosync. +func (s SyncExternalAccessSpec) ResolveMasterEndpoint(syncServiceHostName string, syncServicePort int) []string { + if len(s.MasterEndpoint) > 0 { + return s.MasterEndpoint + } + if ip := s.GetLoadBalancerIP(); ip != "" { + syncServiceHostName = ip + } + return []string{"https://" + net.JoinHostPort(syncServiceHostName, strconv.Itoa(syncServicePort))} +} + +// Validate the given spec +func (s SyncExternalAccessSpec) Validate() error { + if err := s.ExternalAccessSpec.Validate(); err != nil { + return maskAny(err) + } + for _, ep := range s.MasterEndpoint { + if _, err := url.Parse(ep); err != nil { + return maskAny(fmt.Errorf("Failed to parse master endpoint '%s': %s", ep, err)) + } + } + for _, name := range s.AccessPackageSecretNames { + if err := k8sutil.ValidateResourceName(name); err != nil { + return maskAny(fmt.Errorf("Invalid name '%s' in accessPackageSecretNames: %s", name, err)) + } + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *SyncExternalAccessSpec) SetDefaults() { + s.ExternalAccessSpec.SetDefaults() +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *SyncExternalAccessSpec) SetDefaultsFrom(source SyncExternalAccessSpec) { + s.ExternalAccessSpec.SetDefaultsFrom(source.ExternalAccessSpec) + if s.MasterEndpoint == nil && source.MasterEndpoint != nil { + s.MasterEndpoint = append([]string{}, source.MasterEndpoint...) + } + if s.AccessPackageSecretNames == nil && source.AccessPackageSecretNames != nil { + s.AccessPackageSecretNames = append([]string{}, source.AccessPackageSecretNames...) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s SyncExternalAccessSpec) ResetImmutableFields(fieldPrefix string, target *SyncExternalAccessSpec) []string { + result := s.ExternalAccessSpec.ResetImmutableFields(fieldPrefix, &s.ExternalAccessSpec) + return result +} diff --git a/pkg/apis/deployment/v1/sync_spec.go b/pkg/apis/deployment/v1/sync_spec.go new file mode 100644 index 000000000..b3c64867a --- /dev/null +++ b/pkg/apis/deployment/v1/sync_spec.go @@ -0,0 +1,116 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/pkg/errors" + + "github.com/arangodb/kube-arangodb/pkg/util" +) + +// SyncSpec holds dc2dc replication specific configuration settings +type SyncSpec struct { + Enabled *bool `json:"enabled,omitempty"` + + ExternalAccess SyncExternalAccessSpec `json:"externalAccess"` + Authentication SyncAuthenticationSpec `json:"auth"` + TLS TLSSpec `json:"tls"` + Monitoring MonitoringSpec `json:"monitoring"` + Image *string `json:"image"` +} + +// IsEnabled returns the value of enabled. +func (s SyncSpec) IsEnabled() bool { + return util.BoolOrDefault(s.Enabled) +} + +// GetSyncImage returns the syncer image or empty string +func (s SyncSpec) GetSyncImage() string { + return util.StringOrDefault(s.Image) +} + +// HasSyncImage returns whether a special sync image is set +func (s SyncSpec) HasSyncImage() bool { + return s.GetSyncImage() != "" +} + +// Validate the given spec +func (s SyncSpec) Validate(mode DeploymentMode) error { + if s.IsEnabled() && !mode.SupportsSync() { + return maskAny(errors.Wrapf(ValidationError, "Cannot enable sync with mode: '%s'", mode)) + } + if s.IsEnabled() { + if err := s.ExternalAccess.Validate(); err != nil { + return maskAny(err) + } + if err := s.Authentication.Validate(); err != nil { + return maskAny(err) + } + if err := s.TLS.Validate(); err != nil { + return maskAny(err) + } + } + if err := s.Monitoring.Validate(); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *SyncSpec) SetDefaults(defaultJWTSecretName, defaultClientAuthCASecretName, defaultTLSCASecretName, defaultMonitoringSecretName string) { + s.ExternalAccess.SetDefaults() + s.Authentication.SetDefaults(defaultJWTSecretName, defaultClientAuthCASecretName) + s.TLS.SetDefaults(defaultTLSCASecretName) + s.Monitoring.SetDefaults(defaultMonitoringSecretName) +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *SyncSpec) SetDefaultsFrom(source SyncSpec) { + if s.Enabled == nil { + s.Enabled = util.NewBoolOrNil(source.Enabled) + } + if s.Image == nil { + s.Image = util.NewStringOrNil(source.Image) + } + s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess) + s.Authentication.SetDefaultsFrom(source.Authentication) + s.TLS.SetDefaultsFrom(source.TLS) + s.Monitoring.SetDefaultsFrom(source.Monitoring) +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to given field prefix. +func (s SyncSpec) ResetImmutableFields(fieldPrefix string, target *SyncSpec) []string { + var resetFields []string + if list := s.ExternalAccess.ResetImmutableFields(fieldPrefix+".externalAccess", &target.ExternalAccess); len(list) > 0 { + resetFields = append(resetFields, list...) + } + if list := s.Authentication.ResetImmutableFields(fieldPrefix+".auth", &target.Authentication); len(list) > 0 { + resetFields = append(resetFields, list...) + } + if s.GetSyncImage() != target.GetSyncImage() { + resetFields = append(resetFields, fieldPrefix+".image") + } + return resetFields +} diff --git a/pkg/apis/deployment/v1/sync_spec_test.go b/pkg/apis/deployment/v1/sync_spec_test.go new file mode 100644 index 000000000..fc04fa8e6 --- /dev/null +++ b/pkg/apis/deployment/v1/sync_spec_test.go @@ -0,0 +1,105 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestSyncSpecValidate(t *testing.T) { + // Valid + auth := SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("foo-client")} + tls := TLSSpec{CASecretName: util.NewString("None")} + assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeSingle)) + assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeActiveFailover)) + assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeCluster)) + assert.Nil(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeCluster)) + + // Not valid + assert.Error(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeSingle)) + assert.Error(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeActiveFailover)) +} + +func TestSyncSpecSetDefaults(t *testing.T) { + def := func(spec SyncSpec) SyncSpec { + spec.SetDefaults("test-jwt", "test-client-auth-ca", "test-tls-ca", "test-mon") + return spec + } + + assert.False(t, def(SyncSpec{}).IsEnabled()) + assert.False(t, def(SyncSpec{Enabled: util.NewBool(false)}).IsEnabled()) + assert.True(t, def(SyncSpec{Enabled: util.NewBool(true)}).IsEnabled()) + assert.Equal(t, "test-jwt", def(SyncSpec{}).Authentication.GetJWTSecretName()) + assert.Equal(t, "test-mon", def(SyncSpec{}).Monitoring.GetTokenSecretName()) + assert.Equal(t, "foo", def(SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo")}}).Authentication.GetJWTSecretName()) +} + +func TestSyncSpecResetImmutableFields(t *testing.T) { + tests := []struct { + Original SyncSpec + Target SyncSpec + Expected SyncSpec + Result []string + }{ + // Valid "changes" + { + SyncSpec{Enabled: util.NewBool(false)}, + SyncSpec{Enabled: util.NewBool(true)}, + SyncSpec{Enabled: util.NewBool(true)}, + nil, + }, + { + SyncSpec{Enabled: util.NewBool(true)}, + SyncSpec{Enabled: util.NewBool(false)}, + SyncSpec{Enabled: util.NewBool(false)}, + nil, + }, + { + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("None"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("None"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("None"), ClientCASecretName: util.NewString("some")}}, + nil, + }, + { + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("some")}}, + nil, + }, + { + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo2"), ClientCASecretName: util.NewString("some")}}, + SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo2"), ClientCASecretName: util.NewString("some")}}, + nil, + }, + } + + for _, test := range tests { + result := test.Original.ResetImmutableFields("test", &test.Target) + assert.Equal(t, test.Result, result) + assert.Equal(t, test.Expected, test.Target) + } +} diff --git a/pkg/apis/deployment/v1/tls_spec.go b/pkg/apis/deployment/v1/tls_spec.go new file mode 100644 index 000000000..3146cda4d --- /dev/null +++ b/pkg/apis/deployment/v1/tls_spec.go @@ -0,0 +1,128 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "fmt" + "net" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/arangodb/kube-arangodb/pkg/util/validation" +) + +const ( + defaultTLSTTL = Duration("2610h") // About 3 month +) + +// TLSSpec holds TLS specific configuration settings +type TLSSpec struct { + CASecretName *string `json:"caSecretName,omitempty"` + AltNames []string `json:"altNames,omitempty"` + TTL *Duration `json:"ttl,omitempty"` +} + +const ( + // CASecretNameDisabled is the value of CASecretName to use for disabling authentication. + CASecretNameDisabled = "None" +) + +// GetCASecretName returns the value of caSecretName. +func (s TLSSpec) GetCASecretName() string { + return util.StringOrDefault(s.CASecretName) +} + +// GetAltNames returns the value of altNames. +func (s TLSSpec) GetAltNames() []string { + return s.AltNames +} + +// GetTTL returns the value of ttl. +func (s TLSSpec) GetTTL() Duration { + return DurationOrDefault(s.TTL) +} + +// IsSecure returns true when a CA secret has been set, false otherwise. +func (s TLSSpec) IsSecure() bool { + return s.GetCASecretName() != CASecretNameDisabled +} + +// GetParsedAltNames splits the list of AltNames into DNS names, IP addresses & email addresses. +// When an entry is not valid for any of those categories, an error is returned. +func (s TLSSpec) GetParsedAltNames() (dnsNames, ipAddresses, emailAddresses []string, err error) { + for _, name := range s.GetAltNames() { + if net.ParseIP(name) != nil { + ipAddresses = append(ipAddresses, name) + } else if validation.IsValidDNSName(name) { + dnsNames = append(dnsNames, name) + } else if validation.IsValidEmailAddress(name) { + emailAddresses = append(emailAddresses, name) + } else { + return nil, nil, nil, maskAny(fmt.Errorf("'%s' is not a valid alternate name", name)) + } + } + return dnsNames, ipAddresses, emailAddresses, nil +} + +// Validate the given spec +func (s TLSSpec) Validate() error { + if s.IsSecure() { + if err := k8sutil.ValidateResourceName(s.GetCASecretName()); err != nil { + return maskAny(err) + } + if _, _, _, err := s.GetParsedAltNames(); err != nil { + return maskAny(err) + } + if err := s.GetTTL().Validate(); err != nil { + return maskAny(err) + } + } + return nil +} + +// SetDefaults fills in missing defaults +func (s *TLSSpec) SetDefaults(defaultCASecretName string) { + if s.GetCASecretName() == "" { + // Note that we don't check for nil here, since even a specified, but empty + // string should result in the default value. + s.CASecretName = util.NewString(defaultCASecretName) + } + if s.GetTTL() == "" { + // Note that we don't check for nil here, since even a specified, but zero + // should result in the default value. + s.TTL = NewDuration(defaultTLSTTL) + } +} + +// SetDefaultsFrom fills unspecified fields with a value from given source spec. +func (s *TLSSpec) SetDefaultsFrom(source TLSSpec) { + if s.CASecretName == nil { + s.CASecretName = util.NewStringOrNil(source.CASecretName) + } + if s.AltNames == nil { + s.AltNames = source.AltNames + } + if s.TTL == nil { + s.TTL = NewDurationOrNil(source.TTL) + } +} diff --git a/pkg/apis/deployment/v1/tls_spec_test.go b/pkg/apis/deployment/v1/tls_spec_test.go new file mode 100644 index 000000000..23fa63e15 --- /dev/null +++ b/pkg/apis/deployment/v1/tls_spec_test.go @@ -0,0 +1,66 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + "time" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/stretchr/testify/assert" +) + +func TestTLSSpecValidate(t *testing.T) { + // Valid + assert.Nil(t, TLSSpec{CASecretName: util.NewString("foo")}.Validate()) + assert.Nil(t, TLSSpec{CASecretName: util.NewString("None")}.Validate()) + assert.Nil(t, TLSSpec{CASecretName: util.NewString("None"), AltNames: []string{}}.Validate()) + assert.Nil(t, TLSSpec{CASecretName: util.NewString("None"), AltNames: []string{"foo"}}.Validate()) + assert.Nil(t, TLSSpec{CASecretName: util.NewString("None"), AltNames: []string{"email@example.com", "127.0.0.1"}}.Validate()) + + // Not valid + assert.Error(t, TLSSpec{CASecretName: nil}.Validate()) + assert.Error(t, TLSSpec{CASecretName: util.NewString("")}.Validate()) + assert.Error(t, TLSSpec{CASecretName: util.NewString("Foo")}.Validate()) + assert.Error(t, TLSSpec{CASecretName: util.NewString("foo"), AltNames: []string{"@@"}}.Validate()) +} + +func TestTLSSpecIsSecure(t *testing.T) { + assert.True(t, TLSSpec{CASecretName: util.NewString("")}.IsSecure()) + assert.True(t, TLSSpec{CASecretName: util.NewString("foo")}.IsSecure()) + assert.False(t, TLSSpec{CASecretName: util.NewString("None")}.IsSecure()) +} + +func TestTLSSpecSetDefaults(t *testing.T) { + def := func(spec TLSSpec) TLSSpec { + spec.SetDefaults("") + return spec + } + + assert.Equal(t, "", def(TLSSpec{}).GetCASecretName()) + assert.Equal(t, "foo", def(TLSSpec{CASecretName: util.NewString("foo")}).GetCASecretName()) + assert.Len(t, def(TLSSpec{}).GetAltNames(), 0) + assert.Len(t, def(TLSSpec{AltNames: []string{"foo.local"}}).GetAltNames(), 1) + assert.Equal(t, defaultTLSTTL, def(TLSSpec{}).GetTTL()) + assert.Equal(t, time.Hour, def(TLSSpec{TTL: NewDuration("1h")}).GetTTL().AsDuration()) +} diff --git a/pkg/apis/deployment/v1/zz_generated.deepcopy.go b/pkg/apis/deployment/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..233fbbb64 --- /dev/null +++ b/pkg/apis/deployment/v1/zz_generated.deepcopy.go @@ -0,0 +1,996 @@ +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Action) DeepCopyInto(out *Action) { + *out = *in + in.CreationTime.DeepCopyInto(&out.CreationTime) + if in.StartTime != nil { + in, out := &in.StartTime, &out.StartTime + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Action. +func (in *Action) DeepCopy() *Action { + if in == nil { + return nil + } + out := new(Action) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoDeployment) DeepCopyInto(out *ArangoDeployment) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeployment. +func (in *ArangoDeployment) DeepCopy() *ArangoDeployment { + if in == nil { + return nil + } + out := new(ArangoDeployment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoDeployment) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoDeploymentList) DeepCopyInto(out *ArangoDeploymentList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ArangoDeployment, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeploymentList. +func (in *ArangoDeploymentList) DeepCopy() *ArangoDeploymentList { + if in == nil { + return nil + } + out := new(ArangoDeploymentList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoDeploymentList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AuthenticationSpec) DeepCopyInto(out *AuthenticationSpec) { + *out = *in + if in.JWTSecretName != nil { + in, out := &in.JWTSecretName, &out.JWTSecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuthenticationSpec. +func (in *AuthenticationSpec) DeepCopy() *AuthenticationSpec { + if in == nil { + return nil + } + out := new(AuthenticationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BootstrapSpec) DeepCopyInto(out *BootstrapSpec) { + *out = *in + if in.PasswordSecretNames != nil { + in, out := &in.PasswordSecretNames, &out.PasswordSecretNames + *out = make(PasswordSecretNameList, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapSpec. +func (in *BootstrapSpec) DeepCopy() *BootstrapSpec { + if in == nil { + return nil + } + out := new(BootstrapSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ChaosSpec) DeepCopyInto(out *ChaosSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Interval != nil { + in, out := &in.Interval, &out.Interval + *out = new(time.Duration) + **out = **in + } + if in.KillPodProbability != nil { + in, out := &in.KillPodProbability, &out.KillPodProbability + *out = new(Percent) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChaosSpec. +func (in *ChaosSpec) DeepCopy() *ChaosSpec { + if in == nil { + return nil + } + out := new(ChaosSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Condition) DeepCopyInto(out *Condition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. +func (in *Condition) DeepCopy() *Condition { + if in == nil { + return nil + } + out := new(Condition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ConditionList) DeepCopyInto(out *ConditionList) { + { + in := &in + *out = make(ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionList. +func (in ConditionList) DeepCopy() ConditionList { + if in == nil { + return nil + } + out := new(ConditionList) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentRestoreResult) DeepCopyInto(out *DeploymentRestoreResult) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentRestoreResult. +func (in *DeploymentRestoreResult) DeepCopy() *DeploymentRestoreResult { + if in == nil { + return nil + } + out := new(DeploymentRestoreResult) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(DeploymentMode) + **out = **in + } + if in.Environment != nil { + in, out := &in.Environment, &out.Environment + *out = new(Environment) + **out = **in + } + if in.StorageEngine != nil { + in, out := &in.StorageEngine, &out.StorageEngine + *out = new(StorageEngine) + **out = **in + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.ImagePullPolicy != nil { + in, out := &in.ImagePullPolicy, &out.ImagePullPolicy + *out = new(v1.PullPolicy) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.DowntimeAllowed != nil { + in, out := &in.DowntimeAllowed, &out.DowntimeAllowed + *out = new(bool) + **out = **in + } + if in.DisableIPv6 != nil { + in, out := &in.DisableIPv6, &out.DisableIPv6 + *out = new(bool) + **out = **in + } + if in.NetworkAttachedVolumes != nil { + in, out := &in.NetworkAttachedVolumes, &out.NetworkAttachedVolumes + *out = new(bool) + **out = **in + } + if in.RestoreFrom != nil { + in, out := &in.RestoreFrom, &out.RestoreFrom + *out = new(string) + **out = **in + } + in.ExternalAccess.DeepCopyInto(&out.ExternalAccess) + in.RocksDB.DeepCopyInto(&out.RocksDB) + in.Authentication.DeepCopyInto(&out.Authentication) + in.TLS.DeepCopyInto(&out.TLS) + in.Sync.DeepCopyInto(&out.Sync) + in.License.DeepCopyInto(&out.License) + in.Metrics.DeepCopyInto(&out.Metrics) + in.Single.DeepCopyInto(&out.Single) + in.Agents.DeepCopyInto(&out.Agents) + in.DBServers.DeepCopyInto(&out.DBServers) + in.Coordinators.DeepCopyInto(&out.Coordinators) + in.SyncMasters.DeepCopyInto(&out.SyncMasters) + in.SyncWorkers.DeepCopyInto(&out.SyncWorkers) + in.Chaos.DeepCopyInto(&out.Chaos) + in.Bootstrap.DeepCopyInto(&out.Bootstrap) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentSpec. +func (in *DeploymentSpec) DeepCopy() *DeploymentSpec { + if in == nil { + return nil + } + out := new(DeploymentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { + *out = *in + if in.Restore != nil { + in, out := &in.Restore, &out.Restore + *out = new(DeploymentRestoreResult) + **out = **in + } + if in.Images != nil { + in, out := &in.Images, &out.Images + *out = make(ImageInfoList, len(*in)) + copy(*out, *in) + } + if in.CurrentImage != nil { + in, out := &in.CurrentImage, &out.CurrentImage + *out = new(ImageInfo) + **out = **in + } + in.Members.DeepCopyInto(&out.Members) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Plan != nil { + in, out := &in.Plan, &out.Plan + *out = make(Plan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.AcceptedSpec != nil { + in, out := &in.AcceptedSpec, &out.AcceptedSpec + *out = new(DeploymentSpec) + (*in).DeepCopyInto(*out) + } + if in.SecretHashes != nil { + in, out := &in.SecretHashes, &out.SecretHashes + *out = new(SecretHashes) + (*in).DeepCopyInto(*out) + } + if in.ForceStatusReload != nil { + in, out := &in.ForceStatusReload, &out.ForceStatusReload + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatus. +func (in *DeploymentStatus) DeepCopy() *DeploymentStatus { + if in == nil { + return nil + } + out := new(DeploymentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentStatusMembers) DeepCopyInto(out *DeploymentStatusMembers) { + *out = *in + if in.Single != nil { + in, out := &in.Single, &out.Single + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Agents != nil { + in, out := &in.Agents, &out.Agents + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.DBServers != nil { + in, out := &in.DBServers, &out.DBServers + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Coordinators != nil { + in, out := &in.Coordinators, &out.Coordinators + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SyncMasters != nil { + in, out := &in.SyncMasters, &out.SyncMasters + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SyncWorkers != nil { + in, out := &in.SyncWorkers, &out.SyncWorkers + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStatusMembers. +func (in *DeploymentStatusMembers) DeepCopy() *DeploymentStatusMembers { + if in == nil { + return nil + } + out := new(DeploymentStatusMembers) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExternalAccessSpec) DeepCopyInto(out *ExternalAccessSpec) { + *out = *in + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(ExternalAccessType) + **out = **in + } + if in.NodePort != nil { + in, out := &in.NodePort, &out.NodePort + *out = new(int) + **out = **in + } + if in.LoadBalancerIP != nil { + in, out := &in.LoadBalancerIP, &out.LoadBalancerIP + *out = new(string) + **out = **in + } + if in.LoadBalancerSourceRanges != nil { + in, out := &in.LoadBalancerSourceRanges, &out.LoadBalancerSourceRanges + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AdvertisedEndpoint != nil { + in, out := &in.AdvertisedEndpoint, &out.AdvertisedEndpoint + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalAccessSpec. +func (in *ExternalAccessSpec) DeepCopy() *ExternalAccessSpec { + if in == nil { + return nil + } + out := new(ExternalAccessSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageInfo) DeepCopyInto(out *ImageInfo) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageInfo. +func (in *ImageInfo) DeepCopy() *ImageInfo { + if in == nil { + return nil + } + out := new(ImageInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ImageInfoList) DeepCopyInto(out *ImageInfoList) { + { + in := &in + *out = make(ImageInfoList, len(*in)) + copy(*out, *in) + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageInfoList. +func (in ImageInfoList) DeepCopy() ImageInfoList { + if in == nil { + return nil + } + out := new(ImageInfoList) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LicenseSpec) DeepCopyInto(out *LicenseSpec) { + *out = *in + if in.SecretName != nil { + in, out := &in.SecretName, &out.SecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LicenseSpec. +func (in *LicenseSpec) DeepCopy() *LicenseSpec { + if in == nil { + return nil + } + out := new(LicenseSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MemberStatus) DeepCopyInto(out *MemberStatus) { + *out = *in + in.CreatedAt.DeepCopyInto(&out.CreatedAt) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RecentTerminations != nil { + in, out := &in.RecentTerminations, &out.RecentTerminations + *out = make([]metav1.Time, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SideCarSpecs != nil { + in, out := &in.SideCarSpecs, &out.SideCarSpecs + *out = make(map[string]v1.Container, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemberStatus. +func (in *MemberStatus) DeepCopy() *MemberStatus { + if in == nil { + return nil + } + out := new(MemberStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in MemberStatusList) DeepCopyInto(out *MemberStatusList) { + { + in := &in + *out = make(MemberStatusList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemberStatusList. +func (in MemberStatusList) DeepCopy() MemberStatusList { + if in == nil { + return nil + } + out := new(MemberStatusList) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsAuthenticationSpec) DeepCopyInto(out *MetricsAuthenticationSpec) { + *out = *in + if in.JWTTokenSecretName != nil { + in, out := &in.JWTTokenSecretName, &out.JWTTokenSecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsAuthenticationSpec. +func (in *MetricsAuthenticationSpec) DeepCopy() *MetricsAuthenticationSpec { + if in == nil { + return nil + } + out := new(MetricsAuthenticationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsSpec) DeepCopyInto(out *MetricsSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + in.Authentication.DeepCopyInto(&out.Authentication) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsSpec. +func (in *MetricsSpec) DeepCopy() *MetricsSpec { + if in == nil { + return nil + } + out := new(MetricsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MonitoringSpec) DeepCopyInto(out *MonitoringSpec) { + *out = *in + if in.TokenSecretName != nil { + in, out := &in.TokenSecretName, &out.TokenSecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringSpec. +func (in *MonitoringSpec) DeepCopy() *MonitoringSpec { + if in == nil { + return nil + } + out := new(MonitoringSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in PasswordSecretNameList) DeepCopyInto(out *PasswordSecretNameList) { + { + in := &in + *out = make(PasswordSecretNameList, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PasswordSecretNameList. +func (in PasswordSecretNameList) DeepCopy() PasswordSecretNameList { + if in == nil { + return nil + } + out := new(PasswordSecretNameList) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Plan) DeepCopyInto(out *Plan) { + { + in := &in + *out = make(Plan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Plan. +func (in Plan) DeepCopy() Plan { + if in == nil { + return nil + } + out := new(Plan) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RocksDBEncryptionSpec) DeepCopyInto(out *RocksDBEncryptionSpec) { + *out = *in + if in.KeySecretName != nil { + in, out := &in.KeySecretName, &out.KeySecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RocksDBEncryptionSpec. +func (in *RocksDBEncryptionSpec) DeepCopy() *RocksDBEncryptionSpec { + if in == nil { + return nil + } + out := new(RocksDBEncryptionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RocksDBSpec) DeepCopyInto(out *RocksDBSpec) { + *out = *in + in.Encryption.DeepCopyInto(&out.Encryption) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RocksDBSpec. +func (in *RocksDBSpec) DeepCopy() *RocksDBSpec { + if in == nil { + return nil + } + out := new(RocksDBSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretHashes) DeepCopyInto(out *SecretHashes) { + *out = *in + if in.Users != nil { + in, out := &in.Users, &out.Users + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretHashes. +func (in *SecretHashes) DeepCopy() *SecretHashes { + if in == nil { + return nil + } + out := new(SecretHashes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerGroupProbesSpec) DeepCopyInto(out *ServerGroupProbesSpec) { + *out = *in + if in.LivenessProbeDisabled != nil { + in, out := &in.LivenessProbeDisabled, &out.LivenessProbeDisabled + *out = new(bool) + **out = **in + } + if in.ReadinessProbeDisabled != nil { + in, out := &in.ReadinessProbeDisabled, &out.ReadinessProbeDisabled + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerGroupProbesSpec. +func (in *ServerGroupProbesSpec) DeepCopy() *ServerGroupProbesSpec { + if in == nil { + return nil + } + out := new(ServerGroupProbesSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) { + *out = *in + if in.Count != nil { + in, out := &in.Count, &out.Count + *out = new(int) + **out = **in + } + if in.MinCount != nil { + in, out := &in.MinCount, &out.MinCount + *out = new(int) + **out = **in + } + if in.MaxCount != nil { + in, out := &in.MaxCount, &out.MaxCount + *out = new(int) + **out = **in + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.StorageClassName != nil { + in, out := &in.StorageClassName, &out.StorageClassName + *out = new(string) + **out = **in + } + in.Resources.DeepCopyInto(&out.Resources) + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ServiceAccountName != nil { + in, out := &in.ServiceAccountName, &out.ServiceAccountName + *out = new(string) + **out = **in + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Probes != nil { + in, out := &in.Probes, &out.Probes + *out = new(ServerGroupProbesSpec) + (*in).DeepCopyInto(*out) + } + if in.VolumeClaimTemplate != nil { + in, out := &in.VolumeClaimTemplate, &out.VolumeClaimTemplate + *out = new(v1.PersistentVolumeClaim) + (*in).DeepCopyInto(*out) + } + if in.Sidecars != nil { + in, out := &in.Sidecars, &out.Sidecars + *out = make([]v1.Container, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerGroupSpec. +func (in *ServerGroupSpec) DeepCopy() *ServerGroupSpec { + if in == nil { + return nil + } + out := new(ServerGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncAuthenticationSpec) DeepCopyInto(out *SyncAuthenticationSpec) { + *out = *in + if in.JWTSecretName != nil { + in, out := &in.JWTSecretName, &out.JWTSecretName + *out = new(string) + **out = **in + } + if in.ClientCASecretName != nil { + in, out := &in.ClientCASecretName, &out.ClientCASecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncAuthenticationSpec. +func (in *SyncAuthenticationSpec) DeepCopy() *SyncAuthenticationSpec { + if in == nil { + return nil + } + out := new(SyncAuthenticationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncExternalAccessSpec) DeepCopyInto(out *SyncExternalAccessSpec) { + *out = *in + in.ExternalAccessSpec.DeepCopyInto(&out.ExternalAccessSpec) + if in.MasterEndpoint != nil { + in, out := &in.MasterEndpoint, &out.MasterEndpoint + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AccessPackageSecretNames != nil { + in, out := &in.AccessPackageSecretNames, &out.AccessPackageSecretNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncExternalAccessSpec. +func (in *SyncExternalAccessSpec) DeepCopy() *SyncExternalAccessSpec { + if in == nil { + return nil + } + out := new(SyncExternalAccessSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SyncSpec) DeepCopyInto(out *SyncSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + in.ExternalAccess.DeepCopyInto(&out.ExternalAccess) + in.Authentication.DeepCopyInto(&out.Authentication) + in.TLS.DeepCopyInto(&out.TLS) + in.Monitoring.DeepCopyInto(&out.Monitoring) + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SyncSpec. +func (in *SyncSpec) DeepCopy() *SyncSpec { + if in == nil { + return nil + } + out := new(SyncSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TLSSpec) DeepCopyInto(out *TLSSpec) { + *out = *in + if in.CASecretName != nil { + in, out := &in.CASecretName, &out.CASecretName + *out = new(string) + **out = **in + } + if in.AltNames != nil { + in, out := &in.AltNames, &out.AltNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TTL != nil { + in, out := &in.TTL, &out.TTL + *out = new(Duration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSSpec. +func (in *TLSSpec) DeepCopy() *TLSSpec { + if in == nil { + return nil + } + out := new(TLSSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/deployment/v1alpha/deployment.go b/pkg/apis/deployment/v1alpha/deployment.go index 7c2fba55b..92fe09ebd 100644 --- a/pkg/apis/deployment/v1alpha/deployment.go +++ b/pkg/apis/deployment/v1alpha/deployment.go @@ -23,6 +23,7 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -53,7 +54,7 @@ func (d *ArangoDeployment) AsOwner() metav1.OwnerReference { trueVar := true return metav1.OwnerReference{ APIVersion: SchemeGroupVersion.String(), - Kind: ArangoDeploymentResourceKind, + Kind: deployment.ArangoDeploymentResourceKind, Name: d.Name, UID: d.UID, Controller: &trueVar, diff --git a/pkg/apis/deployment/v1alpha/register.go b/pkg/apis/deployment/v1alpha/register.go index a335aedcd..8c832bffc 100644 --- a/pkg/apis/deployment/v1alpha/register.go +++ b/pkg/apis/deployment/v1alpha/register.go @@ -23,26 +23,21 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) const ( - ArangoDeploymentCRDName = ArangoDeploymentResourcePlural + "." + groupName - ArangoDeploymentResourceKind = "ArangoDeployment" - ArangoDeploymentResourcePlural = "arangodeployments" - - groupName = "database.arangodb.com" + ArangoDeploymentVersion = "v1alpha" ) var ( SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) AddToScheme = SchemeBuilder.AddToScheme - SchemeGroupVersion = schema.GroupVersion{Group: groupName, Version: "v1alpha"} - - ArangoDeploymentShortNames = []string{"arangodb", "arango"} + SchemeGroupVersion = schema.GroupVersion{Group: deployment.ArangoDeploymentGroupName, Version: ArangoDeploymentVersion} ) // Resource gets an ArangoCluster GroupResource for a specified resource diff --git a/pkg/apis/replication/definitions.go b/pkg/apis/replication/definitions.go new file mode 100644 index 000000000..f93c08a14 --- /dev/null +++ b/pkg/apis/replication/definitions.go @@ -0,0 +1,34 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Adam Janikowski +// + +package replication + +const ( + ArangoDeploymentReplicationResourceKind = "ArangoDeploymentReplication" + ArangoDeploymentReplicationResourcePlural = "arangodeploymentreplications" + ArangoDeploymentReplicationGroupName = "replication.database.arangodb.com" +) + +var ( + ArangoDeploymentReplicationCRDName = ArangoDeploymentReplicationResourcePlural + "." + ArangoDeploymentReplicationGroupName + ArangoDeploymentReplicationShortNames = []string{"arangorepl"} +) \ No newline at end of file diff --git a/pkg/apis/replication/v1/collection_status.go b/pkg/apis/replication/v1/collection_status.go new file mode 100644 index 000000000..26c31474b --- /dev/null +++ b/pkg/apis/replication/v1/collection_status.go @@ -0,0 +1,32 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// CollectionStatus contains the status of a single collection. +type CollectionStatus struct { + // Name of the collection + Name string `json:"name"` + // Replication status per shard. + // The list is ordered by shard index (0..noShards-1) + Shards []ShardStatus `json:"shards,omitempty"` +} diff --git a/pkg/apis/replication/v1/conditions.go b/pkg/apis/replication/v1/conditions.go new file mode 100644 index 000000000..1bfce090a --- /dev/null +++ b/pkg/apis/replication/v1/conditions.go @@ -0,0 +1,131 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ConditionType is a strongly typed condition name +type ConditionType string + +const ( + // ConditionTypeConfigured indicates that the replication has been configured. + ConditionTypeConfigured ConditionType = "Configured" +) + +// Condition represents one current condition of a deployment or deployment member. +// A condition might not show up if it is not happening. +// For example, if a cluster is not upgrading, the Upgrading condition would not show up. +type Condition struct { + // Type of condition. + Type ConditionType `json:"type"` + // Status of the condition, one of True, False, Unknown. + Status v1.ConditionStatus `json:"status"` + // The last time this condition was updated. + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + // Last time the condition transitioned from one status to another. + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + // The reason for the condition's last transition. + Reason string `json:"reason,omitempty"` + // A human readable message indicating details about the transition. + Message string `json:"message,omitempty"` +} + +// ConditionList is a list of conditions. +// Each type is allowed only once. +type ConditionList []Condition + +// IsTrue return true when a condition with given type exists and its status is `True`. +func (list ConditionList) IsTrue(conditionType ConditionType) bool { + c, found := list.Get(conditionType) + return found && c.Status == v1.ConditionTrue +} + +// Get a condition by type. +// Returns true if found, false if not found. +func (list ConditionList) Get(conditionType ConditionType) (Condition, bool) { + for _, x := range list { + if x.Type == conditionType { + return x, true + } + } + // Not found + return Condition{}, false +} + +// Update the condition, replacing an old condition with same type (if any) +// Returns true when changes were made, false otherwise. +func (list *ConditionList) Update(conditionType ConditionType, status bool, reason, message string) bool { + src := *list + statusX := v1.ConditionFalse + if status { + statusX = v1.ConditionTrue + } + for i, x := range src { + if x.Type == conditionType { + if x.Status != statusX { + // Transition to another status + src[i].Status = statusX + now := metav1.Now() + src[i].LastTransitionTime = now + src[i].LastUpdateTime = now + src[i].Reason = reason + src[i].Message = message + } else if x.Reason != reason || x.Message != message { + src[i].LastUpdateTime = metav1.Now() + src[i].Reason = reason + src[i].Message = message + } else { + return false + } + return true + } + } + // Not found + now := metav1.Now() + *list = append(src, Condition{ + Type: conditionType, + LastUpdateTime: now, + LastTransitionTime: now, + Status: statusX, + Reason: reason, + Message: message, + }) + return true +} + +// Remove the condition with given type. +// Returns true if removed, or false if not found. +func (list *ConditionList) Remove(conditionType ConditionType) bool { + src := *list + for i, x := range src { + if x.Type == conditionType { + *list = append(src[:i], src[i+1:]...) + return true + } + } + // Not found + return false +} diff --git a/pkg/apis/replication/v1/conditions_test.go b/pkg/apis/replication/v1/conditions_test.go new file mode 100644 index 000000000..17966d2ea --- /dev/null +++ b/pkg/apis/replication/v1/conditions_test.go @@ -0,0 +1,95 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestConditionListIsTrue(t *testing.T) { + assert.False(t, ConditionList{}.IsTrue(ConditionTypeConfigured)) + + cl := ConditionList{} + cl.Update(ConditionTypeConfigured, true, "test", "msg") + assert.True(t, cl.IsTrue(ConditionTypeConfigured)) + //assert.False(t, cl.IsTrue(ConditionTypeTerminated)) + + cl.Update(ConditionTypeConfigured, false, "test", "msg") + assert.False(t, cl.IsTrue(ConditionTypeConfigured)) + + cl.Remove(ConditionTypeConfigured) + assert.False(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 0, len(cl)) +} + +func TestConditionListGet(t *testing.T) { + conv := func(c Condition, b bool) []interface{} { + return []interface{}{c, b} + } + + cl := ConditionList{} + assert.EqualValues(t, conv(Condition{}, false), conv(cl.Get(ConditionTypeConfigured))) + cl.Update(ConditionTypeConfigured, false, "test", "msg") + assert.EqualValues(t, conv(cl[0], true), conv(cl.Get(ConditionTypeConfigured))) +} + +func TestConditionListUpdate(t *testing.T) { + cl := ConditionList{} + assert.Equal(t, 0, len(cl)) + + assert.True(t, cl.Update(ConditionTypeConfigured, true, "test", "msg")) + assert.True(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 1, len(cl)) + + assert.False(t, cl.Update(ConditionTypeConfigured, true, "test", "msg")) + assert.True(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeConfigured, false, "test", "msg")) + assert.False(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeConfigured, false, "test2", "msg")) + assert.False(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Update(ConditionTypeConfigured, false, "test2", "msg2")) + assert.False(t, cl.IsTrue(ConditionTypeConfigured)) + assert.Equal(t, 1, len(cl)) +} + +func TestConditionListRemove(t *testing.T) { + cl := ConditionList{} + assert.Equal(t, 0, len(cl)) + + cl.Update(ConditionTypeConfigured, true, "test", "msg") + assert.Equal(t, 1, len(cl)) + + assert.True(t, cl.Remove(ConditionTypeConfigured)) + assert.Equal(t, 0, len(cl)) + + assert.False(t, cl.Remove(ConditionTypeConfigured)) + assert.Equal(t, 0, len(cl)) +} diff --git a/pkg/apis/replication/v1/database_status.go b/pkg/apis/replication/v1/database_status.go new file mode 100644 index 000000000..f30bd02b4 --- /dev/null +++ b/pkg/apis/replication/v1/database_status.go @@ -0,0 +1,32 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// DatabaseStatus contains the status of a single database. +type DatabaseStatus struct { + // Name of the database + Name string `json:"name"` + // Collections holds the replication status of each collection in the database. + // List is ordered by name of the collection. + Collections []CollectionStatus `json:"collections,omitempty"` +} diff --git a/pkg/apis/replication/v1/doc.go b/pkg/apis/replication/v1/doc.go new file mode 100644 index 000000000..d326c2303 --- /dev/null +++ b/pkg/apis/replication/v1/doc.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +// +k8s:deepcopy-gen=package +// +groupName=replication.database.arangodb.com +package v1 diff --git a/pkg/apis/replication/v1/endpoint_authentication_spec.go b/pkg/apis/replication/v1/endpoint_authentication_spec.go new file mode 100644 index 000000000..02b27b84a --- /dev/null +++ b/pkg/apis/replication/v1/endpoint_authentication_spec.go @@ -0,0 +1,89 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/pkg/errors" +) + +// EndpointAuthenticationSpec contains the specification to authentication with the syncmasters +// in either source or destination endpoint. +type EndpointAuthenticationSpec struct { + // KeyfileSecretName holds the name of a Secret containing a client authentication + // certificate formatted at keyfile in a `tls.keyfile` field. + KeyfileSecretName *string `json:"keyfileSecretName,omitempty"` + // UserSecretName holds the name of a Secret containing a `username` & `password` + // field used for basic authentication. + // The user identified by the username must have write access in the `_system` database + // of the ArangoDB cluster at the endpoint. + UserSecretName *string `json:"userSecretName,omitempty"` +} + +// GetKeyfileSecretName returns the value of keyfileSecretName. +func (s EndpointAuthenticationSpec) GetKeyfileSecretName() string { + return util.StringOrDefault(s.KeyfileSecretName) +} + +// GetUserSecretName returns the value of userSecretName. +func (s EndpointAuthenticationSpec) GetUserSecretName() string { + return util.StringOrDefault(s.UserSecretName) +} + +// Validate the given spec, returning an error on validation +// problems or nil if all ok. +func (s EndpointAuthenticationSpec) Validate(keyfileSecretNameRequired bool) error { + if err := k8sutil.ValidateOptionalResourceName(s.GetKeyfileSecretName()); err != nil { + return maskAny(err) + } + if err := k8sutil.ValidateOptionalResourceName(s.GetUserSecretName()); err != nil { + return maskAny(err) + } + if keyfileSecretNameRequired && s.GetKeyfileSecretName() == "" { + return maskAny(errors.Wrapf(ValidationError, "Provide a keyfileSecretName")) + } + return nil +} + +// SetDefaults fills empty field with default values. +func (s *EndpointAuthenticationSpec) SetDefaults() { +} + +// SetDefaultsFrom fills empty field with default values from the given source. +func (s *EndpointAuthenticationSpec) SetDefaultsFrom(source EndpointAuthenticationSpec) { + if s.KeyfileSecretName == nil { + s.KeyfileSecretName = util.NewStringOrNil(source.KeyfileSecretName) + } + if s.UserSecretName == nil { + s.UserSecretName = util.NewStringOrNil(source.UserSecretName) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to `spec.`. +func (s EndpointAuthenticationSpec) ResetImmutableFields(target *EndpointAuthenticationSpec, fieldPrefix string) []string { + var result []string + return result +} diff --git a/pkg/apis/replication/v1/endpoint_spec.go b/pkg/apis/replication/v1/endpoint_spec.go new file mode 100644 index 000000000..a6cdce59d --- /dev/null +++ b/pkg/apis/replication/v1/endpoint_spec.go @@ -0,0 +1,111 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "net/url" + + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/pkg/errors" +) + +// EndpointSpec contains the specification used to reach the syncmasters +// in either source or destination mode. +type EndpointSpec struct { + // DeploymentName holds the name of an ArangoDeployment resource. + // If set this provides default values for masterEndpoint, auth & tls. + DeploymentName *string `json:"deploymentName,omitempty"` + // MasterEndpoint holds a list of URLs used to reach the syncmaster(s). + MasterEndpoint []string `json:"masterEndpoint,omitempty"` + // Authentication holds settings needed to authentication at the syncmaster. + Authentication EndpointAuthenticationSpec `json:"auth"` + // TLS holds settings needed to verify the TLS connection to the syncmaster. + TLS EndpointTLSSpec `json:"tls"` +} + +// GetDeploymentName returns the value of deploymentName. +func (s EndpointSpec) GetDeploymentName() string { + return util.StringOrDefault(s.DeploymentName) +} + +// HasDeploymentName returns the true when a non-empty deployment name it set. +func (s EndpointSpec) HasDeploymentName() bool { + return s.GetDeploymentName() != "" +} + +// Validate the given spec, returning an error on validation +// problems or nil if all ok. +func (s EndpointSpec) Validate(isSourceEndpoint bool) error { + if err := k8sutil.ValidateOptionalResourceName(s.GetDeploymentName()); err != nil { + return maskAny(err) + } + for _, ep := range s.MasterEndpoint { + if _, err := url.Parse(ep); err != nil { + return maskAny(errors.Wrapf(ValidationError, "Invalid master endpoint '%s': %s", ep, err)) + } + } + hasDeploymentName := s.HasDeploymentName() + if !hasDeploymentName && len(s.MasterEndpoint) == 0 { + return maskAny(errors.Wrapf(ValidationError, "Provide a deploy name or at least one master endpoint")) + } + if err := s.Authentication.Validate(isSourceEndpoint || !hasDeploymentName); err != nil { + return maskAny(err) + } + if err := s.TLS.Validate(!hasDeploymentName); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills empty field with default values. +func (s *EndpointSpec) SetDefaults() { + s.Authentication.SetDefaults() + s.TLS.SetDefaults() +} + +// SetDefaultsFrom fills empty field with default values from the given source. +func (s *EndpointSpec) SetDefaultsFrom(source EndpointSpec) { + if s.DeploymentName == nil { + s.DeploymentName = util.NewStringOrNil(source.DeploymentName) + } + s.Authentication.SetDefaultsFrom(source.Authentication) + s.TLS.SetDefaultsFrom(source.TLS) +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to `spec.`. +func (s EndpointSpec) ResetImmutableFields(target *EndpointSpec, fieldPrefix string) []string { + var result []string + if s.GetDeploymentName() != target.GetDeploymentName() { + result = append(result, fieldPrefix+"deploymentName") + } + if list := s.Authentication.ResetImmutableFields(&target.Authentication, fieldPrefix+"auth."); len(list) > 0 { + result = append(result, list...) + } + if list := s.TLS.ResetImmutableFields(&target.TLS, fieldPrefix+"tls."); len(list) > 0 { + result = append(result, list...) + } + return result +} diff --git a/pkg/apis/replication/v1/endpoint_status.go b/pkg/apis/replication/v1/endpoint_status.go new file mode 100644 index 000000000..86826d98c --- /dev/null +++ b/pkg/apis/replication/v1/endpoint_status.go @@ -0,0 +1,30 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// EndpointStatus contains the status of either the source or destination endpoint. +type EndpointStatus struct { + // Databases holds the replication status of all databases from the point of view of this endpoint. + // List is ordered by name of the database. + Databases []DatabaseStatus `json:"databases,omitempty"` +} diff --git a/pkg/apis/replication/v1/endpoint_tls_spec.go b/pkg/apis/replication/v1/endpoint_tls_spec.go new file mode 100644 index 000000000..4d3fd9644 --- /dev/null +++ b/pkg/apis/replication/v1/endpoint_tls_spec.go @@ -0,0 +1,72 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/util" + "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" + "github.com/pkg/errors" +) + +// EndpointTLSSpec contains the specification regarding the TLS connection to the syncmasters +// in either source or destination endpoint. +type EndpointTLSSpec struct { + // CASecretName holds the name of a Secret containing a ca.crt public key for TLS validation. + CASecretName *string `json:"caSecretName,omitempty"` +} + +// GetCASecretName returns the value of caSecretName. +func (s EndpointTLSSpec) GetCASecretName() string { + return util.StringOrDefault(s.CASecretName) +} + +// Validate the given spec, returning an error on validation +// problems or nil if all ok. +func (s EndpointTLSSpec) Validate(caSecretNameRequired bool) error { + if err := k8sutil.ValidateOptionalResourceName(s.GetCASecretName()); err != nil { + return maskAny(err) + } + if caSecretNameRequired && s.GetCASecretName() == "" { + return maskAny(errors.Wrapf(ValidationError, "Provide a caSecretName")) + } + return nil +} + +// SetDefaults fills empty field with default values. +func (s *EndpointTLSSpec) SetDefaults() { +} + +// SetDefaultsFrom fills empty field with default values from the given source. +func (s *EndpointTLSSpec) SetDefaultsFrom(source EndpointTLSSpec) { + if s.CASecretName == nil { + s.CASecretName = util.NewStringOrNil(source.CASecretName) + } +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to `spec.`. +func (s EndpointTLSSpec) ResetImmutableFields(target *EndpointTLSSpec, fieldPrefix string) []string { + var result []string + return result +} diff --git a/pkg/apis/replication/v1/errors.go b/pkg/apis/replication/v1/errors.go new file mode 100644 index 000000000..78af20879 --- /dev/null +++ b/pkg/apis/replication/v1/errors.go @@ -0,0 +1,37 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import "github.com/pkg/errors" + +var ( + // ValidationError indicates a validation failure + ValidationError = errors.New("validation failed") + + maskAny = errors.WithStack +) + +// IsValidation return true when the given error is or is caused by a ValidationError. +func IsValidation(err error) bool { + return errors.Cause(err) == ValidationError +} diff --git a/pkg/apis/replication/v1/register.go b/pkg/apis/replication/v1/register.go new file mode 100644 index 000000000..0a940bf1e --- /dev/null +++ b/pkg/apis/replication/v1/register.go @@ -0,0 +1,57 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/replication" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + ArangoDeploymentReplicationVersion = "v1" +) + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = schema.GroupVersion{Group: replication.ArangoDeploymentReplicationGroupName, + Version: ArangoDeploymentReplicationVersion} +) + +// Resource gets an ArangoCluster GroupResource for a specified resource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// addKnownTypes adds the set of types defined in this package to the supplied scheme. +func addKnownTypes(s *runtime.Scheme) error { + s.AddKnownTypes(SchemeGroupVersion, + &ArangoDeploymentReplication{}, + &ArangoDeploymentReplicationList{}, + ) + metav1.AddToGroupVersion(s, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/replication/v1/replication.go b/pkg/apis/replication/v1/replication.go new file mode 100644 index 000000000..4cebb567b --- /dev/null +++ b/pkg/apis/replication/v1/replication.go @@ -0,0 +1,64 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +import ( + "github.com/arangodb/kube-arangodb/pkg/apis/replication" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoDeploymentReplicationList is a list of ArangoDB deployment replications. +type ArangoDeploymentReplicationList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata + // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata + metav1.ListMeta `json:"metadata,omitempty"` + Items []ArangoDeploymentReplication `json:"items"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ArangoDeploymentReplication contains the entire Kubernetes info for an ArangoDB +// local storage provider. +type ArangoDeploymentReplication struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec DeploymentReplicationSpec `json:"spec"` + Status DeploymentReplicationStatus `json:"status"` +} + +// AsOwner creates an OwnerReference for the given replication +func (d *ArangoDeploymentReplication) AsOwner() metav1.OwnerReference { + trueVar := true + return metav1.OwnerReference{ + APIVersion: SchemeGroupVersion.String(), + Kind: replication.ArangoDeploymentReplicationResourceKind, + Name: d.Name, + UID: d.UID, + Controller: &trueVar, + BlockOwnerDeletion: &trueVar, + } +} diff --git a/pkg/apis/replication/v1/replication_phase.go b/pkg/apis/replication/v1/replication_phase.go new file mode 100644 index 000000000..a2ec0f272 --- /dev/null +++ b/pkg/apis/replication/v1/replication_phase.go @@ -0,0 +1,39 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// DeploymentReplicationPhase is a strongly typed lifetime phase of a deployment replication +type DeploymentReplicationPhase string + +const ( + // DeploymentReplicationPhaseNone indicates that the phase is not set yet + DeploymentReplicationPhaseNone DeploymentReplicationPhase = "" + // DeploymentReplicationPhaseFailed indicates that a deployment replication is in a failed state + // from which automatic recovery is impossible. Inspect `Reason` for more info. + DeploymentReplicationPhaseFailed DeploymentReplicationPhase = "Failed" +) + +// IsFailed returns true if given state is DeploymentStateFailed +func (cs DeploymentReplicationPhase) IsFailed() bool { + return cs == DeploymentReplicationPhaseFailed +} diff --git a/pkg/apis/replication/v1/replication_spec.go b/pkg/apis/replication/v1/replication_spec.go new file mode 100644 index 000000000..07cf9125e --- /dev/null +++ b/pkg/apis/replication/v1/replication_spec.go @@ -0,0 +1,68 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// DeploymentReplicationSpec contains the specification part of +// an ArangoDeploymentReplication. +type DeploymentReplicationSpec struct { + Source EndpointSpec `json:"source"` + Destination EndpointSpec `json:"destination"` +} + +// Validate the given spec, returning an error on validation +// problems or nil if all ok. +func (s DeploymentReplicationSpec) Validate() error { + if err := s.Source.Validate(true); err != nil { + return maskAny(err) + } + if err := s.Destination.Validate(false); err != nil { + return maskAny(err) + } + return nil +} + +// SetDefaults fills empty field with default values. +func (s *DeploymentReplicationSpec) SetDefaults() { + s.Source.SetDefaults() + s.Destination.SetDefaults() +} + +// SetDefaultsFrom fills empty field with default values from the given source. +func (s *DeploymentReplicationSpec) SetDefaultsFrom(source DeploymentReplicationSpec) { + s.Source.SetDefaultsFrom(source.Source) + s.Destination.SetDefaultsFrom(source.Destination) +} + +// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec. +// It returns a list of fields that have been reset. +// Field names are relative to `spec.`. +func (s DeploymentReplicationSpec) ResetImmutableFields(target *DeploymentReplicationSpec) []string { + var result []string + if list := s.Source.ResetImmutableFields(&target.Source, "source."); len(list) > 0 { + result = append(result, list...) + } + if list := s.Destination.ResetImmutableFields(&target.Destination, "destination."); len(list) > 0 { + result = append(result, list...) + } + return result +} diff --git a/pkg/apis/replication/v1/replication_status.go b/pkg/apis/replication/v1/replication_status.go new file mode 100644 index 000000000..f9be660d5 --- /dev/null +++ b/pkg/apis/replication/v1/replication_status.go @@ -0,0 +1,44 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// DeploymentReplicationStatus contains the status part of +// an ArangoDeploymentReplication. +type DeploymentReplicationStatus struct { + // Phase holds the current lifetime phase of the deployment replication + Phase DeploymentReplicationPhase `json:"phase,omitempty"` + // Reason contains a human readable reason for reaching the current phase (can be empty) + Reason string `json:"reason,omitempty"` // Reason for current phase + + // Conditions specific to the entire deployment replication + Conditions ConditionList `json:"conditions,omitempty"` + + // Source contains the detailed status of the source endpoint + Source EndpointStatus `json:"source"` + // Destination contains the detailed status of the destination endpoint + Destination EndpointStatus `json:"destination"` + + // CancelFailures records the number of times that the configuration was canceled + // which resulted in an error. + CancelFailures int `json:"cancel-failures,omitempty"` +} diff --git a/pkg/apis/replication/v1/shard_status.go b/pkg/apis/replication/v1/shard_status.go new file mode 100644 index 000000000..a76d6127c --- /dev/null +++ b/pkg/apis/replication/v1/shard_status.go @@ -0,0 +1,28 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// +// Author Ewout Prangsma +// + +package v1 + +// ShardStatus contains the status of a single shard. +type ShardStatus struct { + Status string `json:"status"` +} diff --git a/pkg/apis/replication/v1/zz_generated.deepcopy.go b/pkg/apis/replication/v1/zz_generated.deepcopy.go new file mode 100644 index 000000000..a070059fc --- /dev/null +++ b/pkg/apis/replication/v1/zz_generated.deepcopy.go @@ -0,0 +1,331 @@ +// +build !ignore_autogenerated + +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoDeploymentReplication) DeepCopyInto(out *ArangoDeploymentReplication) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeploymentReplication. +func (in *ArangoDeploymentReplication) DeepCopy() *ArangoDeploymentReplication { + if in == nil { + return nil + } + out := new(ArangoDeploymentReplication) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoDeploymentReplication) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ArangoDeploymentReplicationList) DeepCopyInto(out *ArangoDeploymentReplicationList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ArangoDeploymentReplication, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeploymentReplicationList. +func (in *ArangoDeploymentReplicationList) DeepCopy() *ArangoDeploymentReplicationList { + if in == nil { + return nil + } + out := new(ArangoDeploymentReplicationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ArangoDeploymentReplicationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CollectionStatus) DeepCopyInto(out *CollectionStatus) { + *out = *in + if in.Shards != nil { + in, out := &in.Shards, &out.Shards + *out = make([]ShardStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CollectionStatus. +func (in *CollectionStatus) DeepCopy() *CollectionStatus { + if in == nil { + return nil + } + out := new(CollectionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Condition) DeepCopyInto(out *Condition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. +func (in *Condition) DeepCopy() *Condition { + if in == nil { + return nil + } + out := new(Condition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ConditionList) DeepCopyInto(out *ConditionList) { + { + in := &in + *out = make(ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConditionList. +func (in ConditionList) DeepCopy() ConditionList { + if in == nil { + return nil + } + out := new(ConditionList) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DatabaseStatus) DeepCopyInto(out *DatabaseStatus) { + *out = *in + if in.Collections != nil { + in, out := &in.Collections, &out.Collections + *out = make([]CollectionStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DatabaseStatus. +func (in *DatabaseStatus) DeepCopy() *DatabaseStatus { + if in == nil { + return nil + } + out := new(DatabaseStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentReplicationSpec) DeepCopyInto(out *DeploymentReplicationSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) + in.Destination.DeepCopyInto(&out.Destination) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentReplicationSpec. +func (in *DeploymentReplicationSpec) DeepCopy() *DeploymentReplicationSpec { + if in == nil { + return nil + } + out := new(DeploymentReplicationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentReplicationStatus) DeepCopyInto(out *DeploymentReplicationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(ConditionList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.Source.DeepCopyInto(&out.Source) + in.Destination.DeepCopyInto(&out.Destination) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentReplicationStatus. +func (in *DeploymentReplicationStatus) DeepCopy() *DeploymentReplicationStatus { + if in == nil { + return nil + } + out := new(DeploymentReplicationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointAuthenticationSpec) DeepCopyInto(out *EndpointAuthenticationSpec) { + *out = *in + if in.KeyfileSecretName != nil { + in, out := &in.KeyfileSecretName, &out.KeyfileSecretName + *out = new(string) + **out = **in + } + if in.UserSecretName != nil { + in, out := &in.UserSecretName, &out.UserSecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointAuthenticationSpec. +func (in *EndpointAuthenticationSpec) DeepCopy() *EndpointAuthenticationSpec { + if in == nil { + return nil + } + out := new(EndpointAuthenticationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointSpec) DeepCopyInto(out *EndpointSpec) { + *out = *in + if in.DeploymentName != nil { + in, out := &in.DeploymentName, &out.DeploymentName + *out = new(string) + **out = **in + } + if in.MasterEndpoint != nil { + in, out := &in.MasterEndpoint, &out.MasterEndpoint + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Authentication.DeepCopyInto(&out.Authentication) + in.TLS.DeepCopyInto(&out.TLS) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointSpec. +func (in *EndpointSpec) DeepCopy() *EndpointSpec { + if in == nil { + return nil + } + out := new(EndpointSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointStatus) DeepCopyInto(out *EndpointStatus) { + *out = *in + if in.Databases != nil { + in, out := &in.Databases, &out.Databases + *out = make([]DatabaseStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointStatus. +func (in *EndpointStatus) DeepCopy() *EndpointStatus { + if in == nil { + return nil + } + out := new(EndpointStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EndpointTLSSpec) DeepCopyInto(out *EndpointTLSSpec) { + *out = *in + if in.CASecretName != nil { + in, out := &in.CASecretName, &out.CASecretName + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointTLSSpec. +func (in *EndpointTLSSpec) DeepCopy() *EndpointTLSSpec { + if in == nil { + return nil + } + out := new(EndpointTLSSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ShardStatus) DeepCopyInto(out *ShardStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ShardStatus. +func (in *ShardStatus) DeepCopy() *ShardStatus { + if in == nil { + return nil + } + out := new(ShardStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/replication/v1alpha/register.go b/pkg/apis/replication/v1alpha/register.go index ccab2f54d..bcce60830 100644 --- a/pkg/apis/replication/v1alpha/register.go +++ b/pkg/apis/replication/v1alpha/register.go @@ -23,24 +23,22 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/replication" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) const ( - ArangoDeploymentReplicationResourceKind = "ArangoDeploymentReplication" - ArangoDeploymentReplicationResourcePlural = "arangodeploymentreplications" - groupName = "replication.database.arangodb.com" + ArangoDeploymentReplicationVersion = "v1alpha" ) var ( SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) AddToScheme = SchemeBuilder.AddToScheme - SchemeGroupVersion = schema.GroupVersion{Group: groupName, Version: "v1alpha"} - ArangoDeploymentReplicationCRDName = ArangoDeploymentReplicationResourcePlural + "." + groupName - ArangoDeploymentReplicationShortNames = []string{"arangorepl"} + SchemeGroupVersion = schema.GroupVersion{Group: replication.ArangoDeploymentReplicationGroupName, + Version: ArangoDeploymentReplicationVersion} ) // Resource gets an ArangoCluster GroupResource for a specified resource diff --git a/pkg/apis/replication/v1alpha/replication.go b/pkg/apis/replication/v1alpha/replication.go index 4bb3be55f..752a27565 100644 --- a/pkg/apis/replication/v1alpha/replication.go +++ b/pkg/apis/replication/v1alpha/replication.go @@ -23,6 +23,7 @@ package v1alpha import ( + "github.com/arangodb/kube-arangodb/pkg/apis/replication" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -54,7 +55,7 @@ func (d *ArangoDeploymentReplication) AsOwner() metav1.OwnerReference { trueVar := true return metav1.OwnerReference{ APIVersion: SchemeGroupVersion.String(), - Kind: ArangoDeploymentReplicationResourceKind, + Kind: replication.ArangoDeploymentReplicationResourceKind, Name: d.Name, UID: d.UID, Controller: &trueVar, diff --git a/pkg/backup/handlers/arango/backup/arango_client.go b/pkg/backup/handlers/arango/backup/arango_client.go index 09464b780..6ad1c1f10 100644 --- a/pkg/backup/handlers/arango/backup/arango_client.go +++ b/pkg/backup/handlers/arango/backup/arango_client.go @@ -27,8 +27,8 @@ import ( "net/http" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) var ( @@ -72,4 +72,4 @@ type ArangoBackupClient interface { Delete(driver.BackupID) error List() (map[driver.BackupID]driver.BackupMeta, error) -} \ No newline at end of file +} diff --git a/pkg/backup/handlers/arango/backup/arango_client_impl.go b/pkg/backup/handlers/arango/backup/arango_client_impl.go index 4d2eb316c..0b20a7efc 100644 --- a/pkg/backup/handlers/arango/backup/arango_client_impl.go +++ b/pkg/backup/handlers/arango/backup/arango_client_impl.go @@ -29,8 +29,8 @@ import ( "time" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" diff --git a/pkg/backup/handlers/arango/backup/arango_client_mock_test.go b/pkg/backup/handlers/arango/backup/arango_client_mock_test.go index ae2b05229..ea2fb144e 100644 --- a/pkg/backup/handlers/arango/backup/arango_client_mock_test.go +++ b/pkg/backup/handlers/arango/backup/arango_client_mock_test.go @@ -29,8 +29,8 @@ import ( "time" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "k8s.io/apimachinery/pkg/util/uuid" ) @@ -76,7 +76,7 @@ type mockArangoClientBackupState struct { type mockArangoClientBackup struct { backup *backupApi.ArangoBackup - state *mockArangoClientBackupState + state *mockArangoClientBackupState } func (m *mockArangoClientBackup) List() (map[driver.BackupID]driver.BackupMeta, error) { diff --git a/pkg/backup/handlers/arango/backup/backup_suite_test.go b/pkg/backup/handlers/arango/backup/backup_suite_test.go index 15f92332d..b6f4bc0ba 100644 --- a/pkg/backup/handlers/arango/backup/backup_suite_test.go +++ b/pkg/backup/handlers/arango/backup/backup_suite_test.go @@ -25,14 +25,16 @@ package backup import ( "fmt" "github.com/arangodb/go-driver" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" "testing" "github.com/arangodb/kube-arangodb/pkg/backup/operator/event" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "k8s.io/client-go/kubernetes/fake" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/backup/state" fakeClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/fake" "github.com/stretchr/testify/require" @@ -90,9 +92,9 @@ func compareTemporaryState(t *testing.T, err error, errorMsg string, handler *ha func newItem(o operation.Operation, namespace, name string) operation.Item { return operation.Item{ - Group: database.SchemeGroupVersion.Group, - Version: database.SchemeGroupVersion.Version, - Kind: backupApi.ArangoBackupResourceKind, + Group: backupApi.SchemeGroupVersion.Group, + Version: backupApi.SchemeGroupVersion.Version, + Kind: backup.ArangoBackupResourceKind, Operation: o, @@ -108,15 +110,15 @@ func newItemFromBackup(operation operation.Operation, backup *backupApi.ArangoBa func newArangoBackup(objectRef, namespace, name string, state state.State) *backupApi.ArangoBackup { return &backupApi.ArangoBackup{ TypeMeta: meta.TypeMeta{ - APIVersion: database.SchemeGroupVersion.String(), - Kind: backupApi.ArangoBackupResourceKind, + APIVersion: backupApi.SchemeGroupVersion.String(), + Kind: backup.ArangoBackupResourceKind, }, ObjectMeta: meta.ObjectMeta{ Name: name, Namespace: namespace, SelfLink: fmt.Sprintf("/api/%s/%s/%s/%s", - database.SchemeGroupVersion.String(), - backupApi.ArangoBackupResourcePlural, + backupApi.SchemeGroupVersion.String(), + backup.ArangoBackupResourcePlural, namespace, name), UID: uuid.NewUUID(), @@ -137,13 +139,13 @@ func newArangoBackup(objectRef, namespace, name string, state state.State) *back func createArangoBackup(t *testing.T, h *handler, backups ...*backupApi.ArangoBackup) { for _, backup := range backups { - _, err := h.client.BackupV1alpha().ArangoBackups(backup.Namespace).Create(backup) + _, err := h.client.BackupV1().ArangoBackups(backup.Namespace).Create(backup) require.NoError(t, err) } } func refreshArangoBackup(t *testing.T, h *handler, backup *backupApi.ArangoBackup) *backupApi.ArangoBackup { - obj, err := h.client.BackupV1alpha().ArangoBackups(backup.Namespace).Get(backup.Name, meta.GetOptions{}) + obj, err := h.client.BackupV1().ArangoBackups(backup.Namespace).Get(backup.Name, meta.GetOptions{}) require.NoError(t, err) return obj } @@ -151,15 +153,15 @@ func refreshArangoBackup(t *testing.T, h *handler, backup *backupApi.ArangoBacku func newArangoDeployment(namespace, name string) *database.ArangoDeployment { return &database.ArangoDeployment{ TypeMeta: meta.TypeMeta{ - APIVersion: database.SchemeGroupVersion.String(), - Kind: database.ArangoDeploymentResourceKind, + APIVersion: backupApi.SchemeGroupVersion.String(), + Kind: deployment.ArangoDeploymentResourceKind, }, ObjectMeta: meta.ObjectMeta{ Name: name, Namespace: namespace, SelfLink: fmt.Sprintf("/api/%s/%s/%s/%s", - database.SchemeGroupVersion.String(), - database.ArangoDeploymentResourcePlural, + backupApi.SchemeGroupVersion.String(), + deployment.ArangoDeploymentResourcePlural, namespace, name), UID: uuid.NewUUID(), @@ -169,7 +171,7 @@ func newArangoDeployment(namespace, name string) *database.ArangoDeployment { func createArangoDeployment(t *testing.T, h *handler, deployments ...*database.ArangoDeployment) { for _, deployment := range deployments { - _, err := h.client.DatabaseV1alpha().ArangoDeployments(deployment.Namespace).Create(deployment) + _, err := h.client.DatabaseV1().ArangoDeployments(deployment.Namespace).Create(deployment) require.NoError(t, err) } } @@ -222,7 +224,7 @@ func wrapperUndefinedDeployment(t *testing.T, state state.State) { newObj := refreshArangoBackup(t, handler, obj) require.Equal(t, newObj.Status.State, backupApi.ArangoBackupStateFailed) - require.Equal(t, newObj.Status.Message, createStateMessage(state, backupApi.ArangoBackupStateFailed, fmt.Sprintf("%s \"%s\" not found", database.ArangoDeploymentCRDName, obj.Name))) + require.Equal(t, newObj.Status.Message, createStateMessage(state, backupApi.ArangoBackupStateFailed, fmt.Sprintf("%s \"%s\" not found", deployment.ArangoDeploymentCRDName, obj.Name))) }) } diff --git a/pkg/backup/handlers/arango/backup/errors.go b/pkg/backup/handlers/arango/backup/errors.go index 9ecf0e995..74393c595 100644 --- a/pkg/backup/handlers/arango/backup/errors.go +++ b/pkg/backup/handlers/arango/backup/errors.go @@ -31,11 +31,11 @@ import ( func newTemporaryError(err error) error { return temporaryError{ - Causer:err, + Causer: err, } } -func newTemporaryErrorf(format string, a ... interface{}) error { +func newTemporaryErrorf(format string, a ...interface{}) error { return newTemporaryError(fmt.Errorf(format, a...)) } @@ -53,11 +53,11 @@ func (t temporaryError) Error() string { func newFatalError(err error) error { return fatalError{ - Causer:err, + Causer: err, } } -func newFatalErrorf(format string, a ... interface{}) error { +func newFatalErrorf(format string, a ...interface{}) error { return newFatalError(fmt.Errorf(format, a...)) } @@ -116,4 +116,4 @@ func switchError(err error) error { } return newFatalError(err) -} \ No newline at end of file +} diff --git a/pkg/backup/handlers/arango/backup/finalizer.go b/pkg/backup/handlers/arango/backup/finalizer.go index dae109afe..e8ac47c89 100644 --- a/pkg/backup/handlers/arango/backup/finalizer.go +++ b/pkg/backup/handlers/arango/backup/finalizer.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/utils" "github.com/rs/zerolog/log" "k8s.io/apimachinery/pkg/api/errors" @@ -61,7 +61,7 @@ func (h *handler) finalize(backup *backupApi.ArangoBackup) error { i) } - if _, err := h.client.BackupV1alpha().ArangoBackups(backup.Namespace).Update(backup); err != nil { + if _, err := h.client.BackupV1().ArangoBackups(backup.Namespace).Update(backup); err != nil { return err } @@ -94,7 +94,7 @@ func (h *handler) finalizeBackup(backup *backupApi.ArangoBackup) error { return err } - backups, err := h.client.BackupV1alpha().ArangoBackups(backup.Namespace).List(meta.ListOptions{}) + backups, err := h.client.BackupV1().ArangoBackups(backup.Namespace).List(meta.ListOptions{}) if err != nil { return err } diff --git a/pkg/backup/handlers/arango/backup/finalizer_test.go b/pkg/backup/handlers/arango/backup/finalizer_test.go index 3ea20509a..d56692ce5 100644 --- a/pkg/backup/handlers/arango/backup/finalizer_test.go +++ b/pkg/backup/handlers/arango/backup/finalizer_test.go @@ -26,7 +26,7 @@ import ( "testing" "time" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "github.com/stretchr/testify/require" meta "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/backup/handlers/arango/backup/flow_test.go b/pkg/backup/handlers/arango/backup/flow_test.go index 3b1b9e008..927acc63e 100644 --- a/pkg/backup/handlers/arango/backup/flow_test.go +++ b/pkg/backup/handlers/arango/backup/flow_test.go @@ -25,7 +25,7 @@ package backup import ( "testing" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/handler.go b/pkg/backup/handlers/arango/backup/handler.go index 5f17ff930..38fa81c49 100644 --- a/pkg/backup/handlers/arango/backup/handler.go +++ b/pkg/backup/handlers/arango/backup/handler.go @@ -24,6 +24,7 @@ package backup import ( "fmt" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" "github.com/arangodb/kube-arangodb/pkg/util" "sync" "time" @@ -43,16 +44,16 @@ import ( "github.com/rs/zerolog/log" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" arangoClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" meta "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( defaultArangoClientTimeout = 30 * time.Second - retryCount = 25 - retryDelay = time.Second + retryCount = 25 + retryDelay = time.Second // StateChange name of the event send when state changed StateChange = "StateChange" @@ -99,7 +100,7 @@ func (h *handler) start(stopCh <-chan struct{}) { } func (h *handler) refresh() error { - deployments, err := h.client.DatabaseV1alpha().ArangoDeployments(h.operator.Namespace()).List(meta.ListOptions{}) + deployments, err := h.client.DatabaseV1().ArangoDeployments(h.operator.Namespace()).List(meta.ListOptions{}) if err != nil { return err } @@ -123,7 +124,7 @@ func (h *handler) refreshDeployment(deployment *database.ArangoDeployment) error return err } - backups, err := h.client.BackupV1alpha().ArangoBackups(deployment.Namespace).List(meta.ListOptions{}) + backups, err := h.client.BackupV1().ArangoBackups(deployment.Namespace).List(meta.ListOptions{}) if err != nil { return err } @@ -172,7 +173,7 @@ func (h *handler) refreshDeploymentBackup(deployment *database.ArangoDeployment, }, } - _, err := h.client.BackupV1alpha().ArangoBackups(backup.Namespace).Create(backup) + _, err := h.client.BackupV1().ArangoBackups(backup.Namespace).Create(backup) if err != nil { return err } @@ -193,19 +194,19 @@ func (h *handler) refreshDeploymentBackup(deployment *database.ArangoDeployment, } func (h *handler) Name() string { - return backupApi.ArangoBackupResourceKind + return backup.ArangoBackupResourceKind } func (h *handler) updateBackupStatus(b *backupApi.ArangoBackup) error { return utils.Retry(retryCount, retryDelay, func() error { - backup, err := h.client.BackupV1alpha().ArangoBackups(b.Namespace).Get(b.Name, meta.GetOptions{}) + backup, err := h.client.BackupV1().ArangoBackups(b.Namespace).Get(b.Name, meta.GetOptions{}) if err != nil { return err } backup.Status = b.Status - _, err = h.client.BackupV1alpha().ArangoBackups(b.Namespace).UpdateStatus(backup) + _, err = h.client.BackupV1().ArangoBackups(b.Namespace).UpdateStatus(backup) return err }) } @@ -229,7 +230,7 @@ func (h *handler) getDeploymentMutex(namespace, deployment string) *sync.Mutex { func (h *handler) Handle(item operation.Item) error { // Get Backup object. It also cover NotFound case - b, err := h.client.BackupV1alpha().ArangoBackups(item.Namespace).Get(item.Name, meta.GetOptions{}) + b, err := h.client.BackupV1().ArangoBackups(item.Namespace).Get(item.Name, meta.GetOptions{}) if err != nil { if errors.IsNotFound(err) { return nil @@ -256,7 +257,7 @@ func (h *handler) Handle(item operation.Item) error { item.Namespace, item.Name) - if _, err = h.client.BackupV1alpha().ArangoBackups(item.Namespace).Update(b); err != nil { + if _, err = h.client.BackupV1().ArangoBackups(item.Namespace).Update(b); err != nil { return err } @@ -270,18 +271,18 @@ func (h *handler) Handle(item operation.Item) error { // Add owner reference if b.OwnerReferences == nil || len(b.OwnerReferences) == 0 { - deployment, err := h.client.DatabaseV1alpha().ArangoDeployments(b.Namespace).Get(b.Spec.Deployment.Name, meta.GetOptions{}) + deployment, err := h.client.DatabaseV1().ArangoDeployments(b.Namespace).Get(b.Spec.Deployment.Name, meta.GetOptions{}) if err == nil { b.OwnerReferences = []meta.OwnerReference{ deployment.AsOwner(), } - if _, err = h.client.BackupV1alpha().ArangoBackups(item.Namespace).Update(b); err != nil { + if _, err = h.client.BackupV1().ArangoBackups(item.Namespace).Update(b); err != nil { return err } } - b, err = h.client.BackupV1alpha().ArangoBackups(item.Namespace).Get(item.Name, meta.GetOptions{}) + b, err = h.client.BackupV1().ArangoBackups(item.Namespace).Get(item.Name, meta.GetOptions{}) if err != nil { if errors.IsNotFound(err) { return nil @@ -374,9 +375,9 @@ func (h *handler) processArangoBackup(backup *backupApi.ArangoBackup) (*backupAp } func (h *handler) CanBeHandled(item operation.Item) bool { - return item.Group == database.SchemeGroupVersion.Group && - item.Version == database.SchemeGroupVersion.Version && - item.Kind == backupApi.ArangoBackupResourceKind + return item.Group == backupApi.SchemeGroupVersion.Group && + item.Version == backupApi.SchemeGroupVersion.Version && + item.Kind == backup.ArangoBackupResourceKind } func (h *handler) getArangoDeploymentObject(backup *backupApi.ArangoBackup) (*database.ArangoDeployment, error) { @@ -384,7 +385,7 @@ func (h *handler) getArangoDeploymentObject(backup *backupApi.ArangoBackup) (*da return nil, newFatalErrorf("deployment ref is not specified for backup %s/%s", backup.Namespace, backup.Name) } - obj, err := h.client.DatabaseV1alpha().ArangoDeployments(backup.Namespace).Get(backup.Spec.Deployment.Name, meta.GetOptions{}) + obj, err := h.client.DatabaseV1().ArangoDeployments(backup.Namespace).Get(backup.Spec.Deployment.Name, meta.GetOptions{}) if err == nil { return obj, nil } diff --git a/pkg/backup/handlers/arango/backup/lifecycle.go b/pkg/backup/handlers/arango/backup/lifecycle.go index 99d801a06..ca5d6f17a 100644 --- a/pkg/backup/handlers/arango/backup/lifecycle.go +++ b/pkg/backup/handlers/arango/backup/lifecycle.go @@ -23,9 +23,9 @@ package backup import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" "time" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" "github.com/arangodb/kube-arangodb/pkg/backup/operator" "github.com/rs/zerolog/log" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,10 +43,10 @@ func (h *handler) LifecyclePreStart() error { }() for { - _, err := h.client.BackupV1alpha().ArangoBackups(h.operator.Namespace()).List(meta.ListOptions{}) + _, err := h.client.BackupV1().ArangoBackups(h.operator.Namespace()).List(meta.ListOptions{}) if err != nil { - log.Warn().Err(err).Msgf("CR for %s not found", backupApi.ArangoBackupResourceKind) + log.Warn().Err(err).Msgf("CR for %s not found", backup.ArangoBackupResourceKind) time.Sleep(250 * time.Millisecond) continue diff --git a/pkg/backup/handlers/arango/backup/register.go b/pkg/backup/handlers/arango/backup/register.go index 0d98136ae..52c62b8c9 100644 --- a/pkg/backup/handlers/arango/backup/register.go +++ b/pkg/backup/handlers/arango/backup/register.go @@ -23,8 +23,8 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator" "github.com/arangodb/kube-arangodb/pkg/backup/operator/event" arangoClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" @@ -33,17 +33,17 @@ import ( ) func newEventInstance(recorder event.Recorder) event.RecorderInstance { - return recorder.NewInstance(database.SchemeGroupVersion.Group, - database.SchemeGroupVersion.Version, - backupApi.ArangoBackupResourceKind) + return recorder.NewInstance(backupApi.SchemeGroupVersion.Group, + backupApi.SchemeGroupVersion.Version, + backup.ArangoBackupResourceKind) } // RegisterInformer into operator func RegisterInformer(operator operator.Operator, recorder event.Recorder, client arangoClientSet.Interface, kubeClient kubernetes.Interface, informer arangoInformer.SharedInformerFactory) error { - if err := operator.RegisterInformer(informer.Backup().V1alpha().ArangoBackups().Informer(), - database.SchemeGroupVersion.Group, - database.SchemeGroupVersion.Version, - backupApi.ArangoBackupResourceKind); err != nil { + if err := operator.RegisterInformer(informer.Backup().V1().ArangoBackups().Informer(), + backupApi.SchemeGroupVersion.Group, + backupApi.SchemeGroupVersion.Version, + backup.ArangoBackupResourceKind); err != nil { return err } diff --git a/pkg/backup/handlers/arango/backup/state.go b/pkg/backup/handlers/arango/backup/state.go index c13c3a516..e4570d8b1 100644 --- a/pkg/backup/handlers/arango/backup/state.go +++ b/pkg/backup/handlers/arango/backup/state.go @@ -23,7 +23,7 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/state" ) diff --git a/pkg/backup/handlers/arango/backup/state_create.go b/pkg/backup/handlers/arango/backup/state_create.go index 851865635..811e673ae 100644 --- a/pkg/backup/handlers/arango/backup/state_create.go +++ b/pkg/backup/handlers/arango/backup/state_create.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateCreateHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { @@ -57,7 +57,7 @@ func stateCreateHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi. } return wrapUpdateStatus(backup, - updateStatusState(backupApi.ArangoBackupStateReady,""), + updateStatusState(backupApi.ArangoBackupStateReady, ""), updateStatusAvailable(true), updateStatusBackup(backupMeta), ) diff --git a/pkg/backup/handlers/arango/backup/state_create_test.go b/pkg/backup/handlers/arango/backup/state_create_test.go index 303a09495..97517877f 100644 --- a/pkg/backup/handlers/arango/backup/state_create_test.go +++ b/pkg/backup/handlers/arango/backup/state_create_test.go @@ -29,7 +29,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_deleted.go b/pkg/backup/handlers/arango/backup/state_deleted.go index f7c544697..7f5de3c8f 100644 --- a/pkg/backup/handlers/arango/backup/state_deleted.go +++ b/pkg/backup/handlers/arango/backup/state_deleted.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateDeletedHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_deleted_test.go b/pkg/backup/handlers/arango/backup/state_deleted_test.go index afbd10eeb..beee76179 100644 --- a/pkg/backup/handlers/arango/backup/state_deleted_test.go +++ b/pkg/backup/handlers/arango/backup/state_deleted_test.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_download.go b/pkg/backup/handlers/arango/backup/state_download.go index da816920d..4a078e448 100644 --- a/pkg/backup/handlers/arango/backup/state_download.go +++ b/pkg/backup/handlers/arango/backup/state_download.go @@ -25,7 +25,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateDownloadHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_download_test.go b/pkg/backup/handlers/arango/backup/state_download_test.go index dff1fafe2..0f9b1d455 100644 --- a/pkg/backup/handlers/arango/backup/state_download_test.go +++ b/pkg/backup/handlers/arango/backup/state_download_test.go @@ -25,7 +25,7 @@ package backup import ( "testing" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "github.com/stretchr/testify/require" ) @@ -104,7 +104,7 @@ func Test_State_Download_TemporaryDownloadFailed(t *testing.T) { // Arrange error := newTemporaryErrorf("error") handler, mock := newErrorsFakeHandler(mockErrorsArangoClientBackup{ - downloadError: error, + downloadError: error, }) obj, deployment := newObjectSet(backupApi.ArangoBackupStateDownload) diff --git a/pkg/backup/handlers/arango/backup/state_downloaderror.go b/pkg/backup/handlers/arango/backup/state_downloaderror.go index ba0e1f115..2c1e6a02c 100644 --- a/pkg/backup/handlers/arango/backup/state_downloaderror.go +++ b/pkg/backup/handlers/arango/backup/state_downloaderror.go @@ -25,7 +25,7 @@ package backup import ( "time" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) const ( diff --git a/pkg/backup/handlers/arango/backup/state_downloaderror_test.go b/pkg/backup/handlers/arango/backup/state_downloaderror_test.go index e0c5d084d..d34d02365 100644 --- a/pkg/backup/handlers/arango/backup/state_downloaderror_test.go +++ b/pkg/backup/handlers/arango/backup/state_downloaderror_test.go @@ -28,7 +28,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_downloading.go b/pkg/backup/handlers/arango/backup/state_downloading.go index dd54cee0f..c87628619 100644 --- a/pkg/backup/handlers/arango/backup/state_downloading.go +++ b/pkg/backup/handlers/arango/backup/state_downloading.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateDownloadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { @@ -60,7 +60,7 @@ func stateDownloadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backu updateStatusState(backupApi.ArangoBackupStateDownloadError, "job with id %s does not exist anymore", backup.Status.Progress.JobID), cleanStatusJob(), - ) + ) } return nil, newTemporaryError(err) @@ -89,7 +89,7 @@ func stateDownloadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backu } return wrapUpdateStatus(backup, - updateStatusState(backupApi.ArangoBackupStateReady,""), + updateStatusState(backupApi.ArangoBackupStateReady, ""), updateStatusAvailable(true), updateStatusBackup(backupMeta), updateStatusBackupDownload(util.NewBool(true)), @@ -98,7 +98,7 @@ func stateDownloadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backu } return wrapUpdateStatus(backup, - updateStatusState(backupApi.ArangoBackupStateDownloading,""), + updateStatusState(backupApi.ArangoBackupStateDownloading, ""), updateStatusJob(backup.Status.Progress.JobID, fmt.Sprintf("%d%%", details.Progress)), ) } diff --git a/pkg/backup/handlers/arango/backup/state_downloading_test.go b/pkg/backup/handlers/arango/backup/state_downloading_test.go index a54370c12..58e6cd18e 100644 --- a/pkg/backup/handlers/arango/backup/state_downloading_test.go +++ b/pkg/backup/handlers/arango/backup/state_downloading_test.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/go-driver" "testing" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "github.com/stretchr/testify/require" ) @@ -293,4 +293,4 @@ func Test_State_Downloading_NotFoundProgress(t *testing.T) { checkBackup(t, newObj, backupApi.ArangoBackupStateDownloadError, false) require.Equal(t, fmt.Sprintf("job with id %s does not exist anymore", progress), newObj.Status.Message) require.Nil(t, newObj.Status.Progress) -} \ No newline at end of file +} diff --git a/pkg/backup/handlers/arango/backup/state_failed.go b/pkg/backup/handlers/arango/backup/state_failed.go index ea0b12a2e..d6748c6cb 100644 --- a/pkg/backup/handlers/arango/backup/state_failed.go +++ b/pkg/backup/handlers/arango/backup/state_failed.go @@ -23,7 +23,7 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateFailedHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_failed_test.go b/pkg/backup/handlers/arango/backup/state_failed_test.go index 49abaa25a..dbfca9009 100644 --- a/pkg/backup/handlers/arango/backup/state_failed_test.go +++ b/pkg/backup/handlers/arango/backup/state_failed_test.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_none.go b/pkg/backup/handlers/arango/backup/state_none.go index 32f9bdf54..2a37bc4be 100644 --- a/pkg/backup/handlers/arango/backup/state_none.go +++ b/pkg/backup/handlers/arango/backup/state_none.go @@ -23,7 +23,7 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateNoneHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_none_test.go b/pkg/backup/handlers/arango/backup/state_none_test.go index d0eac3d1e..d0634d49d 100644 --- a/pkg/backup/handlers/arango/backup/state_none_test.go +++ b/pkg/backup/handlers/arango/backup/state_none_test.go @@ -25,7 +25,7 @@ package backup import ( "testing" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_pending.go b/pkg/backup/handlers/arango/backup/state_pending.go index e6352eaf6..b7271e024 100644 --- a/pkg/backup/handlers/arango/backup/state_pending.go +++ b/pkg/backup/handlers/arango/backup/state_pending.go @@ -23,7 +23,7 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func statePendingHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { @@ -32,7 +32,7 @@ func statePendingHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi return nil, err } - running, err := isBackupRunning(backup, h.client.BackupV1alpha().ArangoBackups(backup.Namespace)) + running, err := isBackupRunning(backup, h.client.BackupV1().ArangoBackups(backup.Namespace)) if err != nil { return nil, err } diff --git a/pkg/backup/handlers/arango/backup/state_pending_test.go b/pkg/backup/handlers/arango/backup/state_pending_test.go index 5aa435f64..e19639798 100644 --- a/pkg/backup/handlers/arango/backup/state_pending_test.go +++ b/pkg/backup/handlers/arango/backup/state_pending_test.go @@ -24,6 +24,7 @@ package backup import ( "fmt" + deploymentType "github.com/arangodb/kube-arangodb/pkg/apis/deployment" "sync" "testing" @@ -31,8 +32,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) @@ -59,7 +59,7 @@ func Test_State_Pending_CheckNamespaceIsolation(t *testing.T) { require.Equal(t, newObj.Status.Message, createStateMessage(backupApi.ArangoBackupStatePending, backupApi.ArangoBackupStateFailed, - fmt.Sprintf("%s \"%s\" not found", database.ArangoDeploymentCRDName, obj.Name))) + fmt.Sprintf("%s \"%s\" not found", deploymentType.ArangoDeploymentCRDName, obj.Name))) } func Test_State_Pending_OneBackupObject(t *testing.T) { diff --git a/pkg/backup/handlers/arango/backup/state_ready.go b/pkg/backup/handlers/arango/backup/state_ready.go index ae6924673..82aa1311c 100644 --- a/pkg/backup/handlers/arango/backup/state_ready.go +++ b/pkg/backup/handlers/arango/backup/state_ready.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateReadyHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { @@ -73,7 +73,7 @@ func stateReadyHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.A if backup.Spec.Upload != nil && (backup.Status.Backup.Uploaded == nil || (backup.Status.Backup.Uploaded != nil && !*backup.Status.Backup.Uploaded)) { // Ensure that we can start upload process - running, err := isBackupRunning(backup, h.client.BackupV1alpha().ArangoBackups(backup.Namespace)) + running, err := isBackupRunning(backup, h.client.BackupV1().ArangoBackups(backup.Namespace)) if err != nil { return nil, err } diff --git a/pkg/backup/handlers/arango/backup/state_ready_test.go b/pkg/backup/handlers/arango/backup/state_ready_test.go index 6b89a0994..ba00bbcfb 100644 --- a/pkg/backup/handlers/arango/backup/state_ready_test.go +++ b/pkg/backup/handlers/arango/backup/state_ready_test.go @@ -31,7 +31,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) @@ -358,7 +358,7 @@ func Test_State_Ready_DoNotReUploadBackup(t *testing.T) { require.NoError(t, err) obj.Status.Backup = createBackupFromMeta(backupMeta, &backupApi.ArangoBackupDetails{ - Uploaded: util.NewBool(true), + Uploaded: util.NewBool(true), }) // Act @@ -388,7 +388,7 @@ func Test_State_Ready_RemoveUploadedFlag(t *testing.T) { require.NoError(t, err) obj.Status.Backup = createBackupFromMeta(backupMeta, &backupApi.ArangoBackupDetails{ - Uploaded: util.NewBool(true), + Uploaded: util.NewBool(true), }) // Act diff --git a/pkg/backup/handlers/arango/backup/state_scheduled.go b/pkg/backup/handlers/arango/backup/state_scheduled.go index 3aaf2fa03..63f6574b4 100644 --- a/pkg/backup/handlers/arango/backup/state_scheduled.go +++ b/pkg/backup/handlers/arango/backup/state_scheduled.go @@ -23,7 +23,7 @@ package backup import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateScheduledHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_scheduled_test.go b/pkg/backup/handlers/arango/backup/state_scheduled_test.go index 333e7bc6f..a8885230a 100644 --- a/pkg/backup/handlers/arango/backup/state_scheduled_test.go +++ b/pkg/backup/handlers/arango/backup/state_scheduled_test.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_unavailable.go b/pkg/backup/handlers/arango/backup/state_unavailable.go index 895edf63c..5fbd8bdc4 100644 --- a/pkg/backup/handlers/arango/backup/state_unavailable.go +++ b/pkg/backup/handlers/arango/backup/state_unavailable.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateUnavailableHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_unavailable_test.go b/pkg/backup/handlers/arango/backup/state_unavailable_test.go index b076a9f37..3c9c42bf1 100644 --- a/pkg/backup/handlers/arango/backup/state_unavailable_test.go +++ b/pkg/backup/handlers/arango/backup/state_unavailable_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/require" "testing" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func Test_State_Unavailable_Common(t *testing.T) { diff --git a/pkg/backup/handlers/arango/backup/state_upload.go b/pkg/backup/handlers/arango/backup/state_upload.go index 9bcba6c27..eac1baa13 100644 --- a/pkg/backup/handlers/arango/backup/state_upload.go +++ b/pkg/backup/handlers/arango/backup/state_upload.go @@ -24,7 +24,7 @@ package backup import ( "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateUploadHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { diff --git a/pkg/backup/handlers/arango/backup/state_upload_test.go b/pkg/backup/handlers/arango/backup/state_upload_test.go index ff24323b8..a6fcda83c 100644 --- a/pkg/backup/handlers/arango/backup/state_upload_test.go +++ b/pkg/backup/handlers/arango/backup/state_upload_test.go @@ -28,7 +28,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_uploaderror.go b/pkg/backup/handlers/arango/backup/state_uploaderror.go index 501fa3a9b..0d7656b3b 100644 --- a/pkg/backup/handlers/arango/backup/state_uploaderror.go +++ b/pkg/backup/handlers/arango/backup/state_uploaderror.go @@ -25,7 +25,7 @@ package backup import ( "time" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) const ( diff --git a/pkg/backup/handlers/arango/backup/state_uploaderror_test.go b/pkg/backup/handlers/arango/backup/state_uploaderror_test.go index 4a27cd6b5..d837e6c0d 100644 --- a/pkg/backup/handlers/arango/backup/state_uploaderror_test.go +++ b/pkg/backup/handlers/arango/backup/state_uploaderror_test.go @@ -31,7 +31,7 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/state_uploading.go b/pkg/backup/handlers/arango/backup/state_uploading.go index e1338d73d..631db7b0a 100644 --- a/pkg/backup/handlers/arango/backup/state_uploading.go +++ b/pkg/backup/handlers/arango/backup/state_uploading.go @@ -27,7 +27,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" ) func stateUploadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backupApi.ArangoBackupStatus, error) { @@ -81,7 +81,7 @@ func stateUploadingHandler(h *handler, backup *backupApi.ArangoBackup) (*backupA } return wrapUpdateStatus(backup, - updateStatusState(backupApi.ArangoBackupStateUploading,""), + updateStatusState(backupApi.ArangoBackupStateUploading, ""), updateStatusAvailable(true), updateStatusJob(backup.Status.Progress.JobID, fmt.Sprintf("%d%%", details.Progress)), ) diff --git a/pkg/backup/handlers/arango/backup/state_uploading_test.go b/pkg/backup/handlers/arango/backup/state_uploading_test.go index 7dee70291..681670f60 100644 --- a/pkg/backup/handlers/arango/backup/state_uploading_test.go +++ b/pkg/backup/handlers/arango/backup/state_uploading_test.go @@ -29,7 +29,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" ) diff --git a/pkg/backup/handlers/arango/backup/status.go b/pkg/backup/handlers/arango/backup/status.go index 51ca327a1..a6bcaf0c5 100644 --- a/pkg/backup/handlers/arango/backup/status.go +++ b/pkg/backup/handlers/arango/backup/status.go @@ -25,7 +25,7 @@ package backup import ( "fmt" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/state" "github.com/arangodb/kube-arangodb/pkg/util" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -33,11 +33,11 @@ import ( type updateStatusFunc func(status *backupApi.ArangoBackupStatus) -func wrapUpdateStatus(backup *backupApi.ArangoBackup, update ... updateStatusFunc) (*backupApi.ArangoBackupStatus, error) { +func wrapUpdateStatus(backup *backupApi.ArangoBackup, update ...updateStatusFunc) (*backupApi.ArangoBackupStatus, error) { return updateStatus(backup, update...), nil } -func updateStatus(backup *backupApi.ArangoBackup, update ... updateStatusFunc) *backupApi.ArangoBackupStatus { +func updateStatus(backup *backupApi.ArangoBackup, update ...updateStatusFunc) *backupApi.ArangoBackupStatus { s := backup.Status.DeepCopy() for _, u := range update { @@ -47,7 +47,7 @@ func updateStatus(backup *backupApi.ArangoBackup, update ... updateStatusFunc) * return s } -func updateStatusState(state state.State, template string, a ... interface{}) updateStatusFunc { +func updateStatusState(state state.State, template string, a ...interface{}) updateStatusFunc { return func(status *backupApi.ArangoBackupStatus) { if status.State != state { status.Time = v1.Now() @@ -145,4 +145,4 @@ func createBackupFromMeta(backupMeta driver.BackupMeta, old *backupApi.ArangoBac obj.ID = string(backupMeta.ID) return obj -} \ No newline at end of file +} diff --git a/pkg/backup/handlers/arango/backup/util.go b/pkg/backup/handlers/arango/backup/util.go index f09ebd4b1..24bb5326b 100644 --- a/pkg/backup/handlers/arango/backup/util.go +++ b/pkg/backup/handlers/arango/backup/util.go @@ -25,11 +25,11 @@ package backup import ( "strings" - clientBackup "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1alpha" + clientBackup "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/state" ) diff --git a/pkg/backup/handlers/arango/policy/handler.go b/pkg/backup/handlers/arango/policy/handler.go index 0825b8fc3..d9b5245b5 100644 --- a/pkg/backup/handlers/arango/policy/handler.go +++ b/pkg/backup/handlers/arango/policy/handler.go @@ -24,6 +24,7 @@ package policy import ( "fmt" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" "reflect" "time" @@ -35,8 +36,7 @@ import ( "k8s.io/client-go/kubernetes" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" arangoClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/robfig/cron" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -57,7 +57,7 @@ type handler struct { } func (*handler) Name() string { - return backupApi.ArangoBackupPolicyResourceKind + return backup.ArangoBackupPolicyResourceKind } func (h *handler) Handle(item operation.Item) error { @@ -67,7 +67,7 @@ func (h *handler) Handle(item operation.Item) error { } // Get Backup object. It also cover NotFound case - policy, err := h.client.BackupV1alpha().ArangoBackupPolicies(item.Namespace).Get(item.Name, meta.GetOptions{}) + policy, err := h.client.BackupV1().ArangoBackupPolicies(item.Namespace).Get(item.Name, meta.GetOptions{}) if err != nil { return err } @@ -85,7 +85,7 @@ func (h *handler) Handle(item operation.Item) error { policy.Status = status // Update status on object - if _, err = h.client.BackupV1alpha().ArangoBackupPolicies(item.Namespace).UpdateStatus(policy); err != nil { + if _, err = h.client.BackupV1().ArangoBackupPolicies(item.Namespace).UpdateStatus(policy); err != nil { return err } @@ -149,7 +149,7 @@ func (h *handler) processBackupPolicy(policy *backupApi.ArangoBackupPolicy) (bac listOptions.LabelSelector = meta.FormatLabelSelector(policy.Spec.DeploymentSelector) } - deployments, err := h.client.DatabaseV1alpha().ArangoDeployments(policy.Namespace).List(listOptions) + deployments, err := h.client.DatabaseV1().ArangoDeployments(policy.Namespace).List(listOptions) if err != nil { h.eventRecorder.Warning(policy, policyError, "Policy Error: %s", err.Error()) @@ -163,7 +163,7 @@ func (h *handler) processBackupPolicy(policy *backupApi.ArangoBackupPolicy) (bac for _, deployment := range deployments.Items { b := policy.NewBackup(deployment.DeepCopy()) - if _, err := h.client.BackupV1alpha().ArangoBackups(b.Namespace).Create(b); err != nil { + if _, err := h.client.BackupV1().ArangoBackups(b.Namespace).Create(b); err != nil { h.eventRecorder.Warning(policy, policyError, "Policy Error: %s", err.Error()) return backupApi.ArangoBackupPolicyStatus{ @@ -187,7 +187,7 @@ func (h *handler) processBackupPolicy(policy *backupApi.ArangoBackupPolicy) (bac } func (*handler) CanBeHandled(item operation.Item) bool { - return item.Group == database.SchemeGroupVersion.Group && - item.Version == database.SchemeGroupVersion.Version && - item.Kind == backupApi.ArangoBackupPolicyResourceKind + return item.Group == backupApi.SchemeGroupVersion.Group && + item.Version == backupApi.SchemeGroupVersion.Version && + item.Kind == backup.ArangoBackupPolicyResourceKind } diff --git a/pkg/backup/handlers/arango/policy/handler_scheduler_test.go b/pkg/backup/handlers/arango/policy/handler_scheduler_test.go index f5f6b3fc1..1ff101b19 100644 --- a/pkg/backup/handlers/arango/policy/handler_scheduler_test.go +++ b/pkg/backup/handlers/arango/policy/handler_scheduler_test.go @@ -28,7 +28,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/backup/operator/operation" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/stretchr/testify/require" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" @@ -287,4 +287,4 @@ func Test_Validate(t *testing.T) { require.NotEmpty(t, newPolicy.Status.Scheduled) }) } -} \ No newline at end of file +} diff --git a/pkg/backup/handlers/arango/policy/handler_suite_test.go b/pkg/backup/handlers/arango/policy/handler_suite_test.go index d2bb20245..20d077be6 100644 --- a/pkg/backup/handlers/arango/policy/handler_suite_test.go +++ b/pkg/backup/handlers/arango/policy/handler_suite_test.go @@ -24,6 +24,8 @@ package policy import ( "fmt" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" "testing" "github.com/arangodb/kube-arangodb/pkg/backup/operator/event" @@ -31,8 +33,8 @@ import ( "k8s.io/client-go/kubernetes/fake" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" fakeClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/fake" "github.com/stretchr/testify/require" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -54,9 +56,9 @@ func newFakeHandler() *handler { func newItem(o operation.Operation, namespace, name string) operation.Item { return operation.Item{ - Group: database.SchemeGroupVersion.Group, - Version: database.SchemeGroupVersion.Version, - Kind: backupApi.ArangoBackupPolicyResourceKind, + Group: backupApi.SchemeGroupVersion.Group, + Version: backupApi.SchemeGroupVersion.Version, + Kind: backup.ArangoBackupPolicyResourceKind, Operation: o, @@ -72,15 +74,15 @@ func newItemFromBackupPolicy(operation operation.Operation, policy *backupApi.Ar func newArangoBackupPolicy(schedule, namespace, name string, selector map[string]string, template backupApi.ArangoBackupTemplate) *backupApi.ArangoBackupPolicy { return &backupApi.ArangoBackupPolicy{ TypeMeta: meta.TypeMeta{ - APIVersion: database.SchemeGroupVersion.String(), - Kind: backupApi.ArangoBackupPolicyResourceKind, + APIVersion: backupApi.SchemeGroupVersion.String(), + Kind: backup.ArangoBackupPolicyResourceKind, }, ObjectMeta: meta.ObjectMeta{ Name: name, Namespace: namespace, SelfLink: fmt.Sprintf("/api/%s/%s/%s/%s", - database.SchemeGroupVersion.String(), - backupApi.ArangoBackupPolicyResourcePlural, + backupApi.SchemeGroupVersion.String(), + backup.ArangoBackupPolicyResourcePlural, namespace, name), UID: uuid.NewUUID(), @@ -96,7 +98,7 @@ func newArangoBackupPolicy(schedule, namespace, name string, selector map[string } func refreshArangoBackupPolicy(t *testing.T, h *handler, policy *backupApi.ArangoBackupPolicy) *backupApi.ArangoBackupPolicy { - newPolicy, err := h.client.BackupV1alpha().ArangoBackupPolicies(policy.Namespace).Get(policy.Name, meta.GetOptions{}) + newPolicy, err := h.client.BackupV1().ArangoBackupPolicies(policy.Namespace).Get(policy.Name, meta.GetOptions{}) require.NoError(t, err) return newPolicy @@ -104,14 +106,14 @@ func refreshArangoBackupPolicy(t *testing.T, h *handler, policy *backupApi.Arang func createArangoBackupPolicy(t *testing.T, h *handler, policies ...*backupApi.ArangoBackupPolicy) { for _, policy := range policies { - _, err := h.client.BackupV1alpha().ArangoBackupPolicies(policy.Namespace).Create(policy) + _, err := h.client.BackupV1().ArangoBackupPolicies(policy.Namespace).Create(policy) require.NoError(t, err) } } func updateArangoBackupPolicy(t *testing.T, h *handler, policies ...*backupApi.ArangoBackupPolicy) { for _, policy := range policies { - _, err := h.client.BackupV1alpha().ArangoBackupPolicies(policy.Namespace).Update(policy) + _, err := h.client.BackupV1().ArangoBackupPolicies(policy.Namespace).Update(policy) require.NoError(t, err) } } @@ -120,15 +122,15 @@ func newArangoDeployment(namespace string, labels map[string]string) *database.A name := string(uuid.NewUUID()) return &database.ArangoDeployment{ TypeMeta: meta.TypeMeta{ - APIVersion: database.SchemeGroupVersion.String(), - Kind: database.ArangoDeploymentResourceKind, + APIVersion: backupApi.SchemeGroupVersion.String(), + Kind: deployment.ArangoDeploymentResourceKind, }, ObjectMeta: meta.ObjectMeta{ Name: name, Namespace: namespace, SelfLink: fmt.Sprintf("/api/%s/%s/%s/%s", - database.SchemeGroupVersion.String(), - database.ArangoDeploymentResourcePlural, + backupApi.SchemeGroupVersion.String(), + deployment.ArangoDeploymentResourcePlural, namespace, name), UID: uuid.NewUUID(), @@ -139,13 +141,13 @@ func newArangoDeployment(namespace string, labels map[string]string) *database.A func createArangoDeployment(t *testing.T, h *handler, deployments ...*database.ArangoDeployment) { for _, deployment := range deployments { - _, err := h.client.DatabaseV1alpha().ArangoDeployments(deployment.Namespace).Create(deployment) + _, err := h.client.DatabaseV1().ArangoDeployments(deployment.Namespace).Create(deployment) require.NoError(t, err) } } func listArangoBackups(t *testing.T, handler *handler, namespace string) []backupApi.ArangoBackup { - result, err := handler.client.BackupV1alpha().ArangoBackups(namespace).List(meta.ListOptions{}) + result, err := handler.client.BackupV1().ArangoBackups(namespace).List(meta.ListOptions{}) require.NoError(t, err) return result.Items diff --git a/pkg/backup/handlers/arango/policy/lifecycle.go b/pkg/backup/handlers/arango/policy/lifecycle.go index b36a5a6ff..1251869b4 100644 --- a/pkg/backup/handlers/arango/policy/lifecycle.go +++ b/pkg/backup/handlers/arango/policy/lifecycle.go @@ -23,9 +23,9 @@ package policy import ( + "github.com/arangodb/kube-arangodb/pkg/apis/backup" "time" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" "github.com/arangodb/kube-arangodb/pkg/backup/operator" "github.com/rs/zerolog/log" meta "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,10 +43,10 @@ func (h *handler) LifecyclePreStart() error { }() for { - _, err := h.client.BackupV1alpha().ArangoBackupPolicies(h.operator.Namespace()).List(meta.ListOptions{}) + _, err := h.client.BackupV1().ArangoBackupPolicies(h.operator.Namespace()).List(meta.ListOptions{}) if err != nil { - log.Warn().Err(err).Msgf("CR for %s not found", backupApi.ArangoBackupPolicyResourceKind) + log.Warn().Err(err).Msgf("CR for %s not found", backup.ArangoBackupPolicyResourceKind) time.Sleep(250 * time.Millisecond) continue diff --git a/pkg/backup/handlers/arango/policy/register.go b/pkg/backup/handlers/arango/policy/register.go index 2aed30c15..35b35e1a1 100644 --- a/pkg/backup/handlers/arango/policy/register.go +++ b/pkg/backup/handlers/arango/policy/register.go @@ -23,8 +23,8 @@ package policy import ( - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/arangodb/kube-arangodb/pkg/backup/operator" "github.com/arangodb/kube-arangodb/pkg/backup/operator/event" arangoClientSet "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" @@ -33,17 +33,17 @@ import ( ) func newEventInstance(eventRecorder event.Recorder) event.RecorderInstance { - return eventRecorder.NewInstance(database.SchemeGroupVersion.Group, - database.SchemeGroupVersion.Version, - backupApi.ArangoBackupPolicyResourceKind) + return eventRecorder.NewInstance(backupApi.SchemeGroupVersion.Group, + backupApi.SchemeGroupVersion.Version, + backup.ArangoBackupPolicyResourceKind) } // RegisterInformer in operator func RegisterInformer(operator operator.Operator, recorder event.Recorder, client arangoClientSet.Interface, kubeClient kubernetes.Interface, informer arangoInformer.SharedInformerFactory) error { - if err := operator.RegisterInformer(informer.Backup().V1alpha().ArangoBackupPolicies().Informer(), - database.SchemeGroupVersion.Group, - database.SchemeGroupVersion.Version, - backupApi.ArangoBackupPolicyResourceKind); err != nil { + if err := operator.RegisterInformer(informer.Backup().V1().ArangoBackupPolicies().Informer(), + backupApi.SchemeGroupVersion.Group, + backupApi.SchemeGroupVersion.Version, + backup.ArangoBackupPolicyResourceKind); err != nil { return err } diff --git a/pkg/deployment/backup/handler.go b/pkg/deployment/backup/handler.go index 439f105b0..325cee56d 100644 --- a/pkg/deployment/backup/handler.go +++ b/pkg/deployment/backup/handler.go @@ -26,8 +26,8 @@ import ( "context" "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/bootstrap.go b/pkg/deployment/bootstrap.go index efe5325c5..86f545c2f 100644 --- a/pkg/deployment/bootstrap.go +++ b/pkg/deployment/bootstrap.go @@ -28,7 +28,7 @@ import ( "encoding/hex" "fmt" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/deployment/chaos/context.go b/pkg/deployment/chaos/context.go index d2d2a4d8a..d1a475eb5 100644 --- a/pkg/deployment/chaos/context.go +++ b/pkg/deployment/chaos/context.go @@ -25,7 +25,7 @@ package chaos import ( "k8s.io/api/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) // Context provides methods to the chaos package. diff --git a/pkg/deployment/client_cache.go b/pkg/deployment/client_cache.go index f2f8084e9..325d7edc5 100644 --- a/pkg/deployment/client_cache.go +++ b/pkg/deployment/client_cache.go @@ -30,7 +30,7 @@ import ( "k8s.io/client-go/kubernetes" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" ) diff --git a/pkg/deployment/cluster_scaling_integration.go b/pkg/deployment/cluster_scaling_integration.go index 9480decc7..45dcbbc45 100644 --- a/pkg/deployment/cluster_scaling_integration.go +++ b/pkg/deployment/cluster_scaling_integration.go @@ -30,7 +30,7 @@ import ( "github.com/rs/zerolog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -159,7 +159,7 @@ func (ci *clusterScalingIntegration) inspectCluster(ctx context.Context, expectS } // Let's update the spec apiObject := ci.depl.apiObject - current, err := ci.depl.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(apiObject.Namespace).Get(apiObject.Name, metav1.GetOptions{}) + current, err := ci.depl.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(apiObject.Namespace).Get(apiObject.Name, metav1.GetOptions{}) if err != nil { return maskAny(err) } diff --git a/pkg/deployment/context_impl.go b/pkg/deployment/context_impl.go index 1dc7c661d..53f14b60e 100644 --- a/pkg/deployment/context_impl.go +++ b/pkg/deployment/context_impl.go @@ -36,8 +36,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/deployment/resources" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -46,7 +46,7 @@ import ( // GetBackup receives information about a backup resource func (d *Deployment) GetBackup(backup string) (*backupApi.ArangoBackup, error) { - return d.deps.DatabaseCRCli.BackupV1alpha().ArangoBackups(d.Namespace()).Get(backup, metav1.GetOptions{}) + return d.deps.DatabaseCRCli.BackupV1().ArangoBackups(d.Namespace()).Get(backup, metav1.GetOptions{}) } // GetAPIObject returns the deployment as k8s object. diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index 8c92ecca5..5b4e36c70 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -36,7 +36,7 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/record" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/deployment/backup" "github.com/arangodb/kube-arangodb/pkg/deployment/chaos" "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile" @@ -297,7 +297,7 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error { log := d.deps.Log.With().Str("deployment", d.apiObject.GetName()).Logger() // Get the most recent version of the deployment from the API server - current, err := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(d.apiObject.GetNamespace()).Get(d.apiObject.GetName(), metav1.GetOptions{}) + current, err := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.apiObject.GetNamespace()).Get(d.apiObject.GetName(), metav1.GetOptions{}) if err != nil { log.Debug().Err(err).Msg("Failed to get current version of deployment from API server") if k8sutil.IsNotFound(err) { @@ -382,7 +382,7 @@ func (d *Deployment) updateCRStatus(force ...bool) error { // Send update to API server ns := d.apiObject.GetNamespace() - depls := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(ns) + depls := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(ns) update := d.apiObject.DeepCopy() attempt := 0 for { @@ -435,7 +435,7 @@ func (d *Deployment) updateCRSpec(newSpec api.DeploymentSpec, force ...bool) err update.Spec = newSpec update.Status = d.status.last ns := d.apiObject.GetNamespace() - newAPIObject, err := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(ns).Update(update) + newAPIObject, err := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(ns).Update(update) if err == nil { // Update internal object d.apiObject = newAPIObject @@ -445,7 +445,7 @@ func (d *Deployment) updateCRSpec(newSpec api.DeploymentSpec, force ...bool) err // API object may have been changed already, // Reload api object and try again var current *api.ArangoDeployment - current, err = d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(ns).Get(update.GetName(), metav1.GetOptions{}) + current, err = d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(ns).Get(update.GetName(), metav1.GetOptions{}) if err == nil { update = current.DeepCopy() continue @@ -485,7 +485,7 @@ func (d *Deployment) reportFailedStatus() { return maskAny(err) } - depl, err := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(d.apiObject.Namespace).Get(d.apiObject.Name, metav1.GetOptions{}) + depl, err := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.apiObject.Namespace).Get(d.apiObject.Name, metav1.GetOptions{}) if err != nil { // Update (PUT) will return conflict even if object is deleted since we have UID set in object. // Because it will check UID first and return something like: diff --git a/pkg/deployment/deployment_finalizers.go b/pkg/deployment/deployment_finalizers.go index e57e1e7ab..3af7ba863 100644 --- a/pkg/deployment/deployment_finalizers.go +++ b/pkg/deployment/deployment_finalizers.go @@ -28,7 +28,7 @@ import ( "github.com/rs/zerolog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -51,7 +51,7 @@ func (d *Deployment) runDeploymentFinalizers(ctx context.Context) error { log := d.deps.Log var removalList []string - depls := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(d.GetNamespace()) + depls := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.GetNamespace()) updated, err := depls.Get(d.apiObject.GetName(), metav1.GetOptions{}) if err != nil { return maskAny(err) @@ -92,7 +92,7 @@ func (d *Deployment) inspectRemoveChildFinalizers(ctx context.Context, log zerol // removeDeploymentFinalizers removes the given finalizers from the given PVC. func removeDeploymentFinalizers(log zerolog.Logger, cli versioned.Interface, depl *api.ArangoDeployment, finalizers []string) error { - depls := cli.DatabaseV1alpha().ArangoDeployments(depl.GetNamespace()) + depls := cli.DatabaseV1().ArangoDeployments(depl.GetNamespace()) getFunc := func() (metav1.Object, error) { result, err := depls.Get(depl.GetName(), metav1.GetOptions{}) if err != nil { diff --git a/pkg/deployment/deployment_inspector.go b/pkg/deployment/deployment_inspector.go index 1444f52a5..137764bd9 100644 --- a/pkg/deployment/deployment_inspector.go +++ b/pkg/deployment/deployment_inspector.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -55,7 +55,7 @@ func (d *Deployment) inspectDeployment(lastInterval util.Interval) util.Interval defer metrics.SetDuration(inspectDeploymentDurationGauges.WithLabelValues(deploymentName), start) // Check deployment still exists - updated, err := d.deps.DatabaseCRCli.DatabaseV1alpha().ArangoDeployments(d.apiObject.GetNamespace()).Get(deploymentName, metav1.GetOptions{}) + updated, err := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.apiObject.GetNamespace()).Get(deploymentName, metav1.GetOptions{}) if k8sutil.IsNotFound(err) { // Deployment is gone log.Info().Msg("Deployment is gone") diff --git a/pkg/deployment/images.go b/pkg/deployment/images.go index c8f1f6c01..60f23af58 100644 --- a/pkg/deployment/images.go +++ b/pkg/deployment/images.go @@ -34,7 +34,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" diff --git a/pkg/deployment/members.go b/pkg/deployment/members.go index a4fffa2f7..b6a37b6c8 100644 --- a/pkg/deployment/members.go +++ b/pkg/deployment/members.go @@ -30,7 +30,7 @@ import ( "github.com/rs/zerolog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/reconcile/action_add_member.go b/pkg/deployment/reconcile/action_add_member.go index 1e282c67e..9892b27dd 100644 --- a/pkg/deployment/reconcile/action_add_member.go +++ b/pkg/deployment/reconcile/action_add_member.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" "github.com/rs/zerolog/log" ) diff --git a/pkg/deployment/reconcile/action_cleanout_member.go b/pkg/deployment/reconcile/action_cleanout_member.go index d7c9c26c2..cb8d83629 100644 --- a/pkg/deployment/reconcile/action_cleanout_member.go +++ b/pkg/deployment/reconcile/action_cleanout_member.go @@ -27,7 +27,7 @@ import ( "time" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" "github.com/arangodb/kube-arangodb/pkg/util/arangod" diff --git a/pkg/deployment/reconcile/action_context.go b/pkg/deployment/reconcile/action_context.go index a64510a30..2eeda69b4 100644 --- a/pkg/deployment/reconcile/action_context.go +++ b/pkg/deployment/reconcile/action_context.go @@ -33,7 +33,7 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) // ActionContext provides methods to the Action implementations diff --git a/pkg/deployment/reconcile/action_remove_member.go b/pkg/deployment/reconcile/action_remove_member.go index 37e8fa632..a6ef3d76b 100644 --- a/pkg/deployment/reconcile/action_remove_member.go +++ b/pkg/deployment/reconcile/action_remove_member.go @@ -31,7 +31,7 @@ import ( "github.com/rs/zerolog" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" ) diff --git a/pkg/deployment/reconcile/action_renew_tls_ca_certificate.go b/pkg/deployment/reconcile/action_renew_tls_ca_certificate.go index 5a0a3543e..0149fd24c 100644 --- a/pkg/deployment/reconcile/action_renew_tls_ca_certificate.go +++ b/pkg/deployment/reconcile/action_renew_tls_ca_certificate.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_renew_tls_certificate.go b/pkg/deployment/reconcile/action_renew_tls_certificate.go index 8ea4c839f..9c219682a 100644 --- a/pkg/deployment/reconcile/action_renew_tls_certificate.go +++ b/pkg/deployment/reconcile/action_renew_tls_certificate.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_rotate_member.go b/pkg/deployment/reconcile/action_rotate_member.go index e6cbe7a07..a7f2ba16c 100644 --- a/pkg/deployment/reconcile/action_rotate_member.go +++ b/pkg/deployment/reconcile/action_rotate_member.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_shutdown_member.go b/pkg/deployment/reconcile/action_shutdown_member.go index b27990cd1..4565bddc5 100644 --- a/pkg/deployment/reconcile/action_shutdown_member.go +++ b/pkg/deployment/reconcile/action_shutdown_member.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_upgrade_current_image.go b/pkg/deployment/reconcile/action_upgrade_current_image.go index aba316826..0bddb5819 100644 --- a/pkg/deployment/reconcile/action_upgrade_current_image.go +++ b/pkg/deployment/reconcile/action_upgrade_current_image.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_upgrade_member.go b/pkg/deployment/reconcile/action_upgrade_member.go index 97f82368a..c3a5b3126 100644 --- a/pkg/deployment/reconcile/action_upgrade_member.go +++ b/pkg/deployment/reconcile/action_upgrade_member.go @@ -26,7 +26,7 @@ import ( "context" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/action_wait_for_member_up.go b/pkg/deployment/reconcile/action_wait_for_member_up.go index fdbf51b8b..e87f8040f 100644 --- a/pkg/deployment/reconcile/action_wait_for_member_up.go +++ b/pkg/deployment/reconcile/action_wait_for_member_up.go @@ -31,7 +31,7 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) // NewWaitForMemberUpAction creates a new Action that implements the given diff --git a/pkg/deployment/reconcile/context.go b/pkg/deployment/reconcile/context.go index c2a51bf39..a1c241055 100644 --- a/pkg/deployment/reconcile/context.go +++ b/pkg/deployment/reconcile/context.go @@ -31,7 +31,7 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/reconcile/plan_builder.go b/pkg/deployment/reconcile/plan_builder.go index 80e96575f..ed3c82a6a 100644 --- a/pkg/deployment/reconcile/plan_builder.go +++ b/pkg/deployment/reconcile/plan_builder.go @@ -32,7 +32,7 @@ import ( "github.com/rs/zerolog/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" v1 "k8s.io/api/core/v1" ) diff --git a/pkg/deployment/reconcile/plan_builder_context.go b/pkg/deployment/reconcile/plan_builder_context.go index 35ca8b47f..48ede82d5 100644 --- a/pkg/deployment/reconcile/plan_builder_context.go +++ b/pkg/deployment/reconcile/plan_builder_context.go @@ -24,7 +24,7 @@ package reconcile import ( driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/deployment/reconcile/plan_builder_storage.go b/pkg/deployment/reconcile/plan_builder_storage.go index 132e0b0c7..67bcb7edc 100644 --- a/pkg/deployment/reconcile/plan_builder_storage.go +++ b/pkg/deployment/reconcile/plan_builder_storage.go @@ -26,7 +26,7 @@ import ( "github.com/rs/zerolog" "k8s.io/api/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/reconcile/plan_builder_test.go b/pkg/deployment/reconcile/plan_builder_test.go index c1f2daace..1d19345b2 100644 --- a/pkg/deployment/reconcile/plan_builder_test.go +++ b/pkg/deployment/reconcile/plan_builder_test.go @@ -32,7 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" v1 "k8s.io/api/core/v1" diff --git a/pkg/deployment/reconcile/plan_builder_tls.go b/pkg/deployment/reconcile/plan_builder_tls.go index 53086ecf7..377414465 100644 --- a/pkg/deployment/reconcile/plan_builder_tls.go +++ b/pkg/deployment/reconcile/plan_builder_tls.go @@ -28,7 +28,7 @@ import ( "net" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/reconcile/plan_executor.go b/pkg/deployment/reconcile/plan_executor.go index 22ba1c39d..4c18482ac 100644 --- a/pkg/deployment/reconcile/plan_executor.go +++ b/pkg/deployment/reconcile/plan_executor.go @@ -30,7 +30,7 @@ import ( "github.com/rs/zerolog" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/reconcile/reconciler.go b/pkg/deployment/reconcile/reconciler.go index 8b667b1d1..41119368d 100644 --- a/pkg/deployment/reconcile/reconciler.go +++ b/pkg/deployment/reconcile/reconciler.go @@ -23,7 +23,7 @@ package reconcile import ( - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/rs/zerolog" ) diff --git a/pkg/deployment/resilience/context.go b/pkg/deployment/resilience/context.go index 4a0c4fa0e..3af2f387b 100644 --- a/pkg/deployment/resilience/context.go +++ b/pkg/deployment/resilience/context.go @@ -26,7 +26,7 @@ import ( "context" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) // Context provides methods to the resilience package. diff --git a/pkg/deployment/resilience/member_failure.go b/pkg/deployment/resilience/member_failure.go index c9d81f3ac..7eab383d7 100644 --- a/pkg/deployment/resilience/member_failure.go +++ b/pkg/deployment/resilience/member_failure.go @@ -27,7 +27,7 @@ import ( "time" "github.com/arangodb/go-driver/agency" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" ) diff --git a/pkg/deployment/resources/certificates_client_auth.go b/pkg/deployment/resources/certificates_client_auth.go index 51c2424d2..d5519a2db 100644 --- a/pkg/deployment/resources/certificates_client_auth.go +++ b/pkg/deployment/resources/certificates_client_auth.go @@ -32,7 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/typed/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/resources/certificates_tls.go b/pkg/deployment/resources/certificates_tls.go index 541c486c2..50dd325b2 100644 --- a/pkg/deployment/resources/certificates_tls.go +++ b/pkg/deployment/resources/certificates_tls.go @@ -32,7 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/typed/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/resources/context.go b/pkg/deployment/resources/context.go index 54d7d9b1b..330bf5b58 100644 --- a/pkg/deployment/resources/context.go +++ b/pkg/deployment/resources/context.go @@ -27,7 +27,7 @@ import ( driver "github.com/arangodb/go-driver" "github.com/arangodb/go-driver/agency" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" diff --git a/pkg/deployment/resources/deployment_health.go b/pkg/deployment/resources/deployment_health.go index 8293d3464..2ed3f4122 100644 --- a/pkg/deployment/resources/deployment_health.go +++ b/pkg/deployment/resources/deployment_health.go @@ -28,7 +28,7 @@ import ( "time" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" ) diff --git a/pkg/deployment/resources/member_cleanup.go b/pkg/deployment/resources/member_cleanup.go index e1f33ddef..b7bc0f363 100644 --- a/pkg/deployment/resources/member_cleanup.go +++ b/pkg/deployment/resources/member_cleanup.go @@ -26,7 +26,7 @@ import ( "time" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/resources/pdbs.go b/pkg/deployment/resources/pdbs.go index 21390c6a3..ecf852ea7 100644 --- a/pkg/deployment/resources/pdbs.go +++ b/pkg/deployment/resources/pdbs.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" policyv1beta1 "k8s.io/api/policy/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/deployment/resources/pod_cleanup.go b/pkg/deployment/resources/pod_cleanup.go index a45862616..cc3493288 100644 --- a/pkg/deployment/resources/pod_cleanup.go +++ b/pkg/deployment/resources/pod_cleanup.go @@ -28,7 +28,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) const ( diff --git a/pkg/deployment/resources/pod_creator.go b/pkg/deployment/resources/pod_creator.go index 944b67eab..ab45510b7 100644 --- a/pkg/deployment/resources/pod_creator.go +++ b/pkg/deployment/resources/pod_creator.go @@ -37,7 +37,7 @@ import ( driver "github.com/arangodb/go-driver" "github.com/arangodb/go-driver/jwt" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/pkg/errors" diff --git a/pkg/deployment/resources/pod_creator_agent_args_test.go b/pkg/deployment/resources/pod_creator_agent_args_test.go index 6760ec6cf..5cae34557 100644 --- a/pkg/deployment/resources/pod_creator_agent_args_test.go +++ b/pkg/deployment/resources/pod_creator_agent_args_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" ) diff --git a/pkg/deployment/resources/pod_creator_coordinator_args_test.go b/pkg/deployment/resources/pod_creator_coordinator_args_test.go index 638b83771..b550c5736 100644 --- a/pkg/deployment/resources/pod_creator_coordinator_args_test.go +++ b/pkg/deployment/resources/pod_creator_coordinator_args_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" ) diff --git a/pkg/deployment/resources/pod_creator_dbserver_args_test.go b/pkg/deployment/resources/pod_creator_dbserver_args_test.go index 7cf0a137e..ec69c64cf 100644 --- a/pkg/deployment/resources/pod_creator_dbserver_args_test.go +++ b/pkg/deployment/resources/pod_creator_dbserver_args_test.go @@ -28,7 +28,7 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" ) diff --git a/pkg/deployment/resources/pod_creator_single_args_test.go b/pkg/deployment/resources/pod_creator_single_args_test.go index 69c45a9ca..ac8622317 100644 --- a/pkg/deployment/resources/pod_creator_single_args_test.go +++ b/pkg/deployment/resources/pod_creator_single_args_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/stretchr/testify/assert" ) diff --git a/pkg/deployment/resources/pod_finalizers.go b/pkg/deployment/resources/pod_finalizers.go index f0c7da54c..cb9335279 100644 --- a/pkg/deployment/resources/pod_finalizers.go +++ b/pkg/deployment/resources/pod_finalizers.go @@ -30,7 +30,7 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" diff --git a/pkg/deployment/resources/pod_inspector.go b/pkg/deployment/resources/pod_inspector.go index eb551c935..fff0cc95f 100644 --- a/pkg/deployment/resources/pod_inspector.go +++ b/pkg/deployment/resources/pod_inspector.go @@ -30,7 +30,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" diff --git a/pkg/deployment/resources/pod_termination.go b/pkg/deployment/resources/pod_termination.go index 7fd19e1ec..ba378a211 100644 --- a/pkg/deployment/resources/pod_termination.go +++ b/pkg/deployment/resources/pod_termination.go @@ -32,7 +32,7 @@ import ( driver "github.com/arangodb/go-driver" "github.com/arangodb/go-driver/agency" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" v1 "k8s.io/api/core/v1" diff --git a/pkg/deployment/resources/pvc_finalizers.go b/pkg/deployment/resources/pvc_finalizers.go index aa0882d49..6fa215c92 100644 --- a/pkg/deployment/resources/pvc_finalizers.go +++ b/pkg/deployment/resources/pvc_finalizers.go @@ -31,7 +31,7 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" diff --git a/pkg/deployment/resources/pvcs.go b/pkg/deployment/resources/pvcs.go index b0af174cc..2cddeb5c5 100644 --- a/pkg/deployment/resources/pvcs.go +++ b/pkg/deployment/resources/pvcs.go @@ -23,7 +23,7 @@ package resources import ( - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/arangodb/kube-arangodb/pkg/util/constants" diff --git a/pkg/deployment/resources/secret_hashes.go b/pkg/deployment/resources/secret_hashes.go index a455b382a..119756a95 100644 --- a/pkg/deployment/resources/secret_hashes.go +++ b/pkg/deployment/resources/secret_hashes.go @@ -36,7 +36,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/resources/secrets.go b/pkg/deployment/resources/secrets.go index 392cbbc95..85058e6fb 100644 --- a/pkg/deployment/resources/secrets.go +++ b/pkg/deployment/resources/secrets.go @@ -29,7 +29,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/resources/servicemonitor.go b/pkg/deployment/resources/servicemonitor.go index 9dd75b199..cc75c450c 100644 --- a/pkg/deployment/resources/servicemonitor.go +++ b/pkg/deployment/resources/servicemonitor.go @@ -23,9 +23,9 @@ package resources import ( + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" - "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" coreosv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1" clientv1 "github.com/coreos/prometheus-operator/pkg/client/versioned/typed/monitoring/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -151,7 +151,7 @@ func (r *Resources) EnsureServiceMonitor() error { // Check if the service monitor is ours, otherwise we do not touch it: found := false for _, owner := range servMon.ObjectMeta.OwnerReferences { - if owner.Kind == v1alpha.ArangoDeploymentResourceKind && + if owner.Kind == deployment.ArangoDeploymentResourceKind && owner.Name == deploymentName { found = true break diff --git a/pkg/deployment/resources/services.go b/pkg/deployment/resources/services.go index 60d21753e..e26caff46 100644 --- a/pkg/deployment/resources/services.go +++ b/pkg/deployment/resources/services.go @@ -29,7 +29,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/prometheus/client_golang/prometheus" diff --git a/pkg/deployment/server_api.go b/pkg/deployment/server_api.go index 4bf82e1c2..3e8c72672 100644 --- a/pkg/deployment/server_api.go +++ b/pkg/deployment/server_api.go @@ -28,7 +28,7 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/server" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/deployment/server_member_api.go b/pkg/deployment/server_member_api.go index a37917b41..92164449f 100644 --- a/pkg/deployment/server_member_api.go +++ b/pkg/deployment/server_member_api.go @@ -25,7 +25,7 @@ package deployment import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/server" ) diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index b48848bfa..f1738c868 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -23,8 +23,11 @@ package versioned import ( + backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" backupv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1alpha" + databasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" databasev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1alpha" + replicationv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1" replicationv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1alpha" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/storage/v1alpha" discovery "k8s.io/client-go/discovery" @@ -35,8 +38,11 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface BackupV1alpha() backupv1alpha.BackupV1alphaInterface + BackupV1() backupv1.BackupV1Interface DatabaseV1alpha() databasev1alpha.DatabaseV1alphaInterface + DatabaseV1() databasev1.DatabaseV1Interface ReplicationV1alpha() replicationv1alpha.ReplicationV1alphaInterface + ReplicationV1() replicationv1.ReplicationV1Interface StorageV1alpha() storagev1alpha.StorageV1alphaInterface } @@ -45,8 +51,11 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient backupV1alpha *backupv1alpha.BackupV1alphaClient + backupV1 *backupv1.BackupV1Client databaseV1alpha *databasev1alpha.DatabaseV1alphaClient + databaseV1 *databasev1.DatabaseV1Client replicationV1alpha *replicationv1alpha.ReplicationV1alphaClient + replicationV1 *replicationv1.ReplicationV1Client storageV1alpha *storagev1alpha.StorageV1alphaClient } @@ -55,16 +64,31 @@ func (c *Clientset) BackupV1alpha() backupv1alpha.BackupV1alphaInterface { return c.backupV1alpha } +// BackupV1 retrieves the BackupV1Client +func (c *Clientset) BackupV1() backupv1.BackupV1Interface { + return c.backupV1 +} + // DatabaseV1alpha retrieves the DatabaseV1alphaClient func (c *Clientset) DatabaseV1alpha() databasev1alpha.DatabaseV1alphaInterface { return c.databaseV1alpha } +// DatabaseV1 retrieves the DatabaseV1Client +func (c *Clientset) DatabaseV1() databasev1.DatabaseV1Interface { + return c.databaseV1 +} + // ReplicationV1alpha retrieves the ReplicationV1alphaClient func (c *Clientset) ReplicationV1alpha() replicationv1alpha.ReplicationV1alphaInterface { return c.replicationV1alpha } +// ReplicationV1 retrieves the ReplicationV1Client +func (c *Clientset) ReplicationV1() replicationv1.ReplicationV1Interface { + return c.replicationV1 +} + // StorageV1alpha retrieves the StorageV1alphaClient func (c *Clientset) StorageV1alpha() storagev1alpha.StorageV1alphaInterface { return c.storageV1alpha @@ -90,14 +114,26 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.backupV1, err = backupv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.databaseV1alpha, err = databasev1alpha.NewForConfig(&configShallowCopy) if err != nil { return nil, err } + cs.databaseV1, err = databasev1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.replicationV1alpha, err = replicationv1alpha.NewForConfig(&configShallowCopy) if err != nil { return nil, err } + cs.replicationV1, err = replicationv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.storageV1alpha, err = storagev1alpha.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -115,8 +151,11 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.backupV1alpha = backupv1alpha.NewForConfigOrDie(c) + cs.backupV1 = backupv1.NewForConfigOrDie(c) cs.databaseV1alpha = databasev1alpha.NewForConfigOrDie(c) + cs.databaseV1 = databasev1.NewForConfigOrDie(c) cs.replicationV1alpha = replicationv1alpha.NewForConfigOrDie(c) + cs.replicationV1 = replicationv1.NewForConfigOrDie(c) cs.storageV1alpha = storagev1alpha.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) @@ -127,8 +166,11 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.backupV1alpha = backupv1alpha.New(c) + cs.backupV1 = backupv1.New(c) cs.databaseV1alpha = databasev1alpha.New(c) + cs.databaseV1 = databasev1.New(c) cs.replicationV1alpha = replicationv1alpha.New(c) + cs.replicationV1 = replicationv1.New(c) cs.storageV1alpha = storagev1alpha.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index da213d4c4..3459d9120 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -24,10 +24,16 @@ package fake import ( clientset "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + backupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" + fakebackupv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1/fake" backupv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1alpha" fakebackupv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1alpha/fake" + databasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" + fakedatabasev1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1/fake" databasev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1alpha" fakedatabasev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1alpha/fake" + replicationv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1" + fakereplicationv1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1/fake" replicationv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1alpha" fakereplicationv1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1alpha/fake" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/storage/v1alpha" @@ -86,16 +92,31 @@ func (c *Clientset) BackupV1alpha() backupv1alpha.BackupV1alphaInterface { return &fakebackupv1alpha.FakeBackupV1alpha{Fake: &c.Fake} } +// BackupV1 retrieves the BackupV1Client +func (c *Clientset) BackupV1() backupv1.BackupV1Interface { + return &fakebackupv1.FakeBackupV1{Fake: &c.Fake} +} + // DatabaseV1alpha retrieves the DatabaseV1alphaClient func (c *Clientset) DatabaseV1alpha() databasev1alpha.DatabaseV1alphaInterface { return &fakedatabasev1alpha.FakeDatabaseV1alpha{Fake: &c.Fake} } +// DatabaseV1 retrieves the DatabaseV1Client +func (c *Clientset) DatabaseV1() databasev1.DatabaseV1Interface { + return &fakedatabasev1.FakeDatabaseV1{Fake: &c.Fake} +} + // ReplicationV1alpha retrieves the ReplicationV1alphaClient func (c *Clientset) ReplicationV1alpha() replicationv1alpha.ReplicationV1alphaInterface { return &fakereplicationv1alpha.FakeReplicationV1alpha{Fake: &c.Fake} } +// ReplicationV1 retrieves the ReplicationV1Client +func (c *Clientset) ReplicationV1() replicationv1.ReplicationV1Interface { + return &fakereplicationv1.FakeReplicationV1{Fake: &c.Fake} +} + // StorageV1alpha retrieves the StorageV1alphaClient func (c *Clientset) StorageV1alpha() storagev1alpha.StorageV1alphaInterface { return &fakestoragev1alpha.FakeStorageV1alpha{Fake: &c.Fake} diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 5325530bf..6851ff001 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -23,8 +23,11 @@ package fake import ( + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" backupv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" databasev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -39,8 +42,11 @@ var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ backupv1alpha.AddToScheme, + backupv1.AddToScheme, databasev1alpha.AddToScheme, + databasev1.AddToScheme, replicationv1alpha.AddToScheme, + replicationv1.AddToScheme, storagev1alpha.AddToScheme, } diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 8b1f5dd60..2de493519 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -23,8 +23,11 @@ package scheme import ( + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" backupv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + databasev1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" databasev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -39,8 +42,11 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ backupv1alpha.AddToScheme, + backupv1.AddToScheme, databasev1alpha.AddToScheme, + databasev1.AddToScheme, replicationv1alpha.AddToScheme, + replicationv1.AddToScheme, storagev1alpha.AddToScheme, } diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/arangobackup.go b/pkg/generated/clientset/versioned/typed/backup/v1/arangobackup.go new file mode 100644 index 000000000..13e594d9f --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/arangobackup.go @@ -0,0 +1,195 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "time" + + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ArangoBackupsGetter has a method to return a ArangoBackupInterface. +// A group's client should implement this interface. +type ArangoBackupsGetter interface { + ArangoBackups(namespace string) ArangoBackupInterface +} + +// ArangoBackupInterface has methods to work with ArangoBackup resources. +type ArangoBackupInterface interface { + Create(*v1.ArangoBackup) (*v1.ArangoBackup, error) + Update(*v1.ArangoBackup) (*v1.ArangoBackup, error) + UpdateStatus(*v1.ArangoBackup) (*v1.ArangoBackup, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.ArangoBackup, error) + List(opts metav1.ListOptions) (*v1.ArangoBackupList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoBackup, err error) + ArangoBackupExpansion +} + +// arangoBackups implements ArangoBackupInterface +type arangoBackups struct { + client rest.Interface + ns string +} + +// newArangoBackups returns a ArangoBackups +func newArangoBackups(c *BackupV1Client, namespace string) *arangoBackups { + return &arangoBackups{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the arangoBackup, and returns the corresponding arangoBackup object, and an error if there is any. +func (c *arangoBackups) Get(name string, options metav1.GetOptions) (result *v1.ArangoBackup, err error) { + result = &v1.ArangoBackup{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangobackups"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ArangoBackups that match those selectors. +func (c *arangoBackups) List(opts metav1.ListOptions) (result *v1.ArangoBackupList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ArangoBackupList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangobackups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested arangoBackups. +func (c *arangoBackups) Watch(opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("arangobackups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a arangoBackup and creates it. Returns the server's representation of the arangoBackup, and an error, if there is any. +func (c *arangoBackups) Create(arangoBackup *v1.ArangoBackup) (result *v1.ArangoBackup, err error) { + result = &v1.ArangoBackup{} + err = c.client.Post(). + Namespace(c.ns). + Resource("arangobackups"). + Body(arangoBackup). + Do(). + Into(result) + return +} + +// Update takes the representation of a arangoBackup and updates it. Returns the server's representation of the arangoBackup, and an error, if there is any. +func (c *arangoBackups) Update(arangoBackup *v1.ArangoBackup) (result *v1.ArangoBackup, err error) { + result = &v1.ArangoBackup{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangobackups"). + Name(arangoBackup.Name). + Body(arangoBackup). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *arangoBackups) UpdateStatus(arangoBackup *v1.ArangoBackup) (result *v1.ArangoBackup, err error) { + result = &v1.ArangoBackup{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangobackups"). + Name(arangoBackup.Name). + SubResource("status"). + Body(arangoBackup). + Do(). + Into(result) + return +} + +// Delete takes name of the arangoBackup and deletes it. Returns an error if one occurs. +func (c *arangoBackups) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("arangobackups"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *arangoBackups) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("arangobackups"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched arangoBackup. +func (c *arangoBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoBackup, err error) { + result = &v1.ArangoBackup{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("arangobackups"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/arangobackuppolicy.go b/pkg/generated/clientset/versioned/typed/backup/v1/arangobackuppolicy.go new file mode 100644 index 000000000..7f080fd8f --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/arangobackuppolicy.go @@ -0,0 +1,195 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "time" + + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ArangoBackupPoliciesGetter has a method to return a ArangoBackupPolicyInterface. +// A group's client should implement this interface. +type ArangoBackupPoliciesGetter interface { + ArangoBackupPolicies(namespace string) ArangoBackupPolicyInterface +} + +// ArangoBackupPolicyInterface has methods to work with ArangoBackupPolicy resources. +type ArangoBackupPolicyInterface interface { + Create(*v1.ArangoBackupPolicy) (*v1.ArangoBackupPolicy, error) + Update(*v1.ArangoBackupPolicy) (*v1.ArangoBackupPolicy, error) + UpdateStatus(*v1.ArangoBackupPolicy) (*v1.ArangoBackupPolicy, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.ArangoBackupPolicy, error) + List(opts metav1.ListOptions) (*v1.ArangoBackupPolicyList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoBackupPolicy, err error) + ArangoBackupPolicyExpansion +} + +// arangoBackupPolicies implements ArangoBackupPolicyInterface +type arangoBackupPolicies struct { + client rest.Interface + ns string +} + +// newArangoBackupPolicies returns a ArangoBackupPolicies +func newArangoBackupPolicies(c *BackupV1Client, namespace string) *arangoBackupPolicies { + return &arangoBackupPolicies{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the arangoBackupPolicy, and returns the corresponding arangoBackupPolicy object, and an error if there is any. +func (c *arangoBackupPolicies) Get(name string, options metav1.GetOptions) (result *v1.ArangoBackupPolicy, err error) { + result = &v1.ArangoBackupPolicy{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ArangoBackupPolicies that match those selectors. +func (c *arangoBackupPolicies) List(opts metav1.ListOptions) (result *v1.ArangoBackupPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ArangoBackupPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested arangoBackupPolicies. +func (c *arangoBackupPolicies) Watch(opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a arangoBackupPolicy and creates it. Returns the server's representation of the arangoBackupPolicy, and an error, if there is any. +func (c *arangoBackupPolicies) Create(arangoBackupPolicy *v1.ArangoBackupPolicy) (result *v1.ArangoBackupPolicy, err error) { + result = &v1.ArangoBackupPolicy{} + err = c.client.Post(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + Body(arangoBackupPolicy). + Do(). + Into(result) + return +} + +// Update takes the representation of a arangoBackupPolicy and updates it. Returns the server's representation of the arangoBackupPolicy, and an error, if there is any. +func (c *arangoBackupPolicies) Update(arangoBackupPolicy *v1.ArangoBackupPolicy) (result *v1.ArangoBackupPolicy, err error) { + result = &v1.ArangoBackupPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + Name(arangoBackupPolicy.Name). + Body(arangoBackupPolicy). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *arangoBackupPolicies) UpdateStatus(arangoBackupPolicy *v1.ArangoBackupPolicy) (result *v1.ArangoBackupPolicy, err error) { + result = &v1.ArangoBackupPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + Name(arangoBackupPolicy.Name). + SubResource("status"). + Body(arangoBackupPolicy). + Do(). + Into(result) + return +} + +// Delete takes name of the arangoBackupPolicy and deletes it. Returns an error if one occurs. +func (c *arangoBackupPolicies) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *arangoBackupPolicies) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("arangobackuppolicies"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched arangoBackupPolicy. +func (c *arangoBackupPolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoBackupPolicy, err error) { + result = &v1.ArangoBackupPolicy{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("arangobackuppolicies"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/backup_client.go b/pkg/generated/clientset/versioned/typed/backup/v1/backup_client.go new file mode 100644 index 000000000..db2044eb7 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/backup_client.go @@ -0,0 +1,99 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type BackupV1Interface interface { + RESTClient() rest.Interface + ArangoBackupsGetter + ArangoBackupPoliciesGetter +} + +// BackupV1Client is used to interact with features provided by the backup.arangodb.com group. +type BackupV1Client struct { + restClient rest.Interface +} + +func (c *BackupV1Client) ArangoBackups(namespace string) ArangoBackupInterface { + return newArangoBackups(c, namespace) +} + +func (c *BackupV1Client) ArangoBackupPolicies(namespace string) ArangoBackupPolicyInterface { + return newArangoBackupPolicies(c, namespace) +} + +// NewForConfig creates a new BackupV1Client for the given config. +func NewForConfig(c *rest.Config) (*BackupV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &BackupV1Client{client}, nil +} + +// NewForConfigOrDie creates a new BackupV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *BackupV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new BackupV1Client for the given RESTClient. +func New(c rest.Interface) *BackupV1Client { + return &BackupV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *BackupV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/doc.go b/pkg/generated/clientset/versioned/typed/backup/v1/doc.go new file mode 100644 index 000000000..ff2718f73 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/backup/v1/fake/doc.go new file mode 100644 index 000000000..7958e7822 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackup.go b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackup.go new file mode 100644 index 000000000..f0cfc9546 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackup.go @@ -0,0 +1,144 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeArangoBackups implements ArangoBackupInterface +type FakeArangoBackups struct { + Fake *FakeBackupV1 + ns string +} + +var arangobackupsResource = schema.GroupVersionResource{Group: "backup.arangodb.com", Version: "v1", Resource: "arangobackups"} + +var arangobackupsKind = schema.GroupVersionKind{Group: "backup.arangodb.com", Version: "v1", Kind: "ArangoBackup"} + +// Get takes name of the arangoBackup, and returns the corresponding arangoBackup object, and an error if there is any. +func (c *FakeArangoBackups) Get(name string, options v1.GetOptions) (result *backupv1.ArangoBackup, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(arangobackupsResource, c.ns, name), &backupv1.ArangoBackup{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackup), err +} + +// List takes label and field selectors, and returns the list of ArangoBackups that match those selectors. +func (c *FakeArangoBackups) List(opts v1.ListOptions) (result *backupv1.ArangoBackupList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(arangobackupsResource, arangobackupsKind, c.ns, opts), &backupv1.ArangoBackupList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &backupv1.ArangoBackupList{ListMeta: obj.(*backupv1.ArangoBackupList).ListMeta} + for _, item := range obj.(*backupv1.ArangoBackupList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested arangoBackups. +func (c *FakeArangoBackups) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(arangobackupsResource, c.ns, opts)) + +} + +// Create takes the representation of a arangoBackup and creates it. Returns the server's representation of the arangoBackup, and an error, if there is any. +func (c *FakeArangoBackups) Create(arangoBackup *backupv1.ArangoBackup) (result *backupv1.ArangoBackup, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(arangobackupsResource, c.ns, arangoBackup), &backupv1.ArangoBackup{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackup), err +} + +// Update takes the representation of a arangoBackup and updates it. Returns the server's representation of the arangoBackup, and an error, if there is any. +func (c *FakeArangoBackups) Update(arangoBackup *backupv1.ArangoBackup) (result *backupv1.ArangoBackup, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(arangobackupsResource, c.ns, arangoBackup), &backupv1.ArangoBackup{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackup), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeArangoBackups) UpdateStatus(arangoBackup *backupv1.ArangoBackup) (*backupv1.ArangoBackup, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(arangobackupsResource, "status", c.ns, arangoBackup), &backupv1.ArangoBackup{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackup), err +} + +// Delete takes name of the arangoBackup and deletes it. Returns an error if one occurs. +func (c *FakeArangoBackups) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(arangobackupsResource, c.ns, name), &backupv1.ArangoBackup{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeArangoBackups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(arangobackupsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &backupv1.ArangoBackupList{}) + return err +} + +// Patch applies the patch and returns the patched arangoBackup. +func (c *FakeArangoBackups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *backupv1.ArangoBackup, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(arangobackupsResource, c.ns, name, pt, data, subresources...), &backupv1.ArangoBackup{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackup), err +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackuppolicy.go b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackuppolicy.go new file mode 100644 index 000000000..47e298a55 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_arangobackuppolicy.go @@ -0,0 +1,144 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeArangoBackupPolicies implements ArangoBackupPolicyInterface +type FakeArangoBackupPolicies struct { + Fake *FakeBackupV1 + ns string +} + +var arangobackuppoliciesResource = schema.GroupVersionResource{Group: "backup.arangodb.com", Version: "v1", Resource: "arangobackuppolicies"} + +var arangobackuppoliciesKind = schema.GroupVersionKind{Group: "backup.arangodb.com", Version: "v1", Kind: "ArangoBackupPolicy"} + +// Get takes name of the arangoBackupPolicy, and returns the corresponding arangoBackupPolicy object, and an error if there is any. +func (c *FakeArangoBackupPolicies) Get(name string, options v1.GetOptions) (result *backupv1.ArangoBackupPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(arangobackuppoliciesResource, c.ns, name), &backupv1.ArangoBackupPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackupPolicy), err +} + +// List takes label and field selectors, and returns the list of ArangoBackupPolicies that match those selectors. +func (c *FakeArangoBackupPolicies) List(opts v1.ListOptions) (result *backupv1.ArangoBackupPolicyList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(arangobackuppoliciesResource, arangobackuppoliciesKind, c.ns, opts), &backupv1.ArangoBackupPolicyList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &backupv1.ArangoBackupPolicyList{ListMeta: obj.(*backupv1.ArangoBackupPolicyList).ListMeta} + for _, item := range obj.(*backupv1.ArangoBackupPolicyList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested arangoBackupPolicies. +func (c *FakeArangoBackupPolicies) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(arangobackuppoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a arangoBackupPolicy and creates it. Returns the server's representation of the arangoBackupPolicy, and an error, if there is any. +func (c *FakeArangoBackupPolicies) Create(arangoBackupPolicy *backupv1.ArangoBackupPolicy) (result *backupv1.ArangoBackupPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(arangobackuppoliciesResource, c.ns, arangoBackupPolicy), &backupv1.ArangoBackupPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackupPolicy), err +} + +// Update takes the representation of a arangoBackupPolicy and updates it. Returns the server's representation of the arangoBackupPolicy, and an error, if there is any. +func (c *FakeArangoBackupPolicies) Update(arangoBackupPolicy *backupv1.ArangoBackupPolicy) (result *backupv1.ArangoBackupPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(arangobackuppoliciesResource, c.ns, arangoBackupPolicy), &backupv1.ArangoBackupPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackupPolicy), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeArangoBackupPolicies) UpdateStatus(arangoBackupPolicy *backupv1.ArangoBackupPolicy) (*backupv1.ArangoBackupPolicy, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(arangobackuppoliciesResource, "status", c.ns, arangoBackupPolicy), &backupv1.ArangoBackupPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackupPolicy), err +} + +// Delete takes name of the arangoBackupPolicy and deletes it. Returns an error if one occurs. +func (c *FakeArangoBackupPolicies) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(arangobackuppoliciesResource, c.ns, name), &backupv1.ArangoBackupPolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeArangoBackupPolicies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(arangobackuppoliciesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &backupv1.ArangoBackupPolicyList{}) + return err +} + +// Patch applies the patch and returns the patched arangoBackupPolicy. +func (c *FakeArangoBackupPolicies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *backupv1.ArangoBackupPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(arangobackuppoliciesResource, c.ns, name, pt, data, subresources...), &backupv1.ArangoBackupPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*backupv1.ArangoBackupPolicy), err +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_backup_client.go b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_backup_client.go new file mode 100644 index 000000000..7dc88e0df --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/fake/fake_backup_client.go @@ -0,0 +1,48 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeBackupV1 struct { + *testing.Fake +} + +func (c *FakeBackupV1) ArangoBackups(namespace string) v1.ArangoBackupInterface { + return &FakeArangoBackups{c, namespace} +} + +func (c *FakeBackupV1) ArangoBackupPolicies(namespace string) v1.ArangoBackupPolicyInterface { + return &FakeArangoBackupPolicies{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeBackupV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/backup/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/backup/v1/generated_expansion.go new file mode 100644 index 000000000..63018ab6d --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/backup/v1/generated_expansion.go @@ -0,0 +1,27 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type ArangoBackupExpansion interface{} + +type ArangoBackupPolicyExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/arangodeployment.go b/pkg/generated/clientset/versioned/typed/deployment/v1/arangodeployment.go new file mode 100644 index 000000000..a856e0d51 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/arangodeployment.go @@ -0,0 +1,195 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "time" + + v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ArangoDeploymentsGetter has a method to return a ArangoDeploymentInterface. +// A group's client should implement this interface. +type ArangoDeploymentsGetter interface { + ArangoDeployments(namespace string) ArangoDeploymentInterface +} + +// ArangoDeploymentInterface has methods to work with ArangoDeployment resources. +type ArangoDeploymentInterface interface { + Create(*v1.ArangoDeployment) (*v1.ArangoDeployment, error) + Update(*v1.ArangoDeployment) (*v1.ArangoDeployment, error) + UpdateStatus(*v1.ArangoDeployment) (*v1.ArangoDeployment, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.ArangoDeployment, error) + List(opts metav1.ListOptions) (*v1.ArangoDeploymentList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoDeployment, err error) + ArangoDeploymentExpansion +} + +// arangoDeployments implements ArangoDeploymentInterface +type arangoDeployments struct { + client rest.Interface + ns string +} + +// newArangoDeployments returns a ArangoDeployments +func newArangoDeployments(c *DatabaseV1Client, namespace string) *arangoDeployments { + return &arangoDeployments{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the arangoDeployment, and returns the corresponding arangoDeployment object, and an error if there is any. +func (c *arangoDeployments) Get(name string, options metav1.GetOptions) (result *v1.ArangoDeployment, err error) { + result = &v1.ArangoDeployment{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangodeployments"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ArangoDeployments that match those selectors. +func (c *arangoDeployments) List(opts metav1.ListOptions) (result *v1.ArangoDeploymentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ArangoDeploymentList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangodeployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested arangoDeployments. +func (c *arangoDeployments) Watch(opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("arangodeployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a arangoDeployment and creates it. Returns the server's representation of the arangoDeployment, and an error, if there is any. +func (c *arangoDeployments) Create(arangoDeployment *v1.ArangoDeployment) (result *v1.ArangoDeployment, err error) { + result = &v1.ArangoDeployment{} + err = c.client.Post(). + Namespace(c.ns). + Resource("arangodeployments"). + Body(arangoDeployment). + Do(). + Into(result) + return +} + +// Update takes the representation of a arangoDeployment and updates it. Returns the server's representation of the arangoDeployment, and an error, if there is any. +func (c *arangoDeployments) Update(arangoDeployment *v1.ArangoDeployment) (result *v1.ArangoDeployment, err error) { + result = &v1.ArangoDeployment{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangodeployments"). + Name(arangoDeployment.Name). + Body(arangoDeployment). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *arangoDeployments) UpdateStatus(arangoDeployment *v1.ArangoDeployment) (result *v1.ArangoDeployment, err error) { + result = &v1.ArangoDeployment{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangodeployments"). + Name(arangoDeployment.Name). + SubResource("status"). + Body(arangoDeployment). + Do(). + Into(result) + return +} + +// Delete takes name of the arangoDeployment and deletes it. Returns an error if one occurs. +func (c *arangoDeployments) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("arangodeployments"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *arangoDeployments) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("arangodeployments"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched arangoDeployment. +func (c *arangoDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoDeployment, err error) { + result = &v1.ArangoDeployment{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("arangodeployments"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/deployment_client.go b/pkg/generated/clientset/versioned/typed/deployment/v1/deployment_client.go new file mode 100644 index 000000000..fb06a4964 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/deployment_client.go @@ -0,0 +1,94 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type DatabaseV1Interface interface { + RESTClient() rest.Interface + ArangoDeploymentsGetter +} + +// DatabaseV1Client is used to interact with features provided by the database.arangodb.com group. +type DatabaseV1Client struct { + restClient rest.Interface +} + +func (c *DatabaseV1Client) ArangoDeployments(namespace string) ArangoDeploymentInterface { + return newArangoDeployments(c, namespace) +} + +// NewForConfig creates a new DatabaseV1Client for the given config. +func NewForConfig(c *rest.Config) (*DatabaseV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &DatabaseV1Client{client}, nil +} + +// NewForConfigOrDie creates a new DatabaseV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *DatabaseV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new DatabaseV1Client for the given RESTClient. +func New(c rest.Interface) *DatabaseV1Client { + return &DatabaseV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *DatabaseV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/doc.go b/pkg/generated/clientset/versioned/typed/deployment/v1/doc.go new file mode 100644 index 000000000..ff2718f73 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/doc.go new file mode 100644 index 000000000..7958e7822 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_arangodeployment.go b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_arangodeployment.go new file mode 100644 index 000000000..8b1604759 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_arangodeployment.go @@ -0,0 +1,144 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeArangoDeployments implements ArangoDeploymentInterface +type FakeArangoDeployments struct { + Fake *FakeDatabaseV1 + ns string +} + +var arangodeploymentsResource = schema.GroupVersionResource{Group: "database.arangodb.com", Version: "v1", Resource: "arangodeployments"} + +var arangodeploymentsKind = schema.GroupVersionKind{Group: "database.arangodb.com", Version: "v1", Kind: "ArangoDeployment"} + +// Get takes name of the arangoDeployment, and returns the corresponding arangoDeployment object, and an error if there is any. +func (c *FakeArangoDeployments) Get(name string, options v1.GetOptions) (result *deploymentv1.ArangoDeployment, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(arangodeploymentsResource, c.ns, name), &deploymentv1.ArangoDeployment{}) + + if obj == nil { + return nil, err + } + return obj.(*deploymentv1.ArangoDeployment), err +} + +// List takes label and field selectors, and returns the list of ArangoDeployments that match those selectors. +func (c *FakeArangoDeployments) List(opts v1.ListOptions) (result *deploymentv1.ArangoDeploymentList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(arangodeploymentsResource, arangodeploymentsKind, c.ns, opts), &deploymentv1.ArangoDeploymentList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &deploymentv1.ArangoDeploymentList{ListMeta: obj.(*deploymentv1.ArangoDeploymentList).ListMeta} + for _, item := range obj.(*deploymentv1.ArangoDeploymentList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested arangoDeployments. +func (c *FakeArangoDeployments) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(arangodeploymentsResource, c.ns, opts)) + +} + +// Create takes the representation of a arangoDeployment and creates it. Returns the server's representation of the arangoDeployment, and an error, if there is any. +func (c *FakeArangoDeployments) Create(arangoDeployment *deploymentv1.ArangoDeployment) (result *deploymentv1.ArangoDeployment, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(arangodeploymentsResource, c.ns, arangoDeployment), &deploymentv1.ArangoDeployment{}) + + if obj == nil { + return nil, err + } + return obj.(*deploymentv1.ArangoDeployment), err +} + +// Update takes the representation of a arangoDeployment and updates it. Returns the server's representation of the arangoDeployment, and an error, if there is any. +func (c *FakeArangoDeployments) Update(arangoDeployment *deploymentv1.ArangoDeployment) (result *deploymentv1.ArangoDeployment, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(arangodeploymentsResource, c.ns, arangoDeployment), &deploymentv1.ArangoDeployment{}) + + if obj == nil { + return nil, err + } + return obj.(*deploymentv1.ArangoDeployment), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeArangoDeployments) UpdateStatus(arangoDeployment *deploymentv1.ArangoDeployment) (*deploymentv1.ArangoDeployment, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(arangodeploymentsResource, "status", c.ns, arangoDeployment), &deploymentv1.ArangoDeployment{}) + + if obj == nil { + return nil, err + } + return obj.(*deploymentv1.ArangoDeployment), err +} + +// Delete takes name of the arangoDeployment and deletes it. Returns an error if one occurs. +func (c *FakeArangoDeployments) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(arangodeploymentsResource, c.ns, name), &deploymentv1.ArangoDeployment{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeArangoDeployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(arangodeploymentsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &deploymentv1.ArangoDeploymentList{}) + return err +} + +// Patch applies the patch and returns the patched arangoDeployment. +func (c *FakeArangoDeployments) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *deploymentv1.ArangoDeployment, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(arangodeploymentsResource, c.ns, name, pt, data, subresources...), &deploymentv1.ArangoDeployment{}) + + if obj == nil { + return nil, err + } + return obj.(*deploymentv1.ArangoDeployment), err +} diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_deployment_client.go b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_deployment_client.go new file mode 100644 index 000000000..ebc0ccb40 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/fake/fake_deployment_client.go @@ -0,0 +1,44 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/deployment/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeDatabaseV1 struct { + *testing.Fake +} + +func (c *FakeDatabaseV1) ArangoDeployments(namespace string) v1.ArangoDeploymentInterface { + return &FakeArangoDeployments{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeDatabaseV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/deployment/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/deployment/v1/generated_expansion.go new file mode 100644 index 000000000..3e94288a7 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/deployment/v1/generated_expansion.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type ArangoDeploymentExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/arangodeploymentreplication.go b/pkg/generated/clientset/versioned/typed/replication/v1/arangodeploymentreplication.go new file mode 100644 index 000000000..62840a138 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/arangodeploymentreplication.go @@ -0,0 +1,195 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "time" + + v1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" + scheme "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ArangoDeploymentReplicationsGetter has a method to return a ArangoDeploymentReplicationInterface. +// A group's client should implement this interface. +type ArangoDeploymentReplicationsGetter interface { + ArangoDeploymentReplications(namespace string) ArangoDeploymentReplicationInterface +} + +// ArangoDeploymentReplicationInterface has methods to work with ArangoDeploymentReplication resources. +type ArangoDeploymentReplicationInterface interface { + Create(*v1.ArangoDeploymentReplication) (*v1.ArangoDeploymentReplication, error) + Update(*v1.ArangoDeploymentReplication) (*v1.ArangoDeploymentReplication, error) + UpdateStatus(*v1.ArangoDeploymentReplication) (*v1.ArangoDeploymentReplication, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.ArangoDeploymentReplication, error) + List(opts metav1.ListOptions) (*v1.ArangoDeploymentReplicationList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoDeploymentReplication, err error) + ArangoDeploymentReplicationExpansion +} + +// arangoDeploymentReplications implements ArangoDeploymentReplicationInterface +type arangoDeploymentReplications struct { + client rest.Interface + ns string +} + +// newArangoDeploymentReplications returns a ArangoDeploymentReplications +func newArangoDeploymentReplications(c *ReplicationV1Client, namespace string) *arangoDeploymentReplications { + return &arangoDeploymentReplications{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the arangoDeploymentReplication, and returns the corresponding arangoDeploymentReplication object, and an error if there is any. +func (c *arangoDeploymentReplications) Get(name string, options metav1.GetOptions) (result *v1.ArangoDeploymentReplication, err error) { + result = &v1.ArangoDeploymentReplication{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ArangoDeploymentReplications that match those selectors. +func (c *arangoDeploymentReplications) List(opts metav1.ListOptions) (result *v1.ArangoDeploymentReplicationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ArangoDeploymentReplicationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested arangoDeploymentReplications. +func (c *arangoDeploymentReplications) Watch(opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a arangoDeploymentReplication and creates it. Returns the server's representation of the arangoDeploymentReplication, and an error, if there is any. +func (c *arangoDeploymentReplications) Create(arangoDeploymentReplication *v1.ArangoDeploymentReplication) (result *v1.ArangoDeploymentReplication, err error) { + result = &v1.ArangoDeploymentReplication{} + err = c.client.Post(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + Body(arangoDeploymentReplication). + Do(). + Into(result) + return +} + +// Update takes the representation of a arangoDeploymentReplication and updates it. Returns the server's representation of the arangoDeploymentReplication, and an error, if there is any. +func (c *arangoDeploymentReplications) Update(arangoDeploymentReplication *v1.ArangoDeploymentReplication) (result *v1.ArangoDeploymentReplication, err error) { + result = &v1.ArangoDeploymentReplication{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + Name(arangoDeploymentReplication.Name). + Body(arangoDeploymentReplication). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *arangoDeploymentReplications) UpdateStatus(arangoDeploymentReplication *v1.ArangoDeploymentReplication) (result *v1.ArangoDeploymentReplication, err error) { + result = &v1.ArangoDeploymentReplication{} + err = c.client.Put(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + Name(arangoDeploymentReplication.Name). + SubResource("status"). + Body(arangoDeploymentReplication). + Do(). + Into(result) + return +} + +// Delete takes name of the arangoDeploymentReplication and deletes it. Returns an error if one occurs. +func (c *arangoDeploymentReplications) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *arangoDeploymentReplications) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched arangoDeploymentReplication. +func (c *arangoDeploymentReplications) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.ArangoDeploymentReplication, err error) { + result = &v1.ArangoDeploymentReplication{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("arangodeploymentreplications"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/doc.go b/pkg/generated/clientset/versioned/typed/replication/v1/doc.go new file mode 100644 index 000000000..ff2718f73 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/replication/v1/fake/doc.go new file mode 100644 index 000000000..7958e7822 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/fake/doc.go @@ -0,0 +1,24 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_arangodeploymentreplication.go b/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_arangodeploymentreplication.go new file mode 100644 index 000000000..6cfd351b8 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_arangodeploymentreplication.go @@ -0,0 +1,144 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeArangoDeploymentReplications implements ArangoDeploymentReplicationInterface +type FakeArangoDeploymentReplications struct { + Fake *FakeReplicationV1 + ns string +} + +var arangodeploymentreplicationsResource = schema.GroupVersionResource{Group: "replication.database.arangodb.com", Version: "v1", Resource: "arangodeploymentreplications"} + +var arangodeploymentreplicationsKind = schema.GroupVersionKind{Group: "replication.database.arangodb.com", Version: "v1", Kind: "ArangoDeploymentReplication"} + +// Get takes name of the arangoDeploymentReplication, and returns the corresponding arangoDeploymentReplication object, and an error if there is any. +func (c *FakeArangoDeploymentReplications) Get(name string, options v1.GetOptions) (result *replicationv1.ArangoDeploymentReplication, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(arangodeploymentreplicationsResource, c.ns, name), &replicationv1.ArangoDeploymentReplication{}) + + if obj == nil { + return nil, err + } + return obj.(*replicationv1.ArangoDeploymentReplication), err +} + +// List takes label and field selectors, and returns the list of ArangoDeploymentReplications that match those selectors. +func (c *FakeArangoDeploymentReplications) List(opts v1.ListOptions) (result *replicationv1.ArangoDeploymentReplicationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(arangodeploymentreplicationsResource, arangodeploymentreplicationsKind, c.ns, opts), &replicationv1.ArangoDeploymentReplicationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &replicationv1.ArangoDeploymentReplicationList{ListMeta: obj.(*replicationv1.ArangoDeploymentReplicationList).ListMeta} + for _, item := range obj.(*replicationv1.ArangoDeploymentReplicationList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested arangoDeploymentReplications. +func (c *FakeArangoDeploymentReplications) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(arangodeploymentreplicationsResource, c.ns, opts)) + +} + +// Create takes the representation of a arangoDeploymentReplication and creates it. Returns the server's representation of the arangoDeploymentReplication, and an error, if there is any. +func (c *FakeArangoDeploymentReplications) Create(arangoDeploymentReplication *replicationv1.ArangoDeploymentReplication) (result *replicationv1.ArangoDeploymentReplication, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(arangodeploymentreplicationsResource, c.ns, arangoDeploymentReplication), &replicationv1.ArangoDeploymentReplication{}) + + if obj == nil { + return nil, err + } + return obj.(*replicationv1.ArangoDeploymentReplication), err +} + +// Update takes the representation of a arangoDeploymentReplication and updates it. Returns the server's representation of the arangoDeploymentReplication, and an error, if there is any. +func (c *FakeArangoDeploymentReplications) Update(arangoDeploymentReplication *replicationv1.ArangoDeploymentReplication) (result *replicationv1.ArangoDeploymentReplication, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(arangodeploymentreplicationsResource, c.ns, arangoDeploymentReplication), &replicationv1.ArangoDeploymentReplication{}) + + if obj == nil { + return nil, err + } + return obj.(*replicationv1.ArangoDeploymentReplication), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeArangoDeploymentReplications) UpdateStatus(arangoDeploymentReplication *replicationv1.ArangoDeploymentReplication) (*replicationv1.ArangoDeploymentReplication, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(arangodeploymentreplicationsResource, "status", c.ns, arangoDeploymentReplication), &replicationv1.ArangoDeploymentReplication{}) + + if obj == nil { + return nil, err + } + return obj.(*replicationv1.ArangoDeploymentReplication), err +} + +// Delete takes name of the arangoDeploymentReplication and deletes it. Returns an error if one occurs. +func (c *FakeArangoDeploymentReplications) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(arangodeploymentreplicationsResource, c.ns, name), &replicationv1.ArangoDeploymentReplication{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeArangoDeploymentReplications) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(arangodeploymentreplicationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &replicationv1.ArangoDeploymentReplicationList{}) + return err +} + +// Patch applies the patch and returns the patched arangoDeploymentReplication. +func (c *FakeArangoDeploymentReplications) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *replicationv1.ArangoDeploymentReplication, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(arangodeploymentreplicationsResource, c.ns, name, pt, data, subresources...), &replicationv1.ArangoDeploymentReplication{}) + + if obj == nil { + return nil, err + } + return obj.(*replicationv1.ArangoDeploymentReplication), err +} diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_replication_client.go b/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_replication_client.go new file mode 100644 index 000000000..096f8a56e --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/fake/fake_replication_client.go @@ -0,0 +1,44 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/replication/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeReplicationV1 struct { + *testing.Fake +} + +func (c *FakeReplicationV1) ArangoDeploymentReplications(namespace string) v1.ArangoDeploymentReplicationInterface { + return &FakeArangoDeploymentReplications{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeReplicationV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/replication/v1/generated_expansion.go new file mode 100644 index 000000000..20cd04960 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/generated_expansion.go @@ -0,0 +1,25 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type ArangoDeploymentReplicationExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/replication/v1/replication_client.go b/pkg/generated/clientset/versioned/typed/replication/v1/replication_client.go new file mode 100644 index 000000000..8eb1d32c4 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/replication/v1/replication_client.go @@ -0,0 +1,94 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" + "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type ReplicationV1Interface interface { + RESTClient() rest.Interface + ArangoDeploymentReplicationsGetter +} + +// ReplicationV1Client is used to interact with features provided by the replication.database.arangodb.com group. +type ReplicationV1Client struct { + restClient rest.Interface +} + +func (c *ReplicationV1Client) ArangoDeploymentReplications(namespace string) ArangoDeploymentReplicationInterface { + return newArangoDeploymentReplications(c, namespace) +} + +// NewForConfig creates a new ReplicationV1Client for the given config. +func NewForConfig(c *rest.Config) (*ReplicationV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ReplicationV1Client{client}, nil +} + +// NewForConfigOrDie creates a new ReplicationV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ReplicationV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ReplicationV1Client for the given RESTClient. +func New(c rest.Interface) *ReplicationV1Client { + return &ReplicationV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ReplicationV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/informers/externalversions/backup/interface.go b/pkg/generated/informers/externalversions/backup/interface.go index 7ebe0aecd..25c3056ba 100644 --- a/pkg/generated/informers/externalversions/backup/interface.go +++ b/pkg/generated/informers/externalversions/backup/interface.go @@ -23,6 +23,7 @@ package backup import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/backup/v1" v1alpha "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/backup/v1alpha" internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" ) @@ -31,6 +32,8 @@ import ( type Interface interface { // V1alpha provides access to shared informers for resources in V1alpha. V1alpha() v1alpha.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface } type group struct { @@ -48,3 +51,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha() v1alpha.Interface { return v1alpha.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/backup/v1/arangobackup.go b/pkg/generated/informers/externalversions/backup/v1/arangobackup.go new file mode 100644 index 000000000..1c0fcee1a --- /dev/null +++ b/pkg/generated/informers/externalversions/backup/v1/arangobackup.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/backup/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ArangoBackupInformer provides access to a shared informer and lister for +// ArangoBackups. +type ArangoBackupInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ArangoBackupLister +} + +type arangoBackupInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewArangoBackupInformer constructs a new informer for ArangoBackup type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewArangoBackupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredArangoBackupInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredArangoBackupInformer constructs a new informer for ArangoBackup type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredArangoBackupInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BackupV1().ArangoBackups(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BackupV1().ArangoBackups(namespace).Watch(options) + }, + }, + &backupv1.ArangoBackup{}, + resyncPeriod, + indexers, + ) +} + +func (f *arangoBackupInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredArangoBackupInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *arangoBackupInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&backupv1.ArangoBackup{}, f.defaultInformer) +} + +func (f *arangoBackupInformer) Lister() v1.ArangoBackupLister { + return v1.NewArangoBackupLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/backup/v1/arangobackuppolicy.go b/pkg/generated/informers/externalversions/backup/v1/arangobackuppolicy.go new file mode 100644 index 000000000..8b9c73434 --- /dev/null +++ b/pkg/generated/informers/externalversions/backup/v1/arangobackuppolicy.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/backup/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ArangoBackupPolicyInformer provides access to a shared informer and lister for +// ArangoBackupPolicies. +type ArangoBackupPolicyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ArangoBackupPolicyLister +} + +type arangoBackupPolicyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewArangoBackupPolicyInformer constructs a new informer for ArangoBackupPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewArangoBackupPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredArangoBackupPolicyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredArangoBackupPolicyInformer constructs a new informer for ArangoBackupPolicy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredArangoBackupPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BackupV1().ArangoBackupPolicies(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BackupV1().ArangoBackupPolicies(namespace).Watch(options) + }, + }, + &backupv1.ArangoBackupPolicy{}, + resyncPeriod, + indexers, + ) +} + +func (f *arangoBackupPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredArangoBackupPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *arangoBackupPolicyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&backupv1.ArangoBackupPolicy{}, f.defaultInformer) +} + +func (f *arangoBackupPolicyInformer) Lister() v1.ArangoBackupPolicyLister { + return v1.NewArangoBackupPolicyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/backup/v1/interface.go b/pkg/generated/informers/externalversions/backup/v1/interface.go new file mode 100644 index 000000000..e4e4f73a3 --- /dev/null +++ b/pkg/generated/informers/externalversions/backup/v1/interface.go @@ -0,0 +1,56 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ArangoBackups returns a ArangoBackupInformer. + ArangoBackups() ArangoBackupInformer + // ArangoBackupPolicies returns a ArangoBackupPolicyInformer. + ArangoBackupPolicies() ArangoBackupPolicyInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ArangoBackups returns a ArangoBackupInformer. +func (v *version) ArangoBackups() ArangoBackupInformer { + return &arangoBackupInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ArangoBackupPolicies returns a ArangoBackupPolicyInformer. +func (v *version) ArangoBackupPolicies() ArangoBackupPolicyInformer { + return &arangoBackupPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/deployment/interface.go b/pkg/generated/informers/externalversions/deployment/interface.go index 9b0cc7e5b..e6000305f 100644 --- a/pkg/generated/informers/externalversions/deployment/interface.go +++ b/pkg/generated/informers/externalversions/deployment/interface.go @@ -23,6 +23,7 @@ package database import ( + v1 "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/deployment/v1" v1alpha "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/deployment/v1alpha" internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" ) @@ -31,6 +32,8 @@ import ( type Interface interface { // V1alpha provides access to shared informers for resources in V1alpha. V1alpha() v1alpha.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface } type group struct { @@ -48,3 +51,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha() v1alpha.Interface { return v1alpha.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/deployment/v1/arangodeployment.go b/pkg/generated/informers/externalversions/deployment/v1/arangodeployment.go new file mode 100644 index 000000000..0ab2e65f2 --- /dev/null +++ b/pkg/generated/informers/externalversions/deployment/v1/arangodeployment.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/deployment/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ArangoDeploymentInformer provides access to a shared informer and lister for +// ArangoDeployments. +type ArangoDeploymentInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ArangoDeploymentLister +} + +type arangoDeploymentInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewArangoDeploymentInformer constructs a new informer for ArangoDeployment type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewArangoDeploymentInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredArangoDeploymentInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredArangoDeploymentInformer constructs a new informer for ArangoDeployment type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredArangoDeploymentInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DatabaseV1().ArangoDeployments(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DatabaseV1().ArangoDeployments(namespace).Watch(options) + }, + }, + &deploymentv1.ArangoDeployment{}, + resyncPeriod, + indexers, + ) +} + +func (f *arangoDeploymentInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredArangoDeploymentInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *arangoDeploymentInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&deploymentv1.ArangoDeployment{}, f.defaultInformer) +} + +func (f *arangoDeploymentInformer) Lister() v1.ArangoDeploymentLister { + return v1.NewArangoDeploymentLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/deployment/v1/interface.go b/pkg/generated/informers/externalversions/deployment/v1/interface.go new file mode 100644 index 000000000..17f9c325e --- /dev/null +++ b/pkg/generated/informers/externalversions/deployment/v1/interface.go @@ -0,0 +1,49 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ArangoDeployments returns a ArangoDeploymentInformer. + ArangoDeployments() ArangoDeploymentInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ArangoDeployments returns a ArangoDeploymentInformer. +func (v *version) ArangoDeployments() ArangoDeploymentInformer { + return &arangoDeploymentInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index 82b35023f..de7fbbda3 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -25,8 +25,11 @@ package externalversions import ( "fmt" + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" v1alpha "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" + deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" deploymentv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" replicationv1alpha "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" storagev1alpha "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -59,16 +62,30 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=backup.arangodb.com, Version=v1alpha + // Group=backup.arangodb.com, Version=v1 + case v1.SchemeGroupVersion.WithResource("arangobackups"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1().ArangoBackups().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("arangobackuppolicies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1().ArangoBackupPolicies().Informer()}, nil + + // Group=backup.arangodb.com, Version=v1alpha case v1alpha.SchemeGroupVersion.WithResource("arangobackups"): return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1alpha().ArangoBackups().Informer()}, nil case v1alpha.SchemeGroupVersion.WithResource("arangobackuppolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Backup().V1alpha().ArangoBackupPolicies().Informer()}, nil + // Group=database.arangodb.com, Version=v1 + case deploymentv1.SchemeGroupVersion.WithResource("arangodeployments"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Database().V1().ArangoDeployments().Informer()}, nil + // Group=database.arangodb.com, Version=v1alpha case deploymentv1alpha.SchemeGroupVersion.WithResource("arangodeployments"): return &genericInformer{resource: resource.GroupResource(), informer: f.Database().V1alpha().ArangoDeployments().Informer()}, nil + // Group=replication.database.arangodb.com, Version=v1 + case replicationv1.SchemeGroupVersion.WithResource("arangodeploymentreplications"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Replication().V1().ArangoDeploymentReplications().Informer()}, nil + // Group=replication.database.arangodb.com, Version=v1alpha case replicationv1alpha.SchemeGroupVersion.WithResource("arangodeploymentreplications"): return &genericInformer{resource: resource.GroupResource(), informer: f.Replication().V1alpha().ArangoDeploymentReplications().Informer()}, nil diff --git a/pkg/generated/informers/externalversions/replication/interface.go b/pkg/generated/informers/externalversions/replication/interface.go index d4bbb9c43..50e09afa0 100644 --- a/pkg/generated/informers/externalversions/replication/interface.go +++ b/pkg/generated/informers/externalversions/replication/interface.go @@ -24,6 +24,7 @@ package replication import ( internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/replication/v1" v1alpha "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/replication/v1alpha" ) @@ -31,6 +32,8 @@ import ( type Interface interface { // V1alpha provides access to shared informers for resources in V1alpha. V1alpha() v1alpha.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface } type group struct { @@ -48,3 +51,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha() v1alpha.Interface { return v1alpha.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/replication/v1/arangodeploymentreplication.go b/pkg/generated/informers/externalversions/replication/v1/arangodeploymentreplication.go new file mode 100644 index 000000000..dc59ad73f --- /dev/null +++ b/pkg/generated/informers/externalversions/replication/v1/arangodeploymentreplication.go @@ -0,0 +1,93 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + replicationv1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" + versioned "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" + v1 "github.com/arangodb/kube-arangodb/pkg/generated/listers/replication/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ArangoDeploymentReplicationInformer provides access to a shared informer and lister for +// ArangoDeploymentReplications. +type ArangoDeploymentReplicationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ArangoDeploymentReplicationLister +} + +type arangoDeploymentReplicationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewArangoDeploymentReplicationInformer constructs a new informer for ArangoDeploymentReplication type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewArangoDeploymentReplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredArangoDeploymentReplicationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredArangoDeploymentReplicationInformer constructs a new informer for ArangoDeploymentReplication type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredArangoDeploymentReplicationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ReplicationV1().ArangoDeploymentReplications(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ReplicationV1().ArangoDeploymentReplications(namespace).Watch(options) + }, + }, + &replicationv1.ArangoDeploymentReplication{}, + resyncPeriod, + indexers, + ) +} + +func (f *arangoDeploymentReplicationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredArangoDeploymentReplicationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *arangoDeploymentReplicationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&replicationv1.ArangoDeploymentReplication{}, f.defaultInformer) +} + +func (f *arangoDeploymentReplicationInformer) Lister() v1.ArangoDeploymentReplicationLister { + return v1.NewArangoDeploymentReplicationLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/replication/v1/interface.go b/pkg/generated/informers/externalversions/replication/v1/interface.go new file mode 100644 index 000000000..e5e2f1d0a --- /dev/null +++ b/pkg/generated/informers/externalversions/replication/v1/interface.go @@ -0,0 +1,49 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/arangodb/kube-arangodb/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ArangoDeploymentReplications returns a ArangoDeploymentReplicationInformer. + ArangoDeploymentReplications() ArangoDeploymentReplicationInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// ArangoDeploymentReplications returns a ArangoDeploymentReplicationInformer. +func (v *version) ArangoDeploymentReplications() ArangoDeploymentReplicationInformer { + return &arangoDeploymentReplicationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/listers/backup/v1/arangobackup.go b/pkg/generated/listers/backup/v1/arangobackup.go new file mode 100644 index 000000000..215385704 --- /dev/null +++ b/pkg/generated/listers/backup/v1/arangobackup.go @@ -0,0 +1,98 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ArangoBackupLister helps list ArangoBackups. +type ArangoBackupLister interface { + // List lists all ArangoBackups in the indexer. + List(selector labels.Selector) (ret []*v1.ArangoBackup, err error) + // ArangoBackups returns an object that can list and get ArangoBackups. + ArangoBackups(namespace string) ArangoBackupNamespaceLister + ArangoBackupListerExpansion +} + +// arangoBackupLister implements the ArangoBackupLister interface. +type arangoBackupLister struct { + indexer cache.Indexer +} + +// NewArangoBackupLister returns a new ArangoBackupLister. +func NewArangoBackupLister(indexer cache.Indexer) ArangoBackupLister { + return &arangoBackupLister{indexer: indexer} +} + +// List lists all ArangoBackups in the indexer. +func (s *arangoBackupLister) List(selector labels.Selector) (ret []*v1.ArangoBackup, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoBackup)) + }) + return ret, err +} + +// ArangoBackups returns an object that can list and get ArangoBackups. +func (s *arangoBackupLister) ArangoBackups(namespace string) ArangoBackupNamespaceLister { + return arangoBackupNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ArangoBackupNamespaceLister helps list and get ArangoBackups. +type ArangoBackupNamespaceLister interface { + // List lists all ArangoBackups in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.ArangoBackup, err error) + // Get retrieves the ArangoBackup from the indexer for a given namespace and name. + Get(name string) (*v1.ArangoBackup, error) + ArangoBackupNamespaceListerExpansion +} + +// arangoBackupNamespaceLister implements the ArangoBackupNamespaceLister +// interface. +type arangoBackupNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ArangoBackups in the indexer for a given namespace. +func (s arangoBackupNamespaceLister) List(selector labels.Selector) (ret []*v1.ArangoBackup, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoBackup)) + }) + return ret, err +} + +// Get retrieves the ArangoBackup from the indexer for a given namespace and name. +func (s arangoBackupNamespaceLister) Get(name string) (*v1.ArangoBackup, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("arangobackup"), name) + } + return obj.(*v1.ArangoBackup), nil +} diff --git a/pkg/generated/listers/backup/v1/arangobackuppolicy.go b/pkg/generated/listers/backup/v1/arangobackuppolicy.go new file mode 100644 index 000000000..cacba56ac --- /dev/null +++ b/pkg/generated/listers/backup/v1/arangobackuppolicy.go @@ -0,0 +1,98 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ArangoBackupPolicyLister helps list ArangoBackupPolicies. +type ArangoBackupPolicyLister interface { + // List lists all ArangoBackupPolicies in the indexer. + List(selector labels.Selector) (ret []*v1.ArangoBackupPolicy, err error) + // ArangoBackupPolicies returns an object that can list and get ArangoBackupPolicies. + ArangoBackupPolicies(namespace string) ArangoBackupPolicyNamespaceLister + ArangoBackupPolicyListerExpansion +} + +// arangoBackupPolicyLister implements the ArangoBackupPolicyLister interface. +type arangoBackupPolicyLister struct { + indexer cache.Indexer +} + +// NewArangoBackupPolicyLister returns a new ArangoBackupPolicyLister. +func NewArangoBackupPolicyLister(indexer cache.Indexer) ArangoBackupPolicyLister { + return &arangoBackupPolicyLister{indexer: indexer} +} + +// List lists all ArangoBackupPolicies in the indexer. +func (s *arangoBackupPolicyLister) List(selector labels.Selector) (ret []*v1.ArangoBackupPolicy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoBackupPolicy)) + }) + return ret, err +} + +// ArangoBackupPolicies returns an object that can list and get ArangoBackupPolicies. +func (s *arangoBackupPolicyLister) ArangoBackupPolicies(namespace string) ArangoBackupPolicyNamespaceLister { + return arangoBackupPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ArangoBackupPolicyNamespaceLister helps list and get ArangoBackupPolicies. +type ArangoBackupPolicyNamespaceLister interface { + // List lists all ArangoBackupPolicies in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.ArangoBackupPolicy, err error) + // Get retrieves the ArangoBackupPolicy from the indexer for a given namespace and name. + Get(name string) (*v1.ArangoBackupPolicy, error) + ArangoBackupPolicyNamespaceListerExpansion +} + +// arangoBackupPolicyNamespaceLister implements the ArangoBackupPolicyNamespaceLister +// interface. +type arangoBackupPolicyNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ArangoBackupPolicies in the indexer for a given namespace. +func (s arangoBackupPolicyNamespaceLister) List(selector labels.Selector) (ret []*v1.ArangoBackupPolicy, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoBackupPolicy)) + }) + return ret, err +} + +// Get retrieves the ArangoBackupPolicy from the indexer for a given namespace and name. +func (s arangoBackupPolicyNamespaceLister) Get(name string) (*v1.ArangoBackupPolicy, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("arangobackuppolicy"), name) + } + return obj.(*v1.ArangoBackupPolicy), nil +} diff --git a/pkg/generated/listers/backup/v1/expansion_generated.go b/pkg/generated/listers/backup/v1/expansion_generated.go new file mode 100644 index 000000000..5ccb00a02 --- /dev/null +++ b/pkg/generated/listers/backup/v1/expansion_generated.go @@ -0,0 +1,39 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// ArangoBackupListerExpansion allows custom methods to be added to +// ArangoBackupLister. +type ArangoBackupListerExpansion interface{} + +// ArangoBackupNamespaceListerExpansion allows custom methods to be added to +// ArangoBackupNamespaceLister. +type ArangoBackupNamespaceListerExpansion interface{} + +// ArangoBackupPolicyListerExpansion allows custom methods to be added to +// ArangoBackupPolicyLister. +type ArangoBackupPolicyListerExpansion interface{} + +// ArangoBackupPolicyNamespaceListerExpansion allows custom methods to be added to +// ArangoBackupPolicyNamespaceLister. +type ArangoBackupPolicyNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/deployment/v1/arangodeployment.go b/pkg/generated/listers/deployment/v1/arangodeployment.go new file mode 100644 index 000000000..a91fda7bc --- /dev/null +++ b/pkg/generated/listers/deployment/v1/arangodeployment.go @@ -0,0 +1,98 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ArangoDeploymentLister helps list ArangoDeployments. +type ArangoDeploymentLister interface { + // List lists all ArangoDeployments in the indexer. + List(selector labels.Selector) (ret []*v1.ArangoDeployment, err error) + // ArangoDeployments returns an object that can list and get ArangoDeployments. + ArangoDeployments(namespace string) ArangoDeploymentNamespaceLister + ArangoDeploymentListerExpansion +} + +// arangoDeploymentLister implements the ArangoDeploymentLister interface. +type arangoDeploymentLister struct { + indexer cache.Indexer +} + +// NewArangoDeploymentLister returns a new ArangoDeploymentLister. +func NewArangoDeploymentLister(indexer cache.Indexer) ArangoDeploymentLister { + return &arangoDeploymentLister{indexer: indexer} +} + +// List lists all ArangoDeployments in the indexer. +func (s *arangoDeploymentLister) List(selector labels.Selector) (ret []*v1.ArangoDeployment, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoDeployment)) + }) + return ret, err +} + +// ArangoDeployments returns an object that can list and get ArangoDeployments. +func (s *arangoDeploymentLister) ArangoDeployments(namespace string) ArangoDeploymentNamespaceLister { + return arangoDeploymentNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ArangoDeploymentNamespaceLister helps list and get ArangoDeployments. +type ArangoDeploymentNamespaceLister interface { + // List lists all ArangoDeployments in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.ArangoDeployment, err error) + // Get retrieves the ArangoDeployment from the indexer for a given namespace and name. + Get(name string) (*v1.ArangoDeployment, error) + ArangoDeploymentNamespaceListerExpansion +} + +// arangoDeploymentNamespaceLister implements the ArangoDeploymentNamespaceLister +// interface. +type arangoDeploymentNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ArangoDeployments in the indexer for a given namespace. +func (s arangoDeploymentNamespaceLister) List(selector labels.Selector) (ret []*v1.ArangoDeployment, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoDeployment)) + }) + return ret, err +} + +// Get retrieves the ArangoDeployment from the indexer for a given namespace and name. +func (s arangoDeploymentNamespaceLister) Get(name string) (*v1.ArangoDeployment, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("arangodeployment"), name) + } + return obj.(*v1.ArangoDeployment), nil +} diff --git a/pkg/generated/listers/deployment/v1/expansion_generated.go b/pkg/generated/listers/deployment/v1/expansion_generated.go new file mode 100644 index 000000000..04ddfe8cb --- /dev/null +++ b/pkg/generated/listers/deployment/v1/expansion_generated.go @@ -0,0 +1,31 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// ArangoDeploymentListerExpansion allows custom methods to be added to +// ArangoDeploymentLister. +type ArangoDeploymentListerExpansion interface{} + +// ArangoDeploymentNamespaceListerExpansion allows custom methods to be added to +// ArangoDeploymentNamespaceLister. +type ArangoDeploymentNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/replication/v1/arangodeploymentreplication.go b/pkg/generated/listers/replication/v1/arangodeploymentreplication.go new file mode 100644 index 000000000..22edffa28 --- /dev/null +++ b/pkg/generated/listers/replication/v1/arangodeploymentreplication.go @@ -0,0 +1,98 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ArangoDeploymentReplicationLister helps list ArangoDeploymentReplications. +type ArangoDeploymentReplicationLister interface { + // List lists all ArangoDeploymentReplications in the indexer. + List(selector labels.Selector) (ret []*v1.ArangoDeploymentReplication, err error) + // ArangoDeploymentReplications returns an object that can list and get ArangoDeploymentReplications. + ArangoDeploymentReplications(namespace string) ArangoDeploymentReplicationNamespaceLister + ArangoDeploymentReplicationListerExpansion +} + +// arangoDeploymentReplicationLister implements the ArangoDeploymentReplicationLister interface. +type arangoDeploymentReplicationLister struct { + indexer cache.Indexer +} + +// NewArangoDeploymentReplicationLister returns a new ArangoDeploymentReplicationLister. +func NewArangoDeploymentReplicationLister(indexer cache.Indexer) ArangoDeploymentReplicationLister { + return &arangoDeploymentReplicationLister{indexer: indexer} +} + +// List lists all ArangoDeploymentReplications in the indexer. +func (s *arangoDeploymentReplicationLister) List(selector labels.Selector) (ret []*v1.ArangoDeploymentReplication, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoDeploymentReplication)) + }) + return ret, err +} + +// ArangoDeploymentReplications returns an object that can list and get ArangoDeploymentReplications. +func (s *arangoDeploymentReplicationLister) ArangoDeploymentReplications(namespace string) ArangoDeploymentReplicationNamespaceLister { + return arangoDeploymentReplicationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ArangoDeploymentReplicationNamespaceLister helps list and get ArangoDeploymentReplications. +type ArangoDeploymentReplicationNamespaceLister interface { + // List lists all ArangoDeploymentReplications in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.ArangoDeploymentReplication, err error) + // Get retrieves the ArangoDeploymentReplication from the indexer for a given namespace and name. + Get(name string) (*v1.ArangoDeploymentReplication, error) + ArangoDeploymentReplicationNamespaceListerExpansion +} + +// arangoDeploymentReplicationNamespaceLister implements the ArangoDeploymentReplicationNamespaceLister +// interface. +type arangoDeploymentReplicationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ArangoDeploymentReplications in the indexer for a given namespace. +func (s arangoDeploymentReplicationNamespaceLister) List(selector labels.Selector) (ret []*v1.ArangoDeploymentReplication, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ArangoDeploymentReplication)) + }) + return ret, err +} + +// Get retrieves the ArangoDeploymentReplication from the indexer for a given namespace and name. +func (s arangoDeploymentReplicationNamespaceLister) Get(name string) (*v1.ArangoDeploymentReplication, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("arangodeploymentreplication"), name) + } + return obj.(*v1.ArangoDeploymentReplication), nil +} diff --git a/pkg/generated/listers/replication/v1/expansion_generated.go b/pkg/generated/listers/replication/v1/expansion_generated.go new file mode 100644 index 000000000..f5da10998 --- /dev/null +++ b/pkg/generated/listers/replication/v1/expansion_generated.go @@ -0,0 +1,31 @@ +// +// DISCLAIMER +// +// Copyright 2018 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// ArangoDeploymentReplicationListerExpansion allows custom methods to be added to +// ArangoDeploymentReplicationLister. +type ArangoDeploymentReplicationListerExpansion interface{} + +// ArangoDeploymentReplicationNamespaceListerExpansion allows custom methods to be added to +// ArangoDeploymentReplicationNamespaceLister. +type ArangoDeploymentReplicationNamespaceListerExpansion interface{} diff --git a/pkg/operator/crd.go b/pkg/operator/crd.go index 5a36dff3f..d723c970b 100644 --- a/pkg/operator/crd.go +++ b/pkg/operator/crd.go @@ -23,9 +23,9 @@ package operator import ( - deplapi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" - backapi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - replapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + "github.com/arangodb/kube-arangodb/pkg/apis/backup" + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" + "github.com/arangodb/kube-arangodb/pkg/apis/replication" lsapi "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" "github.com/arangodb/kube-arangodb/pkg/util/crd" ) @@ -37,14 +37,14 @@ func (o *Operator) waitForCRD(enableDeployment, enableDeploymentReplication, ena if enableDeployment { log.Debug().Msg("Waiting for ArangoDeployment CRD to be ready") - if err := crd.WaitCRDReady(o.KubeExtCli, deplapi.ArangoDeploymentCRDName); err != nil { + if err := crd.WaitCRDReady(o.KubeExtCli, deployment.ArangoDeploymentCRDName); err != nil { return maskAny(err) } } if enableDeploymentReplication { log.Debug().Msg("Waiting for ArangoDeploymentReplication CRD to be ready") - if err := crd.WaitCRDReady(o.KubeExtCli, replapi.ArangoDeploymentReplicationCRDName); err != nil { + if err := crd.WaitCRDReady(o.KubeExtCli, replication.ArangoDeploymentReplicationCRDName); err != nil { return maskAny(err) } } @@ -58,7 +58,7 @@ func (o *Operator) waitForCRD(enableDeployment, enableDeploymentReplication, ena if enableBackup { log.Debug().Msg("Wait for ArangoBackup CRD to be ready") - if err := crd.WaitCRDReady(o.KubeExtCli, backapi.ArangoBackupCRDName); err != nil { + if err := crd.WaitCRDReady(o.KubeExtCli, backup.ArangoBackupCRDName); err != nil { return maskAny(err) } } diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index fe0e66209..a026164b9 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -38,8 +38,8 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/record" - deplapi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" - replapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + deplapi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + replapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" lsapi "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha" "github.com/arangodb/kube-arangodb/pkg/backup/handlers/arango/backup" "github.com/arangodb/kube-arangodb/pkg/backup/handlers/arango/policy" diff --git a/pkg/operator/operator_deployment.go b/pkg/operator/operator_deployment.go index c8e3d5320..b01a69f54 100644 --- a/pkg/operator/operator_deployment.go +++ b/pkg/operator/operator_deployment.go @@ -24,12 +24,13 @@ package operator import ( "fmt" + deploymentType "github.com/arangodb/kube-arangodb/pkg/apis/deployment" "github.com/pkg/errors" kwatch "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/cache" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/deployment" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -48,8 +49,8 @@ var ( func (o *Operator) runDeployments(stop <-chan struct{}) { rw := k8sutil.NewResourceWatcher( o.log, - o.Dependencies.CRCli.DatabaseV1alpha().RESTClient(), - api.ArangoDeploymentResourcePlural, + o.Dependencies.CRCli.DatabaseV1().RESTClient(), + deploymentType.ArangoDeploymentResourcePlural, o.Config.Namespace, &api.ArangoDeployment{}, cache.ResourceEventHandlerFuncs{ diff --git a/pkg/operator/operator_deployment_relication.go b/pkg/operator/operator_deployment_relication.go index 9f9af01a0..74689e6c4 100644 --- a/pkg/operator/operator_deployment_relication.go +++ b/pkg/operator/operator_deployment_relication.go @@ -24,12 +24,13 @@ package operator import ( "fmt" + replication2 "github.com/arangodb/kube-arangodb/pkg/apis/replication" "github.com/pkg/errors" kwatch "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/cache" - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/metrics" "github.com/arangodb/kube-arangodb/pkg/replication" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -48,8 +49,8 @@ var ( func (o *Operator) runDeploymentReplications(stop <-chan struct{}) { rw := k8sutil.NewResourceWatcher( o.log, - o.Dependencies.CRCli.ReplicationV1alpha().RESTClient(), - api.ArangoDeploymentReplicationResourcePlural, + o.Dependencies.CRCli.ReplicationV1().RESTClient(), + replication2.ArangoDeploymentReplicationResourcePlural, o.Config.Namespace, &api.ArangoDeploymentReplication{}, cache.ResourceEventHandlerFuncs{ diff --git a/pkg/replication/deployment_replication.go b/pkg/replication/deployment_replication.go index 5d3d22709..532d64c28 100644 --- a/pkg/replication/deployment_replication.go +++ b/pkg/replication/deployment_replication.go @@ -34,7 +34,7 @@ import ( "k8s.io/client-go/tools/record" "github.com/arangodb/arangosync-client/client" - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/arangodb/kube-arangodb/pkg/util/retry" @@ -190,7 +190,7 @@ func (dr *DeploymentReplication) run() { // handleArangoDeploymentReplicationUpdatedEvent is called when the deployment replication is updated by the user. func (dr *DeploymentReplication) handleArangoDeploymentReplicationUpdatedEvent(event *deploymentReplicationEvent) error { log := dr.deps.Log.With().Str("deployoment-replication", event.DeploymentReplication.GetName()).Logger() - repls := dr.deps.CRCli.ReplicationV1alpha().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) + repls := dr.deps.CRCli.ReplicationV1().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) // Get the most recent version of the deployment replication from the API server current, err := repls.Get(dr.apiObject.GetName(), metav1.GetOptions{}) @@ -251,7 +251,7 @@ func (dr *DeploymentReplication) updateCRStatus() error { // Send update to API server log := dr.deps.Log - repls := dr.deps.CRCli.ReplicationV1alpha().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) + repls := dr.deps.CRCli.ReplicationV1().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) update := dr.apiObject.DeepCopy() attempt := 0 for { @@ -285,7 +285,7 @@ func (dr *DeploymentReplication) updateCRStatus() error { // On success, d.apiObject is updated. func (dr *DeploymentReplication) updateCRSpec(newSpec api.DeploymentReplicationSpec) error { log := dr.deps.Log - repls := dr.deps.CRCli.ReplicationV1alpha().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) + repls := dr.deps.CRCli.ReplicationV1().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) // Send update to API server update := dr.apiObject.DeepCopy() @@ -330,7 +330,7 @@ func (dr *DeploymentReplication) failOnError(err error, msg string) { func (dr *DeploymentReplication) reportFailedStatus() { log := dr.deps.Log log.Info().Msg("local storage failed. Reporting failed reason...") - repls := dr.deps.CRCli.ReplicationV1alpha().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) + repls := dr.deps.CRCli.ReplicationV1().ArangoDeploymentReplications(dr.apiObject.GetNamespace()) op := func() error { dr.status.Phase = api.DeploymentReplicationPhaseFailed diff --git a/pkg/replication/finalizers.go b/pkg/replication/finalizers.go index 019796811..63bb6c9c5 100644 --- a/pkg/replication/finalizers.go +++ b/pkg/replication/finalizers.go @@ -31,7 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/arangodb/arangosync-client/client" - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util/constants" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -98,7 +98,7 @@ func (dr *DeploymentReplication) inspectFinalizerDeplReplStopSync(ctx context.Co // Inspect deployment deletion state in source abort := dr.status.CancelFailures > maxCancelFailures - depls := dr.deps.CRCli.DatabaseV1alpha().ArangoDeployments(p.GetNamespace()) + depls := dr.deps.CRCli.DatabaseV1().ArangoDeployments(p.GetNamespace()) if name := p.Spec.Source.GetDeploymentName(); name != "" { depl, err := depls.Get(name, metav1.GetOptions{}) if k8sutil.IsNotFound(err) { @@ -167,7 +167,7 @@ func (dr *DeploymentReplication) inspectFinalizerDeplReplStopSync(ctx context.Co // removeDeploymentReplicationFinalizers removes the given finalizers from the given DeploymentReplication. func removeDeploymentReplicationFinalizers(log zerolog.Logger, crcli versioned.Interface, p *api.ArangoDeploymentReplication, finalizers []string, ignoreNotFound bool) error { - repls := crcli.ReplicationV1alpha().ArangoDeploymentReplications(p.GetNamespace()) + repls := crcli.ReplicationV1().ArangoDeploymentReplications(p.GetNamespace()) getFunc := func() (metav1.Object, error) { result, err := repls.Get(p.GetName(), metav1.GetOptions{}) if err != nil { diff --git a/pkg/replication/server_api.go b/pkg/replication/server_api.go index 13e6dddbb..6408fcbd8 100644 --- a/pkg/replication/server_api.go +++ b/pkg/replication/server_api.go @@ -23,7 +23,7 @@ package replication import ( - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/server" ) diff --git a/pkg/replication/server_endpoint_api.go b/pkg/replication/server_endpoint_api.go index b6b026eaf..ab2ffd524 100644 --- a/pkg/replication/server_endpoint_api.go +++ b/pkg/replication/server_endpoint_api.go @@ -23,7 +23,7 @@ package replication import ( - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/replication/sync_client.go b/pkg/replication/sync_client.go index da5ff3c16..1f68a467f 100644 --- a/pkg/replication/sync_client.go +++ b/pkg/replication/sync_client.go @@ -31,7 +31,7 @@ import ( "github.com/arangodb/arangosync-client/tasks" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) @@ -105,7 +105,7 @@ func (dr *DeploymentReplication) createSyncMasterClient(epSpec api.EndpointSpec) func (dr *DeploymentReplication) createArangoSyncEndpoint(epSpec api.EndpointSpec) (client.Endpoint, error) { if epSpec.HasDeploymentName() { deploymentName := epSpec.GetDeploymentName() - depls := dr.deps.CRCli.DatabaseV1alpha().ArangoDeployments(dr.apiObject.GetNamespace()) + depls := dr.deps.CRCli.DatabaseV1().ArangoDeployments(dr.apiObject.GetNamespace()) depl, err := depls.Get(deploymentName, metav1.GetOptions{}) if err != nil { dr.deps.Log.Debug().Err(err).Str("deployment", deploymentName).Msg("Failed to get deployment") @@ -164,7 +164,7 @@ func (dr *DeploymentReplication) getEndpointSecretNames(epSpec api.EndpointSpec) userSecretName = epSpec.Authentication.GetUserSecretName() if epSpec.HasDeploymentName() { deploymentName := epSpec.GetDeploymentName() - depls := dr.deps.CRCli.DatabaseV1alpha().ArangoDeployments(dr.apiObject.GetNamespace()) + depls := dr.deps.CRCli.DatabaseV1().ArangoDeployments(dr.apiObject.GetNamespace()) depl, err := depls.Get(deploymentName, metav1.GetOptions{}) if err != nil { dr.deps.Log.Debug().Err(err).Str("deployment", deploymentName).Msg("Failed to get deployment") diff --git a/pkg/replication/sync_inspector.go b/pkg/replication/sync_inspector.go index 7fb2fcd57..a39e94a1c 100644 --- a/pkg/replication/sync_inspector.go +++ b/pkg/replication/sync_inspector.go @@ -28,7 +28,7 @@ import ( "time" "github.com/arangodb/arangosync-client/client" - api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" ) // inspectDeploymentReplication inspects the entire deployment replication diff --git a/pkg/server/handlers_deployment.go b/pkg/server/handlers_deployment.go index 6993b2ffe..3140e3d2f 100644 --- a/pkg/server/handlers_deployment.go +++ b/pkg/server/handlers_deployment.go @@ -29,7 +29,7 @@ import ( "github.com/gin-gonic/gin" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" ) // Deployment is the API implemented by an ArangoDeployment. diff --git a/pkg/util/arangod/client.go b/pkg/util/arangod/client.go index 406a14cdf..78b4e7781 100644 --- a/pkg/util/arangod/client.go +++ b/pkg/util/arangod/client.go @@ -37,7 +37,7 @@ import ( "github.com/arangodb/go-driver/jwt" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/pkg/util/k8sutil/test/events_test.go b/pkg/util/k8sutil/test/events_test.go index fe983bd6e..e126ee959 100644 --- a/pkg/util/k8sutil/test/events_test.go +++ b/pkg/util/k8sutil/test/events_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) diff --git a/tests/auth_test.go b/tests/auth_test.go index 300652247..e1b41a20b 100644 --- a/tests/auth_test.go +++ b/tests/auth_test.go @@ -30,7 +30,7 @@ import ( "github.com/dchest/uniuri" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/arangod" @@ -51,7 +51,7 @@ func TestAuthenticationSingleDefaultSecret(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -107,7 +107,7 @@ func TestAuthenticationSingleCustomSecret(t *testing.T) { defer removeSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -151,7 +151,7 @@ func TestAuthenticationNoneSingle(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -189,7 +189,7 @@ func TestAuthenticationClusterDefaultSecret(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -244,7 +244,7 @@ func TestAuthenticationClusterCustomSecret(t *testing.T) { } // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -291,7 +291,7 @@ func TestAuthenticationNoneCluster(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/backup_test.go b/tests/backup_test.go index 05873e65b..f010228aa 100644 --- a/tests/backup_test.go +++ b/tests/backup_test.go @@ -31,7 +31,7 @@ import ( "testing" "time" - backupClient "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1alpha" + backupClient "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned/typed/backup/v1" "github.com/rs/zerolog/log" "k8s.io/apimachinery/pkg/util/uuid" @@ -39,8 +39,8 @@ import ( "github.com/stretchr/testify/require" "github.com/arangodb/go-driver" - backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1alpha" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" @@ -56,7 +56,7 @@ var backupAPIAvailable *bool func waitUntilBackup(ci versioned.Interface, name, ns string, predicate func(*backupApi.ArangoBackup, error) error, timeout ...time.Duration) (*backupApi.ArangoBackup, error) { var result *backupApi.ArangoBackup op := func() error { - obj, err := ci.BackupV1alpha().ArangoBackups(ns).Get(name, metav1.GetOptions{}) + obj, err := ci.BackupV1().ArangoBackups(ns).Get(name, metav1.GetOptions{}) result = obj if predicate != nil { if err := predicate(obj, err); err != nil { @@ -236,7 +236,7 @@ func statBackupMeta(client driver.Client, backupID driver.BackupID) (bool, drive func ensureBackup(t *testing.T, deployment, ns string, deploymentClient versioned.Interface, predicate func(*backupApi.ArangoBackup, error) error, options *EnsureBackupOptions) (*backupApi.ArangoBackup, string, driver.BackupID) { backup := newBackup(fmt.Sprintf("my-backup-%s", uniuri.NewLen(4)), deployment, options) - _, err := deploymentClient.BackupV1alpha().ArangoBackups(ns).Create(backup) + _, err := deploymentClient.BackupV1().ArangoBackups(ns).Create(backup) require.NoError(t, err, "failed to create backup: %s", err) name := backup.GetName() @@ -321,8 +321,8 @@ func TestBackupCluster(t *testing.T) { deploymentClient := kubeArangoClient.MustNewInCluster() ns := getNamespace(t) - backupPolicyClient := deploymentClient.BackupV1alpha().ArangoBackupPolicies(ns) - backupClient := deploymentClient.BackupV1alpha().ArangoBackups(ns) + backupPolicyClient := deploymentClient.BackupV1().ArangoBackupPolicies(ns) + backupClient := deploymentClient.BackupV1().ArangoBackups(ns) cmd := []string{ "--backup.api-enabled=jwt", @@ -363,11 +363,11 @@ func TestBackupCluster(t *testing.T) { defer deferedCleanupDeployment(c, depl2.GetName(), ns) // Create deployment - apiObject, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := deploymentClient.DatabaseV1().ArangoDeployments(ns).Create(depl) defer removeDeployment(deploymentClient, depl.GetName(), ns) require.NoError(t, err, "failed to create deployment: %s", err) - api2Object, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(ns).Create(depl2) + api2Object, err := deploymentClient.DatabaseV1().ArangoDeployments(ns).Create(depl2) defer removeDeployment(deploymentClient, depl2.GetName(), ns) require.NoError(t, err, "failed to create deployment two: %s", err) diff --git a/tests/change_args_test.go b/tests/change_args_test.go index 6090a8f94..7a6892def 100644 --- a/tests/change_args_test.go +++ b/tests/change_args_test.go @@ -33,7 +33,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" ) @@ -51,7 +51,7 @@ func TestChangeArgsAgents(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeActiveFailover) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -130,7 +130,7 @@ func TestChangeArgsDBServer(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/cursor_test.go b/tests/cursor_test.go index 5892aa8c9..9cff0f8cc 100644 --- a/tests/cursor_test.go +++ b/tests/cursor_test.go @@ -32,7 +32,7 @@ import ( "github.com/stretchr/testify/require" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" ) @@ -49,7 +49,7 @@ func TestCursorSingle(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -93,7 +93,7 @@ func TestCursorActiveFailover(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeActiveFailover) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -137,7 +137,7 @@ func TestCursorCluster(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/deployments_test.go b/tests/deployments_test.go index 7ec0beb25..1d58fc251 100644 --- a/tests/deployments_test.go +++ b/tests/deployments_test.go @@ -32,7 +32,7 @@ import ( driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" ) @@ -82,7 +82,7 @@ func deploymentSubTest(t *testing.T, mode api.DeploymentMode, engine api.Storage depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) require.NoError(t, err, fmt.Sprintf("Create deployment failed: %v", err)) defer deferedCleanupDeployment(c, depl.GetName(), ns) @@ -123,11 +123,11 @@ func TestMultiDeployment(t *testing.T) { depl2.Spec.SetDefaults(depl2.GetName()) // this must be last // Create deployments - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl1) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl1) require.NoError(t, err, fmt.Sprintf("Deployment creation failed: %v", err)) defer deferedCleanupDeployment(c, depl1.GetName(), ns) - _, err = c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl2) + _, err = c.DatabaseV1().ArangoDeployments(ns).Create(depl2) require.NoError(t, err, fmt.Sprintf("Deployment creation failed: %v", err)) defer deferedCleanupDeployment(c, depl2.GetName(), ns) diff --git a/tests/environments_test.go b/tests/environments_test.go index 2f4609e63..ec919af73 100644 --- a/tests/environments_test.go +++ b/tests/environments_test.go @@ -31,7 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -75,7 +75,7 @@ func TestEnvironmentProduction(t *testing.T) { } // Create deployment - if _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl); err != nil { + if _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl); err != nil { // REVIEW - should the test already fail here t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/immutable_test.go b/tests/immutable_test.go index 9771b59f3..d582bf336 100644 --- a/tests/immutable_test.go +++ b/tests/immutable_test.go @@ -31,7 +31,7 @@ import ( "github.com/dchest/uniuri" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" ) @@ -50,7 +50,7 @@ func TestImmutableFields(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/load_balancer_source_ranges_test.go b/tests/load_balancer_source_ranges_test.go index 1ae28d30c..587d03830 100644 --- a/tests/load_balancer_source_ranges_test.go +++ b/tests/load_balancer_source_ranges_test.go @@ -30,7 +30,7 @@ import ( "github.com/dchest/uniuri" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -54,7 +54,7 @@ func TestLoadBalancingSourceRanges(t *testing.T) { depl.Spec.ExternalAccess.LoadBalancerSourceRanges = append(depl.Spec.ExternalAccess.LoadBalancerSourceRanges, "1.2.3.0/24", "0.0.0.0/0") // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/load_balancer_test.go b/tests/load_balancer_test.go index c0542b093..a175d175b 100644 --- a/tests/load_balancer_test.go +++ b/tests/load_balancer_test.go @@ -31,7 +31,7 @@ import ( "github.com/dchest/uniuri" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -71,7 +71,7 @@ func loadBalancingCursorSubtest(t *testing.T, useVst bool) { depl.Spec.Image = util.NewString("arangodb/arangodb:3.3.13") // Note: 3.3.13 is the first version supporting the cursor forwarding feature. // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/member_resilience_test.go b/tests/member_resilience_test.go index 0b8d999f8..c049285b3 100644 --- a/tests/member_resilience_test.go +++ b/tests/member_resilience_test.go @@ -32,7 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/retry" ) @@ -52,7 +52,7 @@ func TestMemberResilienceAgents(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -75,7 +75,7 @@ func TestMemberResilienceAgents(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -109,7 +109,7 @@ func TestMemberResilienceAgents(t *testing.T) { } else { // Wait for member to be replaced op := func() error { - updatedObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + updatedObject, err := c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { return maskAny(err) } @@ -153,7 +153,7 @@ func TestMemberResilienceCoordinators(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -176,7 +176,7 @@ func TestMemberResilienceCoordinators(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -210,7 +210,7 @@ func TestMemberResilienceCoordinators(t *testing.T) { } else { // Wait for member to be replaced op := func() error { - updatedObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + updatedObject, err := c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { return maskAny(err) } @@ -250,7 +250,7 @@ func TestMemberResilienceDBServers(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -273,7 +273,7 @@ func TestMemberResilienceDBServers(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -307,7 +307,7 @@ func TestMemberResilienceDBServers(t *testing.T) { } else { // Wait for member to be replaced op := func() error { - updatedObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + updatedObject, err := c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { return maskAny(err) } diff --git a/tests/metrics_test.go b/tests/metrics_test.go index b45fb5d5c..370fb9a62 100644 --- a/tests/metrics_test.go +++ b/tests/metrics_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/dchest/uniuri" @@ -49,7 +49,7 @@ func TestAddingMetrics(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - deployment, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + deployment, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/operator_upgrade_test.go b/tests/operator_upgrade_test.go index 21ec33772..d32a1e40f 100644 --- a/tests/operator_upgrade_test.go +++ b/tests/operator_upgrade_test.go @@ -9,7 +9,7 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/fields" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/arangodb/kube-arangodb/pkg/util/retry" @@ -48,7 +48,7 @@ func TestOperatorUpgradeFrom038(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - if _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl); err != nil { + if _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl); err != nil { t.Fatalf("Create deployment failed: %v", err) } defer removeDeployment(c, depl.GetName(), ns) diff --git a/tests/pc_test.go b/tests/pc_test.go index 2e3e55b6f..bbfa0b2d4 100644 --- a/tests/pc_test.go +++ b/tests/pc_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/retry" @@ -20,7 +20,7 @@ import ( func waitForPriorityOfServerGroup(kube kubernetes.Interface, c versioned.Interface, depl, ns string, group api.ServerGroup, priority int32) error { return retry.Retry(func() error { - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl, metav1.GetOptions{}) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Get(depl, metav1.GetOptions{}) if err != nil { return err } @@ -94,7 +94,7 @@ func TestPriorityClasses(t *testing.T) { defer deferedCleanupDeployment(c, depl.GetName(), ns) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/pdb_test.go b/tests/pdb_test.go index 80bdd90a0..e417fcda1 100644 --- a/tests/pdb_test.go +++ b/tests/pdb_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/deployment/resources" "github.com/arangodb/kube-arangodb/pkg/util" @@ -88,7 +88,7 @@ func TestPDBCreate(t *testing.T) { assert.NoError(t, depl.Spec.Validate()) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/persistent_volumes_test.go b/tests/persistent_volumes_test.go index 420a9bf45..3644d031a 100644 --- a/tests/persistent_volumes_test.go +++ b/tests/persistent_volumes_test.go @@ -32,7 +32,7 @@ import ( "github.com/dchest/uniuri" "github.com/stretchr/testify/assert" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" corev1 "k8s.io/api/core/v1" @@ -74,7 +74,7 @@ func TestPVCExists(t *testing.T) { assert.NoError(t, deploymentTemplate.Spec.Validate()) // Create deployment - _, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) + _, err := deploymentClient.DatabaseV1().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) assert.NoError(t, err, "failed to create deplyment: %s", err) _, err = waitUntilDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace, deploymentIsReady()) @@ -108,7 +108,7 @@ func TestPVCResize(t *testing.T) { assert.NoError(t, deploymentTemplate.Spec.Validate()) // Create deployment - _, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) + _, err := deploymentClient.DatabaseV1().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) defer removeDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace) assert.NoError(t, err, "failed to create deplyment: %s", err) @@ -195,7 +195,7 @@ func TestPVCTemplateResize(t *testing.T) { deploymentTemplate.Spec.DBServers.VolumeClaimTemplate.Spec.Resources.Requests[corev1.ResourceStorage] = size08GB // Create deployment - _, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) + _, err := deploymentClient.DatabaseV1().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate) defer removeDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace) assert.NoError(t, err, "failed to create deplyment: %s", err) diff --git a/tests/predicates.go b/tests/predicates.go index c73c40d2a..3b7f06fb4 100644 --- a/tests/predicates.go +++ b/tests/predicates.go @@ -26,7 +26,7 @@ import ( "fmt" v1 "k8s.io/api/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" diff --git a/tests/resilience_test.go b/tests/resilience_test.go index 91016fa50..d24208450 100644 --- a/tests/resilience_test.go +++ b/tests/resilience_test.go @@ -35,7 +35,7 @@ import ( "k8s.io/apimachinery/pkg/types" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/arangodb/kube-arangodb/pkg/util/retry" @@ -57,7 +57,7 @@ func TestResiliencePod(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -80,7 +80,7 @@ func TestResiliencePod(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -174,7 +174,7 @@ func testResiliencePVC(testGroup api.ServerGroup, t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -197,7 +197,7 @@ func testResiliencePVC(testGroup api.ServerGroup, t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -267,7 +267,7 @@ func TestResiliencePVDBServer(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -290,7 +290,7 @@ func TestResiliencePVDBServer(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -371,7 +371,7 @@ func TestResilienceService(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -394,7 +394,7 @@ func TestResilienceService(t *testing.T) { } // Fetch latest status so we know all member details - apiObject, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } diff --git a/tests/resources_test.go b/tests/resources_test.go index ba180db39..a8a241a11 100644 --- a/tests/resources_test.go +++ b/tests/resources_test.go @@ -26,7 +26,7 @@ import ( "fmt" "testing" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" @@ -58,7 +58,7 @@ func TestResourcesChangeLimitsCluster(t *testing.T) { defer deferedCleanupDeployment(c, depl.GetName(), ns) // Create deployment - _, err := deploymentClient.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := deploymentClient.DatabaseV1().ArangoDeployments(ns).Create(depl) defer removeDeployment(deploymentClient, depl.GetName(), ns) assert.NoError(t, err, "failed to create deplyment: %s", err) diff --git a/tests/rocksdb_encryption_test.go b/tests/rocksdb_encryption_test.go index 7d40597cb..d3d6d8bdf 100644 --- a/tests/rocksdb_encryption_test.go +++ b/tests/rocksdb_encryption_test.go @@ -32,7 +32,7 @@ import ( "github.com/dchest/uniuri" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" @@ -66,7 +66,7 @@ func TestRocksDBEncryptionSingle(t *testing.T) { } // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/scale_test.go b/tests/scale_test.go index daa2ab769..48455289c 100644 --- a/tests/scale_test.go +++ b/tests/scale_test.go @@ -29,7 +29,7 @@ import ( "github.com/dchest/uniuri" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -49,7 +49,7 @@ func TestScaleClusterNonTLS(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -120,7 +120,7 @@ func TestScaleCluster(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -194,7 +194,7 @@ func TestScaleClusterWithSync(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/secret_hashes_test.go b/tests/secret_hashes_test.go index b8958f55b..7fbf4de97 100644 --- a/tests/secret_hashes_test.go +++ b/tests/secret_hashes_test.go @@ -30,7 +30,7 @@ import ( "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/constants" @@ -54,7 +54,7 @@ func TestSecretHashesRootUser(t *testing.T) { depl.Spec.Bootstrap.PasswordSecretNames[api.UserNameRoot] = api.PasswordSecretNameAuto // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -114,7 +114,7 @@ func TestSecretHashesRootUser(t *testing.T) { err = retry.Retry(func() error { // check if root secret hash has changed - depl, err = c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + depl, err = c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } diff --git a/tests/service_account_test.go b/tests/service_account_test.go index b87faba64..460bf12ce 100644 --- a/tests/service_account_test.go +++ b/tests/service_account_test.go @@ -34,7 +34,7 @@ import ( "k8s.io/client-go/kubernetes" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -58,7 +58,7 @@ func TestServiceAccountSingle(t *testing.T) { depl.Spec.Single.ServiceAccountName = util.NewString(saName) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -107,7 +107,7 @@ func TestServiceAccountActiveFailover(t *testing.T) { depl.Spec.Agents.ServiceAccountName = util.NewString(saName) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -158,7 +158,7 @@ func TestServiceAccountCluster(t *testing.T) { depl.Spec.Coordinators.ServiceAccountName = util.NewString(saName) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -215,7 +215,7 @@ func TestServiceAccountClusterWithSync(t *testing.T) { depl.Spec.SyncWorkers.ServiceAccountName = util.NewString(saName) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/sidecar_test.go b/tests/sidecar_test.go index 9e498897b..aa3c12386 100644 --- a/tests/sidecar_test.go +++ b/tests/sidecar_test.go @@ -28,7 +28,7 @@ import ( "time" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/dchest/uniuri" @@ -122,7 +122,7 @@ func runSideCarTest(t *testing.T, spec SideCarTest) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - deployment, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + deployment, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/simple_test.go b/tests/simple_test.go index 056b94312..e0769b928 100644 --- a/tests/simple_test.go +++ b/tests/simple_test.go @@ -30,7 +30,7 @@ import ( "github.com/stretchr/testify/assert" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -47,7 +47,7 @@ func TestSimpleSingle(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeSingle) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -85,7 +85,7 @@ func TestSimpleActiveFailover(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeActiveFailover) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -123,7 +123,7 @@ func TestSimpleCluster(t *testing.T) { depl.Spec.Mode = api.NewMode(api.DeploymentModeCluster) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } @@ -164,7 +164,7 @@ func TestSimpleClusterWithSync(t *testing.T) { depl.Spec.Sync.Enabled = util.NewBool(true) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/sync/main.go b/tests/sync/main.go index d73f98788..377a85ad1 100644 --- a/tests/sync/main.go +++ b/tests/sync/main.go @@ -22,8 +22,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - dapi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" - rapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + dapi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + rapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util" ) @@ -139,7 +139,7 @@ func newArangoSyncTestJob(ns, name string) *batchv1.Job { func waitForSyncDeploymentReady(ctx context.Context, ns, name string, kubecli kubernetes.Interface, c versioned.Interface) error { return retry.Retry(func() error { - deployment, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(name, metav1.GetOptions{}) + deployment, err := c.DatabaseV1().ArangoDeployments(ns).Get(name, metav1.GetOptions{}) if err != nil { return err } @@ -167,15 +167,15 @@ func setupArangoDBCluster(ctx context.Context, kube kubernetes.Interface, c vers dstSpec := newSyncDeployment(namespace, dstDeploymentName, false) srcSpec := newSyncDeployment(namespace, srcDeploymentName, true) - if _, err := c.DatabaseV1alpha().ArangoDeployments(namespace).Create(srcSpec); err != nil { + if _, err := c.DatabaseV1().ArangoDeployments(namespace).Create(srcSpec); err != nil { return err } - if _, err := c.DatabaseV1alpha().ArangoDeployments(namespace).Create(dstSpec); err != nil { + if _, err := c.DatabaseV1().ArangoDeployments(namespace).Create(dstSpec); err != nil { return err } replSpec := newReplication(namespace, replicationResourceName) - if _, err := c.ReplicationV1alpha().ArangoDeploymentReplications(namespace).Create(replSpec); err != nil { + if _, err := c.ReplicationV1().ArangoDeploymentReplications(namespace).Create(replSpec); err != nil { return err } @@ -196,7 +196,7 @@ func setupArangoDBCluster(ctx context.Context, kube kubernetes.Interface, c vers func waitForReplicationGone(ns, name string, c versioned.Interface) error { return retry.Retry(func() error { - if _, err := c.ReplicationV1alpha().ArangoDeploymentReplications(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { + if _, err := c.ReplicationV1().ArangoDeploymentReplications(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { return nil } else if err != nil { return err @@ -207,7 +207,7 @@ func waitForReplicationGone(ns, name string, c versioned.Interface) error { func waitForDeploymentGone(ns, name string, c versioned.Interface) error { return retry.Retry(func() error { - if _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { + if _, err := c.DatabaseV1().ArangoDeployments(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { return nil } else if err != nil { return err @@ -217,7 +217,7 @@ func waitForDeploymentGone(ns, name string, c versioned.Interface) error { } func removeReplicationWaitForCompletion(ns, name string, c versioned.Interface) error { - if err := c.ReplicationV1alpha().ArangoDeploymentReplications(ns).Delete(name, &metav1.DeleteOptions{}); err != nil { + if err := c.ReplicationV1().ArangoDeploymentReplications(ns).Delete(name, &metav1.DeleteOptions{}); err != nil { if k8sutil.IsNotFound(err) { return nil } @@ -230,7 +230,7 @@ func removeReplicationWaitForCompletion(ns, name string, c versioned.Interface) } func removeDeploymentWaitForCompletion(ns, name string, c versioned.Interface) error { - if err := c.DatabaseV1alpha().ArangoDeployments(ns).Delete(name, &metav1.DeleteOptions{}); err != nil { + if err := c.DatabaseV1().ArangoDeployments(ns).Delete(name, &metav1.DeleteOptions{}); err != nil { if k8sutil.IsNotFound(err) { return nil } diff --git a/tests/sync_test.go b/tests/sync_test.go index 5d3d6d57b..e06cbdb83 100644 --- a/tests/sync_test.go +++ b/tests/sync_test.go @@ -32,7 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util" @@ -43,7 +43,7 @@ import ( // waitUntilReplicationNotFound waits until a replication resource is deleted func waitUntilReplicationNotFound(ns, name string, cli versioned.Interface) error { return retry.Retry(func() error { - if _, err := cli.ReplicationV1alpha().ArangoDeploymentReplications(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { + if _, err := cli.ReplicationV1().ArangoDeploymentReplications(ns).Get(name, metav1.GetOptions{}); k8sutil.IsNotFound(err) { return nil } else if err != nil { return err @@ -71,7 +71,7 @@ func TestSyncSimple(t *testing.T) { depla.Spec.Sync.ExternalAccess.AccessPackageSecretNames = []string{apname} // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depla) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depla) if err != nil { t.Fatalf("Create deployment a failed: %v", err) } @@ -85,7 +85,7 @@ func TestSyncSimple(t *testing.T) { deplb.Spec.Sync.ExternalAccess.Type = api.NewExternalAccessType(api.ExternalAccessTypeNone) // Create deployment - _, err = c.DatabaseV1alpha().ArangoDeployments(ns).Create(deplb) + _, err = c.DatabaseV1().ArangoDeployments(ns).Create(deplb) if err != nil { t.Fatalf("Create deployment b failed: %v", err) } @@ -106,7 +106,7 @@ func TestSyncSimple(t *testing.T) { repl.Spec.Source.Authentication.KeyfileSecretName = util.NewString(apname) repl.Spec.Source.TLS.CASecretName = util.NewString(apname) repl.Spec.Destination.DeploymentName = util.NewString(deplb.GetName()) - _, err = c.ReplicationV1alpha().ArangoDeploymentReplications(ns).Create(repl) + _, err = c.ReplicationV1().ArangoDeploymentReplications(ns).Create(repl) if err != nil { t.Fatalf("Create replication resource failed: %v", err) } @@ -169,7 +169,7 @@ func TestSyncToggleEnabled(t *testing.T) { depl.Spec.Image = util.NewString(img) // Create deployment - _, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + _, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/test_util.go b/tests/test_util.go index 45cec4b01..cdb4eb252 100644 --- a/tests/test_util.go +++ b/tests/test_util.go @@ -26,6 +26,8 @@ import ( "context" "crypto/tls" "fmt" + "github.com/arangodb/kube-arangodb/pkg/apis/deployment" + "github.com/arangodb/kube-arangodb/pkg/apis/replication" "net" "os" "reflect" @@ -48,8 +50,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" - rapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + rapi "github.com/arangodb/kube-arangodb/pkg/apis/replication/v1" cl "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned" "github.com/arangodb/kube-arangodb/pkg/util" @@ -246,7 +248,7 @@ func newReplication(name string) *rapi.ArangoDeploymentReplication { repl := &rapi.ArangoDeploymentReplication{ TypeMeta: metav1.TypeMeta{ APIVersion: rapi.SchemeGroupVersion.String(), - Kind: rapi.ArangoDeploymentReplicationResourceKind, + Kind: replication.ArangoDeploymentReplicationResourceKind, }, ObjectMeta: metav1.ObjectMeta{ Name: strings.ToLower(name), @@ -262,7 +264,7 @@ func newDeployment(name string) *api.ArangoDeployment { depl := &api.ArangoDeployment{ TypeMeta: metav1.TypeMeta{ APIVersion: api.SchemeGroupVersion.String(), - Kind: api.ArangoDeploymentResourceKind, + Kind: deployment.ArangoDeploymentResourceKind, }, ObjectMeta: metav1.ObjectMeta{ Name: strings.ToLower(name), @@ -297,7 +299,7 @@ func newDeployment(name string) *api.ArangoDeployment { func waitUntilDeployment(cli versioned.Interface, deploymentName, ns string, predicate func(*api.ArangoDeployment) error, timeout ...time.Duration) (*api.ArangoDeployment, error) { var result *api.ArangoDeployment op := func() error { - obj, err := cli.DatabaseV1alpha().ArangoDeployments(ns).Get(deploymentName, metav1.GetOptions{}) + obj, err := cli.DatabaseV1().ArangoDeployments(ns).Get(deploymentName, metav1.GetOptions{}) if err != nil { result = nil return maskAny(err) @@ -571,7 +573,7 @@ func waitUntilClusterSidecarsEqualSpec(t *testing.T, spec api.DeploymentMode, de for start := time.Now(); time.Since(start) < 600*time.Second; { // Fetch latest status so we know all member details - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Get(depl.GetName(), metav1.GetOptions{}) if err != nil { t.Fatalf("Failed to get deployment: %v", err) } @@ -643,12 +645,12 @@ func clusterHealthEqualsSpec(h driver.ClusterHealth, spec api.DeploymentSpec) er func updateDeployment(cli versioned.Interface, deploymentName, ns string, update func(*api.DeploymentSpec)) (*api.ArangoDeployment, error) { for { // Get current version - current, err := cli.DatabaseV1alpha().ArangoDeployments(ns).Get(deploymentName, metav1.GetOptions{}) + current, err := cli.DatabaseV1().ArangoDeployments(ns).Get(deploymentName, metav1.GetOptions{}) if err != nil { return nil, maskAny(err) } update(¤t.Spec) - current, err = cli.DatabaseV1alpha().ArangoDeployments(ns).Update(current) + current, err = cli.DatabaseV1().ArangoDeployments(ns).Update(current) if k8sutil.IsConflict(err) { // Retry } else if err != nil { @@ -660,7 +662,7 @@ func updateDeployment(cli versioned.Interface, deploymentName, ns string, update // removeDeployment removes a deployment func removeDeployment(cli versioned.Interface, deploymentName, ns string) error { - if err := cli.DatabaseV1alpha().ArangoDeployments(ns).Delete(deploymentName, nil); err != nil && k8sutil.IsNotFound(err) { + if err := cli.DatabaseV1().ArangoDeployments(ns).Delete(deploymentName, nil); err != nil && k8sutil.IsNotFound(err) { return maskAny(err) } return nil @@ -668,7 +670,7 @@ func removeDeployment(cli versioned.Interface, deploymentName, ns string) error // removeReplication removes a deployment func removeReplication(cli versioned.Interface, replicationName, ns string) error { - if err := cli.ReplicationV1alpha().ArangoDeploymentReplications(ns).Delete(replicationName, nil); err != nil && k8sutil.IsNotFound(err) { + if err := cli.ReplicationV1().ArangoDeploymentReplications(ns).Delete(replicationName, nil); err != nil && k8sutil.IsNotFound(err) { return maskAny(err) } return nil diff --git a/tests/upgrade_test.go b/tests/upgrade_test.go index 13aed3902..598ec375d 100644 --- a/tests/upgrade_test.go +++ b/tests/upgrade_test.go @@ -28,7 +28,7 @@ import ( "testing" driver "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/dchest/uniuri" @@ -237,7 +237,7 @@ func runUpgradeTest(t *testing.T, spec UpgradeTest) { depl.Spec.SetDefaults(depl.GetName()) // this must be last // Create deployment - deployment, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + deployment, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) } diff --git a/tests/version_test.go b/tests/version_test.go index 708fadca3..a0fa729ac 100644 --- a/tests/version_test.go +++ b/tests/version_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/arangodb/go-driver" - api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha" + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" "github.com/arangodb/kube-arangodb/pkg/client" "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/arangod" @@ -25,7 +25,7 @@ func TestIsVersionSet(t *testing.T) { depl.Spec.SetDefaults(depl.GetName()) depl.Spec.Image = util.NewString("arangodb/arangodb:" + string(expectedVersion)) // Create deployment - apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl) + apiObject, err := c.DatabaseV1().ArangoDeployments(ns).Create(depl) if err != nil { t.Fatalf("Create deployment failed: %v", err) }