├── .github
├── ISSUE_TEMPLATE
│ ├── cn_bug_report.yml
│ ├── cn_feature_request.yml
│ ├── config.yml
│ ├── en_bug_report.yml
│ └── en_feature_request.yml
└── workflows
│ ├── commit-ci-build.yml
│ ├── commit-message-checker.yml
│ ├── issue-translator.yml
│ ├── pr-ci-build.yml
│ ├── release-v6-builder-runner.yml
│ ├── release-v6-standalone.yml
│ └── release-v6.yml
├── .gitignore
├── ADDITIONAL_TERMS.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── LICENSES
├── apache
│ ├── apisix-ingress-controller
│ │ └── LICENSE
│ └── apisix
│ │ └── LICENSE
├── minio
│ └── minio
│ │ └── LICENSE
└── rancher
│ ├── local-path-provisioner
│ └── LICENSE
│ └── rke2
│ └── LICENSE
├── Makefile
├── README-zh.md
├── README.md
├── api
├── api
│ └── api_interface.go
├── api_routers
│ ├── doc
│ │ └── html.go
│ ├── gateway
│ │ └── gateway.go
│ ├── license
│ │ └── license.go
│ ├── router.go
│ ├── version2
│ │ ├── v2Plugin.go
│ │ ├── v2Routers.go
│ │ └── v2Rules.go
│ └── websocket
│ │ └── websocket.go
├── client
│ └── prometheus
│ │ ├── interface.go
│ │ ├── monitor.go
│ │ ├── prometheus.go
│ │ └── types.go
├── controller
│ ├── apigateway
│ │ ├── api_gateway.go
│ │ ├── api_gateway_cert.go
│ │ ├── api_gateway_route.go
│ │ └── api_gateway_service.go
│ ├── app.go
│ ├── app_restore.go
│ ├── application.go
│ ├── application_config_group.go
│ ├── autoscaler.go
│ ├── batch_operation.go
│ ├── check.go
│ ├── cluster.go
│ ├── enterprise.go
│ ├── event.go
│ ├── event_log.go
│ ├── gateway.go
│ ├── group.go
│ ├── helm.go
│ ├── k8s_attribute.go
│ ├── labels.go
│ ├── lg_pack.go
│ ├── license.go
│ ├── manager.go
│ ├── nodes.go
│ ├── plugin.go
│ ├── pods.go
│ ├── public_func.go
│ ├── registry.go
│ ├── registry_auth_secret.go
│ ├── registry_image.go
│ ├── resources.go
│ ├── root_func.go
│ ├── service_action.go
│ ├── service_monitor.go
│ ├── service_share.go
│ ├── third_party_service.go
│ ├── upload
│ │ ├── attachment.go
│ │ ├── body.go
│ │ ├── dir.go
│ │ ├── file_default_manager.go
│ │ ├── file_manager.go
│ │ ├── meta.go
│ │ ├── upload.go
│ │ └── web.go
│ ├── validation
│ │ └── validation.go
│ ├── volume.go
│ ├── volume_type.go
│ └── websocket.go
├── db
│ └── db.go
├── eventlog
│ ├── conf
│ │ └── conf.go
│ ├── db
│ │ ├── UnifyDB.go
│ │ ├── eventFilePlugin.go
│ │ ├── filePlugin.go
│ │ ├── manager.go
│ │ └── model.go
│ ├── entry
│ │ ├── docker_log_server.go
│ │ ├── event_log_server.go
│ │ ├── grpc
│ │ │ ├── client
│ │ │ │ └── event_log_client.go
│ │ │ ├── pb
│ │ │ │ ├── event_log.pb.go
│ │ │ │ └── event_log.proto
│ │ │ └── server
│ │ │ │ └── event_log_server.go
│ │ ├── monitor_message_server.go
│ │ ├── new_monitor_message_server.go
│ │ └── server.go
│ ├── exit
│ │ ├── monitor
│ │ │ └── monitor.go
│ │ └── web
│ │ │ ├── getter.go
│ │ │ ├── manager.go
│ │ │ └── pusher.go
│ ├── store
│ │ ├── barrel.go
│ │ ├── docker_log_store.go
│ │ ├── handle_message_store.go
│ │ ├── manager.go
│ │ ├── new_monitor_message_store.go
│ │ ├── read_message_store.go
│ │ └── store.go
│ └── util
│ │ ├── buffer.go
│ │ ├── common.go
│ │ ├── conn.go
│ │ ├── file.go
│ │ ├── filepath.go
│ │ ├── protocol.go
│ │ └── streamserver.go
├── handler
│ ├── LicenseHandler.go
│ ├── PluginHandler.go
│ ├── app.go
│ ├── app_governance_mode
│ │ └── adaptor
│ │ │ ├── app_governance_mode.go
│ │ │ ├── build_in.go
│ │ │ ├── istio.go
│ │ │ └── kubernetes_native.go
│ ├── app_restore_action.go
│ ├── app_restore_handler.go
│ ├── application_config_group.go
│ ├── application_handler.go
│ ├── cert.go
│ ├── cloud.go
│ ├── cloudHandler.go
│ ├── cluster.go
│ ├── covert_resource.go
│ ├── etcd_handler.go
│ ├── event.go
│ ├── eventLog.go
│ ├── eventlog_interface.go
│ ├── gateway_action.go
│ ├── gateway_handler.go
│ ├── get_namespace_resource_name.go
│ ├── group
│ │ └── group_backup.go
│ ├── handler.go
│ ├── helm.go
│ ├── helmhandler.go
│ ├── k8s_attribute.go
│ ├── license.go
│ ├── license_pack.go
│ ├── monitor.go
│ ├── nodes.go
│ ├── plugin.go
│ ├── pod_action.go
│ ├── pod_handler.go
│ ├── proxy.go
│ ├── registry_auth_secret_action.go
│ ├── registry_auth_secret_handler.go
│ ├── registry_image.go
│ ├── resource.go
│ ├── resource_import.go
│ ├── resource_public_function.go
│ ├── rootFunc.go
│ ├── rootFuncHandler.go
│ ├── service.go
│ ├── service_batch_operation.go
│ ├── service_check.go
│ ├── service_handler.go
│ ├── service_monitor.go
│ ├── service_operation.go
│ ├── service_plugin.go
│ ├── share
│ │ ├── plugin_share.go
│ │ └── service_share.go
│ ├── tenant.go
│ ├── tenant_handler.go
│ ├── tenantsResource.go
│ ├── third_party_service_handler.go
│ ├── tokenIden.go
│ ├── tokenIdenHandler.go
│ ├── types.go
│ ├── volume_type_handler.go
│ └── yaml_resource.go
├── metric
│ └── metric.go
├── middleware
│ ├── license.go
│ ├── middleware.go
│ ├── token.go
│ └── version.go
├── model
│ ├── ability.go
│ ├── api_gateway_model.go
│ ├── app.go
│ ├── app_restore.go
│ ├── autoscaler.go
│ ├── batch_service.go
│ ├── cloudModel.go
│ ├── cluster.go
│ ├── component.go
│ ├── convert_resource.go
│ ├── defineSources.go
│ ├── etcd.go
│ ├── event_log.go
│ ├── gateway_model.go
│ ├── logModel.go
│ ├── model.go
│ ├── namespace_resource.go
│ ├── netStreamRulesModel.go
│ ├── nodes.go
│ ├── pluginModel.go
│ ├── pods.go
│ ├── registry.go
│ ├── registry_auth_secret_model.go
│ ├── resource_handle.go
│ ├── service_model.go
│ ├── service_monitor.go
│ ├── tenantResourceModel.go
│ ├── third_party_srvice.go
│ ├── tsdbModel.go
│ ├── volume.go
│ └── volume_type.go
├── proxy
│ ├── http_proxy.go
│ ├── lb.go
│ ├── proxy.go
│ └── websocket_proxy.go
├── server
│ └── api.go
├── util
│ ├── bcode
│ │ ├── api_gateway.go
│ │ ├── application.go
│ │ ├── bcode.go
│ │ ├── ingress.go
│ │ ├── service.go
│ │ └── tenant.go
│ ├── ctx
│ │ └── ctx.go
│ ├── events.go
│ ├── handleError.go
│ ├── http.go
│ ├── license
│ │ └── license.go
│ └── volume.go
└── webcli
│ ├── app
│ ├── app.go
│ ├── app_test.go
│ ├── exec.go
│ ├── http_logger.go
│ ├── monitor.go
│ ├── out.go
│ ├── tty_test.go
│ └── ws_wrapper.go
│ └── term
│ ├── BUILD
│ ├── resize.go
│ ├── resizeevents.go
│ ├── resizeevents_windows.go
│ ├── term.go
│ ├── term_writer.go
│ └── term_writer_test.go
├── build.sh
├── builder
├── api
│ ├── controller
│ │ ├── checkController.go
│ │ ├── eventController.go
│ │ └── versionController.go
│ └── router.go
├── build
│ ├── build.go
│ ├── code_build.go
│ ├── dockerfile_build.go
│ └── netcore_build.go
├── clean
│ ├── clean.go
│ └── clean_test.go
├── cloudos
│ ├── alioss.go
│ ├── alioss_test.go
│ ├── cloudos.go
│ ├── cloudos_test.go
│ ├── errors.go
│ ├── goodrain-logo.png
│ ├── s3.go
│ └── s3_test.go
├── discover
│ └── discover.go
├── exector
│ ├── build_from_image_run.go
│ ├── build_from_market_slug.go
│ ├── build_from_sourcecode_run.go
│ ├── build_from_vm.go
│ ├── exector.go
│ ├── export_app.go
│ ├── garbage_collection.go
│ ├── groupapp_backup.go
│ ├── groupapp_backup_test.go
│ ├── groupapp_restore.go
│ ├── groupapp_restore_test.go
│ ├── import_app.go
│ ├── import_app_test.go
│ ├── plugin_dockerfile.go
│ ├── plugin_dockerfile_test.go
│ ├── plugin_image.go
│ ├── plugin_image_test.go
│ ├── service_check.go
│ ├── share_image.go
│ ├── share_plugin.go
│ ├── share_slug.go
│ └── worker.go
├── job
│ └── job.go
├── model
│ └── model.go
├── monitor
│ └── monitor.go
├── parser
│ ├── code
│ │ ├── dependencies.go
│ │ ├── lang.go
│ │ ├── multisvc
│ │ │ ├── maven.go
│ │ │ ├── maven_test.go
│ │ │ └── multi_services.go
│ │ ├── procfile.go
│ │ ├── rainbondfile
│ │ ├── rainbondfile.go
│ │ ├── rainbondfile_test.go
│ │ ├── runtime.go
│ │ ├── runtime_test.go
│ │ └── specification.go
│ ├── compose
│ │ ├── compose.go
│ │ ├── compose_object.go
│ │ ├── utils.go
│ │ ├── version12.go
│ │ └── version3.go
│ ├── discovery
│ │ ├── discovery.go
│ │ ├── etcd.go
│ │ └── etcd_test.go
│ ├── docker_compose.go
│ ├── docker_run.go
│ ├── parser.go
│ ├── source_code.go
│ ├── third_party_service.go
│ ├── types
│ │ └── types.go
│ └── vm_service.go
├── repostory.go
└── sources
│ ├── container_client.go
│ ├── container_config.go
│ ├── containerd_client.go
│ ├── docker_client.go
│ ├── file_test.go
│ ├── git.go
│ ├── git_test.go
│ ├── home.go
│ ├── image.go
│ ├── image_client.go
│ ├── image_containerd_client.go
│ ├── image_docker_client.go
│ ├── image_test.go
│ ├── jsonmessage.go
│ ├── parse_dockerfile.go
│ ├── registry.go
│ ├── registry
│ ├── authchallenge.go
│ ├── basictransport.go
│ ├── clean_repo.go
│ ├── errors.go
│ ├── errortransport.go
│ ├── json.go
│ ├── manifest.go
│ ├── registry.go
│ ├── repostories.go
│ ├── tag.go
│ └── tokentransport.go
│ ├── registry_test.go
│ ├── repo.go
│ ├── repo_test.go
│ ├── sftp.go
│ ├── sftp_test.go
│ ├── svn.go
│ ├── svn_test.go
│ └── trust.go
├── check.sh
├── cmd
├── api
│ ├── main.go
│ ├── option
│ │ └── option.go
│ └── swagger.json
├── builder
│ ├── builder.go
│ └── option
│ │ └── option.go
├── grctl
│ ├── grctl.go
│ ├── option
│ │ └── conf.go
│ └── server
│ │ └── grctl.go
├── init-probe
│ ├── cmd
│ │ └── probe_cmd.go
│ ├── healthy
│ │ └── depends_health.go
│ └── probe.go
├── mq
│ └── mq.go
├── version.go
└── worker
│ ├── option
│ └── option.go
│ └── worker.go
├── config
├── configs
│ ├── config.go
│ ├── db_config.go
│ ├── es_config.go
│ ├── filepersistence_config.go
│ ├── k8s_config.go
│ ├── log_config.go
│ ├── options.go
│ ├── prometheus_config.go
│ ├── public_config.go
│ ├── rbdcomponent
│ │ ├── api_config.go
│ │ ├── chaos_config.go
│ │ ├── mq_config.go
│ │ └── worker_config.go
│ ├── server_config.go
│ ├── storage_config.go
│ └── websocket_config.go
└── crd
│ ├── rainbond.io_componentdefinitions.yaml
│ ├── rainbond.io_helmapps.yaml
│ ├── rainbond.io_rbdabilities.yaml
│ ├── rainbond.io_rbdplugins.yaml
│ └── rainbond.io_thirdcomponents.yaml
├── db
├── config
│ └── config.go
├── dao
│ ├── dao.go
│ └── dao_mock.go
├── db.go
├── db_mock.go
├── errors
│ └── errors.go
├── mock.sh
├── model
│ ├── apiClass.go
│ ├── app.go
│ ├── application.go
│ ├── cloud.go
│ ├── codecheck.go
│ ├── component.go
│ ├── event.go
│ ├── eventlog.go
│ ├── gateway.go
│ ├── key_value.go
│ ├── kubernetes.go
│ ├── license.go
│ ├── monitor.go
│ ├── plugin.go
│ ├── protocol.go
│ ├── tenant.go
│ ├── third_party_service.go
│ ├── version.go
│ └── volume_type.go
└── mysql
│ ├── dao
│ ├── 3rd_party.go
│ ├── apiClass.go
│ ├── app.go
│ ├── application.go
│ ├── application_config_group.go
│ ├── application_config_group_test.go
│ ├── cloud.go
│ ├── codecheck.go
│ ├── enterprise.go
│ ├── event.go
│ ├── gateway.go
│ ├── k8s.go
│ ├── k8s_resource.go
│ ├── key_value.go
│ ├── lg_pack.go
│ ├── license.go
│ ├── monitor.go
│ ├── over_score.go
│ ├── plugin.go
│ ├── service.go
│ ├── tenants.go
│ ├── version.go
│ └── volume_type.go
│ ├── dao_impl.go
│ └── mysql.go
├── docs
├── arch.jpeg
├── arch_en.png
├── bell-outline-badge.svg
├── rainbond_architecture.png
├── rainbond_architecture.svg
├── rainbond_logo.png
├── topology.gif
├── wechat.png
└── wechatgroup.png
├── event
├── log_optoins.go
├── manager.go
└── manager_mock.go
├── go.mod
├── go.sum
├── grctl
├── clients
│ └── kubernetes.go
├── cluster
│ ├── cluster.go
│ └── vergion.go
├── cmd
│ ├── build.go
│ ├── cmd.go
│ ├── config.go
│ ├── gpushare.go
│ ├── license.go
│ ├── migrate.go
│ ├── registry.go
│ └── replace.go
└── registry
│ ├── freecomponent.go
│ ├── freeimage.go
│ ├── freeversion.go
│ └── registry.go
├── hack
├── contrib
│ └── docker
│ │ ├── README.md
│ │ ├── api
│ │ ├── Dockerfile
│ │ └── entrypoint.sh
│ │ ├── buildstack
│ │ ├── Dockerfile
│ │ └── libzmq
│ │ │ ├── bin
│ │ │ └── curve_keygen
│ │ │ ├── include
│ │ │ ├── zmq.h
│ │ │ └── zmq_utils.h
│ │ │ ├── lib
│ │ │ ├── libzmq.a
│ │ │ ├── libzmq.la
│ │ │ ├── libzmq.so
│ │ │ ├── libzmq.so.3
│ │ │ ├── libzmq.so.3.1.0
│ │ │ └── pkgconfig
│ │ │ │ └── libzmq.pc
│ │ │ └── share
│ │ │ └── man
│ │ │ ├── man3
│ │ │ ├── zmq_bind.3
│ │ │ ├── zmq_close.3
│ │ │ ├── zmq_connect.3
│ │ │ ├── zmq_ctx_destroy.3
│ │ │ ├── zmq_ctx_get.3
│ │ │ ├── zmq_ctx_new.3
│ │ │ ├── zmq_ctx_set.3
│ │ │ ├── zmq_ctx_term.3
│ │ │ ├── zmq_curve_keypair.3
│ │ │ ├── zmq_disconnect.3
│ │ │ ├── zmq_errno.3
│ │ │ ├── zmq_getsockopt.3
│ │ │ ├── zmq_init.3
│ │ │ ├── zmq_msg_close.3
│ │ │ ├── zmq_msg_copy.3
│ │ │ ├── zmq_msg_data.3
│ │ │ ├── zmq_msg_get.3
│ │ │ ├── zmq_msg_init.3
│ │ │ ├── zmq_msg_init_data.3
│ │ │ ├── zmq_msg_init_size.3
│ │ │ ├── zmq_msg_more.3
│ │ │ ├── zmq_msg_move.3
│ │ │ ├── zmq_msg_recv.3
│ │ │ ├── zmq_msg_send.3
│ │ │ ├── zmq_msg_set.3
│ │ │ ├── zmq_msg_size.3
│ │ │ ├── zmq_poll.3
│ │ │ ├── zmq_proxy.3
│ │ │ ├── zmq_recv.3
│ │ │ ├── zmq_recvmsg.3
│ │ │ ├── zmq_send.3
│ │ │ ├── zmq_send_const.3
│ │ │ ├── zmq_sendmsg.3
│ │ │ ├── zmq_setsockopt.3
│ │ │ ├── zmq_socket.3
│ │ │ ├── zmq_socket_monitor.3
│ │ │ ├── zmq_strerror.3
│ │ │ ├── zmq_term.3
│ │ │ ├── zmq_unbind.3
│ │ │ ├── zmq_version.3
│ │ │ ├── zmq_z85_decode.3
│ │ │ └── zmq_z85_encode.3
│ │ │ └── man7
│ │ │ ├── zmq.7
│ │ │ ├── zmq_curve.7
│ │ │ ├── zmq_epgm.7
│ │ │ ├── zmq_inproc.7
│ │ │ ├── zmq_ipc.7
│ │ │ ├── zmq_null.7
│ │ │ ├── zmq_pgm.7
│ │ │ ├── zmq_plain.7
│ │ │ └── zmq_tcp.7
│ │ ├── chaos
│ │ ├── Dockerfile
│ │ ├── entrypoint.sh
│ │ └── export-app
│ │ │ └── run.sh
│ │ ├── grctl
│ │ ├── Dockerfile
│ │ ├── README.md
│ │ ├── entrypoint.sh
│ │ ├── grctl.yaml
│ │ └── libzmq.so.3
│ │ ├── init-probe
│ │ ├── Dockerfile
│ │ └── entrypoint.sh
│ │ ├── mq
│ │ ├── Dockerfile
│ │ └── entrypoint.sh
│ │ ├── rbd-shell
│ │ └── Dockerfile
│ │ ├── run-image
│ │ ├── Dockerfile
│ │ └── libzmq.so.3
│ │ └── worker
│ │ ├── Dockerfile
│ │ └── entrypoint.sh
└── k8s
│ └── codegen
│ ├── README.md
│ ├── boilerplate.go.txt
│ ├── tools.go
│ ├── update-generated.sh
│ └── verify-generated.sh
├── localcheck.sh
├── mockgen.sh
├── mq
├── api
│ ├── controller
│ │ └── controller.go
│ ├── grpc
│ │ ├── pb
│ │ │ ├── build.sh
│ │ │ ├── message.pb.go
│ │ │ └── message.proto
│ │ └── server
│ │ │ └── server.go
│ └── mq
│ │ ├── mq.go
│ │ └── store.go
├── client
│ └── client.go
├── monitor
│ └── monitor.go
└── mqcomponent
│ ├── grpcserver
│ └── server.go
│ ├── metrics
│ └── server.go
│ └── mqclient
│ └── client.go
├── pkg
├── apis
│ └── rainbond
│ │ ├── group.go
│ │ └── v1alpha1
│ │ ├── componentdefinition.go
│ │ ├── doc.go
│ │ ├── helmapp_status.go
│ │ ├── helmapp_types.go
│ │ ├── rbdability_types.go
│ │ ├── rbdplugin_types.go
│ │ ├── register.go
│ │ ├── third_component.go
│ │ └── zz_generated.deepcopy.go
├── common
│ └── scheme.go
├── component
│ ├── README.md
│ ├── core.go
│ ├── es
│ │ └── esComponent.go
│ ├── eventlog
│ │ └── eventlog.go
│ ├── filepersistence
│ │ ├── filepersistence.go
│ │ ├── volcengine.go
│ │ └── volcengine_test.go
│ ├── grpc
│ │ └── grpcComponent.go
│ ├── hubregistry
│ │ └── registryComponent.go
│ ├── k8s
│ │ └── k8sComponent.go
│ ├── mq
│ │ └── mqComponent.go
│ ├── prom
│ │ └── promComponent.go
│ └── storage
│ │ ├── local_storage.go
│ │ ├── s3_storage.go
│ │ └── storage.go
├── generated
│ ├── clientset
│ │ └── versioned
│ │ │ ├── clientset.go
│ │ │ ├── doc.go
│ │ │ ├── fake
│ │ │ ├── clientset_generated.go
│ │ │ ├── doc.go
│ │ │ └── register.go
│ │ │ ├── scheme
│ │ │ ├── doc.go
│ │ │ └── register.go
│ │ │ └── typed
│ │ │ └── rainbond
│ │ │ └── v1alpha1
│ │ │ ├── componentdefinition.go
│ │ │ ├── doc.go
│ │ │ ├── fake
│ │ │ ├── doc.go
│ │ │ ├── fake_componentdefinition.go
│ │ │ ├── fake_helmapp.go
│ │ │ ├── fake_rainbond_client.go
│ │ │ ├── fake_rbdability.go
│ │ │ ├── fake_rbdplugin.go
│ │ │ └── fake_thirdcomponent.go
│ │ │ ├── generated_expansion.go
│ │ │ ├── helmapp.go
│ │ │ ├── rainbond_client.go
│ │ │ ├── rbdability.go
│ │ │ ├── rbdplugin.go
│ │ │ └── thirdcomponent.go
│ ├── informers
│ │ └── externalversions
│ │ │ ├── factory.go
│ │ │ ├── generic.go
│ │ │ ├── internalinterfaces
│ │ │ └── factory_interfaces.go
│ │ │ └── rainbond
│ │ │ ├── interface.go
│ │ │ └── v1alpha1
│ │ │ ├── componentdefinition.go
│ │ │ ├── helmapp.go
│ │ │ ├── interface.go
│ │ │ ├── rbdability.go
│ │ │ ├── rbdplugin.go
│ │ │ └── thirdcomponent.go
│ └── listers
│ │ └── rainbond
│ │ └── v1alpha1
│ │ ├── componentdefinition.go
│ │ ├── expansion_generated.go
│ │ ├── helmapp.go
│ │ ├── rbdability.go
│ │ ├── rbdplugin.go
│ │ └── thirdcomponent.go
├── gogo
│ ├── go.go
│ └── option.go
├── helm
│ ├── config.go
│ ├── helm.go
│ ├── repo.go
│ ├── repo_test.go
│ └── update.go
├── interceptors
│ └── http.go
└── rainbond
│ ├── component.go
│ └── registry.go
├── precheck.sh
├── util
├── ansible
│ └── node.go
├── apply
│ ├── apply.go
│ └── patch.go
├── bytes.go
├── cert
│ └── certutil.go
├── chan.go
├── comman.go
├── comman_test.go
├── command.go
├── commonutil
│ └── convert_types.go
├── constants.go
├── constants
│ └── constants.go
├── convert_types.go
├── copydir.go
├── copyio.go
├── criutil
│ └── criutil.go
├── dockerfile
│ ├── command
│ │ └── command.go
│ └── parser
│ │ ├── dumper
│ │ └── main.go
│ │ ├── json_test.go
│ │ ├── line_parsers.go
│ │ ├── parser.go
│ │ ├── parser_test.go
│ │ ├── testfile-line
│ │ └── Dockerfile
│ │ ├── testfiles-negative
│ │ ├── env_no_value
│ │ │ └── Dockerfile
│ │ └── shykes-nested-json
│ │ │ └── Dockerfile
│ │ ├── testfiles
│ │ ├── ADD-COPY-with-JSON
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── brimstone-consuldock
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── brimstone-docker-consul
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── continueIndent
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── cpuguy83-nagios
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── docker
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── env
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── escape-after-comment
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── escape-nonewline
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── escape
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── escapes
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── flags
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── health
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── influxdb
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── jeztah-invalid-json-json-inside-string-double
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── jeztah-invalid-json-json-inside-string
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── jeztah-invalid-json-single-quotes
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── jeztah-invalid-json-unterminated-bracket
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── jeztah-invalid-json-unterminated-string
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── json
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── kartar-entrypoint-oddities
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── lk4d4-the-edge-case-generator
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── mail
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── multiple-volumes
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── mumble
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── nginx
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── tf2
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ ├── weechat
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ └── znc
│ │ │ ├── Dockerfile
│ │ │ └── result
│ │ └── utils.go
├── endpoint
│ └── validation.go
├── envoy
│ ├── v1
│ │ ├── builder.go
│ │ ├── keys.go
│ │ └── resource.go
│ └── v2
│ │ ├── builder.go
│ │ └── util.go
├── envutil
│ └── envutil.go
├── etcd
│ ├── client.go
│ ├── error.go
│ ├── etcd.go
│ └── etcdlock
│ │ └── master.go
├── fuzzy
│ ├── fuzzy.go
│ └── levenshtein.go
├── get_my_namespace.go
├── govalidator
│ ├── LICENSE.md
│ ├── custom_rules.go
│ ├── errors.go
│ ├── field_validator.go
│ ├── helper.go
│ ├── regex_patterns.go
│ ├── rules.go
│ ├── validator.go
│ ├── validator_map.go
│ └── validator_struct.go
├── grpc
│ └── resolver.go
├── hash.go
├── hash_test.go
├── hosts.go
├── http
│ ├── README.md
│ └── api.go
├── ingress-nginx
│ ├── ingress
│ │ ├── controller
│ │ │ ├── process
│ │ │ │ └── nginx.go
│ │ │ └── store
│ │ │ │ ├── endpoint.go
│ │ │ │ ├── ingress.go
│ │ │ │ ├── secret.go
│ │ │ │ ├── service.go
│ │ │ │ └── store.go
│ │ └── errors
│ │ │ └── errors.go
│ ├── k8s
│ │ └── main.go
│ └── task
│ │ └── queue.go
├── interrupt
│ └── interrupt.go
├── ip.go
├── ip_test.go
├── ippool.go
├── ippool_test.go
├── k8s
│ └── k8s.go
├── language.go
├── leader
│ └── kube_leader.go
├── license
│ ├── license.go
│ ├── license_test.go
│ └── testdata
│ │ ├── expire_license.yb
│ │ ├── ok_license.yb
│ │ └── wrong_license.yb
├── log
│ └── logger.go
├── pprofer.go
├── prober
│ ├── manager.go
│ ├── manager_test.go
│ ├── probes
│ │ ├── http.go
│ │ ├── probe.go
│ │ └── tcp.go
│ └── types
│ │ └── v1
│ │ └── types.go
├── retryutil
│ └── retry_util.go
├── sshclient.go
├── sshclient_test.go
├── string.go
├── string_test.go
├── sync
│ └── sync_db.go
├── termtables
│ ├── .travis.yml
│ ├── LICENSE
│ ├── README.md
│ ├── cell.go
│ ├── cell_test.go
│ ├── html.go
│ ├── html_test.go
│ ├── row.go
│ ├── row_test.go
│ ├── separator.go
│ ├── straight_separator.go
│ ├── style.go
│ ├── table.go
│ ├── table_test.go
│ └── term
│ │ ├── env.go
│ │ ├── getsize.go
│ │ ├── sizes_unix.go
│ │ ├── sizes_windows.go
│ │ └── wrapper.go
├── uuid.go
├── uuid_test.go
├── watch
│ ├── api.go
│ ├── event.go
│ ├── interface.go
│ ├── util.go
│ ├── watch.go
│ └── watcher.go
├── windows
│ └── service_windows.go
└── zip
│ ├── reader.go
│ ├── register.go
│ ├── struct.go
│ └── writer.go
└── worker
├── appm
├── componentdefinition
│ ├── component_properties.go
│ ├── componentdefinition.go
│ ├── parse.go
│ └── thirdcomponentdefinition.go
├── controller
│ ├── apply_plugin_config.go
│ ├── apply_rule.go
│ ├── controller.go
│ ├── export.go
│ ├── kube-controller.go
│ ├── refresh_xpa.go
│ ├── restart.go
│ ├── scaling.go
│ ├── start.go
│ ├── status.go
│ ├── stop.go
│ └── upgrade.go
├── conversion
│ ├── autoscaler.go
│ ├── autoscaler_test.go
│ ├── common.go
│ ├── configgroup.go
│ ├── conversion.go
│ ├── errors.go
│ ├── gateway.go
│ ├── monitor.go
│ ├── plugin.go
│ ├── resource.go
│ ├── service.go
│ └── version.go
├── f
│ └── function.go
├── store
│ ├── clean.go
│ ├── custom_resource.go
│ ├── informer.go
│ ├── lister.go
│ ├── mock_store.go
│ ├── resource.go
│ ├── store.go
│ └── store_test.go
├── thirdparty
│ ├── discovery
│ │ ├── discovery.go
│ │ ├── etcd.go
│ │ └── etcd_test.go
│ └── endpoints.go
├── types
│ └── v1
│ │ ├── endpoint.go
│ │ ├── labels.go
│ │ ├── patch.go
│ │ ├── patch_test.go
│ │ ├── pod_status.go
│ │ ├── status.go
│ │ ├── storeage_class.go
│ │ └── v1.go
└── volume
│ ├── config-file.go
│ ├── local.go
│ ├── memoryfs.go
│ ├── other.go
│ ├── plugin-storage.go
│ ├── share-file.go
│ ├── volcengine.go
│ └── volume.go
├── client
├── client.go
└── client_pod.go
├── discover
├── manager.go
└── model
│ └── model.go
├── gc
└── gc.go
├── handle
└── manager.go
├── master
├── controller
│ ├── controller.go
│ ├── helmapp
│ │ ├── app.go
│ │ ├── controller.go
│ │ ├── controlloop.go
│ │ ├── controlloop_test.go
│ │ ├── detector.go
│ │ ├── finilizer.go
│ │ ├── status.go
│ │ ├── store.go
│ │ └── suite_test.go
│ └── thirdcomponent
│ │ ├── controller.go
│ │ ├── discover
│ │ ├── discover.go
│ │ └── staticendpoint.go
│ │ ├── discover_pool.go
│ │ ├── prober
│ │ ├── prober.go
│ │ ├── prober_manager.go
│ │ ├── prober_test.go
│ │ ├── results
│ │ │ ├── results_manager.go
│ │ │ └── results_manager_test.go
│ │ └── worker.go
│ │ └── worker.go
├── master.go
├── podevent
│ └── podevent.go
└── volumes
│ ├── provider
│ ├── lib
│ │ ├── controller
│ │ │ ├── controller.go
│ │ │ ├── metrics
│ │ │ │ └── metrics.go
│ │ │ └── volume.go
│ │ └── util
│ │ │ └── util.go
│ ├── rainbondsslc.go
│ ├── rainbondsslc_test.go
│ └── rainbondsssc.go
│ ├── statistical
│ └── cache.go
│ └── sync
│ └── sync.go
├── monitor
├── collector
│ └── collector.go
└── exporter.go
├── server
├── pb
│ ├── app_runtime_server.pb.go
│ ├── app_runtime_server.proto
│ ├── protoc.sh
│ └── worker
│ │ └── server
│ │ └── pb
│ │ └── app_runtime_server.pb.go
├── pod.go
└── server.go
└── util
├── dns.go
├── pod.go
├── pod_test.go
├── thirdparty.go
├── volumetype.go
└── volumetype_test.go
/.github/ISSUE_TEMPLATE/cn_feature_request.yml:
--------------------------------------------------------------------------------
1 | name: 🚀 功能建议
2 | description: Request a new feature
3 | title: "🚀 功能建议:请填写标题,不要留空"
4 | labels: ["Feature"]
5 | assignees: ["zzzhangqi"]
6 |
7 | body:
8 | - type: textarea
9 | id: feature_description
10 | attributes:
11 | label: 功能描述
12 | description: 请描述你希望的功能,有必要的话可以提供截图,以供参考。
13 | placeholder: 功能描述
14 | validations:
15 | required: true
16 |
17 | - type: textarea
18 | id: feature_usecase
19 | attributes:
20 | label: 使用场景
21 | description: |
22 | 请描述你希望功能的使用场景。
23 | 如果该功能没有明确的使用场景,或是无法被理解,可能会被降低优先级或忽略,因此请务必清晰描述。
24 | placeholder: 使用场景
25 | validations:
26 | required: true
27 |
28 | - type: textarea
29 | id: resolution
30 | attributes:
31 | label: 实现方案(可选)
32 | description: 对于该功能,您有什么预想的实现方案,或者建议?
33 | placeholder: 实现方案
34 |
35 | - type: checkboxes
36 | id: PR
37 | attributes:
38 | label: 是否愿意提交 PR 实现该功能
39 | description: 我们非常欢迎您提交 PR,提交 PR 是实现该功能的最快的方式。
40 | options:
41 | - label: 我愿意提交 PR 实现该功能
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/en_feature_request.yml:
--------------------------------------------------------------------------------
1 | name: 🚀 Feature request
2 | description: Request a new feature
3 | title: "🚀 Feature request: Please fill in the title, do not leave blank"
4 | labels: ["Feature"]
5 | assignees: ["zzzhangqi"]
6 |
7 | body:
8 | - type: textarea
9 | id: feature_description
10 | attributes:
11 | label: Feature description
12 | description: Please describe the feature, with screenshots if necessary.
13 | placeholder: Feature description
14 | validations:
15 | required: true
16 |
17 | - type: textarea
18 | id: feature_usecase
19 | attributes:
20 | label: Use case
21 | description: |
22 | Please describe the use case of the feature.
23 | If the feature does not have a clear use case, or is unclear, it may be ignored or downgraded in priority, so please be as clear as possible.
24 | placeholder: Use case
25 | validations:
26 | required: true
27 |
28 | - type: textarea
29 | id: resolution
30 | attributes:
31 | label: Implementation plan (optional)
32 | description: Please describe the implementation plan if necessary.
33 | placeholder: Implementation plan
34 | validations:
35 | required: true
36 |
37 | - type: checkboxes
38 | id: PR
39 | attributes:
40 | label: Whether to submit a PR to implement the feature
41 | description: We welcome your PR to implement the feature, the fastest way to implement the feature is to submit a PR.
42 | options:
43 | - label: I want to submit a PR to implement the feature
--------------------------------------------------------------------------------
/.github/workflows/commit-ci-build.yml:
--------------------------------------------------------------------------------
1 | name: commit-ci-build
2 |
3 | on:
4 | push:
5 | branches: [main]
6 |
7 | jobs:
8 | rainbond:
9 | runs-on: ubuntu-latest
10 | strategy:
11 | matrix:
12 | component: [api, chaos, worker, init-probe, mq]
13 | steps:
14 | - name: Checkout repository
15 | uses: actions/checkout@v3
16 |
17 | - name: Set up Docker Buildx
18 | uses: docker/setup-buildx-action@v3
19 |
20 | - name: Set release description
21 | run: |
22 | buildTime=$(date +%F-%H)
23 | git_commit=$(git log -n 1 --pretty --format=%h)
24 | release_desc="dev-${git_commit}-${buildTime}"
25 | echo "release_desc=$release_desc" >> $GITHUB_ENV
26 |
27 | - name: Build and push
28 | uses: docker/build-push-action@v6
29 | with:
30 | platforms: linux/amd64
31 | build-args: |
32 | RELEASE_DESC=${{ env.release_desc }}
33 | context: .
34 | file: hack/contrib/docker/${{ matrix.component }}/Dockerfile
35 | push: false
36 | tags: |
37 | rainbond/rbd-${{ matrix.component }}:dev
--------------------------------------------------------------------------------
/.github/workflows/commit-message-checker.yml:
--------------------------------------------------------------------------------
1 | name: 'Commit Message Check'
2 | on:
3 | pull_request:
4 | types:
5 | - opened
6 | - edited
7 | - reopened
8 | - synchronize
9 | push:
10 | branches: [main, V5.*, fixbug*, Develop*]
11 |
12 | jobs:
13 | check-commit-message:
14 | name: Check Commit Message
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Check Commit Type
18 | uses: gsactions/commit-message-checker@v1
19 | with:
20 | pattern: '^\s*(feat|fix|docs|style|refactor|test|ci|perf|revert|chore|to)(\(.+\))?\: .+'
21 | flags: 'gm'
22 | error: 'Your first line has to contain a commit type like "feat: xxx".'
23 | - name: Check Line Length
24 | uses: gsactions/commit-message-checker@v1
25 | with:
26 | pattern: '^.{1,72}$'
27 | error: 'The maximum line length of 72 characters is exceeded.'
28 | excludeDescription: 'true' # optional: this excludes the description body of a pull request
29 | excludeTitle: 'true' # optional: this excludes the title of a pull request
30 | checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
31 | accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
32 |
--------------------------------------------------------------------------------
/.github/workflows/issue-translator.yml:
--------------------------------------------------------------------------------
1 | name: 'issue-translator'
2 | on:
3 | issue_comment:
4 | types: [created]
5 | issues:
6 | types: [opened]
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: tomsun28/issues-translate-action@v2.6
13 | with:
14 | IS_MODIFY_TITLE: false
15 | # not require, default false, . Decide whether to modify the issue title
16 | # if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
17 | CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
18 | # not require. Customize the translation robot prefix message.
19 |
--------------------------------------------------------------------------------
/.github/workflows/pr-ci-build.yml:
--------------------------------------------------------------------------------
1 | name: pr-ci-build
2 |
3 | on:
4 | pull_request:
5 | types: [opened, edited, synchronize, labeled, unlabeled]
6 |
7 | jobs:
8 | rainbond:
9 | runs-on: ubuntu-latest
10 | strategy:
11 | matrix:
12 | component: [api, chaos, worker, init-probe, mq]
13 | steps:
14 | - name: Checkout repository
15 | uses: actions/checkout@v3
16 |
17 | - name: Set up Docker Buildx
18 | uses: docker/setup-buildx-action@v3
19 |
20 | - name: Set release description
21 | run: |
22 | buildTime=$(date +%F-%H)
23 | git_commit=$(git log -n 1 --pretty --format=%h)
24 | release_desc="dev-${git_commit}-${buildTime}"
25 | echo "release_desc=$release_desc" >> $GITHUB_ENV
26 |
27 | - name: Build and push
28 | uses: docker/build-push-action@v6
29 | with:
30 | platforms: linux/amd64
31 | build-args: |
32 | RELEASE_DESC=${{ env.release_desc }}
33 | context: .
34 | file: hack/contrib/docker/${{ matrix.component }}/Dockerfile
35 | push: false
36 | tags: |
37 | rainbond/rbd-${{ matrix.component }}:dev
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #Mr Developer
3 | .mr.developer.cfg
4 |
5 | # Godeps workspace
6 | /Godeps/_workspace
7 |
8 | .DS_Store
9 | tags
10 |
11 | # direnv .envrc files
12 | .envrc
13 |
14 | # make-related metadata
15 | /.make/
16 |
17 | # precommit temporary directories created by ./hack/verify-generated-docs.sh and ./hack/lib/util.sh
18 | /_tmp/
19 | /doc_tmp/
20 |
21 | # User cluster configs
22 | .kubeconfig
23 |
24 | #Emacs
25 | .#*
26 | venv/
27 |
28 | # VS-code
29 | .vscode/
30 |
31 | # Pycharm
32 | .idea/
33 |
34 | # Eclipse files
35 | .classpath
36 | .project
37 | .settings/**
38 |
39 |
40 | # OSX leaves these everywhere on SMB shares
41 | ._*
42 |
43 | # build for rainbond
44 |
45 | .release/
46 | _output/
47 | .cache
48 |
49 |
50 | hack/deb/ubuntu-trusty
51 | hack/contrib/docker/node/release.sh
52 | admin.kubeconfig
53 | test/*
54 | test.db
55 | *.bak
56 | temp
57 | vendor
58 |
59 | .scannerwork
60 | Library
61 | .cache
62 | headerfile.py
63 | localcheck.sh
64 | go.work
65 |
--------------------------------------------------------------------------------
/ADDITIONAL_TERMS.md:
--------------------------------------------------------------------------------
1 | ## Additional Terms of Use
2 |
3 | These additional terms supplement the Apache License 2.0 ("Main License") and apply to all use, reproduction, and distribution of the Software.
4 |
5 | ### 1. Prohibition on Multi-Tenant SaaS Services
6 |
7 | Without the copyright holder’s prior written consent, you may not use the Software or any Derivative Works to provide multi-tenant Software as a Service (SaaS) services. Any commercial use of the Software beyond the scope of the Main License requires a separate commercial license agreement with the copyright holder.
8 |
9 | ### 2. Trademark and Logo Restrictions
10 |
11 | The trademarks, logos, and brand identifiers ("Logos") included in the Software are the property of the copyright holder. You may not modify, distort, or misuse the Logos in any way without prior written permission. When using the Software, you must maintain the Logos’ original design and integrity and may not use them in any context that could damage the copyright holder’s brand image.
--------------------------------------------------------------------------------
/api/api_routers/license/license.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package license
20 |
21 | import (
22 | "github.com/goodrain/rainbond/api/controller"
23 |
24 | "github.com/go-chi/chi"
25 | )
26 |
27 | // License license struct
28 | type License struct{}
29 |
30 | // Routes routes
31 | func Routes() chi.Router {
32 | r := chi.NewRouter()
33 | r.Get("/", controller.GetLicenseManager().Getlicense)
34 | r.Get("/features", controller.GetLicenseManager().GetlicenseFeature)
35 | return r
36 | }
37 |
--------------------------------------------------------------------------------
/api/api_routers/router.go:
--------------------------------------------------------------------------------
1 | package api_routers
2 |
3 | import (
4 | "net/http"
5 |
6 | "github.com/gin-gonic/gin"
7 | )
8 |
9 | type RouteStruct struct {
10 | // Add any necessary fields here
11 | }
12 |
13 | func (r *RouteStruct) SetRoutes(engine *gin.Engine) {
14 | // 应用 CORS 中间件到所有路由
15 | engine.Use(func(c *gin.Context) {
16 | controller.CORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
17 | c.Next()
18 | })).ServeHTTP(c.Writer, c.Request)
19 | })
20 |
21 | // ... 其余路由注册代码
22 | }
--------------------------------------------------------------------------------
/api/api_routers/version2/v2Rules.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package version2
20 |
21 | import (
22 | "github.com/go-chi/chi"
23 | )
24 |
25 | // PluginRouter plugin router
26 | func (v2 *V2) rulesRouter() chi.Router {
27 | r := chi.NewRouter()
28 | // service rule
29 | // url: v2/tenant/{tenant_name}/services/{service_alias}/net-rule/xxx
30 | // -- --
31 | //upstream
32 | r.Mount("/upstream", v2.upstreamRouter())
33 | return r
34 | }
35 |
36 | func (v2 *V2) upstreamRouter() chi.Router {
37 | r := chi.NewRouter()
38 | return r
39 | }
40 |
--------------------------------------------------------------------------------
/api/client/prometheus/interface.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2020-2020 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package prometheus
20 |
21 | import "time"
22 |
23 | //Interface monitor interface
24 | type Interface interface {
25 | GetMetric(expr string, time time.Time) Metric
26 | GetMetricOverTime(expr string, start, end time.Time, step time.Duration) Metric
27 | GetMetadata(namespace string) []Metadata
28 | //TODO Query dimensions to be improved
29 | GetAppMetadata(namespace, appID string) []Metadata
30 | GetComponentMetadata(namespace, componentID string) []Metadata
31 | GetMetricLabelSet(expr string, start, end time.Time) []map[string]string
32 | }
33 |
--------------------------------------------------------------------------------
/api/controller/apigateway/api_gateway.go:
--------------------------------------------------------------------------------
1 | package apigateway
2 |
3 | // Struct -
4 | type Struct struct{}
5 | type responseBody struct {
6 | Name string `json:"name"`
7 | Body interface{} `json:"body"`
8 | }
9 |
--------------------------------------------------------------------------------
/api/controller/registry_image.go:
--------------------------------------------------------------------------------
1 | package controller
2 |
3 | import (
4 | "github.com/goodrain/rainbond/api/handler"
5 | httputil "github.com/goodrain/rainbond/util/http"
6 | "net/http"
7 | )
8 |
9 | // RegistryImageRepositories -
10 | func RegistryImageRepositories(w http.ResponseWriter, r *http.Request) {
11 | namespace := r.FormValue("namespace")
12 | repositories, err := handler.GetServiceManager().RegistryImageRepositories(namespace)
13 | if err != nil {
14 | err.Handle(r, w)
15 | return
16 | }
17 | httputil.ReturnSuccess(r, w, repositories)
18 | }
19 |
20 | // RegistryImageTags -
21 | func RegistryImageTags(w http.ResponseWriter, r *http.Request) {
22 | repository := r.FormValue("repository")
23 | tags, err := handler.GetServiceManager().RegistryImageTags(repository)
24 | if err != nil {
25 | err.Handle(r, w)
26 | return
27 | }
28 | httputil.ReturnSuccess(r, w, tags)
29 | }
30 |
--------------------------------------------------------------------------------
/api/controller/root_func.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package controller
20 |
21 | //RootFuncManager root function manager
22 | type RootFuncManager struct{}
23 |
24 | var rootFuncManager *RootFuncManager
25 |
26 | //GetRootFuncManager get root function Manager
27 | func GetRootFuncManager() *RootFuncManager {
28 | if rootFuncManager != nil {
29 | return rootFuncManager
30 | }
31 | rootFuncManager = &RootFuncManager{}
32 | return rootFuncManager
33 | }
34 |
--------------------------------------------------------------------------------
/api/controller/upload/body.go:
--------------------------------------------------------------------------------
1 | package upload
2 |
3 | import (
4 | "io"
5 | "mime/multipart"
6 | "os"
7 | )
8 |
9 | // Upload body info.
10 | type body struct {
11 | XFile *os.File
12 | body io.Reader
13 | MR *multipart.Reader
14 | Available bool
15 | }
16 |
17 | // Check exists body in xfile and return body.
18 | func newBody(req_body io.Reader) (*body, error) {
19 | return &body{body: req_body, Available: true}, nil
20 | }
21 |
22 | // Close filehandler of body if XFile exists.
23 | func (body *body) Close() error {
24 | if body.XFile != nil {
25 | return body.XFile.Close()
26 | }
27 |
28 | return nil
29 | }
30 |
--------------------------------------------------------------------------------
/api/controller/upload/dir.go:
--------------------------------------------------------------------------------
1 | package upload
2 |
3 | import (
4 | "math/rand"
5 | "os"
6 | "path/filepath"
7 | "strconv"
8 | "time"
9 | )
10 |
11 | // Directory mananger
12 | type dirManager struct {
13 | Root string
14 | Path string
15 | }
16 |
17 | // Prepare dirManager given root, mime.
18 | func createDir(root, mime string) (*dirManager, error) {
19 | dm := newDirManager(root)
20 |
21 | dm.CalcPath(mime)
22 | if err := dm.create(); err != nil {
23 | return nil, err
24 | }
25 |
26 | return dm, nil
27 | }
28 |
29 | // newDirManager returns a new dirManager given a root.
30 | func newDirManager(root string) *dirManager {
31 | return &dirManager{Root: root}
32 | }
33 |
34 | // Return absolute path for directory
35 | func (dm *dirManager) Abs() string {
36 | return filepath.Join(dm.Root, dm.Path)
37 | }
38 |
39 | // Create directory obtained by concatenating the root and path.
40 | func (dm *dirManager) create() error {
41 | return os.MkdirAll(dm.Root+dm.Path, 0755)
42 | }
43 |
44 | // Generate path given mime and date.
45 | func (dm *dirManager) CalcPath(mime string) {
46 | dm.Path = ""
47 | }
48 |
49 | func yearDay(t time.Time) string {
50 | return strconv.FormatInt(int64(t.YearDay()), 36)
51 | }
52 |
53 | func containerName(t time.Time) string {
54 | r := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(1000)
55 | seconds := t.Hour()*3600 + t.Minute()*60 + t.Second()
56 |
57 | return strconv.FormatInt(int64(seconds*1000+r), 36)
58 | }
59 |
--------------------------------------------------------------------------------
/api/controller/upload/file_default_manager.go:
--------------------------------------------------------------------------------
1 | package upload
2 |
3 | import (
4 | "os"
5 | )
6 |
7 | type fileDefaultManager struct {
8 | *fileBaseManager
9 | Size int64
10 | }
11 |
12 | func (fdm *fileDefaultManager) convert(src string) error {
13 | return fdm.rawCopy(src)
14 | }
15 |
16 | func (fdm *fileDefaultManager) ToJson() map[string]interface{} {
17 | return map[string]interface{}{
18 | "url": fdm.Url(),
19 | "filename": fdm.Filename,
20 | "size": fdm.Size,
21 | }
22 | }
23 |
24 | func (fdm *fileDefaultManager) rawCopy(src string) error {
25 | if err := fdm.copyFile(src, fdm.Filepath()); err != nil {
26 | return err
27 | }
28 |
29 | f, err := os.Open(fdm.Filepath())
30 | if err != nil {
31 | return err
32 | }
33 | fi, err := f.Stat()
34 | if err != nil {
35 | return err
36 | }
37 | fdm.Size = fi.Size()
38 |
39 | return nil
40 | }
41 |
--------------------------------------------------------------------------------
/api/controller/upload/web.go:
--------------------------------------------------------------------------------
1 | package upload
2 |
3 | import (
4 | httputil "github.com/goodrain/rainbond/util/http"
5 | "net/http"
6 | )
7 |
8 | type Storage struct {
9 | output string
10 | verbosity int
11 | }
12 |
13 | func (s *Storage) StorageDir() string {
14 | return s.output
15 | }
16 |
17 | func NewStorage(rootDir string) *Storage {
18 | return &Storage{output: rootDir}
19 | }
20 |
21 | // UploadHandler is the endpoint for uploading and storing files.
22 | func (s *Storage) UploadHandler(w http.ResponseWriter, r *http.Request) {
23 |
24 | // Performs the processing of writing data into chunk files.
25 | files, err := process(r, s.StorageDir())
26 |
27 | if err == incomplete {
28 | httputil.ReturnSuccess(r, w, nil)
29 | return
30 | }
31 | if err != nil {
32 | httputil.ReturnError(r, w, 500, err.Error())
33 | return
34 | }
35 |
36 | data := make([]map[string]interface{}, 0)
37 |
38 | for _, file := range files {
39 | attachment, err := create(s.StorageDir(), file, true)
40 | if err != nil {
41 | httputil.ReturnError(r, w, 500, err.Error())
42 | return
43 | }
44 | data = append(data, attachment.ToJson())
45 | }
46 | httputil.ReturnSuccess(r, w, data)
47 | }
48 |
--------------------------------------------------------------------------------
/api/eventlog/db/UnifyDB.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package db
20 |
--------------------------------------------------------------------------------
/api/eventlog/entry/grpc/client/event_log_client.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package client
20 |
21 | import (
22 | "context"
23 | "github.com/goodrain/rainbond/api/eventlog/entry/grpc/pb"
24 | grpc1 "google.golang.org/grpc"
25 | )
26 |
27 | // NewEventClient new a event client
28 | func NewEventClient(ctx context.Context, server string) (pb.EventLogClient, error) {
29 | conn, err := grpc1.DialContext(ctx, server, grpc1.WithInsecure())
30 | if err != nil {
31 | return nil, err
32 | }
33 | return pb.NewEventLogClient(conn), nil
34 | }
35 |
--------------------------------------------------------------------------------
/api/eventlog/entry/grpc/pb/event_log.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package pb;
3 |
4 | service EventLog {
5 | rpc Log (stream LogMessage) returns (Reply) {}
6 | }
7 |
8 |
9 | message LogMessage {
10 | bytes log = 1;
11 | }
12 |
13 | message Reply {
14 | string status = 1;
15 | string message = 2;
16 | }
--------------------------------------------------------------------------------
/api/eventlog/exit/web/getter.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2019 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package web
20 |
21 | import (
22 | "net/http"
23 | "strconv"
24 |
25 | "github.com/go-chi/chi"
26 | httputil "github.com/goodrain/rainbond/util/http"
27 | )
28 |
29 | // getDockerLogs get history docker logs
30 | func (s *SocketServer) GetDockerLogs(w http.ResponseWriter, r *http.Request) {
31 | rows, _ := strconv.Atoi(r.URL.Query().Get("rows"))
32 | serviceID := chi.URLParam(r, "serviceID")
33 | if rows == 0 {
34 | rows = 100
35 | }
36 | loglist := s.storemanager.GetDockerLogs(serviceID, rows)
37 | httputil.ReturnSuccess(r, w, loglist)
38 | }
39 |
--------------------------------------------------------------------------------
/api/eventlog/util/file.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import "os"
22 |
23 | //AppendToFile 文件名字(带全路径)
24 | // content: 写入的内容
25 | func AppendToFile(fileName string, content string) error {
26 | f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
27 | if err != nil {
28 | return err
29 | }
30 | _, err = f.WriteString(content)
31 | defer f.Close()
32 | return err
33 | }
34 |
--------------------------------------------------------------------------------
/api/eventlog/util/filepath.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "crypto/sha256"
5 | "fmt"
6 | "path"
7 | "strconv"
8 | )
9 |
10 | // DockerLogFilePath returns the directory to save Docker log files
11 | func DockerLogFilePath(homepath, key string) string {
12 | return path.Join(homepath, getServiceAliasID(key))
13 | }
14 |
15 | // DockerLogFileName returns the file name of Docker log file.
16 | func DockerLogFileName(filePath string) string {
17 | return path.Join(filePath, "stdout.log")
18 | }
19 |
20 | //python:
21 | //new_word = str(ord(string[10])) + string + str(ord(string[3])) + 'log' + str(ord(string[2]) / 7)
22 | //new_id = hashlib.sha224(new_word).hexdigest()[0:16]
23 | //
24 | func getServiceAliasID(ServiceID string) string {
25 | if len(ServiceID) > 11 {
26 | newWord := strconv.Itoa(int(ServiceID[10])) + ServiceID + strconv.Itoa(int(ServiceID[3])) + "log" + strconv.Itoa(int(ServiceID[2])/7)
27 | ha := sha256.New224()
28 | ha.Write([]byte(newWord))
29 | return fmt.Sprintf("%x", ha.Sum(nil))[0:16]
30 | }
31 | return ServiceID
32 | }
33 |
34 | // EventLogFilePath returns the directory to save event log files
35 | func EventLogFilePath(homePath string) string {
36 | return path.Join(homePath, "eventlog")
37 | }
38 |
39 | // EventLogFileName returns the file name of event log file.
40 | func EventLogFileName(filePath, key string) string {
41 | return path.Join(filePath, key+".log")
42 | }
43 |
--------------------------------------------------------------------------------
/api/handler/app_governance_mode/adaptor/build_in.go:
--------------------------------------------------------------------------------
1 | package adaptor
2 |
3 | type buildInServiceMeshMode struct{}
4 |
5 | // NewBuildInServiceMeshMode -
6 | func NewBuildInServiceMeshMode() AppGoveranceModeHandler {
7 | return &buildInServiceMeshMode{}
8 | }
9 |
10 | // IsInstalledControlPlane -
11 | func (b *buildInServiceMeshMode) IsInstalledControlPlane() bool {
12 | return true
13 | }
14 |
15 | // GetInjectLabels -
16 | func (b *buildInServiceMeshMode) GetInjectLabels() map[string]string {
17 | return nil
18 | }
19 |
--------------------------------------------------------------------------------
/api/handler/app_governance_mode/adaptor/istio.go:
--------------------------------------------------------------------------------
1 | package adaptor
2 |
3 | import (
4 | "context"
5 | "os"
6 | "time"
7 |
8 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9 | clientset "k8s.io/client-go/kubernetes"
10 | )
11 |
12 | type istioServiceMeshMode struct {
13 | kubeClient clientset.Interface
14 | }
15 |
16 | // NewIstioGoveranceMode -
17 | func NewIstioGoveranceMode(kubeClient clientset.Interface) AppGoveranceModeHandler {
18 | return &istioServiceMeshMode{
19 | kubeClient: kubeClient,
20 | }
21 | }
22 |
23 | // IsInstalledControlPlane -
24 | func (i *istioServiceMeshMode) IsInstalledControlPlane() bool {
25 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
26 | defer cancel()
27 | cmName := os.Getenv("ISTIO_CM")
28 | if cmName == "" {
29 | cmName = "istio-sidecar-injector"
30 | }
31 | _, err := i.kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Get(ctx, cmName, metav1.GetOptions{})
32 | if err != nil {
33 | return false
34 | }
35 | return true
36 | }
37 |
38 | // GetInjectLabels -
39 | func (i *istioServiceMeshMode) GetInjectLabels() map[string]string {
40 | return map[string]string{"sidecar.istio.io/inject": "true"}
41 | }
42 |
--------------------------------------------------------------------------------
/api/handler/app_governance_mode/adaptor/kubernetes_native.go:
--------------------------------------------------------------------------------
1 | package adaptor
2 |
3 | type kubernetesNativeMode struct {
4 | }
5 |
6 | // NewKubernetesNativeMode -
7 | func NewKubernetesNativeMode() AppGoveranceModeHandler {
8 | return &kubernetesNativeMode{}
9 | }
10 |
11 | // IsInstalledControlPlane -
12 | func (k *kubernetesNativeMode) IsInstalledControlPlane() bool {
13 | return true
14 | }
15 |
16 | // GetInjectLabels -
17 | func (k *kubernetesNativeMode) GetInjectLabels() map[string]string {
18 | return nil
19 | }
20 |
--------------------------------------------------------------------------------
/api/handler/app_restore_handler.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | apimodel "github.com/goodrain/rainbond/api/model"
5 | )
6 |
7 | // AppRestoreHandler defines handler methods to restore app.
8 | // app means market service.
9 | type AppRestoreHandler interface {
10 | RestoreEnvs(tenantID, serviceID string, req *apimodel.RestoreEnvsReq) error
11 | RestorePorts(tenantID, serviceID string, req *apimodel.RestorePortsReq) error
12 | RestoreVolumes(tenantID, serviceID string, req *apimodel.RestoreVolumesReq) error
13 | RestoreProbe(serviceID string, req *apimodel.ServiceProbe) error
14 | RestoreDeps(tenantID, serviceID string, req *apimodel.RestoreDepsReq) error
15 | RestoreDepVols(tenantID, serviceID string, req *apimodel.RestoreDepVolsReq) error
16 | RestorePlugins(tenantID, serviceID string, req *apimodel.RestorePluginsReq) error
17 | }
18 |
19 | // NewAppRestoreHandler creates a new AppRestoreHandler.
20 | func NewAppRestoreHandler() AppRestoreHandler {
21 | return &AppRestoreAction{}
22 | }
23 |
--------------------------------------------------------------------------------
/api/handler/cloudHandler.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package handler
20 |
21 | import (
22 | apimodel "github.com/goodrain/rainbond/api/model"
23 | "github.com/goodrain/rainbond/api/util"
24 | dbmodel "github.com/goodrain/rainbond/db/model"
25 | )
26 |
27 | // CloudHandler define source handler
28 | type CloudHandler interface {
29 | TokenDispatcher(gt *apimodel.GetUserToken) (*apimodel.TokenInfo, *util.APIHandleError)
30 | GetTokenInfo(eid string) (*dbmodel.RegionUserInfo, *util.APIHandleError)
31 | UpdateTokenTime(eid string, vd int) *util.APIHandleError
32 | }
33 |
--------------------------------------------------------------------------------
/api/handler/helmhandler.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | apimodel "github.com/goodrain/rainbond/api/model"
5 | "github.com/goodrain/rainbond/api/util"
6 | )
7 |
8 | // HelmHandler -
9 | type HelmHandler interface {
10 | AddHelmRepo(helmRepo apimodel.CheckHelmApp) error
11 | CheckHelmApp(checkHelmApp apimodel.CheckHelmApp) (string, error)
12 | GetChartInformation(chart apimodel.ChartInformation) (*[]apimodel.HelmChartInformation, *util.APIHandleError)
13 | UpdateHelmRepo(names string) error
14 | GetYamlByChart(chartPath, namespace, name, version string, overrides []string) (string, error)
15 | GetUploadChartInformation(eventID string) ([]apimodel.HelmChartInformation, error)
16 | CheckUploadChart(name, version, namespace, eventID string) error
17 | GetUploadChartResource(name, version, namespace, eventID string, overrides []string) (interface{}, error)
18 | GetUploadChartValue(eventID string) (*apimodel.UploadChartValueYaml, error)
19 | }
20 |
--------------------------------------------------------------------------------
/api/handler/pod_action.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "github.com/goodrain/rainbond/worker/server/pb"
5 | "strings"
6 |
7 | "github.com/goodrain/rainbond/worker/client"
8 | "github.com/goodrain/rainbond/worker/server"
9 | )
10 |
11 | // PodAction is an implementation of PodHandler
12 | type PodAction struct {
13 | statusCli *client.AppRuntimeSyncClient
14 | }
15 |
16 | // PodDetail -
17 | func (p *PodAction) PodDetail(namespace, podName string) (*pb.PodDetail, error) {
18 | pd, err := p.statusCli.GetPodDetail(namespace, podName)
19 | if err != nil {
20 | if strings.Contains(err.Error(), server.ErrPodNotFound.Error()) {
21 | return nil, server.ErrPodNotFound
22 | }
23 | return nil, err
24 | }
25 | return pd, nil
26 | }
27 |
28 | // PodExecCmd 进入pod执行命令
29 |
--------------------------------------------------------------------------------
/api/handler/pod_handler.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "github.com/goodrain/rainbond/pkg/component/grpc"
5 | "github.com/goodrain/rainbond/worker/server/pb"
6 | )
7 |
8 | // PodHandler defines handler methods about k8s pods.
9 | type PodHandler interface {
10 | PodDetail(namespace, podName string) (*pb.PodDetail, error)
11 | }
12 |
13 | // NewPodHandler creates a new PodHandler.
14 | func NewPodHandler() PodHandler {
15 | return &PodAction{
16 | statusCli: grpc.Default().StatusClient,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/api/handler/registry_auth_secret_handler.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package handler
20 |
21 | import (
22 | apimodel "github.com/goodrain/rainbond/api/model"
23 | )
24 |
25 | //RegistryAuthSecretHandler registry auth secret handler
26 | type RegistryAuthSecretHandler interface {
27 | AddOrUpdateRegistryAuthSecret(req *apimodel.AddOrUpdateRegistryAuthSecretStruct) error
28 | DeleteRegistryAuthSecret(req *apimodel.DeleteRegistryAuthSecretStruct) error
29 | }
30 |
--------------------------------------------------------------------------------
/api/handler/registry_image.go:
--------------------------------------------------------------------------------
1 | package handler
2 |
3 | import (
4 | "github.com/goodrain/rainbond/api/util"
5 | "github.com/sirupsen/logrus"
6 | "path"
7 | "strings"
8 | )
9 |
10 | // RegistryImageRepositories -
11 | func (s *ServiceAction) RegistryImageRepositories(namespace string) ([]string, *util.APIHandleError) {
12 | var tenantRepositories []string
13 | repositories, err := s.registryCli.Repositories()
14 | if err != nil {
15 | logrus.Errorf("get tenant repositories failure: %v", err)
16 | return nil, util.CreateAPIHandleError(500, err)
17 | }
18 | for _, repository := range repositories {
19 | if strings.HasPrefix(repository, namespace+"/") {
20 | url := s.registryCli.URL
21 | urlList := strings.Split(url, "//")
22 | if urlList != nil && len(urlList) == 2 {
23 | url = urlList[1]
24 | }
25 | if url == "rbd-hub:5000" {
26 | url = "goodrain.me"
27 | }
28 | repository = path.Join(url, repository)
29 | tenantRepositories = append(tenantRepositories, repository)
30 | }
31 | }
32 |
33 | return tenantRepositories, nil
34 | }
35 |
36 | // RegistryImageTags -
37 | func (s *ServiceAction) RegistryImageTags(repository string) ([]string, *util.APIHandleError) {
38 | repositoryList := strings.SplitN(repository, "/", 2)
39 | if len(repositoryList) == 2 {
40 | repository = repositoryList[1]
41 | }
42 | tags, err := s.registryCli.Tags(repository)
43 | if err != nil {
44 | logrus.Errorf("get tenant repository %v tags failure: %v", repository, err)
45 | return nil, util.CreateAPIHandleError(500, err)
46 | }
47 | return tags, nil
48 | }
49 |
--------------------------------------------------------------------------------
/api/handler/rootFuncHandler.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package handler
20 |
21 | //RootFuncHandler root function handler interface
22 | type RootFuncHandler interface {
23 | }
24 |
25 | var defaultRootFuncHandler RootFuncHandler
26 |
27 | //CreateRootFuncHandler create root func handler
28 | func CreateRootFuncHandler() error {
29 | if defaultRootFuncHandler != nil {
30 | return nil
31 | }
32 | defaultRootFuncHandler = CreateRootFuncManager()
33 | return nil
34 | }
35 |
36 | //GetRootFuncHandler get root handler
37 | func GetRootFuncHandler() RootFuncHandler {
38 | return defaultRootFuncHandler
39 | }
40 |
--------------------------------------------------------------------------------
/api/handler/types.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package handler
20 |
21 | import "errors"
22 |
23 | var (
24 | // ErrTenantStillHasServices -
25 | ErrTenantStillHasServices = errors.New("tenant still has services")
26 | // ErrTenantStillHasPlugins -
27 | ErrTenantStillHasPlugins = errors.New("tenant still has plugins")
28 | )
29 |
--------------------------------------------------------------------------------
/api/middleware/license.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "github.com/goodrain/rainbond/config/configs"
5 | "net/http"
6 |
7 | httputil "github.com/goodrain/rainbond/util/http"
8 | licutil "github.com/goodrain/rainbond/util/license"
9 | )
10 |
11 | // License -
12 | type License struct {
13 | LicensePath string `json:"license_path"`
14 | LicSoPath string `json:"lic_so_path"`
15 | }
16 |
17 | // NewLicense -
18 | func NewLicense() *License {
19 | apiConfig := configs.Default().APIConfig
20 | return &License{
21 | LicensePath: apiConfig.LicensePath,
22 | LicSoPath: apiConfig.LicSoPath,
23 | }
24 | }
25 |
26 | // Verify parses the license to make the content inside it take effect.
27 | func (l *License) Verify(next http.Handler) http.Handler {
28 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
29 | if !licutil.VerifyTime(l.LicensePath, l.LicSoPath) {
30 | httputil.Return(r, w, 401, httputil.ResponseBody{
31 | Bean: map[string]interface{}{
32 | "msg": "invalid license",
33 | "code": 10400,
34 | },
35 | })
36 | return
37 | }
38 | next.ServeHTTP(w, r)
39 | })
40 | }
41 |
--------------------------------------------------------------------------------
/api/middleware/version.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package middleware
20 |
21 | import (
22 | "context"
23 | "net/http"
24 |
25 | ctxutil "github.com/goodrain/rainbond/api/util/ctx"
26 | )
27 |
28 | //APIVersion api版本
29 | func APIVersion(next http.Handler) http.Handler {
30 | fn := func(w http.ResponseWriter, r *http.Request) {
31 | apiVersion := r.Header.Get("API_VERSION")
32 | if apiVersion == "" {
33 | apiVersion = "default"
34 | }
35 | ctx := context.WithValue(r.Context(), ctxutil.ContextKey("api_version"), apiVersion)
36 | next.ServeHTTP(w, r.WithContext(ctx))
37 | }
38 | return http.HandlerFunc(fn)
39 | }
40 |
--------------------------------------------------------------------------------
/api/model/ability.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | import "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
4 |
5 | // UpdateAbilityReq -
6 | type UpdateAbilityReq struct {
7 | //AbilityID string `json:"ability_id" validate:"required"`
8 | Object *unstructured.Unstructured `json:"object" validate:"required"`
9 | }
10 |
11 | // AbilityResp -
12 | type AbilityResp struct {
13 | Name string `json:"name"`
14 | APIVersion string `json:"api_version"`
15 | Kind string `json:"kind"`
16 | AbilityID string `json:"ability_id"`
17 | }
18 |
19 | // ComponentStatus holds the status information of a component
20 | type ComponentStatus struct {
21 | Name string `json:"name"`
22 | Status string `json:"status"` // Completed, Upgrading, Failed
23 | Progress int64 `json:"progress"`
24 | Message string `json:"message"`
25 | }
26 |
--------------------------------------------------------------------------------
/api/model/api_gateway_model.go:
--------------------------------------------------------------------------------
1 | package model
2 |
--------------------------------------------------------------------------------
/api/model/etcd.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | // EtcdCleanReq etcd clean request struct
4 | type EtcdCleanReq struct {
5 | Keys []string `json:"etcd_keys"`
6 | }
7 |
--------------------------------------------------------------------------------
/api/model/event_log.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | // HistoryLogFile represents a history log file for service
4 | type HistoryLogFile struct {
5 | Filename string `json:"filename"`
6 | RelativePath string `json:"relative_path"`
7 | }
8 |
9 | // MyTeamsEventsReq -
10 | type MyTeamsEventsReq struct {
11 | TenantIDs []string `json:"tenant_ids"`
12 | }
13 |
--------------------------------------------------------------------------------
/api/model/pods.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | // PodDetail -
4 | type PodDetail struct {
5 | Name string `json:"name,omitempty"`
6 | Node string `json:"node,omitempty"`
7 | StartTime string `json:"start_time,omitempty"`
8 | Status *PodStatus `json:"status,omitempty"`
9 | IP string `json:"ip,omitempty"`
10 | InitContainers []*PodContainer `json:"init_containers,omitempty"`
11 | Containers []*PodContainer `json:"containers,omitempty"`
12 | Events []*PodEvent `json:"events,omitempty"`
13 | }
14 |
15 | // PodStatus -
16 | type PodStatus struct {
17 | Type int `json:"type,omitempty"`
18 | TypeStr string `json:"type_str,omitempty"`
19 | Reason string `json:"reason,omitempty"`
20 | Message string `json:"message,omitempty"`
21 | Advice string `json:"advice,omitempty"`
22 | }
23 |
24 | // PodContainer -
25 | type PodContainer struct {
26 | Image string `json:"image,omitempty"`
27 | State string `json:"state,omitempty"`
28 | Reason string `json:"reason,omitempty"`
29 | Started string `json:"started,omitempty"`
30 | LimitMemory string `json:"limit_memory,omitempty"`
31 | LimitCPU string `json:"limit_cpu,omitempty"`
32 | }
33 |
34 | // PodEvent -
35 | type PodEvent struct {
36 | Type string `json:"type,omitempty"`
37 | Reason string `json:"reason,omitempty"`
38 | Age string `json:"age,omitempty"`
39 | Message string `json:"message,omitempty"`
40 | }
41 |
--------------------------------------------------------------------------------
/api/model/registry.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | // SearchByDomainRequest 根据地址账号密码查询所有的仓库信息
4 | type SearchByDomainRequest struct {
5 | Domain string `json:"domain" validate:"domain|required"`
6 | UserName string `json:"username"`
7 | Password string `json:"password"`
8 | }
9 |
--------------------------------------------------------------------------------
/api/model/tsdbModel.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package model
20 |
21 | // MontiorData opentsdb data
22 | // swagger:parameters oentsdbquery
23 | type MontiorData struct {
24 | //in: body
25 | Body struct {
26 | // in: body
27 | // required: true
28 | Start string `json:"start" validate:"start"`
29 | // in: body
30 | // required: true
31 | Queries string `json:"queries" validate:"queries"`
32 | //Queries []tsdbClient.SubQuery `json:"queries" validate:"queries"`
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/api/util/bcode/ingress.go:
--------------------------------------------------------------------------------
1 | package bcode
2 |
3 | // ingress: 11200~11299
4 | var (
5 | ErrIngressHTTPRuleNotFound = newByMessage(404, 11200, "http rule not found")
6 | ErrIngressTCPRuleNotFound = newByMessage(404, 11201, "tcp rule not found")
7 | )
8 |
--------------------------------------------------------------------------------
/api/util/bcode/service.go:
--------------------------------------------------------------------------------
1 | package bcode
2 |
3 | // service: 10000~10099
4 | var (
5 | //ErrPortNotFound -
6 | ErrPortNotFound = newByMessage(404, 10001, "service port not found")
7 | //ErrServiceMonitorNotFound -
8 | ErrServiceMonitorNotFound = newByMessage(404, 10101, "service monitor not found")
9 | //ErrServiceMonitorNameExist -
10 | ErrServiceMonitorNameExist = newByMessage(400, 10102, "service monitor name is exist")
11 | // ErrSyncOperation -
12 | ErrSyncOperation = newByMessage(409, 10103, "The asynchronous operation is executing")
13 | // ErrHorizontalDueToNoChange
14 | ErrHorizontalDueToNoChange = newByMessage(400, 10104, "The number of components has not changed, no need to scale")
15 | ErrPodNotFound = newByMessage(404, 10105, "pod not found")
16 | ErrK8sComponentNameExists = newByMessage(400, 10106, "k8s component name exists")
17 | )
18 |
--------------------------------------------------------------------------------
/api/util/bcode/tenant.go:
--------------------------------------------------------------------------------
1 | package bcode
2 |
3 | // tenant 11300~11399
4 | var (
5 | ErrNamespaceExists = newByMessage(400, 11300, "tenant namespace exists")
6 | )
7 |
--------------------------------------------------------------------------------
/api/util/ctx/ctx.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2021-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package ctx
20 |
21 | //ContextKey ctx key type
22 | type ContextKey string
23 |
--------------------------------------------------------------------------------
/api/util/volume.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "strings"
5 |
6 | dbmodel "github.com/goodrain/rainbond/db/model"
7 | "github.com/twinj/uuid"
8 | )
9 |
10 | // SetVolumeDefaultValue set volume default value
11 | func SetVolumeDefaultValue(info *dbmodel.TenantServiceVolume) {
12 | if info.VolumeName == "" {
13 | info.VolumeName = uuid.NewV4().String()
14 | }
15 |
16 | if info.AccessMode != "" {
17 | info.AccessMode = strings.ToUpper(info.AccessMode)
18 | } else {
19 | info.AccessMode = "RWO"
20 | }
21 |
22 | if info.SharePolicy == "" {
23 | info.SharePolicy = "exclusive"
24 | }
25 |
26 | if info.BackupPolicy == "" {
27 | info.BackupPolicy = "exclusive"
28 | }
29 |
30 | if info.ReclaimPolicy == "" {
31 | info.ReclaimPolicy = "retain"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/api/webcli/app/app_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2020 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package app
20 |
21 | import (
22 | "testing"
23 | )
24 |
25 | func TestSendCommand(t *testing.T) {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/api/webcli/app/http_logger.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package app
20 |
21 | import (
22 | "bufio"
23 | "net"
24 | "net/http"
25 | )
26 |
27 | type responseWrapper struct {
28 | http.ResponseWriter
29 | status int
30 | }
31 |
32 | func (w *responseWrapper) WriteHeader(status int) {
33 | w.status = status
34 | w.ResponseWriter.WriteHeader(status)
35 | }
36 |
37 | func (w *responseWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
38 | hj, _ := w.ResponseWriter.(http.Hijacker)
39 | w.status = http.StatusSwitchingProtocols
40 | return hj.Hijack()
41 | }
42 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # 检查是否提供了服务名称和镜像名称
4 | if [ "$#" -lt 2 ]; then
5 | echo "Usage: $0 "
6 | echo "Example: $0 api my-api-image:1.0"
7 | exit 1
8 | fi
9 |
10 | # 获取输入参数
11 | service_name=$1
12 | image_name=$2
13 |
14 | # 自动生成目标目录路径
15 | base_dir="./hack/contrib/docker"
16 | target_dir="$base_dir/$service_name"
17 |
18 | # 检查服务目录是否存在
19 | if [ ! -d "$target_dir" ]; then
20 | echo "Error: Directory for service '$service_name' ('$target_dir') does not exist."
21 | exit 1
22 | fi
23 |
24 | # 检查是否存在 Dockerfile
25 | if [ ! -f "$target_dir/Dockerfile" ]; then
26 | echo "Error: No Dockerfile found in '$target_dir'."
27 | exit 1
28 | fi
29 |
30 | # 构建镜像
31 | echo "Building Docker image '$image_name' for service '$service_name' from directory '$target_dir'..."
32 | nerdctl build -f "$target_dir/Dockerfile" -t "$image_name" --namespace=k8s.io --address /var/run/k3s/containerd/containerd.sock ./
33 |
34 | if [ $? -eq 0 ]; then
35 | echo "Successfully built image: $image_name"
36 | else
37 | echo "Failed to build image: $image_name"
38 | exit 1
39 | fi
40 |
--------------------------------------------------------------------------------
/builder/clean/clean_test.go:
--------------------------------------------------------------------------------
1 | package clean
2 |
3 | import (
4 | "fmt"
5 | "github.com/goodrain/rainbond/builder/sources/registry"
6 | "sort"
7 | "testing"
8 | )
9 |
10 | // TestAutoClean 执行此方法你应该通过第三方组件将rbd-hub暴露出来,并且通过kubectl命令查找仓库账号密码
11 | func TestAutoClean(t *testing.T) {
12 | reg, _ := registry.New("", "", "")
13 | rep := ""
14 | tags, err := reg.Tags(rep)
15 | if err != nil {
16 | return
17 | }
18 |
19 | sort.Strings(tags)
20 | fmt.Println(tags)
21 | for _, v := range tags {
22 | v2, err := reg.ManifestDigestV2(rep, v)
23 | if err != nil {
24 | fmt.Println(err)
25 | }
26 | fmt.Println(v2)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/builder/cloudos/alioss_test.go:
--------------------------------------------------------------------------------
1 | package cloudos
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func TestAliOssDeleteObject(t *testing.T) {
8 | cfg := &Config{
9 | ProviderType: S3ProviderAliOSS,
10 | Endpoint: "dummy",
11 | AccessKey: "dummy",
12 | SecretKey: "dummy",
13 | BucketName: "hrhtest",
14 | }
15 | cr, err := newAliOSS(cfg)
16 | if err != nil {
17 | t.Fatalf("create alioss: %v", err)
18 | }
19 |
20 | if err := cr.DeleteObject("ca932c3215ec4d3891c30799e9aaacba_20191024205031.zip"); err != nil {
21 | t.Error(err)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/builder/cloudos/errors.go:
--------------------------------------------------------------------------------
1 | package cloudos
2 |
3 | import "fmt"
4 |
5 | // S3SDKError -
6 | type S3SDKError struct {
7 | Code string // The error code returned from S3 to the caller
8 | Message string // The detail error message from S3
9 | RawMessage string // The raw messages from S3
10 | StatusCode int // HTTP status code
11 | }
12 |
13 | // Error implements interface error
14 | func (e S3SDKError) Error() string {
15 | return fmt.Sprintf("storage: service returned error: StatusCode=%d, ErrorCode=%s, ErrorMessage=\"%s\"",
16 | e.StatusCode, e.Code, e.Message)
17 | }
18 |
--------------------------------------------------------------------------------
/builder/cloudos/goodrain-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/builder/cloudos/goodrain-logo.png
--------------------------------------------------------------------------------
/builder/cloudos/s3_test.go:
--------------------------------------------------------------------------------
1 | package cloudos
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func TestS3PutObject(t *testing.T) {
8 | cfg := &Config{
9 | Endpoint: "9000.gr4433a2.52bli69h.0196bd.grapps.cn",
10 | AccessKey: "dummy",
11 | SecretKey: "dummy",
12 | BucketName: "my-bucket",
13 | }
14 |
15 | cs, err := newS3(cfg)
16 | if err != nil {
17 | t.Fatalf("create storage driver: %v", err)
18 | }
19 |
20 | if err := cs.PutObject("aws-sdk-go-1.25.25.zip", "/Users/abewang/Downloads/aws-sdk-go-1.25.25.zip"); err != nil {
21 | t.Error(err)
22 | }
23 | }
24 |
25 | func TestS3GetObject(t *testing.T) {
26 | cfg := &Config{
27 | Endpoint: "9000.gr4433a2.52bli69h.0196bd.grapps.cn",
28 | AccessKey: "access_key",
29 | SecretKey: "dummy",
30 | BucketName: "my-bucket",
31 | }
32 |
33 | cs, err := newS3(cfg)
34 | if err != nil {
35 | t.Fatalf("create storage driver: %v", err)
36 | }
37 |
38 | if err := cs.GetObject("goodrain-logo.png", "goodrain-logo2.png"); err != nil {
39 | t.Error(err)
40 | }
41 | }
42 |
43 | func TestS3DeleteObject(t *testing.T) {
44 | cfg := &Config{
45 | Endpoint: "9000.gr4433a2.52bli69h.0196bd.grapps.cn",
46 | AccessKey: "access_key",
47 | SecretKey: "dummy",
48 | BucketName: "my-bucket",
49 | }
50 |
51 | cs, err := newS3(cfg)
52 | if err != nil {
53 | t.Fatalf("create storage driver: %v", err)
54 | }
55 |
56 | if err := cs.DeleteObject("goodrain-logo.png"); err != nil {
57 | t.Error(err)
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/builder/exector/import_app_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2020-2020 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package exector
20 |
21 | import (
22 | "path"
23 | "testing"
24 | )
25 |
26 | func TestPath(t *testing.T) {
27 | t.Log(path.Ext("/grdata/app/import/69f31ed1b03d4f84bd8be2fc92c6eb01/物联网-1.0.zip"))
28 | }
29 |
--------------------------------------------------------------------------------
/builder/exector/plugin_dockerfile_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package exector
20 |
21 | import (
22 | "bufio"
23 | "fmt"
24 | "io"
25 | "os/exec"
26 | "testing"
27 | )
28 |
29 | func TestExec(t *testing.T) {
30 | cmd := exec.Command("ping", "127.0.0.1", "-t", "10")
31 | stdout, _ := cmd.StdoutPipe()
32 | cmd.Start()
33 | reader := bufio.NewReader(stdout)
34 | go func() {
35 | for {
36 | line, err2 := reader.ReadString('\n')
37 | if err2 != nil || io.EOF == err2 {
38 | break
39 | }
40 | fmt.Print(line)
41 | }
42 | }()
43 | cmd.Wait()
44 | }
45 |
--------------------------------------------------------------------------------
/builder/exector/plugin_image_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package exector
20 |
--------------------------------------------------------------------------------
/builder/parser/code/multisvc/multi_services.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package multi
20 |
21 | import (
22 | "github.com/goodrain/rainbond/builder/parser/types"
23 | )
24 |
25 | // ServiceInterface is the interface that wraps the required methods to gather information
26 | // about multi-service project.
27 | type ServiceInterface interface {
28 | ListModules(path string) ([]*types.Service, error)
29 | }
30 |
31 | // NewMultiServiceI creates a new MultiModuler.
32 | func NewMultiServiceI(lang string) ServiceInterface {
33 | switch lang {
34 | case "Java-maven":
35 | return NewMaven()
36 | }
37 | return nil
38 | }
39 |
--------------------------------------------------------------------------------
/builder/parser/code/procfile.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package code
20 |
21 | import (
22 | "io/ioutil"
23 | "path"
24 |
25 | "github.com/goodrain/rainbond/util"
26 | )
27 |
28 | //CheckProcfile check runtime with lang
29 | func CheckProcfile(buildPath string, lang Lang) (bool, string) {
30 | if ok, _ := util.FileExists(path.Join(buildPath, "Procfile")); ok {
31 | body, _ := ioutil.ReadFile(path.Join(buildPath, "Procfile"))
32 | return true, string(body)
33 | }
34 | return false, ""
35 | }
36 |
--------------------------------------------------------------------------------
/builder/parser/code/rainbondfile:
--------------------------------------------------------------------------------
1 | language: Java-maven
2 | envs:
3 | ENV_KEYA: ENV_VALUEA
4 | ENV_KEYB: ENV_VALUEB
5 | ports:
6 | - port: 7777
7 | protocol: http
8 | services:
9 | - name: pig-eureka
10 | ports:
11 | - port: 9090
12 | protocol: http
13 | - port: 6000
14 | protocol: tcp
15 | envs:
16 | ENV_KEY1: ENV_VALUE1
17 | ENV_KEY2: ENV_VALUE2
18 | - name: pig-common/pig-common-security
19 | ports:
20 | - port: 8080
21 | protocol: http
22 | - port: 5000
23 | protocol: tcp
24 | envs:
25 | ENV_KEY3: ENV_VALUE3
26 | ENV_KEY4: ENV_VALUE4
--------------------------------------------------------------------------------
/builder/parser/code/rainbondfile_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package code
20 |
21 | import (
22 | "testing"
23 | )
24 |
25 | func TestReadRainbondFile(t *testing.T) {
26 | rbdfile, err := ReadRainbondFile("./")
27 | if err != nil {
28 | t.Fatal(err)
29 | }
30 | t.Log(rbdfile)
31 | }
32 |
--------------------------------------------------------------------------------
/builder/parser/code/runtime_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package code
20 |
21 | import "testing"
22 |
23 | func TestCheckRuntime(t *testing.T) {
24 | t.Log(CheckRuntime("/tmp/php", PHP))
25 | t.Log(CheckRuntime("/tmp/java", JavaJar))
26 | }
27 |
--------------------------------------------------------------------------------
/builder/parser/discovery/etcd_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package discovery
20 |
--------------------------------------------------------------------------------
/builder/sources/file_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package sources
20 |
21 | import (
22 | "testing"
23 |
24 | "github.com/goodrain/rainbond/event"
25 | )
26 |
27 | func TestCopyFileWithProgress(t *testing.T) {
28 | logger := event.GetTestLogger()
29 | if err := CopyFileWithProgress("/tmp/src.tgz", "/tmp/abc/desc1.tgz", logger); err != nil {
30 | t.Fatal(err)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/builder/sources/registry/basictransport.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package registry
20 |
21 | import (
22 | "net/http"
23 | "strings"
24 | )
25 |
26 | type BasicTransport struct {
27 | Transport http.RoundTripper
28 | URL string
29 | Username string
30 | Password string
31 | }
32 |
33 | func (t *BasicTransport) RoundTrip(req *http.Request) (*http.Response, error) {
34 | if strings.HasPrefix(req.URL.String(), t.URL) {
35 | if t.Username != "" || t.Password != "" {
36 | req.SetBasicAuth(t.Username, t.Password)
37 | }
38 | }
39 | resp, err := t.Transport.RoundTrip(req)
40 | return resp, err
41 | }
42 |
--------------------------------------------------------------------------------
/builder/sources/registry/errors.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package registry
20 |
21 | import "github.com/pkg/errors"
22 |
23 | // registry error
24 | var (
25 | ErrRegistryNotFound = errors.New("registry not found")
26 |
27 | // ErrRepositoryNotFound means the repository can not be found.
28 | ErrRepositoryNotFound = errors.New("repository not found")
29 |
30 | ErrManifestNotFound = errors.New("manifest not found")
31 |
32 | ErrOperationIsUnsupported = errors.New("The operation is unsupported")
33 | )
34 |
--------------------------------------------------------------------------------
/builder/sources/registry_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2019 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package sources
20 |
21 | import "testing"
22 |
23 | func TestPublicImageExist(t *testing.T) {
24 | exist, err := ImageExist("barnett/nextcloud-runtime:0.2", "", "")
25 | if err != nil {
26 | t.Fail()
27 | }
28 | if exist {
29 | t.Log("image exist")
30 | }
31 | }
32 |
33 | func TestPrivateImageExist(t *testing.T) {
34 | exist, err := ImageExist("harbor.smartqi.cn:80/library/nginx:1.11", "admin", "Harbor12345")
35 | if err != nil {
36 | t.Fatal(err)
37 | }
38 | if exist {
39 | t.Log("image exist")
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/builder/sources/repo_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package sources
20 |
21 | import (
22 | "fmt"
23 | "testing"
24 | )
25 |
26 | func TestCreateRepostoryBuildInfo(t *testing.T) {
27 | info, err := CreateRepostoryBuildInfo("ssh://git@gr5042d6.7804f67d.ali-sh-s1.goodrain.net:20905/root/private2018.git?dir=abc", "master", "ADSASDADAD", "", "")
28 | if err != nil {
29 | t.Fatal(err)
30 | }
31 | fmt.Printf("%+v \n", info)
32 | }
33 |
--------------------------------------------------------------------------------
/check.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
3 |
4 | URL="https://api.github.com/repos/goodrain/rainbond/pulls/${pull_number}/files"
5 |
6 | # 请求 GitHub api 接口,解析变更的文件
7 | # 这里用 jq 过滤了部分文件
8 | CHANGED_MARKDOWN_FILES=$(curl -s -X GET -G $URL | jq -r '.[] | select(.status != "removed") | select(.filename | endswith(".go")) | .filename')
9 | for file in ${CHANGED_MARKDOWN_FILES}; do
10 | echo "golint ${file}"
11 | golint -set_exit_status=true ${file} || exit 1
12 | done
13 |
14 | echo "code golint check success"
--------------------------------------------------------------------------------
/cmd/api/option/option.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/cmd/api/option/option.go
--------------------------------------------------------------------------------
/cmd/builder/option/option.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/cmd/builder/option/option.go
--------------------------------------------------------------------------------
/cmd/grctl/grctl.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package main
20 |
21 | import (
22 | "fmt"
23 | "os"
24 |
25 | "github.com/goodrain/rainbond/cmd"
26 | "github.com/goodrain/rainbond/cmd/grctl/server"
27 | )
28 |
29 | func main() {
30 | if len(os.Args) > 1 && os.Args[1] == "version" {
31 | cmd.ShowVersion("grctl")
32 | }
33 | if err := server.Run(); err != nil {
34 | fmt.Fprintf(os.Stderr, "error: %v\n", err)
35 | os.Exit(1)
36 | }
37 | os.Exit(0)
38 | }
39 |
--------------------------------------------------------------------------------
/cmd/version.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package cmd
20 |
21 | import (
22 | "fmt"
23 | "os"
24 | )
25 |
26 | var version string
27 |
28 | // ShowVersion 显示版本
29 | func ShowVersion(module string) {
30 | if version != "" {
31 | fmt.Printf("Rainbond %s %s\n", module, version)
32 | } else {
33 | fmt.Printf("Rainbond %s %s\n", module, os.Getenv("RELEASE_DESC"))
34 | }
35 | os.Exit(0)
36 | }
37 |
38 | // GetVersion GetVersion
39 | func GetVersion() string {
40 | return version
41 | }
42 |
--------------------------------------------------------------------------------
/cmd/worker/option/option.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/cmd/worker/option/option.go
--------------------------------------------------------------------------------
/config/configs/db_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type DBConfig struct {
6 | DBType string `json:"db_type"`
7 | DBConnectionInfo string `json:"db_connection_info"`
8 | ShowSQL bool `json:"show_sql"`
9 | }
10 |
11 | func AddDBFlags(fs *pflag.FlagSet, dc *DBConfig) {
12 | fs.StringVar(&dc.DBType, "db-type", "mysql", "db type mysql or etcd")
13 | fs.StringVar(&dc.DBConnectionInfo, "mysql", "admin:admin@tcp(127.0.0.1:3306)/region", "mysql db connection info")
14 | fs.BoolVar(&dc.ShowSQL, "show-sql", false, "The trigger for showing sql.")
15 | }
16 |
--------------------------------------------------------------------------------
/config/configs/es_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type ESConfig struct {
6 | ElasticSearchURL string `json:"elastic_search_url"`
7 | ElasticSearchUsername string `json:"elastic_search_username"`
8 | ElasticSearchPassword string `json:"elastic_search_password"`
9 | ElasticEnable bool `json:"elastic_enable"`
10 | }
11 |
12 | func AddESFlags(fs *pflag.FlagSet, esc *ESConfig) {
13 | fs.StringVar(&esc.ElasticSearchURL, "es-url", "http://47.92.106.114:9200", "es url")
14 | fs.StringVar(&esc.ElasticSearchUsername, "es-username", "", "es username")
15 | fs.StringVar(&esc.ElasticSearchPassword, "es-password", "", "es pwd")
16 | fs.BoolVar(&esc.ElasticEnable, "es-enable", false, "enable es")
17 | }
18 |
--------------------------------------------------------------------------------
/config/configs/k8s_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type K8SConfig struct {
6 | KubeConfigPath string
7 | KubeAPIQPS int
8 | KubeAPIBurst int
9 | }
10 |
11 | func AddK8SFlags(fs *pflag.FlagSet, k8sc *K8SConfig) {
12 | fs.StringVar(&k8sc.KubeConfigPath, "kube-config", "", "kube config file path, No setup is required to run in a cluster.")
13 | fs.IntVar(&k8sc.KubeAPIQPS, "kube-api-qps", 50, "kube client qps")
14 | fs.IntVar(&k8sc.KubeAPIBurst, "kube-api-burst", 10, "kube clint burst")
15 | }
16 |
--------------------------------------------------------------------------------
/config/configs/log_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type LogConfig struct {
6 | LogLevel string `json:"log_level"`
7 | LogPath string `json:"log_path"`
8 | LoggerFile string `json:"logger_file"`
9 | LogOutType string `json:"log_out_type"`
10 | }
11 |
12 | func AddLogFlags(fs *pflag.FlagSet, lc *LogConfig) {
13 | fs.StringVar(&lc.LogLevel, "log-level", "info", "the api log level")
14 | fs.StringVar(&lc.LogPath, "log-path", "/grdata/logs", "Where Docker log files and event log files are stored.")
15 | fs.StringVar(&lc.LoggerFile, "logger-file", "/logs/request.log", "request log file path")
16 | fs.StringVar(&lc.LogOutType, "log.type", "stdout", "app log output type. stdout or file ")
17 | }
18 |
--------------------------------------------------------------------------------
/config/configs/prometheus_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type PrometheusConfig struct {
6 | PrometheusMetricPath string
7 | }
8 |
9 | func AddPrometheusFlags(fs *pflag.FlagSet, pc *PrometheusConfig) {
10 | fs.StringVar(&pc.PrometheusMetricPath, "metric", "/metrics", "prometheus metrics path")
11 | }
12 |
--------------------------------------------------------------------------------
/config/configs/public_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import (
4 | "github.com/goodrain/rainbond-operator/util/constants"
5 | utils "github.com/goodrain/rainbond/util"
6 | "github.com/spf13/pflag"
7 | )
8 |
9 | type PublicConfig struct {
10 | RbdNamespace string
11 | GrdataPVCName string
12 | HostIP string
13 | }
14 |
15 | func AddPublicFlags(fs *pflag.FlagSet, pc *PublicConfig) {
16 | fs.StringVar(&pc.RbdNamespace, "rbd-namespace", utils.GetenvDefault("RBD_NAMESPACE", constants.Namespace), "rbd component namespace")
17 | fs.StringVar(&pc.GrdataPVCName, "grdata-pvc-name", "rbd-cpt-grdata", "The name of grdata persistent volume claim")
18 | fs.StringVar(&pc.HostIP, "hostIP", "", "Current node Intranet IP")
19 | }
20 |
--------------------------------------------------------------------------------
/config/configs/rbdcomponent/mq_config.go:
--------------------------------------------------------------------------------
1 | package rbdcomponent
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type MQConfig struct {
6 | KeyPrefix string
7 | RunMode string //http grpc
8 | HostName string
9 | APIPort int
10 | }
11 |
12 | func AddMQFlags(fs *pflag.FlagSet, mqc *MQConfig) {
13 | fs.StringVar(&mqc.KeyPrefix, "key-prefix", "/mq", "key prefix ")
14 | fs.StringVar(&mqc.RunMode, "mode", "grpc", "the api server run mode grpc or http")
15 | fs.StringVar(&mqc.HostName, "hostName", "", "Current node host name")
16 | fs.IntVar(&mqc.APIPort, "api-port", 6300, "the api server listen port")
17 | }
18 |
--------------------------------------------------------------------------------
/config/configs/server_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type ServerConfig struct {
6 | RbdWorker string
7 | EventLogServers []string
8 | PrometheusEndpoint string
9 | RbdHub string
10 | MQAPI string
11 | }
12 |
13 | func AddServerFlags(fs *pflag.FlagSet, sc *ServerConfig) {
14 | fs.StringSliceVar(&sc.EventLogServers, "event-servers", []string{"rbd-api-api-inner:6366"}, "event log server address")
15 | fs.StringVar(&sc.RbdWorker, "worker-api", "rbd-worker:6535", "the rbd-worker server api")
16 | fs.StringVar(&sc.PrometheusEndpoint, "prom-api", "rbd-monitor:9999", "The service DNS name of Prometheus api. Default to rbd-monitor:9999")
17 | fs.StringVar(&sc.RbdHub, "hub-api", "http://rbd-hub:5000", "the rbd-hub server api")
18 | fs.StringVar(&sc.MQAPI, "mq-api", "rbd-mq:6300", "the rbd-mq server api")
19 | }
20 |
--------------------------------------------------------------------------------
/config/configs/storage_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type StorageConfig struct {
6 | StorageType string `json:"storage_type"`
7 | S3Endpoint string `json:"s3_endpoint"`
8 | S3AccessKeyID string `json:"s3_access_key_id"`
9 | S3SecretAccessKey string `json:"s3_secret_access_key"`
10 | }
11 |
12 | func AddStorageFlags(fs *pflag.FlagSet, sc *StorageConfig) {
13 | fs.StringVar(&sc.StorageType, "storage-type", "s3", "s3 or local")
14 | fs.StringVar(&sc.S3Endpoint, "s3-endpoint", "http://minio-service:9000", "s3 endpoint")
15 | fs.StringVar(&sc.S3AccessKeyID, "s3-access-key-id", "admin", "s3 accessKeyID")
16 | fs.StringVar(&sc.S3SecretAccessKey, "s3-secret-access-key", "admin1234", "s3 secretAccessKey")
17 | }
18 |
--------------------------------------------------------------------------------
/config/configs/websocket_config.go:
--------------------------------------------------------------------------------
1 | package configs
2 |
3 | import "github.com/spf13/pflag"
4 |
5 | type WebSocketConfig struct {
6 | WebsocketSSL bool
7 | WebsocketCertFile string
8 | WebsocketKeyFile string
9 | WebsocketAddr string
10 | }
11 |
12 | func AddWebSocketFlags(fs *pflag.FlagSet, wsc *WebSocketConfig) {
13 | fs.BoolVar(&wsc.WebsocketSSL, "ws-ssl-enable", false, "whether to enable websocket SSL")
14 | fs.StringVar(&wsc.WebsocketCertFile, "ws-ssl-certfile", "/etc/ssl/goodrain.com/goodrain.com.crt", "websocket and fileserver ssl cert file")
15 | fs.StringVar(&wsc.WebsocketKeyFile, "ws-ssl-keyfile", "/etc/ssl/goodrain.com/goodrain.com.key", "websocket and fileserver ssl key file")
16 | fs.StringVar(&wsc.WebsocketAddr, "ws-addr", "0.0.0.0:6060", "the websocket server listen address")
17 | }
18 |
--------------------------------------------------------------------------------
/db/config/config.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package config
20 |
21 | // Config db config
22 | type Config struct {
23 | MysqlConnectionInfo string
24 | DBType string
25 | ShowSQL bool
26 | }
27 |
--------------------------------------------------------------------------------
/db/errors/errors.go:
--------------------------------------------------------------------------------
1 | package errors
2 |
3 | import (
4 | "errors"
5 | )
6 |
7 | var (
8 | // ErrRecordAlreadyExist record already exist error, happens when find any matched data when creating with a struct
9 | ErrRecordAlreadyExist = errors.New("record already exist")
10 | )
11 |
--------------------------------------------------------------------------------
/db/mock.sh:
--------------------------------------------------------------------------------
1 | mockgen -source=db.go -destination db_mock.go -package db
--------------------------------------------------------------------------------
/db/model/eventlog.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package model
20 |
21 | //EventLogMessage event log message struct
22 | type EventLogMessage struct {
23 | Model
24 | EventID string `gorm:"column:event_id;size:40"`
25 | StartTime string `gorm:"column:start_time;size:40"`
26 | Message []byte `gorm:"column:message"`
27 | }
28 |
29 | //TableName 表名
30 | func (t *EventLogMessage) TableName() string {
31 | return "event_log_message"
32 | }
33 |
--------------------------------------------------------------------------------
/db/model/key_value.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | // KeyValue -
4 | type KeyValue struct {
5 | K string `gorm:"column:k;type:varchar(100);primary_key" json:"k"`
6 | V string `gorm:"column:v;type:longtext" json:"v"`
7 | }
8 |
9 | // TableName -
10 | func (KeyValue) TableName() string {
11 | return "key_value"
12 | }
13 |
--------------------------------------------------------------------------------
/db/model/license.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package model
20 |
21 | //LicenseInfo 信息
22 | type LicenseInfo struct {
23 | //Model
24 | IDModel
25 | Token string `gorm:"column:token;size:40;" json:"token"`
26 | License string `gorm:"column:license;" json:"license"`
27 | Label string `gorm:"column:label" json:"label"`
28 | }
29 |
30 | //TableName 返回license表名称
31 | func (l *LicenseInfo) TableName() string {
32 | return "rainbond_license"
33 | }
34 |
--------------------------------------------------------------------------------
/db/model/monitor.go:
--------------------------------------------------------------------------------
1 | package model
2 |
3 | //TenantServiceMonitor custom service monitor
4 | type TenantServiceMonitor struct {
5 | Model
6 | TenantID string `gorm:"column:tenant_id;size:40;unique_index:unique_tenant_id_name" json:"tenant_id"`
7 | ServiceID string `gorm:"column:service_id;size:40" json:"service_id"`
8 | Name string `gorm:"column:name;size:40;unique_index:unique_tenant_id_name" json:"name"`
9 | ServiceShowName string `gorm:"column:service_show_name" json:"service_show_name"`
10 | Port int `gorm:"column:port;size:5" json:"port"`
11 | Path string `gorm:"column:path;size:255" json:"path"`
12 | Interval string `gorm:"column:interval;size:20" json:"interval"`
13 | }
14 |
15 | // TableName returns table name of TenantServiceMonitor
16 | func (TenantServiceMonitor) TableName() string {
17 | return "tenant_services_monitor"
18 | }
19 |
--------------------------------------------------------------------------------
/db/mysql/dao/enterprise.go:
--------------------------------------------------------------------------------
1 | package dao
2 |
3 | import (
4 | "github.com/goodrain/rainbond/db/model"
5 | "github.com/jinzhu/gorm"
6 | )
7 |
8 | //EnterpriseDaoImpl 租户信息管理
9 | type EnterpriseDaoImpl struct {
10 | DB *gorm.DB
11 | }
12 |
13 | // GetEnterpriseTenants -
14 | func (e *EnterpriseDaoImpl) GetEnterpriseTenants(enterpriseID string) ([]*model.Tenants, error) {
15 | var tenants []*model.Tenants
16 | if enterpriseID == "" {
17 | return []*model.Tenants{}, nil
18 | }
19 | if err := e.DB.Where("eid= ?", enterpriseID).Find(&tenants).Error; err != nil {
20 | return nil, err
21 | }
22 | return tenants, nil
23 | }
24 |
--------------------------------------------------------------------------------
/db/mysql/dao/key_value.go:
--------------------------------------------------------------------------------
1 | package dao
2 |
3 | import (
4 | dbmodel "github.com/goodrain/rainbond/db/model"
5 | "github.com/jinzhu/gorm"
6 | )
7 |
8 | // KeyValueImpl -
9 | type KeyValueImpl struct {
10 | DB *gorm.DB
11 | }
12 |
13 | // DeleteWithPrefix -
14 | func (k KeyValueImpl) DeleteWithPrefix(prefix string) error {
15 | return k.DB.Where("k LIKE ?", prefix+"%").Delete(dbmodel.KeyValue{}).Error
16 | }
17 |
18 | // WithPrefix -
19 | func (k KeyValueImpl) WithPrefix(prefix string) ([]dbmodel.KeyValue, error) {
20 | var keyValues = make([]dbmodel.KeyValue, 0)
21 |
22 | if err := k.DB.Where("k LIKE ?", prefix+"%").Find(&keyValues).Error; err != nil {
23 | return nil, err
24 | }
25 |
26 | return keyValues, nil
27 | }
28 |
29 | // Put -
30 | func (k KeyValueImpl) Put(key, value string) error {
31 | keyValue := dbmodel.KeyValue{K: key, V: value}
32 |
33 | if err := k.DB.Create(&keyValue).Error; err != nil {
34 | return err
35 | }
36 |
37 | return nil
38 | }
39 |
40 | // Get -
41 | func (k KeyValueImpl) Get(key string) (*dbmodel.KeyValue, error) {
42 | var keyValue dbmodel.KeyValue
43 | if err := k.DB.Where("k = ?", key).First(&keyValue).Error; err != nil {
44 | if gorm.IsRecordNotFoundError(err) {
45 | return nil, nil
46 | }
47 | return nil, err
48 | }
49 |
50 | return &keyValue, nil
51 | }
52 |
53 | // Delete -
54 | func (k KeyValueImpl) Delete(key string) error {
55 | return k.DB.Where("k = ?", key).Delete(dbmodel.KeyValue{}).Error
56 | }
57 |
--------------------------------------------------------------------------------
/db/mysql/dao/service.go:
--------------------------------------------------------------------------------
1 | package dao
2 |
3 | import "github.com/goodrain/rainbond/db/model"
4 |
5 | func (t *TenantServicesDaoImpl) ListByAppID(appID string) ([]*model.TenantServices, error) {
6 | var services []*model.TenantServices
7 | if err := t.DB.Where("app_id=?", appID).Find(&services).Error; err != nil {
8 | return nil, err
9 | }
10 | return services, nil
11 | }
12 |
13 | func (t *TenantServicesDaoImpl) ListByAppIDs(appID []string) ([]*model.TenantServices, error) {
14 | var services []*model.TenantServices
15 | if err := t.DB.Where("app_id in (?)", appID).Find(&services).Error; err != nil {
16 | return nil, err
17 | }
18 | return services, nil
19 | }
20 |
21 | func (t *TenantServicesDaoImpl) ListComponentIDsByAppID(appID string) ([]string, error) {
22 | var componentIDs []string
23 | if err := t.DB.Model(&model.TenantServices{}).Where("app_id=?", appID).Pluck("service_id", &componentIDs).Error; err != nil {
24 | return nil, err
25 | }
26 | return componentIDs, nil
27 | }
28 |
--------------------------------------------------------------------------------
/docs/arch.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/arch.jpeg
--------------------------------------------------------------------------------
/docs/arch_en.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/arch_en.png
--------------------------------------------------------------------------------
/docs/bell-outline-badge.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/rainbond_architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/rainbond_architecture.png
--------------------------------------------------------------------------------
/docs/rainbond_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/rainbond_logo.png
--------------------------------------------------------------------------------
/docs/topology.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/topology.gif
--------------------------------------------------------------------------------
/docs/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/wechat.png
--------------------------------------------------------------------------------
/docs/wechatgroup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/docs/wechatgroup.png
--------------------------------------------------------------------------------
/event/log_optoins.go:
--------------------------------------------------------------------------------
1 | package event
2 |
3 | // GetLoggerOption -
4 | func GetLoggerOption(status string) map[string]string {
5 | return map[string]string{"step": "appruntime", "status": status}
6 | }
7 |
8 | //GetCallbackLoggerOption get callback logger
9 | func GetCallbackLoggerOption() map[string]string {
10 | return map[string]string{"step": "callback", "status": "failure"}
11 | }
12 |
13 | //GetTimeoutLoggerOption get callback logger
14 | func GetTimeoutLoggerOption() map[string]string {
15 | return map[string]string{"step": "callback", "status": "timeout"}
16 | }
17 |
18 | //GetLastLoggerOption get last logger
19 | func GetLastLoggerOption() map[string]string {
20 | return map[string]string{"step": "last", "status": "success"}
21 | }
22 |
--------------------------------------------------------------------------------
/hack/contrib/docker/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/README.md
--------------------------------------------------------------------------------
/hack/contrib/docker/api/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rainbond/golang:1.23-alpine as compile
2 | ARG TARGETARCH
3 | ARG RELEASE_DESC
4 | ARG GOPROXY
5 |
6 | ENV CGO_ENABLED=1
7 | ENV GOARCH=${TARGETARCH}
8 | ENV GOPROXY=${GOPROXY}
9 | ENV GOOS=linux
10 |
11 | COPY . /go/src/github.com/goodrain/rainbond
12 | WORKDIR /go/src/github.com/goodrain/rainbond
13 | RUN apk --no-cache add binutils-gold && go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=$RELEASE_DESC" -o /run/rainbond-api ./cmd/api;
14 |
15 | FROM ubuntu:24.04 as compress
16 | COPY --from=compile /run/rainbond-api /run/rainbond-api
17 |
18 | RUN apt-get update && apt -y install upx && \
19 | upx --best --lzma /run/rainbond-api
20 | RUN mkdir -p /logs && touch /logs/request.log
21 |
22 | FROM rainbond/alpine:3
23 | ARG RELEASE_DESC
24 |
25 | ENV RELEASE_DESC=${RELEASE_DESC}
26 | RUN apk add --no-cache libzmq
27 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/api/entrypoint.sh /run/entrypoint.sh
28 | COPY --from=compress /run/rainbond-api /run/rainbond-api
29 | COPY --from=compress /logs/request.log /logs/request.log
30 |
31 | WORKDIR /run
32 |
33 | ENTRYPOINT ["/run/entrypoint.sh"]
34 |
--------------------------------------------------------------------------------
/hack/contrib/docker/api/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-api version
6 | else
7 | exec /sbin/tini -- /run/rainbond-api --start=true "$@"
8 | fi
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.23-alpine
2 | ARG TARGETARCH
3 |
4 | COPY libzmq /opt/libzmq
5 | ENV PKG_CONFIG_PATH=/opt/libzmq/lib/pkgconfig/
6 |
7 | RUN if [ "$TARGETARCH" = "amd64" ]; then \
8 | apk --no-cache add gcc libc-dev tzdata ca-certificates libc6-compat libgcc libstdc++ g++ binutils-gold pkgconfig gcc musl-dev; \
9 | cp /opt/libzmq/include/* /usr/include/ && cp -r /opt/libzmq/share/* /usr/share/ && cp -r /opt/libzmq/lib/* /usr/lib/; \
10 | elif [ "$TARGETARCH" = "arm64" ]; then \
11 | apk --no-cache add gcc libc-dev tzdata ca-certificates libc6-compat libgcc libstdc++ g++ zeromq-dev gcc libc-dev; \
12 | fi
13 |
14 | WORKDIR /go
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/bin/curve_keygen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/buildstack/libzmq/bin/curve_keygen
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/libzmq.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/buildstack/libzmq/lib/libzmq.a
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/libzmq.la:
--------------------------------------------------------------------------------
1 | # libzmq.la - a libtool library file
2 | # Generated by libtool (GNU libtool) 2.4.6
3 | #
4 | # Please DO NOT delete this file!
5 | # It is necessary for linking the library.
6 |
7 | # The name that we can dlopen(3).
8 | dlname='libzmq.so.3'
9 |
10 | # Names of this library.
11 | library_names='libzmq.so.3.1.0 libzmq.so.3 libzmq.so'
12 |
13 | # The name of the static archive.
14 | old_library='libzmq.a'
15 |
16 | # Linker flags that cannot go in dependency_libs.
17 | inherited_linker_flags=''
18 |
19 | # Libraries that this one depends upon.
20 | dependency_libs=' -lrt -lpthread'
21 |
22 | # Names of additional weak libraries provided by this library
23 | weak_library_names=''
24 |
25 | # Version information for libzmq.
26 | current=4
27 | age=1
28 | revision=0
29 |
30 | # Is this an already installed library?
31 | installed=yes
32 |
33 | # Should we warn about portability when linking against -modules?
34 | shouldnotlink=no
35 |
36 | # Files to dlopen/dlpreopen
37 | dlopen=''
38 | dlpreopen=''
39 |
40 | # Directory that this library needs to be installed in:
41 | libdir='/usr/local/libzmq/lib'
42 |
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so.3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so.3
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so.3.1.0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/buildstack/libzmq/lib/libzmq.so.3.1.0
--------------------------------------------------------------------------------
/hack/contrib/docker/buildstack/libzmq/lib/pkgconfig/libzmq.pc:
--------------------------------------------------------------------------------
1 | prefix=/usr/local/libzmq
2 | exec_prefix=${prefix}
3 | libdir=${exec_prefix}/lib
4 | includedir=${prefix}/include
5 |
6 | Name: libzmq
7 | Description: 0MQ c++ library
8 | Version: 4.0.4
9 | Libs: -L${libdir} -lzmq
10 | Cflags: -I${includedir}
11 |
--------------------------------------------------------------------------------
/hack/contrib/docker/chaos/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rainbond/golang:1.23-alpine as compile
2 | ARG TARGETARCH
3 | ARG RELEASE_DESC
4 | ARG GOPROXY
5 |
6 | ENV CGO_ENABLED=1
7 | ENV GOARCH=${TARGETARCH}
8 | ENV GOPROXY=${GOPROXY}
9 | ENV GOOS=linux
10 |
11 | COPY . /go/src/github.com/goodrain/rainbond
12 | WORKDIR /go/src/github.com/goodrain/rainbond
13 | RUN apk --no-cache add binutils-gold && go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=$RELEASE_DESC" -o /run/rainbond-chaos ./cmd/builder;
14 |
15 | FROM ubuntu:24.04 as compress
16 | COPY --from=compile /run/rainbond-chaos /run/rainbond-chaos
17 |
18 | RUN apt-get update && apt -y install upx && \
19 | upx --best --lzma /run/rainbond-chaos
20 |
21 | FROM rainbond/alpine:3
22 | ARG RELEASE_DESC
23 |
24 | RUN apk add --no-cache openssl openssh-client subversion libzmq
25 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/chaos/entrypoint.sh /run/entrypoint.sh
26 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/chaos/export-app /src/export-app
27 | COPY --from=compress /run/rainbond-chaos /run/rainbond-chaos
28 |
29 | WORKDIR /run
30 |
31 | ENV RELEASE_DESC=${RELEASE_DESC}
32 |
33 | ENTRYPOINT ["/run/entrypoint.sh"]
34 |
--------------------------------------------------------------------------------
/hack/contrib/docker/chaos/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-chaos version
6 | else
7 | exec /sbin/tini -- /run/rainbond-chaos "$@"
8 | fi
--------------------------------------------------------------------------------
/hack/contrib/docker/grctl/Dockerfile:
--------------------------------------------------------------------------------
1 | ARG BASE_IMAGE_VERSION
2 | FROM goodrainapps/alpine:${BASE_IMAGE_VERSION}
3 | ARG RELEASE_DESC
4 | COPY ./libzmq.so.3 /usr/lib
5 | COPY . /run
6 | RUN chmod +x /run/rainbond-grctl /run/entrypoint.sh
7 | VOLUME [ "/rootfs/root","/rootfs/path","/ssl" ]
8 | ENV RELEASE_DESC=${RELEASE_DESC}
9 | ENTRYPOINT ["/run/entrypoint.sh"]
--------------------------------------------------------------------------------
/hack/contrib/docker/grctl/README.md:
--------------------------------------------------------------------------------
1 | ## Install
2 |
3 | ### necessary condition
4 | `~/.kube/config` exist
5 |
6 | ### install shell
7 | ```bash
8 | docker run -it --rm -v /:/rootfs goodrain.me/rbd-grctl:V5.2-dev copy
9 | grctl install
10 | ```
--------------------------------------------------------------------------------
/hack/contrib/docker/grctl/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-grctl version
6 | elif [ "$1" = "copy" ];then
7 | cp -a /run/rainbond-grctl /rootfs/usr/local/bin/
8 | else
9 | exec /run/rainbond-grctl "$@"
10 | fi
--------------------------------------------------------------------------------
/hack/contrib/docker/grctl/grctl.yaml:
--------------------------------------------------------------------------------
1 | region_api:
2 | endpoints:
3 | - https://region.goodrain.me:8443
4 | client-ca-file: /opt/rainbond/etc/rbd-api/region.goodrain.me/ssl/ca.pem
5 | tls-cert-file: /opt/rainbond/etc/rbd-api/region.goodrain.me/ssl/client.pem
6 | tls-private-key-file: /opt/rainbond/etc/rbd-api/region.goodrain.me/ssl/client.key.pem
--------------------------------------------------------------------------------
/hack/contrib/docker/grctl/libzmq.so.3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/grctl/libzmq.so.3
--------------------------------------------------------------------------------
/hack/contrib/docker/init-probe/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rainbond/golang:1.23-alpine as compile
2 | ARG TARGETARCH
3 | ARG RELEASE_DESC
4 | ARG GOPROXY
5 |
6 | ENV CGO_ENABLED=1
7 | ENV GOARCH=${TARGETARCH}
8 | ENV GOPROXY=${GOPROXY}
9 | ENV GOOS=linux
10 |
11 | COPY . /go/src/github.com/goodrain/rainbond
12 | WORKDIR /go/src/github.com/goodrain/rainbond
13 | RUN go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=$RELEASE_DESC" -o /run/rainbond-init-probe ./cmd/init-probe;
14 |
15 | FROM ubuntu:24.04 as compress
16 | COPY --from=compile /run/rainbond-init-probe /run/rainbond-init-probe
17 |
18 | RUN apt-get update && apt -y install upx && \
19 | upx --best --lzma /run/rainbond-init-probe
20 |
21 | FROM rainbond/alpine:3
22 | ARG RELEASE_DESC
23 |
24 | ENV RELEASE_DESC=${RELEASE_DESC}
25 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/init-probe/entrypoint.sh /run/entrypoint.sh
26 | COPY --from=compress /run/rainbond-init-probe /run/rainbond-init-probe
27 |
28 | WORKDIR /run
29 |
30 | ENTRYPOINT ["/run/entrypoint.sh"]
31 | CMD ["decoupling_probe"]
32 |
33 |
--------------------------------------------------------------------------------
/hack/contrib/docker/init-probe/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-init-probe version
6 | else
7 | exec /sbin/tini -- /run/rainbond-init-probe "$@"
8 | fi
--------------------------------------------------------------------------------
/hack/contrib/docker/mq/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rainbond/golang:1.23-alpine as compile
2 | ARG TARGETARCH
3 | ARG RELEASE_DESC
4 | ARG GOPROXY
5 |
6 | ENV CGO_ENABLED=1
7 | ENV GOARCH=${TARGETARCH}
8 | ENV GOPROXY=${GOPROXY}
9 | ENV GOOS=linux
10 |
11 | COPY . /go/src/github.com/goodrain/rainbond
12 | WORKDIR /go/src/github.com/goodrain/rainbond
13 | RUN apk --no-cache add binutils-gold && \
14 | go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=$RELEASE_DESC" -o /run/rainbond-mq ./cmd/mq;
15 |
16 | FROM ubuntu:24.04 as compress
17 | COPY --from=compile /run/rainbond-mq /run/rainbond-mq
18 |
19 | RUN apt-get update && apt -y install upx && \
20 | upx --best --lzma /run/rainbond-mq
21 |
22 | FROM rainbond/alpine:3
23 | ARG RELEASE_DESC
24 |
25 | ENV RELEASE_DESC=${RELEASE_DESC}
26 | RUN apk add --no-cache libzmq
27 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/mq/entrypoint.sh /run/entrypoint.sh
28 | COPY --from=compress /run/rainbond-mq /run/rainbond-mq
29 |
30 | WORKDIR /run
31 |
32 | ENTRYPOINT ["/run/entrypoint.sh"]
--------------------------------------------------------------------------------
/hack/contrib/docker/mq/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-mq version
6 | else
7 | exec /sbin/tini -- /run/rainbond-mq "$@"
8 | fi
--------------------------------------------------------------------------------
/hack/contrib/docker/rbd-shell/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3 as binary
2 | ARG TARGETARCH
3 |
4 | RUN apk add --no-cache curl
5 |
6 | RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" \
7 | && chmod +x kubectl \
8 | && curl -L "https://get.helm.sh/helm-v3.17.2-linux-${TARGETARCH}.tar.gz" | tar -xzvf - \
9 | && mv linux-${TARGETARCH} linux
10 |
11 | FROM alpine:3
12 |
13 | COPY --from=binary /kubectl /bin/kubectl
14 | COPY --from=binary /linux/helm /bin/helm
15 |
16 | ENTRYPOINT [ "sleep", "infinity" ]
17 |
--------------------------------------------------------------------------------
/hack/contrib/docker/run-image/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM alpine:3
2 |
3 | COPY ./libzmq.so.3 /usr/lib
4 | RUN apk add --no-cache tzdata libstdc++ libc6-compat tar sed wget curl bash su-exec netcat-openbsd tini && \
5 | sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd && \
6 | ln -s /lib /lib64 && \
7 | cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
8 | echo "Asia/Shanghai" > /etc/timezone && \
9 | date && apk del --no-cache tzdata
10 |
11 | ENV LANG en_US.utf8
--------------------------------------------------------------------------------
/hack/contrib/docker/run-image/libzmq.so.3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/hack/contrib/docker/run-image/libzmq.so.3
--------------------------------------------------------------------------------
/hack/contrib/docker/worker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM rainbond/golang:1.23-alpine as compile
2 | ARG TARGETARCH
3 | ARG RELEASE_DESC
4 | ARG GOPROXY
5 |
6 | ENV CGO_ENABLED=1
7 | ENV GOARCH=${TARGETARCH}
8 | ENV GOPROXY=${GOPROXY}
9 | ENV GOOS=linux
10 |
11 | COPY . /go/src/github.com/goodrain/rainbond
12 | WORKDIR /go/src/github.com/goodrain/rainbond
13 |
14 | RUN apk --no-cache add binutils-gold && go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=$RELEASE_DESC" -o /run/rainbond-worker ./cmd/worker;
15 |
16 | FROM ubuntu:24.04 as compress
17 | COPY --from=compile /run/rainbond-worker /run/rainbond-worker
18 |
19 | RUN apt-get update && apt -y install upx && \
20 | upx --best --lzma /run/rainbond-worker
21 |
22 | FROM rainbond/alpine:3
23 | ARG RELEASE_DESC
24 |
25 | ENV RELEASE_DESC=${RELEASE_DESC}
26 | RUN apk add --no-cache libzmq
27 | COPY --from=compile /go/src/github.com/goodrain/rainbond/hack/contrib/docker/worker/entrypoint.sh /run/entrypoint.sh
28 | COPY --from=compress /run/rainbond-worker /run/rainbond-worker
29 |
30 | WORKDIR /run
31 |
32 | ENTRYPOINT ["/run/entrypoint.sh"]
--------------------------------------------------------------------------------
/hack/contrib/docker/worker/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$1" = "bash" ];then
3 | exec /bin/bash
4 | elif [ "$1" = "version" ];then
5 | /run/rainbond-worker version
6 | else
7 | exec /sbin/tini -- /run/rainbond-worker "$@"
8 | fi
--------------------------------------------------------------------------------
/hack/k8s/codegen/README.md:
--------------------------------------------------------------------------------
1 | ## How to use codegen
2 |
3 | ```sh
4 | ./hack/k8s/codegen/update-generated.sh
5 | ```
6 |
7 | It should print:
8 |
9 | ```
10 | Generating deepcopy funcs
11 | Generating clientset for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/clientset
12 | Generating listers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/listers
13 | Generating informers for etcd:v1beta2 at github.com/coreos/etcd-operator/pkg/generated/informers
14 | ```
15 |
--------------------------------------------------------------------------------
/hack/k8s/codegen/boilerplate.go.txt:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
--------------------------------------------------------------------------------
/hack/k8s/codegen/tools.go:
--------------------------------------------------------------------------------
1 | // +build tools
2 | package tools
3 |
4 | import _ "k8s.io/code-generator"
5 |
--------------------------------------------------------------------------------
/hack/k8s/codegen/update-generated.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -o errexit
4 | set -o nounset
5 | set -o pipefail
6 |
7 | vendor/k8s.io/code-generator/generate-groups.sh \
8 | "defaulter,client,lister,informer" \
9 | "github.com/goodrain/rainbond/pkg/generated" \
10 | "github.com/goodrain/rainbond/pkg/apis" \
11 | "rainbond:v1alpha1" \
12 | --go-header-file "./hack/k8s/codegen/boilerplate.go.txt" \
13 | $@
14 |
--------------------------------------------------------------------------------
/hack/k8s/codegen/verify-generated.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -o errexit
4 | set -o nounset
5 | set -o pipefail
6 |
7 |
8 | if ! output=$(./hack/k8s/codegen/update-generated.sh --verify-only 2>&1); then
9 | echo "FAILURE: verification of codegen failed:"
10 | echo "${output}"
11 | exit 1
12 | fi
13 |
14 | echo "Verified generated code ==="
15 |
--------------------------------------------------------------------------------
/localcheck.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | TARGET_BRANCH=${TARGET_BRANCH:-'master'}
3 |
4 | CHANGED_MARKDOWN_FILES=$(git diff --name-only ${TARGET_BRANCH} | grep .go)
5 | for file in ${CHANGED_MARKDOWN_FILES}; do
6 | echo "golint ${file}"
7 | golint -set_exit_status=true ${file} || exit 1
8 | done
9 |
10 | echo "code golint check success"
--------------------------------------------------------------------------------
/mockgen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | mockgen -source=worker/appm/store/store.go -destination=worker/appm/store/mock_store.go -package=store
3 | mockgen -source=db/db.go -destination=db/db_mock.go -package=db
4 | mockgen -source=db/dao/dao.go -destination=db/dao/dao_mock.go -package=dao
5 | mockgen -source=event/manager.go -destination=event/manager_mock.go -package=event
--------------------------------------------------------------------------------
/mq/api/grpc/pb/build.sh:
--------------------------------------------------------------------------------
1 | protoc --go_out=plugins=grpc:./ message.proto
--------------------------------------------------------------------------------
/mq/api/grpc/pb/message.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package pb;
3 | option go_package = "mq/api/grpc/pb";
4 |
5 | service TaskQueue {
6 | rpc Enqueue (EnqueueRequest) returns (TaskReply) {}
7 | rpc Topics (TopicRequest) returns (TaskReply) {}
8 | rpc Dequeue (DequeueRequest) returns (TaskMessage) {}
9 | }
10 |
11 | message TaskMessage {
12 | string task_id = 1;
13 | string task_type = 2;
14 | bytes task_body = 3;
15 | string create_time = 4;
16 | string user = 5;
17 | string arch = 6;
18 | }
19 |
20 | message EnqueueRequest {
21 | string topic = 1;
22 | TaskMessage message = 2;
23 | }
24 |
25 | message DequeueRequest {
26 | string topic = 1;
27 | string client_host = 2;
28 | }
29 |
30 | message TaskReply {
31 | string status = 1;
32 | string message = 2;
33 | repeated string topics = 3;
34 | }
35 |
36 | message TopicRequest{
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/mq/mqcomponent/mqclient/client.go:
--------------------------------------------------------------------------------
1 | package mqclient
2 |
3 | import (
4 | "context"
5 | "github.com/goodrain/rainbond/mq/api/mq"
6 | )
7 |
8 | var defaultMQClientComponent *Component
9 |
10 | // Component -
11 | type Component struct {
12 | actionMQ mq.ActionMQ
13 | }
14 |
15 | // Default -
16 | func Default() *Component {
17 | return defaultMQClientComponent
18 | }
19 |
20 | // ActionMQ -
21 | func (m *Component) ActionMQ() mq.ActionMQ {
22 | return m.actionMQ
23 | }
24 |
25 | // Start -
26 | func (m *Component) Start(ctx context.Context) error {
27 | m.actionMQ = mq.NewActionMQ(ctx)
28 | return m.actionMQ.Start()
29 | }
30 |
31 | // CloseHandle -
32 | func (m *Component) CloseHandle() {
33 | }
34 |
35 | // New -
36 | func New() *Component {
37 | defaultMQClientComponent = &Component{}
38 | return defaultMQClientComponent
39 | }
40 |
--------------------------------------------------------------------------------
/pkg/apis/rainbond/group.go:
--------------------------------------------------------------------------------
1 | // Package rainbond contains rainbond API versions.
2 | //
3 | // This file ensures Go source parsers acknowledge the rainbond package
4 | // and any child packages. It can be removed if any other Go source files are
5 | // added to this package.
6 | package rainbond
7 |
--------------------------------------------------------------------------------
/pkg/apis/rainbond/v1alpha1/doc.go:
--------------------------------------------------------------------------------
1 | // Package v1alpha1 contains API Schema definitions for the rainbond v1alpha1 API group
2 | // +k8s:deepcopy-gen=package,register
3 | // +groupName=rainbond.io
4 | package v1alpha1
5 |
--------------------------------------------------------------------------------
/pkg/apis/rainbond/v1alpha1/register.go:
--------------------------------------------------------------------------------
1 | // NOTE: Boilerplate only. Ignore this file.
2 |
3 | // Package v1alpha1 contains API Schema definitions for the rainbond v1alpha1 API group
4 | // +k8s:deepcopy-gen=package,register
5 | // +groupName=rainbond.io
6 | package v1alpha1
7 |
8 | import (
9 | "k8s.io/apimachinery/pkg/runtime/schema"
10 | "sigs.k8s.io/controller-runtime/pkg/scheme"
11 | )
12 |
13 | var (
14 | // SchemeGroupVersion is group version used to register these objects
15 | SchemeGroupVersion = schema.GroupVersion{Group: "rainbond.io", Version: "v1alpha1"}
16 |
17 | // SchemeBuilder is used to add go types to the GroupVersionKind scheme
18 | SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
19 | // AddToScheme adds all registered types to s.
20 | AddToScheme = SchemeBuilder.AddToScheme
21 | )
22 |
23 | // Resource gets an EtcdCluster GroupResource for a specified resource
24 | func Resource(resource string) schema.GroupResource {
25 | return SchemeGroupVersion.WithResource(resource).GroupResource()
26 | }
27 |
--------------------------------------------------------------------------------
/pkg/component/README.md:
--------------------------------------------------------------------------------
1 | # 通用的封装的组件
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/doc.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | // This package has the automatically generated clientset.
22 | package versioned
23 |
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/fake/doc.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | // This package has the automatically generated fake clientset.
22 | package fake
23 |
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/scheme/doc.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | // This package contains the scheme of the automatically generated clientset.
22 | package scheme
23 |
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1/doc.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | // This package has the automatically generated typed clients.
22 | package v1alpha1
23 |
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1/fake/doc.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | // Package fake has the automatically generated clients.
22 | package fake
23 |
--------------------------------------------------------------------------------
/pkg/generated/clientset/versioned/typed/rainbond/v1alpha1/generated_expansion.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | // Code generated by client-gen. DO NOT EDIT.
20 |
21 | package v1alpha1
22 |
23 | type ComponentDefinitionExpansion interface{}
24 |
25 | type HelmAppExpansion interface{}
26 |
27 | type RBDAbilityExpansion interface{}
28 |
29 | type RBDPluginExpansion interface{}
30 |
31 | type ThirdComponentExpansion interface{}
32 |
--------------------------------------------------------------------------------
/pkg/gogo/option.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2021-2024 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package gogo
20 |
21 | import "context"
22 |
23 | type Option func(*Options)
24 |
25 | type Options struct {
26 | ctx context.Context
27 | }
28 |
29 | func WithContext(ctx context.Context) Option {
30 | return func(o *Options) {
31 | o.ctx = ctx
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/pkg/helm/config.go:
--------------------------------------------------------------------------------
1 | package helm
2 |
3 | import "path"
4 |
5 | type Config struct {
6 | helmCache string
7 | }
8 |
9 | func (c *Config) RepoFile() string {
10 | return path.Join(c.helmCache, "/repository/repositories.yaml")
11 | }
12 |
13 | func (c *Config) RepoCache() string {
14 | return path.Join(c.helmCache, "cache")
15 | }
16 |
17 | func (c *Config) ChartCache() string {
18 | return path.Join(c.helmCache, "chart")
19 | }
20 |
--------------------------------------------------------------------------------
/pkg/helm/repo_test.go:
--------------------------------------------------------------------------------
1 | package helm
2 |
3 | import (
4 | "github.com/goodrain/rainbond/util"
5 | "github.com/stretchr/testify/assert"
6 | "testing"
7 | )
8 |
9 | func TestRepoAdd(t *testing.T) {
10 | repo := NewRepo(
11 | "/tmp/helm/repoName/repositories.yaml",
12 | "/tmp/helm/cache")
13 | err := repo.Add(util.NewUUID(), "https://openchart.goodrain.com/goodrain/rainbond", "", "")
14 | assert.Nil(t, err)
15 | }
16 |
--------------------------------------------------------------------------------
/precheck.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")
4 |
5 | if [[ "$STAGED_GO_FILES" = "" ]]; then
6 | exit 0
7 | fi
8 |
9 | PASS=true
10 |
11 | for FILE in $STAGED_GO_FILES
12 | do
13 | goimports -w $FILE
14 | golangci-lint run --fix --disable=typecheck $FILE
15 | if [[ $? != 0 ]]; then
16 | PASS=false
17 | fi
18 | done
19 |
20 | if ! $PASS; then
21 | printf "COMMIT FAILED\n"
22 | exit 1
23 | else
24 | printf "COMMIT SUCCEEDED\n"
25 | git add
26 | fi
27 |
28 | exit 0
29 |
--------------------------------------------------------------------------------
/util/bytes.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | //BytesSliceEqual BytesSliceEqual
22 | func BytesSliceEqual(a, b []byte) bool {
23 | if len(a) != len(b) {
24 | return false
25 | }
26 | if (a == nil) != (b == nil) {
27 | return false
28 | }
29 | for i, v := range a {
30 | if v != b[i] {
31 | return false
32 | }
33 | }
34 | return true
35 | }
36 |
--------------------------------------------------------------------------------
/util/commonutil/convert_types.go:
--------------------------------------------------------------------------------
1 | package commonutil
2 |
3 | // String returns a pointer to the string value passed in.
4 | func String(v string) *string {
5 | return &v
6 | }
7 |
8 | // BoolValue returns the value of the bool pointer passed in or
9 | // false if the pointer is nil.
10 | func BoolValue(v *bool) bool {
11 | if v != nil {
12 | return *v
13 | }
14 | return false
15 | }
16 |
17 | // Int64 returns a pointer to the int64 value passed in.
18 | func Int64(v int64) *int64 {
19 | return &v
20 | }
21 |
--------------------------------------------------------------------------------
/util/constants.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | //StatelessServiceType 无状态应用
22 | var StatelessServiceType = "StatelessServiceType"
23 |
24 | //StatefulServiceType 有状态应用
25 | var StatefulServiceType = "StatefulServiceType"
26 |
--------------------------------------------------------------------------------
/util/constants/constants.go:
--------------------------------------------------------------------------------
1 | package constants
2 |
3 | const (
4 | // Namespace -
5 | Namespace = "rbd-system"
6 | // Rainbond -
7 | Rainbond = "rainbond"
8 | // DefImageRepository default private image repository
9 | DefImageRepository = "goodrain.me"
10 | // GrdataLogPath -
11 | GrdataLogPath = "/grdata/logs"
12 | // ImagePullSecretKey the key of environment IMAGE_PULL_SECRET
13 | ImagePullSecretKey = "IMAGE_PULL_SECRET"
14 | // DefOnlineImageRepository default private image repository
15 | DefOnlineImageRepository = "registry.cn-hangzhou.aliyuncs.com/goodrain"
16 |
17 | // NotFound
18 | NotFound = "not found"
19 |
20 | // TenantQuotaCPULack
21 | TenantQuotaCPULack = "tenant_quota_cpu_lack"
22 |
23 | // enantQuotaMemoryLack
24 | TenantQuotaMemoryLack = "tenant_quota_memory_lack"
25 |
26 | // TenantLackOfMemory
27 | TenantLackOfMemory = "tenant_lack_of_memory"
28 |
29 | // TenantLackOfCPU
30 | TenantLackOfCPU = "tenant_lack_of_cpu"
31 |
32 | // TenantLackOfStorage
33 | TenantLackOfStorage = "tenant_lack_of_storage"
34 |
35 | // ClusterLackOfMemory
36 | ClusterLackOfMemory = "cluster_lack_of_memory"
37 | )
38 |
39 | // Kubernetes recommended Labels
40 | // Refer to: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels
41 | const (
42 | ResourceManagedByLabel = "app.kubernetes.io/managed-by"
43 | ResourceInstanceLabel = "app.kubernetes.io/instance"
44 | ResourceAppLabel = "app"
45 | )
46 |
--------------------------------------------------------------------------------
/util/dockerfile/command/command.go:
--------------------------------------------------------------------------------
1 | // Package command contains the set of Dockerfile commands.
2 | package command
3 |
4 | // Define constants for the command strings
5 | const (
6 | Add = "add"
7 | Arg = "arg"
8 | Cmd = "cmd"
9 | Copy = "copy"
10 | Entrypoint = "entrypoint"
11 | Env = "env"
12 | Expose = "expose"
13 | From = "from"
14 | Healthcheck = "healthcheck"
15 | Label = "label"
16 | Maintainer = "maintainer"
17 | Onbuild = "onbuild"
18 | Run = "run"
19 | Shell = "shell"
20 | StopSignal = "stopsignal"
21 | User = "user"
22 | Volume = "volume"
23 | Workdir = "workdir"
24 | )
25 |
26 | // Commands is list of all Dockerfile commands
27 | var Commands = map[string]struct{}{
28 | Add: {},
29 | Arg: {},
30 | Cmd: {},
31 | Copy: {},
32 | Entrypoint: {},
33 | Env: {},
34 | Expose: {},
35 | From: {},
36 | Healthcheck: {},
37 | Label: {},
38 | Maintainer: {},
39 | Onbuild: {},
40 | Run: {},
41 | Shell: {},
42 | StopSignal: {},
43 | User: {},
44 | Volume: {},
45 | Workdir: {},
46 | }
47 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/dumper/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "github.com/goodrain/rainbond/util/dockerfile/parser"
8 | )
9 |
10 | func main() {
11 | var f *os.File
12 | var err error
13 |
14 | if len(os.Args) < 2 {
15 | fmt.Println("please supply filename(s)")
16 | os.Exit(1)
17 | }
18 |
19 | for _, fn := range os.Args[1:] {
20 | f, err = os.Open(fn)
21 | if err != nil {
22 | panic(err)
23 | }
24 |
25 | d := parser.Directive{LookingForDirectives: true}
26 | parser.SetEscapeToken(parser.DefaultEscapeToken, &d)
27 |
28 | ast, err := parser.Parse(f, &d)
29 | if err != nil {
30 | panic(err)
31 | } else {
32 | fmt.Println(ast.Dump())
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfile-line/Dockerfile:
--------------------------------------------------------------------------------
1 | # ESCAPE=\
2 |
3 |
4 |
5 | FROM brimstone/ubuntu:14.04
6 |
7 |
8 | # TORUN -v /var/run/docker.sock:/var/run/docker.sock
9 |
10 |
11 | ENV GOPATH \
12 | /go
13 |
14 |
15 |
16 | # Install the packages we need, clean up after them and us
17 | RUN apt-get update \
18 | && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean \
19 |
20 |
21 | && apt-get install -y --no-install-recommends git golang ca-certificates \
22 | && apt-get clean \
23 | && rm -rf /var/lib/apt/lists \
24 |
25 | && go get -v github.com/brimstone/consuldock \
26 | && mv $GOPATH/bin/consuldock /usr/local/bin/consuldock \
27 |
28 | && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \
29 | && apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \
30 | && rm /tmp/dpkg.* \
31 | && rm -rf $GOPATH
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles-negative/env_no_value/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM busybox
2 |
3 | ENV PATH
4 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles-negative/shykes-nested-json/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD [ "echo", [ "nested json" ] ]
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/ADD-COPY-with-JSON/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | MAINTAINER Seongyeol Lim
3 |
4 | COPY . /go/src/github.com/docker/docker
5 | ADD . /
6 | ADD null /
7 | COPY nullfile /tmp
8 | ADD [ "vimrc", "/tmp" ]
9 | COPY [ "bashrc", "/tmp" ]
10 | COPY [ "test file", "/tmp" ]
11 | ADD [ "test file", "/tmp/test file" ]
12 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/ADD-COPY-with-JSON/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (maintainer "Seongyeol Lim ")
3 | (copy "." "/go/src/github.com/docker/docker")
4 | (add "." "/")
5 | (add "null" "/")
6 | (copy "nullfile" "/tmp")
7 | (add "vimrc" "/tmp")
8 | (copy "bashrc" "/tmp")
9 | (copy "test file" "/tmp")
10 | (add "test file" "/tmp/test file")
11 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/brimstone-consuldock/Dockerfile:
--------------------------------------------------------------------------------
1 | #escape=\
2 | FROM brimstone/ubuntu:14.04
3 |
4 | MAINTAINER brimstone@the.narro.ws
5 |
6 | # TORUN -v /var/run/docker.sock:/var/run/docker.sock
7 |
8 | ENV GOPATH /go
9 |
10 | # Set our command
11 | ENTRYPOINT ["/usr/local/bin/consuldock"]
12 |
13 | # Install the packages we need, clean up after them and us
14 | RUN apt-get update \
15 | && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean \
16 | && apt-get install -y --no-install-recommends git golang ca-certificates \
17 | && apt-get clean \
18 | && rm -rf /var/lib/apt/lists \
19 |
20 | && go get -v github.com/brimstone/consuldock \
21 | && mv $GOPATH/bin/consuldock /usr/local/bin/consuldock \
22 |
23 | && dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \
24 | && apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \
25 | && rm /tmp/dpkg.* \
26 | && rm -rf $GOPATH
27 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/brimstone-consuldock/result:
--------------------------------------------------------------------------------
1 | (from "brimstone/ubuntu:14.04")
2 | (maintainer "brimstone@the.narro.ws")
3 | (env "GOPATH" "/go")
4 | (entrypoint "/usr/local/bin/consuldock")
5 | (run "apt-get update \t&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.clean && apt-get install -y --no-install-recommends git golang ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists \t&& go get -v github.com/brimstone/consuldock && mv $GOPATH/bin/consuldock /usr/local/bin/consuldock \t&& dpkg -l | awk '/^ii/ {print $2}' > /tmp/dpkg.dirty \t&& apt-get remove --purge -y $(diff /tmp/dpkg.clean /tmp/dpkg.dirty | awk '/^>/ {print $2}') \t&& rm /tmp/dpkg.* \t&& rm -rf $GOPATH")
6 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/continueIndent/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 |
3 | RUN echo hello\
4 | world\
5 | goodnight \
6 | moon\
7 | light\
8 | ning
9 | RUN echo hello \
10 | world
11 | RUN echo hello \
12 | world
13 | RUN echo hello \
14 | goodbye\
15 | frog
16 | RUN echo hello \
17 | world
18 | RUN echo hi \
19 | \
20 | world \
21 | \
22 | good\
23 | \
24 | night
25 | RUN echo goodbye\
26 | frog
27 | RUN echo good\
28 | bye\
29 | frog
30 |
31 | RUN echo hello \
32 | # this is a comment
33 |
34 | # this is a comment with a blank line surrounding it
35 |
36 | this is some more useful stuff
37 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/continueIndent/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (run "echo hello world goodnight moon lightning")
3 | (run "echo hello world")
4 | (run "echo hello world")
5 | (run "echo hello goodbyefrog")
6 | (run "echo hello world")
7 | (run "echo hi world goodnight")
8 | (run "echo goodbyefrog")
9 | (run "echo goodbyefrog")
10 | (run "echo hello this is some more useful stuff")
11 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/env/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu
2 | ENV name value
3 | ENV name=value
4 | ENV name=value name2=value2
5 | ENV name="value value1"
6 | ENV name=value\ value2
7 | ENV name="value'quote space'value2"
8 | ENV name='value"double quote"value2'
9 | ENV name=value\ value2 name2=value2\ value3
10 | ENV name="a\"b"
11 | ENV name="a\'b"
12 | ENV name='a\'b'
13 | ENV name='a\'b''
14 | ENV name='a\"b'
15 | ENV name="''"
16 | # don't put anything after the next line - it must be the last line of the
17 | # Dockerfile and it must end with \
18 | ENV name=value \
19 | name1=value1 \
20 | name2="value2a \
21 | value2b" \
22 | name3="value3a\n\"value3b\"" \
23 | name4="value4a\\nvalue4b" \
24 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/env/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu")
2 | (env "name" "value")
3 | (env "name" "value")
4 | (env "name" "value" "name2" "value2")
5 | (env "name" "\"value value1\"")
6 | (env "name" "value\\ value2")
7 | (env "name" "\"value'quote space'value2\"")
8 | (env "name" "'value\"double quote\"value2'")
9 | (env "name" "value\\ value2" "name2" "value2\\ value3")
10 | (env "name" "\"a\\\"b\"")
11 | (env "name" "\"a\\'b\"")
12 | (env "name" "'a\\'b'")
13 | (env "name" "'a\\'b''")
14 | (env "name" "'a\\\"b'")
15 | (env "name" "\"''\"")
16 | (env "name" "value" "name1" "value1" "name2" "\"value2a value2b\"" "name3" "\"value3a\\n\\\"value3b\\\"\"" "name4" "\"value4a\\\\nvalue4b\"")
17 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape-after-comment/Dockerfile:
--------------------------------------------------------------------------------
1 | # Comment here. Should not be looking for the following parser directive.
2 | # Hence the following line will be ignored, and the subsequent backslash
3 | # continuation will be the default.
4 | # escape = `
5 |
6 | FROM image
7 | MAINTAINER foo@bar.com
8 | ENV GOPATH \
9 | \go
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape-after-comment/result:
--------------------------------------------------------------------------------
1 | (from "image")
2 | (maintainer "foo@bar.com")
3 | (env "GOPATH" "\\go")
4 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape-nonewline/Dockerfile:
--------------------------------------------------------------------------------
1 | # escape = ``
2 | # There is no white space line after the directives. This still succeeds, but goes
3 | # against best practices.
4 | FROM image
5 | MAINTAINER foo@bar.com
6 | ENV GOPATH `
7 | \go
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape-nonewline/result:
--------------------------------------------------------------------------------
1 | (from "image")
2 | (maintainer "foo@bar.com")
3 | (env "GOPATH" "\\go")
4 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape/Dockerfile:
--------------------------------------------------------------------------------
1 | #escape = `
2 |
3 | FROM image
4 | MAINTAINER foo@bar.com
5 | ENV GOPATH `
6 | \go
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escape/result:
--------------------------------------------------------------------------------
1 | (from "image")
2 | (maintainer "foo@bar.com")
3 | (env "GOPATH" "\\go")
4 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escapes/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | MAINTAINER Erik \\Hollensbe \"
3 |
4 | RUN apt-get \update && \
5 | apt-get \"install znc -y
6 | ADD \conf\\" /.znc
7 |
8 | RUN foo \
9 |
10 | bar \
11 |
12 | baz
13 |
14 | CMD [ "\/usr\\\"/bin/znc", "-f", "-r" ]
15 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/escapes/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (maintainer "Erik \\\\Hollensbe \\\"")
3 | (run "apt-get \\update && apt-get \\\"install znc -y")
4 | (add "\\conf\\\\\"" "/.znc")
5 | (run "foo bar baz")
6 | (cmd "/usr\\\"/bin/znc" "-f" "-r")
7 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/flags/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM scratch
2 | COPY foo /tmp/
3 | COPY --user=me foo /tmp/
4 | COPY --doit=true foo /tmp/
5 | COPY --user=me --doit=true foo /tmp/
6 | COPY --doit=true -- foo /tmp/
7 | COPY -- foo /tmp/
8 | CMD --doit [ "a", "b" ]
9 | CMD --doit=true -- [ "a", "b" ]
10 | CMD --doit -- [ ]
11 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/flags/result:
--------------------------------------------------------------------------------
1 | (from "scratch")
2 | (copy "foo" "/tmp/")
3 | (copy ["--user=me"] "foo" "/tmp/")
4 | (copy ["--doit=true"] "foo" "/tmp/")
5 | (copy ["--user=me" "--doit=true"] "foo" "/tmp/")
6 | (copy ["--doit=true"] "foo" "/tmp/")
7 | (copy "foo" "/tmp/")
8 | (cmd ["--doit"] "a" "b")
9 | (cmd ["--doit=true"] "a" "b")
10 | (cmd ["--doit"])
11 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/health/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian
2 | ADD check.sh main.sh /app/
3 | CMD /app/main.sh
4 | HEALTHCHECK
5 | HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
6 | CMD /app/check.sh --quiet
7 | HEALTHCHECK CMD
8 | HEALTHCHECK CMD a b
9 | HEALTHCHECK --timeout=3s CMD ["foo"]
10 | HEALTHCHECK CONNECT TCP 7000
11 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/health/result:
--------------------------------------------------------------------------------
1 | (from "debian")
2 | (add "check.sh" "main.sh" "/app/")
3 | (cmd "/app/main.sh")
4 | (healthcheck)
5 | (healthcheck ["--interval=5s" "--timeout=3s" "--retries=3"] "CMD" "/app/check.sh --quiet")
6 | (healthcheck "CMD")
7 | (healthcheck "CMD" "a b")
8 | (healthcheck ["--timeout=3s"] "CMD" "foo")
9 | (healthcheck "CONNECT" "TCP 7000")
10 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/influxdb/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 |
3 | RUN apt-get update && apt-get install wget -y
4 | RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
5 | RUN dpkg -i influxdb_latest_amd64.deb
6 | RUN rm -r /opt/influxdb/shared
7 |
8 | VOLUME /opt/influxdb/shared
9 |
10 | CMD /usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml
11 |
12 | EXPOSE 8083
13 | EXPOSE 8086
14 | EXPOSE 8090
15 | EXPOSE 8099
16 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/influxdb/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (run "apt-get update && apt-get install wget -y")
3 | (run "wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb")
4 | (run "dpkg -i influxdb_latest_amd64.deb")
5 | (run "rm -r /opt/influxdb/shared")
6 | (volume "/opt/influxdb/shared")
7 | (cmd "/usr/bin/influxdb --pidfile /var/run/influxdb.pid -config /opt/influxdb/shared/config.toml")
8 | (expose "8083")
9 | (expose "8086")
10 | (expose "8090")
11 | (expose "8099")
12 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-json-inside-string-double/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD "[\"echo\", \"Phew, I just managed to escaped those double quotes\"]"
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-json-inside-string-double/result:
--------------------------------------------------------------------------------
1 | (cmd "\"[\\\"echo\\\", \\\"Phew, I just managed to escaped those double quotes\\\"]\"")
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-json-inside-string/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD '["echo", "Well, JSON in a string is JSON too?"]'
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-json-inside-string/result:
--------------------------------------------------------------------------------
1 | (cmd "'[\"echo\", \"Well, JSON in a string is JSON too?\"]'")
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-single-quotes/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD ['echo','single quotes are invalid JSON']
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-single-quotes/result:
--------------------------------------------------------------------------------
1 | (cmd "['echo','single quotes are invalid JSON']")
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-unterminated-bracket/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD ["echo", "Please, close the brackets when you're done"
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-unterminated-bracket/result:
--------------------------------------------------------------------------------
1 | (cmd "[\"echo\", \"Please, close the brackets when you're done\"")
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-unterminated-string/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD ["echo", "look ma, no quote!]
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/jeztah-invalid-json-unterminated-string/result:
--------------------------------------------------------------------------------
1 | (cmd "[\"echo\", \"look ma, no quote!]")
2 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/json/Dockerfile:
--------------------------------------------------------------------------------
1 | CMD []
2 | CMD [""]
3 | CMD ["a"]
4 | CMD ["a","b"]
5 | CMD [ "a", "b" ]
6 | CMD [ "a", "b" ]
7 | CMD [ "a", "b" ]
8 | CMD ["abc 123", "♥", "☃", "\" \\ \/ \b \f \n \r \t \u0000"]
9 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/json/result:
--------------------------------------------------------------------------------
1 | (cmd)
2 | (cmd "")
3 | (cmd "a")
4 | (cmd "a" "b")
5 | (cmd "a" "b")
6 | (cmd "a" "b")
7 | (cmd "a" "b")
8 | (cmd "abc 123" "♥" "☃" "\" \\ / \b \f \n \r \t \x00")
9 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/kartar-entrypoint-oddities/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | MAINTAINER James Turnbull "james@example.com"
3 | ENV REFRESHED_AT 2014-06-01
4 | RUN apt-get update
5 | RUN apt-get -y install redis-server redis-tools
6 | EXPOSE 6379
7 | ENTRYPOINT [ "/usr/bin/redis-server" ]
8 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/kartar-entrypoint-oddities/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (maintainer "James Turnbull \"james@example.com\"")
3 | (env "REFRESHED_AT" "2014-06-01")
4 | (run "apt-get update")
5 | (run "apt-get -y install redis-server redis-tools")
6 | (expose "6379")
7 | (entrypoint "/usr/bin/redis-server")
8 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/lk4d4-the-edge-case-generator/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM busybox:buildroot-2014.02
2 |
3 | MAINTAINER docker
4 |
5 | ONBUILD RUN ["echo", "test"]
6 | ONBUILD RUN echo test
7 | ONBUILD COPY . /
8 |
9 |
10 | # RUN Commands \
11 | # linebreak in comment \
12 | RUN ["ls", "-la"]
13 | RUN ["echo", "'1234'"]
14 | RUN echo "1234"
15 | RUN echo 1234
16 | RUN echo '1234' && \
17 | echo "456" && \
18 | echo 789
19 | RUN sh -c 'echo root:testpass \
20 | > /tmp/passwd'
21 | RUN mkdir -p /test /test2 /test3/test
22 |
23 | # ENV \
24 | ENV SCUBA 1 DUBA 3
25 | ENV SCUBA "1 DUBA 3"
26 |
27 | # CMD \
28 | CMD ["echo", "test"]
29 | CMD echo test
30 | CMD echo "test"
31 | CMD echo 'test'
32 | CMD echo 'test' | wc -
33 |
34 | #EXPOSE\
35 | EXPOSE 3000
36 | EXPOSE 9000 5000 6000
37 |
38 | USER docker
39 | USER docker:root
40 |
41 | VOLUME ["/test"]
42 | VOLUME ["/test", "/test2"]
43 | VOLUME /test3
44 |
45 | WORKDIR /test
46 |
47 | ADD . /
48 | COPY . copy
49 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/lk4d4-the-edge-case-generator/result:
--------------------------------------------------------------------------------
1 | (from "busybox:buildroot-2014.02")
2 | (maintainer "docker ")
3 | (onbuild (run "echo" "test"))
4 | (onbuild (run "echo test"))
5 | (onbuild (copy "." "/"))
6 | (run "ls" "-la")
7 | (run "echo" "'1234'")
8 | (run "echo \"1234\"")
9 | (run "echo 1234")
10 | (run "echo '1234' && echo \"456\" && echo 789")
11 | (run "sh -c 'echo root:testpass > /tmp/passwd'")
12 | (run "mkdir -p /test /test2 /test3/test")
13 | (env "SCUBA" "1 DUBA 3")
14 | (env "SCUBA" "\"1 DUBA 3\"")
15 | (cmd "echo" "test")
16 | (cmd "echo test")
17 | (cmd "echo \"test\"")
18 | (cmd "echo 'test'")
19 | (cmd "echo 'test' | wc -")
20 | (expose "3000")
21 | (expose "9000" "5000" "6000")
22 | (user "docker")
23 | (user "docker:root")
24 | (volume "/test")
25 | (volume "/test" "/test2")
26 | (volume "/test3")
27 | (workdir "/test")
28 | (add "." "/")
29 | (copy "." "copy")
30 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/mail/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 |
3 | RUN apt-get update -qy && apt-get install mutt offlineimap vim-nox abook elinks curl tmux cron zsh -y
4 | ADD .muttrc /
5 | ADD .offlineimaprc /
6 | ADD .tmux.conf /
7 | ADD mutt /.mutt
8 | ADD vim /.vim
9 | ADD vimrc /.vimrc
10 | ADD crontab /etc/crontab
11 | RUN chmod 644 /etc/crontab
12 | RUN mkdir /Mail
13 | RUN mkdir /.offlineimap
14 | RUN echo "export TERM=screen-256color" >/.zshenv
15 |
16 | CMD setsid cron; tmux -2
17 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/mail/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (run "apt-get update -qy && apt-get install mutt offlineimap vim-nox abook elinks curl tmux cron zsh -y")
3 | (add ".muttrc" "/")
4 | (add ".offlineimaprc" "/")
5 | (add ".tmux.conf" "/")
6 | (add "mutt" "/.mutt")
7 | (add "vim" "/.vim")
8 | (add "vimrc" "/.vimrc")
9 | (add "crontab" "/etc/crontab")
10 | (run "chmod 644 /etc/crontab")
11 | (run "mkdir /Mail")
12 | (run "mkdir /.offlineimap")
13 | (run "echo \"export TERM=screen-256color\" >/.zshenv")
14 | (cmd "setsid cron; tmux -2")
15 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/multiple-volumes/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM foo
2 |
3 | VOLUME /opt/nagios/var /opt/nagios/etc /opt/nagios/libexec /var/log/apache2 /usr/share/snmp/mibs
4 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/multiple-volumes/result:
--------------------------------------------------------------------------------
1 | (from "foo")
2 | (volume "/opt/nagios/var" "/opt/nagios/etc" "/opt/nagios/libexec" "/var/log/apache2" "/usr/share/snmp/mibs")
3 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/mumble/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 |
3 | RUN apt-get update && apt-get install libcap2-bin mumble-server -y
4 |
5 | ADD ./mumble-server.ini /etc/mumble-server.ini
6 |
7 | CMD /usr/sbin/murmurd
8 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/mumble/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (run "apt-get update && apt-get install libcap2-bin mumble-server -y")
3 | (add "./mumble-server.ini" "/etc/mumble-server.ini")
4 | (cmd "/usr/sbin/murmurd")
5 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | MAINTAINER Erik Hollensbe
3 |
4 | RUN apt-get update && apt-get install nginx-full -y
5 | RUN rm -rf /etc/nginx
6 | ADD etc /etc/nginx
7 | RUN chown -R root:root /etc/nginx
8 | RUN /usr/sbin/nginx -qt
9 | RUN mkdir /www
10 |
11 | CMD ["/usr/sbin/nginx"]
12 |
13 | VOLUME /www
14 | EXPOSE 80
15 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/nginx/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (maintainer "Erik Hollensbe ")
3 | (run "apt-get update && apt-get install nginx-full -y")
4 | (run "rm -rf /etc/nginx")
5 | (add "etc" "/etc/nginx")
6 | (run "chown -R root:root /etc/nginx")
7 | (run "/usr/sbin/nginx -qt")
8 | (run "mkdir /www")
9 | (cmd "/usr/sbin/nginx")
10 | (volume "/www")
11 | (expose "80")
12 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/tf2/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:12.04
2 |
3 | EXPOSE 27015
4 | EXPOSE 27005
5 | EXPOSE 26901
6 | EXPOSE 27020
7 |
8 | RUN apt-get update && apt-get install libc6-dev-i386 curl unzip -y
9 | RUN mkdir -p /steam
10 | RUN curl http://media.steampowered.com/client/steamcmd_linux.tar.gz | tar vxz -C /steam
11 | ADD ./script /steam/script
12 | RUN /steam/steamcmd.sh +runscript /steam/script
13 | RUN curl http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.0-linux.tar.gz | tar vxz -C /steam/tf2/tf
14 | RUN curl http://mirror.pointysoftware.net/alliedmodders/sourcemod-1.5.3-linux.tar.gz | tar vxz -C /steam/tf2/tf
15 | ADD ./server.cfg /steam/tf2/tf/cfg/server.cfg
16 | ADD ./ctf_2fort.cfg /steam/tf2/tf/cfg/ctf_2fort.cfg
17 | ADD ./sourcemod.cfg /steam/tf2/tf/cfg/sourcemod/sourcemod.cfg
18 | RUN rm -r /steam/tf2/tf/addons/sourcemod/configs
19 | ADD ./configs /steam/tf2/tf/addons/sourcemod/configs
20 | RUN mkdir -p /steam/tf2/tf/addons/sourcemod/translations/en
21 | RUN cp /steam/tf2/tf/addons/sourcemod/translations/*.txt /steam/tf2/tf/addons/sourcemod/translations/en
22 |
23 | CMD cd /steam/tf2 && ./srcds_run -port 27015 +ip 0.0.0.0 +map ctf_2fort -autoupdate -steam_dir /steam -steamcmd_script /steam/script +tf_bot_quota 12 +tf_bot_quota_mode fill
24 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/tf2/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:12.04")
2 | (expose "27015")
3 | (expose "27005")
4 | (expose "26901")
5 | (expose "27020")
6 | (run "apt-get update && apt-get install libc6-dev-i386 curl unzip -y")
7 | (run "mkdir -p /steam")
8 | (run "curl http://media.steampowered.com/client/steamcmd_linux.tar.gz | tar vxz -C /steam")
9 | (add "./script" "/steam/script")
10 | (run "/steam/steamcmd.sh +runscript /steam/script")
11 | (run "curl http://mirror.pointysoftware.net/alliedmodders/mmsource-1.10.0-linux.tar.gz | tar vxz -C /steam/tf2/tf")
12 | (run "curl http://mirror.pointysoftware.net/alliedmodders/sourcemod-1.5.3-linux.tar.gz | tar vxz -C /steam/tf2/tf")
13 | (add "./server.cfg" "/steam/tf2/tf/cfg/server.cfg")
14 | (add "./ctf_2fort.cfg" "/steam/tf2/tf/cfg/ctf_2fort.cfg")
15 | (add "./sourcemod.cfg" "/steam/tf2/tf/cfg/sourcemod/sourcemod.cfg")
16 | (run "rm -r /steam/tf2/tf/addons/sourcemod/configs")
17 | (add "./configs" "/steam/tf2/tf/addons/sourcemod/configs")
18 | (run "mkdir -p /steam/tf2/tf/addons/sourcemod/translations/en")
19 | (run "cp /steam/tf2/tf/addons/sourcemod/translations/*.txt /steam/tf2/tf/addons/sourcemod/translations/en")
20 | (cmd "cd /steam/tf2 && ./srcds_run -port 27015 +ip 0.0.0.0 +map ctf_2fort -autoupdate -steam_dir /steam -steamcmd_script /steam/script +tf_bot_quota 12 +tf_bot_quota_mode fill")
21 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/weechat/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 |
3 | RUN apt-get update -qy && apt-get install tmux zsh weechat-curses -y
4 |
5 | ADD .weechat /.weechat
6 | ADD .tmux.conf /
7 | RUN echo "export TERM=screen-256color" >/.zshenv
8 |
9 | CMD zsh -c weechat
10 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/weechat/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (run "apt-get update -qy && apt-get install tmux zsh weechat-curses -y")
3 | (add ".weechat" "/.weechat")
4 | (add ".tmux.conf" "/")
5 | (run "echo \"export TERM=screen-256color\" >/.zshenv")
6 | (cmd "zsh -c weechat")
7 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/znc/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:14.04
2 | MAINTAINER Erik Hollensbe
3 |
4 | RUN apt-get update && apt-get install znc -y
5 | ADD conf /.znc
6 |
7 | CMD [ "/usr/bin/znc", "-f", "-r" ]
8 |
--------------------------------------------------------------------------------
/util/dockerfile/parser/testfiles/znc/result:
--------------------------------------------------------------------------------
1 | (from "ubuntu:14.04")
2 | (maintainer "Erik Hollensbe ")
3 | (run "apt-get update && apt-get install znc -y")
4 | (add "conf" "/.znc")
5 | (cmd "/usr/bin/znc" "-f" "-r")
6 |
--------------------------------------------------------------------------------
/util/envoy/v1/builder.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/util/envoy/v1/builder.go
--------------------------------------------------------------------------------
/util/envoy/v1/keys.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/util/envoy/v1/keys.go
--------------------------------------------------------------------------------
/util/envoy/v1/resource.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/util/envoy/v1/resource.go
--------------------------------------------------------------------------------
/util/envoy/v2/builder.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/util/envoy/v2/builder.go
--------------------------------------------------------------------------------
/util/envoy/v2/util.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/goodrain/rainbond/38d6e38e0cdf755915ef145c686f37ba430940be/util/envoy/v2/util.go
--------------------------------------------------------------------------------
/util/envutil/envutil.go:
--------------------------------------------------------------------------------
1 | package envutil
2 |
3 | import "os"
4 |
5 | // GetMemoryType returns the memory type based on the given memory size.
6 | func GetMemoryType(memorySize int) string {
7 | memoryType := "small"
8 | if v, ok := memoryLabels[memorySize]; ok {
9 | memoryType = v
10 | }
11 | return memoryType
12 | }
13 |
14 | var memoryLabels = map[int]string{
15 | 128: "micro",
16 | 256: "small",
17 | 512: "medium",
18 | 1024: "large",
19 | 2048: "2xlarge",
20 | 4096: "4xlarge",
21 | 8192: "8xlarge",
22 | 16384: "16xlarge",
23 | 32768: "32xlarge",
24 | 65536: "64xlarge",
25 | }
26 |
27 | // IsCustomMemory -
28 | func IsCustomMemory(memory int) bool {
29 | if _, ok := memoryLabels[memory]; ok {
30 | return false
31 | }
32 | return true
33 | }
34 |
35 | // GetenvDefault Used to define environment variables and default values.
36 | func GetenvDefault(key, def string) string {
37 | if val := os.Getenv(key); val != "" {
38 | return val
39 | }
40 | return def
41 | }
42 |
--------------------------------------------------------------------------------
/util/fuzzy/levenshtein.go:
--------------------------------------------------------------------------------
1 | package fuzzy
2 |
3 | // LevenshteinDistance measures the difference between two strings.
4 | // The Levenshtein distance between two words is the minimum number of
5 | // single-character edits (i.e. insertions, deletions or substitutions)
6 | // required to change one word into the other.
7 | //
8 | // This implemention is optimized to use O(min(m,n)) space and is based on the
9 | // optimized C version found here:
10 | // http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C
11 | func LevenshteinDistance(s, t string) int {
12 | r1, r2 := []rune(s), []rune(t)
13 | column := make([]int, len(r1)+1)
14 |
15 | for y := 1; y <= len(r1); y++ {
16 | column[y] = y
17 | }
18 |
19 | for x := 1; x <= len(r2); x++ {
20 | column[0] = x
21 |
22 | for y, lastDiag := 1, x-1; y <= len(r1); y++ {
23 | oldDiag := column[y]
24 | cost := 0
25 | if r1[y-1] != r2[x-1] {
26 | cost = 1
27 | }
28 | column[y] = min(column[y]+1, column[y-1]+1, lastDiag+cost)
29 | lastDiag = oldDiag
30 | }
31 | }
32 |
33 | return column[len(r1)]
34 | }
35 |
36 | func min(a, b, c int) int {
37 | if a < b && a < c {
38 | return a
39 | } else if b < c {
40 | return b
41 | }
42 | return c
43 | }
44 |
--------------------------------------------------------------------------------
/util/get_my_namespace.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import "io/ioutil"
4 |
5 | const namespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
6 |
7 | func GetMyNamespace() (string, error) {
8 | data, err := ioutil.ReadFile(namespaceFile)
9 | if err != nil {
10 | return "", err
11 | }
12 | return string(data), nil
13 | }
14 |
--------------------------------------------------------------------------------
/util/govalidator/LICENSE.md:
--------------------------------------------------------------------------------
1 | # The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Saddam H
4 |
5 | > Permission is hereby granted, free of charge, to any person obtaining a copy
6 | > of this software and associated documentation files (the "Software"), to deal
7 | > in the Software without restriction, including without limitation the rights
8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | > copies of the Software, and to permit persons to whom the Software is
10 | > furnished to do so, subject to the following conditions:
11 | >
12 | > The above copyright notice and this permission notice shall be included in
13 | > all copies or substantial portions of the Software.
14 | >
15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | > THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/util/govalidator/custom_rules.go:
--------------------------------------------------------------------------------
1 | package validator
2 |
3 | import (
4 | "fmt"
5 | "net/url"
6 | "strings"
7 | )
8 |
9 | var customRules = make(map[string]func(string, interface{}, string) error, 0)
10 |
11 | // AddCustomRule help to add custom rules for validator
12 | // First argument it takes the rule name and second arg a func
13 | // Second arg must have this signature below
14 | // fn func(fieldName string, fieldValue string, rule string) error
15 | func AddCustomRule(name string, fn func(field string, value interface{}, rule string) error) {
16 | if isRuleExist(name) {
17 | panic(fmt.Errorf("validator: %s is already defined in rules", name))
18 | }
19 | customRules[name] = fn
20 | }
21 |
22 | // validateCustomRules validate custom rules
23 | func validateCustomRules(field string, value interface{}, rule string, errsBag url.Values) {
24 | for k, v := range customRules {
25 | if k == rule || strings.HasPrefix(rule, k+":") {
26 | err := v(field, value, rule)
27 | if err != nil {
28 | errsBag.Add(field, err.Error())
29 | }
30 | break
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/util/govalidator/errors.go:
--------------------------------------------------------------------------------
1 | package validator
2 |
3 | import "errors"
4 |
5 | var (
6 | errStringToInt = errors.New("validator: unable to parse string to integer")
7 | errValidateArgsMismatch = errors.New("validator: provide at least *http.Request and rules for Validate method")
8 | errValidateMapJSONArgsMismatch = errors.New("validator: provide at least *http.Request and rules for ValidateMapJSON method")
9 | errValidateJSONArgsMismatch = errors.New("validator: provide at least *http.Request and data structure for ValidateJSON method")
10 | errInvalidArgument = errors.New("validator: invalid number of argument")
11 | errRequirePtr = errors.New("validator: provide pointer to the data structure")
12 | )
13 |
--------------------------------------------------------------------------------
/util/hash_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import "testing"
22 |
23 | func TestCreateFileHash(t *testing.T) {
24 | if err := CreateFileHash("/tmp/hashtest", "/tmp/hashtest.md5"); err != nil {
25 | t.Fatal(err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/util/ingress-nginx/ingress/controller/store/endpoint.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2015 The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package store
18 |
19 | import (
20 | apiv1 "k8s.io/api/core/v1"
21 | "k8s.io/client-go/tools/cache"
22 | )
23 |
24 | // EndpointLister makes a store that lists Endpoints.
25 | type EndpointLister struct {
26 | cache.Store
27 | }
28 |
29 | // ByKey returns the Endpoints of the Service matching key in the local Endpoint store.
30 | func (s *EndpointLister) ByKey(key string) (*apiv1.Endpoints, error) {
31 | eps, exists, err := s.GetByKey(key)
32 | if err != nil {
33 | return nil, err
34 | }
35 | if !exists {
36 | return nil, NotExistsError(key)
37 | }
38 | return eps.(*apiv1.Endpoints), nil
39 | }
40 |
--------------------------------------------------------------------------------
/util/ingress-nginx/ingress/controller/store/ingress.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2015 The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package store
18 |
19 | import (
20 | "k8s.io/client-go/tools/cache"
21 | )
22 |
23 | // IngressLister makes a store that lists Ingress.
24 | type IngressLister struct {
25 | cache.Store
26 | }
27 |
28 | // ByKey returns the Ingress matching key in the local Ingress store.
29 | func (il IngressLister) ByKey(key string) (interface{}, error) {
30 | i, exists, err := il.GetByKey(key)
31 | if err != nil {
32 | return nil, err
33 | }
34 | if !exists {
35 | return nil, NotExistsError(key)
36 | }
37 | return i, nil
38 | }
39 |
--------------------------------------------------------------------------------
/util/ingress-nginx/ingress/controller/store/secret.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2015 The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package store
18 |
19 | import (
20 | apiv1 "k8s.io/api/core/v1"
21 | "k8s.io/client-go/tools/cache"
22 | )
23 |
24 | // SecretLister makes a Store that lists Secrets.
25 | type SecretLister struct {
26 | cache.Store
27 | }
28 |
29 | // ByKey returns the Secret matching key in the local Secret Store.
30 | func (sl *SecretLister) ByKey(key string) (*apiv1.Secret, error) {
31 | s, exists, err := sl.GetByKey(key)
32 | if err != nil {
33 | return nil, err
34 | }
35 | if !exists {
36 | return nil, NotExistsError(key)
37 | }
38 | return s.(*apiv1.Secret), nil
39 | }
40 |
--------------------------------------------------------------------------------
/util/ingress-nginx/ingress/controller/store/service.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2015 The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | package store
18 |
19 | import (
20 | apiv1 "k8s.io/api/core/v1"
21 | "k8s.io/client-go/tools/cache"
22 | )
23 |
24 | // ServiceLister makes a store that lists Services.
25 | type ServiceLister struct {
26 | cache.Store
27 | }
28 |
29 | // ByKey returns the Service matching key in the local Service store.
30 | func (sl *ServiceLister) ByKey(key string) (*apiv1.Service, error) {
31 | s, exists, err := sl.GetByKey(key)
32 | if err != nil {
33 | return nil, err
34 | }
35 | if !exists {
36 | return nil, NotExistsError(key)
37 | }
38 | return s.(*apiv1.Service), nil
39 | }
40 |
--------------------------------------------------------------------------------
/util/ingress-nginx/ingress/controller/store/store.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2017 The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package store
17 |
18 | import "fmt"
19 |
20 | // NotExistsError is returned when an object does not exist in a local store.
21 | type NotExistsError string
22 |
23 | // Error implements the error interface.
24 | func (e NotExistsError) Error() string {
25 | return fmt.Sprintf("no object matching key %q in local store", string(e))
26 | }
27 |
--------------------------------------------------------------------------------
/util/ip.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2019 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import "net"
22 |
23 | //CheckIP Verify IP address validity
24 | func CheckIP(ip string) bool {
25 | i := net.ParseIP(ip)
26 | return i != nil && !i.IsLoopback() && !i.IsUnspecified()
27 | }
28 |
--------------------------------------------------------------------------------
/util/ip_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2019 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import "testing"
22 |
23 | func TestCheckIP(t *testing.T) {
24 | t.Logf("ip %s %t", "1829.123", CheckIP("1829.123"))
25 | t.Logf("ip %s %t", "1829.123.1", CheckIP("1829.123.1"))
26 | t.Logf("ip %s %t", "1829.123.2.1", CheckIP("1829.123.2.1"))
27 | t.Logf("ip %s %t", "y.123", CheckIP("y.123"))
28 | t.Logf("ip %s %t", "0.0.0.0", CheckIP("0.0.0.0"))
29 | t.Logf("ip %s %t", "127.0.0.1", CheckIP("127.0.0.1"))
30 | t.Logf("ip %s %t", "localhost", CheckIP("localhost"))
31 | t.Logf("ip %s %t", "192.168.0.1", CheckIP("192.168.0.1"))
32 | }
33 |
--------------------------------------------------------------------------------
/util/ippool_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2019 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import (
22 | "fmt"
23 | "testing"
24 | )
25 |
26 | func TestWatchAndListIP(t *testing.T) {
27 | pool := NewIPPool([]string{"p2p0"})
28 | if pool.Ready() {
29 | fmt.Println(pool.GetHostIPs())
30 | for e := range pool.GetWatchIPChan() {
31 | t.Log(e)
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/util/license/testdata/expire_license.yb:
--------------------------------------------------------------------------------
1 | JYW3j1nNcSFUWsH-ghPkDvaHXPOUsqLEHFn9QAP7n6esZl3UJ5RMeWt_CPy1bL7V5g_zDAtGVf3Z84M-A6uIeke2OVrhT02gDhE0nkkP3607qIIzgtRm9dR-qxGlgZpdA6lGX3KvOtxd90Gu9uBAPTozum4cy8l4cuW7Xu7Ac_Jx1fwx_i0GmorqCpmpboRqfxvhjQ5BrUaYMiaqyOtu9CNwm8T_AY9qqKO4afwTs6Q7XJisliJCB5v-TcNYVzDUU5rk1oRZtQWDbfJlL1kwUYI_PfanyergX44gc7U445b9PiAB3A
--------------------------------------------------------------------------------
/util/license/testdata/ok_license.yb:
--------------------------------------------------------------------------------
1 | NuSDevakyxmuVAaOknLanRsSIAK6xJ-SFZx9H1bWzJC71e30J7x-p-gntGveasg5FJpXPRELr5voa-P0qD_jMG2xq_64KDtrv3W-J5_SvKi467OM06n8dnwL_-iiisV0m6TR6lKfbUDMr1rIeCTFPthNiUIlzsVnaLWk_6i8O9p1jF8N6mRsLhzKHT1zX_IgoWeqT0FdTMtVL8F0Xa2seZrHKeJ_PqWMOsgsv3EOWHD7Ig0C2-GQYZbiUe23w4if4pcU0hQKfgcTjCW1bt2TS_ccF3EMSpoMxq0jTKQQsbz57TzJ2w
--------------------------------------------------------------------------------
/util/license/testdata/wrong_license.yb:
--------------------------------------------------------------------------------
1 | wrong license
--------------------------------------------------------------------------------
/util/sshclient_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import (
22 | "bytes"
23 | "testing"
24 |
25 | "github.com/sirupsen/logrus"
26 | )
27 |
28 | func TestSSHClient(t *testing.T) {
29 | var stdout bytes.Buffer
30 | var stderr bytes.Buffer
31 | client := NewSSHClient("172.16.100.105", "root", "", "/usr/bin/whoami", 22, &stdout, &stderr)
32 | if err := client.Connection(); err != nil {
33 | logrus.Error("init endpoint node error:", err.Error())
34 | return
35 | }
36 | logrus.Info(stdout.String())
37 | }
38 |
--------------------------------------------------------------------------------
/util/string_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 | package util
19 |
20 | import "testing"
21 |
22 | func TestReverse(t *testing.T) {
23 | t.Log(Reverse([]string{"1", "2", "3"}))
24 | t.Log(Reverse([]string{"1", "2", "3", "4"}))
25 | }
26 |
--------------------------------------------------------------------------------
/util/sync/sync_db.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package sync
20 |
21 | //Sync 同步与校验数据库数据
22 | func Sync() {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/util/termtables/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - 1.6
4 | - 1.7
5 | - tip
6 |
7 | script:
8 | - go vet $(go list ./...|grep -v "/vendor/")
9 | - go test -v -race ./...
10 |
--------------------------------------------------------------------------------
/util/termtables/row_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012-2015 Apcera Inc. All rights reserved.
2 |
3 | package termtables
4 |
5 | import (
6 | "testing"
7 | )
8 |
9 | func TestBasicRowRender(t *testing.T) {
10 | row := CreateRow([]interface{}{"foo", "bar"})
11 | style := &renderStyle{TableStyle: TableStyle{BorderX: "-", BorderY: "|", BorderI: "+",
12 | PaddingLeft: 1, PaddingRight: 1}, cellWidths: map[int]int{0: 3, 1: 3}}
13 |
14 | output := row.Render(style)
15 | if output != "| foo | bar |" {
16 | t.Fatal("Unexpected output:", output)
17 | }
18 | }
19 |
20 | func TestRowRenderWidthBasedPadding(t *testing.T) {
21 | row := CreateRow([]interface{}{"foo", "bar"})
22 | style := &renderStyle{TableStyle: TableStyle{BorderX: "-", BorderY: "|", BorderI: "+",
23 | PaddingLeft: 1, PaddingRight: 1}, cellWidths: map[int]int{0: 3, 1: 5}}
24 |
25 | output := row.Render(style)
26 | if output != "| foo | bar |" {
27 | t.Fatal("Unexpected output:", output)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/util/termtables/straight_separator.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Apcera Inc. All rights reserved.
2 |
3 | package termtables
4 |
5 | import (
6 | "strings"
7 | "unicode/utf8"
8 | )
9 |
10 | // A StraightSeparator is a horizontal line with associated information about
11 | // what sort of position it takes in the table, so as to control which shapes
12 | // will be used where vertical lines are expected to touch this horizontal
13 | // line.
14 | type StraightSeparator struct {
15 | where lineType
16 | }
17 |
18 | // Render returns a string representing this separator, with all border
19 | // crossings appropriately chosen.
20 | func (s *StraightSeparator) Render(style *renderStyle) string {
21 | // loop over getting dashes
22 | width := 0
23 | for i := 0; i < style.columns; i++ {
24 | width += style.PaddingLeft + style.CellWidth(i) + style.PaddingRight + utf8.RuneCountInString(style.BorderI)
25 | }
26 |
27 | switch s.where {
28 | case LINE_TOP:
29 | return style.BorderTopLeft + strings.Repeat(style.BorderX, width-1) + style.BorderTopRight
30 | case LINE_INNER, LINE_SUBTOP:
31 | return style.BorderLeft + strings.Repeat(style.BorderX, width-1) + style.BorderRight
32 | case LINE_BOTTOM:
33 | return style.BorderBottomLeft + strings.Repeat(style.BorderX, width-1) + style.BorderBottomRight
34 | }
35 | panic("not reached")
36 | }
37 |
--------------------------------------------------------------------------------
/util/termtables/term/env.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Apcera Inc. All rights reserved.
2 |
3 | package term
4 |
5 | import (
6 | "os"
7 | "strconv"
8 | )
9 |
10 | // GetEnvWindowSize returns the window Size, as determined by process
11 | // environment; if either LINES or COLUMNS is present, and whichever is
12 | // present is also numeric, the Size will be non-nil. If Size is nil,
13 | // there's insufficient data in environ. If one entry is 0, that means
14 | // that the environment does not include that data. If a value is
15 | // negative, we treat that as an error.
16 | func GetEnvWindowSize() *Size {
17 | lines := os.Getenv("LINES")
18 | columns := os.Getenv("COLUMNS")
19 | if lines == "" && columns == "" {
20 | return nil
21 | }
22 |
23 | nLines := 0
24 | nColumns := 0
25 | var err error
26 | if lines != "" {
27 | nLines, err = strconv.Atoi(lines)
28 | if err != nil || nLines < 0 {
29 | return nil
30 | }
31 | }
32 | if columns != "" {
33 | nColumns, err = strconv.Atoi(columns)
34 | if err != nil || nColumns < 0 {
35 | return nil
36 | }
37 | }
38 |
39 | return &Size{
40 | Lines: nLines,
41 | Columns: nColumns,
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/util/termtables/term/getsize.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Apcera Inc. All rights reserved.
2 |
3 | package term
4 |
5 | import (
6 | "os"
7 | )
8 |
9 | // Size is the size of a terminal, expressed in character cells, as Lines and
10 | // Columns. This might come from environment variables or OS-dependent
11 | // resources.
12 | type Size struct {
13 | Lines int
14 | Columns int
15 | }
16 |
17 | // GetSize will return the terminal window size.
18 | //
19 | // We prefer environ $LINES/$COLUMNS, then fall back to tty-held information.
20 | // We do not support use of termcap/terminfo to derive default size information.
21 | func GetSize() (*Size, error) {
22 | envSize := GetEnvWindowSize()
23 | if envSize != nil && envSize.Lines != 0 && envSize.Columns != 0 {
24 | return envSize, nil
25 | }
26 |
27 | fh, err := os.Open("/dev/tty")
28 | if err != nil {
29 | // no tty, no point continuing; we only let the environ
30 | // avoid an error in this case because if someone has faked
31 | // up an environ with LINES/COLUMNS _both_ set, we should let
32 | // them
33 | return nil, err
34 | }
35 |
36 | size, err := GetTerminalWindowSize(fh)
37 | if err != nil {
38 | if envSize != nil {
39 | return envSize, nil
40 | }
41 | return nil, err
42 | }
43 | if envSize == nil {
44 | return size, err
45 | }
46 |
47 | if envSize.Lines == 0 {
48 | envSize.Lines = size.Lines
49 | }
50 | if envSize.Columns == 0 {
51 | envSize.Columns = size.Columns
52 | }
53 | return envSize, nil
54 | }
55 |
--------------------------------------------------------------------------------
/util/termtables/term/sizes_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Apcera Inc. All rights reserved.
2 |
3 | // +build !windows
4 |
5 | package term
6 |
7 | import (
8 | "errors"
9 | "os"
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | // ErrGetWinsizeFailed indicates that the system call to extract the size of
15 | // a Unix tty from the kernel failed.
16 | var ErrGetWinsizeFailed = errors.New("term: syscall.TIOCGWINSZ failed")
17 |
18 | // GetTerminalWindowSize returns the terminal size maintained by the kernel
19 | // for a Unix TTY, passed in as an *os.File. This information can be seen
20 | // with the stty(1) command, and changes in size (eg, terminal emulator
21 | // resized) should trigger a SIGWINCH signal delivery to the foreground process
22 | // group at the time of the change, so a long-running process might reasonably
23 | // watch for SIGWINCH and arrange to re-fetch the size when that happens.
24 | func GetTerminalWindowSize(file *os.File) (*Size, error) {
25 | // Based on source from from golang.org/x/crypto/ssh/terminal/util.go
26 | var dimensions [4]uint16
27 | if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, file.Fd(), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 {
28 | return nil, err
29 | }
30 |
31 | return &Size{
32 | Lines: int(dimensions[0]),
33 | Columns: int(dimensions[1]),
34 | }, nil
35 | }
36 |
--------------------------------------------------------------------------------
/util/termtables/term/sizes_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Apcera Inc. All rights reserved.
2 |
3 | // +build windows
4 |
5 | package term
6 |
7 | // Used when we have no other source for getting platform-specific information
8 | // about the terminal sizes available.
9 |
10 | import (
11 | "os"
12 | "syscall"
13 | "unsafe"
14 | )
15 |
16 | // Based on source from from golang.org/x/crypto/ssh/terminal/util_windows.go
17 | var (
18 | kernel32 = syscall.NewLazyDLL("kernel32.dll")
19 |
20 | procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
21 | )
22 |
23 | type (
24 | short int16
25 | word uint16
26 |
27 | coord struct {
28 | x short
29 | y short
30 | }
31 | smallRect struct {
32 | left short
33 | top short
34 | right short
35 | bottom short
36 | }
37 | consoleScreenBufferInfo struct {
38 | size coord
39 | cursorPosition coord
40 | attributes word
41 | window smallRect
42 | maximumWindowSize coord
43 | }
44 | )
45 |
46 | // GetTerminalWindowSize returns the width and height of a terminal in Windows.
47 | func GetTerminalWindowSize(file *os.File) (*Size, error) {
48 | var info consoleScreenBufferInfo
49 | _, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, file.Fd(), uintptr(unsafe.Pointer(&info)), 0)
50 | if e != 0 {
51 | return nil, error(e)
52 | }
53 | return &Size{
54 | Lines: int(info.size.y),
55 | Columns: int(info.size.x),
56 | }, nil
57 | }
58 |
--------------------------------------------------------------------------------
/util/termtables/term/wrapper.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Apcera Inc. All rights reserved.
2 |
3 | // +build ignore
4 |
5 | package main
6 |
7 | import (
8 | "fmt"
9 | "os"
10 |
11 | "github.com/goodrain/rainbond/util/termtables/term"
12 | )
13 |
14 | func main() {
15 | size, err := term.GetSize()
16 | if err != nil {
17 | fmt.Fprintf(os.Stderr, "failed: %s\n", err)
18 | os.Exit(1)
19 | }
20 |
21 | fmt.Printf("Lines %d Columns %d\n", size.Lines, size.Columns)
22 | }
23 |
--------------------------------------------------------------------------------
/util/uuid.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2014-2018 Goodrain Co., Ltd.
2 | // RAINBOND, Application Management Platform
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import (
22 | "fmt"
23 | "strings"
24 | "time"
25 |
26 | "github.com/twinj/uuid"
27 | )
28 |
29 | //NewUUID 创建无-的32位uuid
30 | func NewUUID() string {
31 | uid := uuid.NewV4().String()
32 | return strings.Replace(uid, "-", "", -1)
33 | }
34 |
35 | //TimeVersion time version
36 | type TimeVersion string
37 |
38 | //NewTimeVersion return version string by time
39 | func NewTimeVersion() TimeVersion {
40 | now := time.Now()
41 | return TimeVersion(fmt.Sprintf("%d", now.UnixNano()))
42 | }
43 |
--------------------------------------------------------------------------------
/util/uuid_test.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import "testing"
22 |
23 | func TestTimeVersion(t *testing.T) {
24 | version := NewTimeVersion()
25 | t.Log(version)
26 | }
27 |
--------------------------------------------------------------------------------
/worker/appm/conversion/common.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package conversion
20 |
21 | import (
22 | "k8s.io/api/core/v1"
23 | )
24 |
25 | func conversionPortProtocol(protocol string) v1.Protocol {
26 | if protocol == "udp" {
27 | return v1.ProtocolUDP
28 | } else if protocol == "sctp" {
29 | return v1.ProtocolSCTP
30 | } else {
31 | return v1.ProtocolTCP
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/worker/appm/conversion/errors.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package conversion
20 |
21 | import "errors"
22 |
23 | //ErrServiceNotFound error not found
24 | var ErrServiceNotFound = errors.New("service not found")
25 |
--------------------------------------------------------------------------------
/worker/appm/store/clean.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package store
20 |
21 | import (
22 | "time"
23 |
24 | "github.com/goodrain/rainbond/util"
25 | )
26 |
27 | //clean clean Possible duplicate resources
28 | func (a *appRuntimeStore) clean() {
29 | util.Exec(a.ctx, func() error {
30 | a.appServices.Range(func(k, v interface{}) bool {
31 | //appservice := v.(*v1.AppService)
32 | //fmt.Println(appservice.String())
33 | return true
34 | })
35 | //logrus.Debugf("app store is cleaned")
36 | return nil
37 | }, time.Second*10)
38 | }
39 |
--------------------------------------------------------------------------------
/worker/master/controller/controller.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2021-2021 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package controller
20 |
21 | import (
22 | "github.com/prometheus/client_golang/prometheus"
23 | "sigs.k8s.io/controller-runtime/pkg/reconcile"
24 | )
25 |
26 | type Controller interface {
27 | reconcile.Reconciler
28 | Collect(ch chan<- prometheus.Metric)
29 | }
30 |
--------------------------------------------------------------------------------
/worker/master/controller/thirdcomponent/prober/results/results_manager_test.go:
--------------------------------------------------------------------------------
1 | package results
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/assert"
7 | )
8 |
9 | func TestCacheOperations(t *testing.T) {
10 | m := NewManager(make(chan Update))
11 |
12 | unsetID := "unset"
13 | setID := "set"
14 |
15 | _, found := m.Get(unsetID)
16 | assert.False(t, found, "unset result found")
17 |
18 | m.Set(setID, Success)
19 | result, found := m.Get(setID)
20 | assert.True(t, result == Success, "set result")
21 | assert.True(t, found, "set result found")
22 |
23 | m.Remove(setID)
24 | _, found = m.Get(setID)
25 | assert.False(t, found, "removed result found")
26 | }
27 |
--------------------------------------------------------------------------------
/worker/master/volumes/sync/sync.go:
--------------------------------------------------------------------------------
1 | package sync
2 |
3 | import (
4 | "github.com/goodrain/rainbond/db"
5 | "github.com/goodrain/rainbond/db/model"
6 | "github.com/sirupsen/logrus"
7 | )
8 |
9 | // VolumeTypeEvent -
10 | type VolumeTypeEvent struct {
11 | vtEventCh chan *model.TenantServiceVolumeType
12 | stopCh chan struct{}
13 | }
14 |
15 | // New -
16 | func New(stopCh chan struct{}) *VolumeTypeEvent {
17 | return &VolumeTypeEvent{
18 | stopCh: stopCh,
19 | vtEventCh: make(chan *model.TenantServiceVolumeType, 100),
20 | }
21 | }
22 |
23 | // GetChan -
24 | func (e *VolumeTypeEvent) GetChan() chan<- *model.TenantServiceVolumeType {
25 | return e.vtEventCh
26 | }
27 |
28 | // Handle -
29 | func (e *VolumeTypeEvent) Handle() {
30 | for {
31 | select {
32 | case <-e.stopCh:
33 | return
34 | case vt := <-e.vtEventCh:
35 | if vt.VolumeType == "local-path" {
36 | vt.NameShow = "本地存储"
37 | }
38 | if _, err := db.GetManager().VolumeTypeDao().CreateOrUpdateVolumeType(vt); err != nil {
39 | logrus.Errorf("sync storageClass error : %s, ignore it", err.Error())
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/worker/server/pb/protoc.sh:
--------------------------------------------------------------------------------
1 | protoc --go_out=plugins=grpc:. *.proto
--------------------------------------------------------------------------------
/worker/util/dns.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "context"
5 | "fmt"
6 |
7 | "github.com/sirupsen/logrus"
8 |
9 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10 |
11 | corev1 "k8s.io/api/core/v1"
12 | "k8s.io/client-go/kubernetes"
13 | )
14 |
15 | func dns2Config(endpoint *corev1.Endpoints, podNamespace string) (podDNSConfig *corev1.PodDNSConfig) {
16 | servers := make([]string, 0)
17 | for _, sub := range endpoint.Subsets {
18 | for _, addr := range sub.Addresses {
19 | servers = append(servers, addr.IP)
20 | }
21 | }
22 | searchRBDDNS := fmt.Sprintf("%s.svc.cluster.local", podNamespace)
23 | ndotsValue := "5"
24 | return &corev1.PodDNSConfig{
25 | Nameservers: servers,
26 | Options: []corev1.PodDNSConfigOption{{Name: "ndots", Value: &ndotsValue}},
27 | Searches: []string{searchRBDDNS, "svc.cluster.local", "cluster.local"},
28 | }
29 | }
30 |
31 | // MakePodDNSConfig make pod dns config
32 | func MakePodDNSConfig(clientset kubernetes.Interface, podNamespace, rbdNamespace, rbdEndpointDNSName string) (podDNSConfig *corev1.PodDNSConfig) {
33 | endpoints, err := clientset.CoreV1().Endpoints(rbdNamespace).Get(context.Background(), rbdEndpointDNSName, metav1.GetOptions{})
34 | if err != nil {
35 | logrus.Warningf("get rbd-dns[namespace: %s, name: %s] endpoints error: %s", rbdNamespace, rbdEndpointDNSName, err.Error())
36 | return nil
37 | }
38 | return dns2Config(endpoints, podNamespace)
39 | }
40 |
--------------------------------------------------------------------------------
/worker/util/thirdparty.go:
--------------------------------------------------------------------------------
1 | // RAINBOND, Application Management Platform
2 | // Copyright (C) 2014-2017 Goodrain Co., Ltd.
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version. For any non-GPL usage of Rainbond,
8 | // one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9 | // must be obtained first.
10 |
11 | // This program is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 |
16 | // You should have received a copy of the GNU General Public License
17 | // along with this program. If not, see .
18 |
19 | package util
20 |
21 | import (
22 | "fmt"
23 | "strings"
24 | )
25 |
26 | // CreateEndpointsName creates name for third-party endpoints
27 | //the names of Kubernetes resources should be up to maximum length of 253
28 | // characters and consist of lower case alphanumeric characters, -, and .,
29 | // but certain resources have more specific restrictions.
30 | func CreateEndpointsName(tenantName, serviceName, uuid string) string {
31 | str := fmt.Sprintf("%s-%s-%s", tenantName, serviceName, uuid)
32 | str = strings.ToLower(str)
33 | // TODO: - and .
34 | return str
35 | }
36 |
--------------------------------------------------------------------------------
/worker/util/volumetype_test.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | dbmodel "github.com/goodrain/rainbond/db/model"
5 | storagev1 "k8s.io/api/storage/v1"
6 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
7 | "testing"
8 | )
9 |
10 | func TestTransStorageClass2RBDVolumeType(t *testing.T) {
11 | type args struct {
12 | sc *storagev1.StorageClass
13 | }
14 | tests := []struct {
15 | name string
16 | args args
17 | want *dbmodel.TenantServiceVolumeType
18 | }{
19 | {
20 | name: "without_annotation",
21 | args: args{sc: &storagev1.StorageClass{
22 | ObjectMeta: v1.ObjectMeta{
23 | Name: "ali-disk-sc",
24 | },
25 | Provisioner: "aaa",
26 | Parameters: map[string]string{},
27 | }},
28 | },
29 | {
30 | name: "with_wrong_annotation",
31 | args: args{sc: &storagev1.StorageClass{
32 | ObjectMeta: v1.ObjectMeta{
33 | Name: "ali-disk-sc",
34 | Annotations: map[string]string{"volume_show": "123"},
35 | },
36 | }},
37 | },
38 | {
39 | name: "with_annotation",
40 | args: args{sc: &storagev1.StorageClass{
41 | ObjectMeta: v1.ObjectMeta{
42 | Name: "ali-disk-sc",
43 | Annotations: map[string]string{"rbd_volume_name": "new-volume-type"},
44 | },
45 | }},
46 | },
47 | }
48 | for _, tt := range tests {
49 | t.Run(tt.name, func(t *testing.T) {
50 | got := TransStorageClass2RBDVolumeType(tt.args.sc)
51 | t.Logf("volume type is : %+v", got)
52 | })
53 | }
54 | }
55 |
--------------------------------------------------------------------------------