├── .chglog ├── CHANGELOG.tpl └── config.yml ├── .dockerignore ├── .github ├── .codecov.yml └── workflows │ ├── codeql.yml │ ├── e2e.yml │ ├── gh-pages.yml │ ├── image-build.yml │ ├── lint.yml │ ├── local-build.yml │ └── test.yml ├── .gitignore ├── .golangci.yml ├── .hadolint.yaml ├── .markdownlint.json ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── Readme_zh.md ├── assets ├── architecture.excalidraw ├── architecture.png ├── sigma-low.png ├── sigma.ai ├── sigma.png ├── sigma.svg ├── title.ai └── title.svg ├── bin └── .gitkeep ├── build ├── all.alpine.Dockerfile ├── all.debian.Dockerfile ├── builder.Dockerfile ├── local.Dockerfile ├── trivy.Dockerfile └── web.Dockerfile ├── cmd ├── builder │ ├── builder.go │ ├── cache.go │ ├── checker.go │ ├── init.go │ └── tag.go ├── distribution.go ├── imports │ ├── apis.go │ ├── builder.go │ ├── cronjob.go │ ├── daemon.go │ ├── distribution.go │ ├── mock.go │ ├── oci.go │ └── storage.go ├── root.go ├── server.go ├── tools.go ├── version.go └── worker.go ├── conf ├── ca.crt ├── ca.key ├── config-compose.yaml ├── config-dev.yaml ├── config-full.yaml ├── config.yaml ├── sigma.test.io.crt └── sigma.test.io.key ├── deploy └── sigma │ ├── .helmignore │ ├── Chart.lock │ ├── Chart.yaml │ ├── templates │ ├── _helpers.tpl │ ├── configmap.yaml │ ├── distribution │ │ ├── deployment.yaml │ │ ├── hpa.yaml │ │ └── service.yaml │ ├── ingress.yaml │ ├── namespace.yaml │ ├── post-job.yaml │ ├── sercret.yaml │ ├── server │ │ ├── deployment.yaml │ │ ├── hpa.yaml │ │ └── service.yaml │ ├── serviceaccount.yaml │ ├── web │ │ ├── deployment.yaml │ │ ├── hpa.yaml │ │ └── service.yaml │ └── worker │ │ ├── deployment.yaml │ │ ├── hpa.yaml │ │ └── service.yaml │ └── values.yaml ├── docker-compose.yml ├── docs ├── .gitignore ├── .yarnrc.yml ├── babel.config.js ├── blog │ ├── 2023-12-26-introduction.mdx │ └── authors.yml ├── docs │ ├── configuration.mdx │ ├── cosign.mdx │ ├── push │ │ ├── apptainer.mdx │ │ ├── docker.mdx │ │ └── helm.mdx │ ├── quickstart.mdx │ └── sigma.mdx ├── docusaurus.config.js ├── i18n │ └── zh │ │ ├── code.json │ │ ├── docusaurus-plugin-content-blog │ │ ├── 2023-12-26-introduction.mdx │ │ ├── authors.yml │ │ └── options.json │ │ ├── docusaurus-plugin-content-docs │ │ └── current.json │ │ └── docusaurus-theme-classic │ │ └── navbar.json ├── package.json ├── sidebars.js ├── src │ ├── components │ │ ├── Hero │ │ │ └── index.tsx │ │ └── Typed │ │ │ └── index.tsx │ ├── css │ │ └── custom.scss │ ├── pages │ │ ├── index.tsx │ │ └── markdown-page.md │ └── svg │ │ ├── AWS │ │ └── index.tsx │ │ ├── Apple │ │ └── index.tsx │ │ ├── ArrowRight │ │ └── index.tsx │ │ ├── Azure │ │ └── index.tsx │ │ ├── CSharp │ │ └── index.tsx │ │ ├── Close │ │ └── index.tsx │ │ ├── CloudRun │ │ ├── google-cloud-run.svg │ │ └── index.tsx │ │ ├── Create │ │ └── index.tsx │ │ ├── CreateBg │ │ └── index.tsx │ │ ├── Datadog │ │ └── index.tsx │ │ ├── Deno │ │ └── index.tsx │ │ ├── Develop │ │ └── index.tsx │ │ ├── DevelopBg │ │ └── index.tsx │ │ ├── Docker │ │ └── index.tsx │ │ ├── Dots │ │ └── index.tsx │ │ ├── Explore │ │ └── index.tsx │ │ ├── ExploreBg │ │ └── index.tsx │ │ ├── GCP │ │ └── index.tsx │ │ ├── Go │ │ └── index.tsx │ │ ├── Grafana │ │ └── index.tsx │ │ ├── Hamburger │ │ └── index.tsx │ │ ├── Hero │ │ └── index.tsx │ │ ├── Heroku │ │ └── index.tsx │ │ ├── Java │ │ └── index.tsx │ │ ├── Jenkins │ │ └── index.tsx │ │ ├── Kubernetes │ │ └── index.tsx │ │ ├── Launchpad │ │ ├── index.tsx │ │ ├── launchpad-promo.png │ │ └── launchpad.svg │ │ ├── Linux │ │ └── index.tsx │ │ ├── Netlify │ │ └── index.tsx │ │ ├── Node │ │ └── index.tsx │ │ ├── Nodejs │ │ └── index.tsx │ │ ├── Operate │ │ └── index.tsx │ │ ├── OperateBg │ │ └── index.tsx │ │ ├── Php │ │ └── index.tsx │ │ ├── Python │ │ └── index.tsx │ │ ├── Rectangles │ │ └── index.tsx │ │ ├── Ruby │ │ └── index.tsx │ │ ├── Shape │ │ └── index.tsx │ │ ├── Vercel │ │ └── index.tsx │ │ └── Windows │ │ └── index.tsx ├── static │ ├── .nojekyll │ └── img │ │ ├── favicon.svg │ │ ├── header.jpg │ │ ├── logo.svg │ │ ├── undraw_docusaurus_mountain.svg │ │ ├── undraw_docusaurus_react.svg │ │ └── undraw_docusaurus_tree.svg ├── tsconfig.json └── yarn.lock ├── e2e ├── multiarch │ ├── alpine.Dockerfile │ ├── buildkit.toml │ ├── cosign.key │ ├── cosign.pub │ └── push.sh ├── push.sh └── sc.js ├── go.mod ├── go.sum ├── main.go ├── pkg ├── auth │ ├── artifact.go │ ├── auth.go │ ├── auth_test.go │ ├── mocks │ │ ├── service.go │ │ └── service_factory.go │ ├── namespace.go │ ├── repository.go │ └── tag.go ├── builder │ ├── builder.go │ ├── builder_test.go │ ├── docker │ │ ├── docker.go │ │ ├── docker_test.go │ │ └── informer.go │ ├── kubernetes │ │ ├── informer.go │ │ └── k8s.go │ ├── logger │ │ ├── database │ │ │ └── database.go │ │ ├── logger.go │ │ └── obs │ │ │ └── obs.go │ └── podman │ │ └── podman.go ├── cmds │ ├── distribution │ │ └── distribution.go │ ├── helper.go │ ├── server │ │ └── server.go │ └── worker │ │ └── worker.go ├── configs │ ├── configs.go │ ├── configs_test.go │ ├── configuration.go │ ├── default.go │ ├── default_test.go │ ├── middleware.go │ └── middleware_test.go ├── consts │ ├── consts.go │ ├── regex.go │ └── setting.go ├── cronjob │ ├── builder │ │ └── builder.go │ └── cronjob.go ├── daemon │ ├── builder │ │ └── builder.go │ ├── coderepo │ │ ├── coderepo.go │ │ ├── diff.go │ │ ├── gitea.go │ │ ├── github.go │ │ └── gitlab.go │ ├── gc │ │ ├── decorator.go │ │ ├── gc_artifact.go │ │ ├── gc_artifact_test.go │ │ ├── gc_blob.go │ │ ├── gc_blob_test.go │ │ ├── gc_repository.go │ │ ├── gc_repository_test.go │ │ ├── gc_tag.go │ │ ├── gc_tag_test.go │ │ └── testdata │ │ │ ├── gc_artifact_normal.mysql.sql │ │ │ ├── gc_artifact_normal.postgresql.sql │ │ │ ├── gc_artifact_normal.sqlite3.sql │ │ │ ├── gc_blob_normal.mysql.sql │ │ │ ├── gc_blob_normal.postgresql.sql │ │ │ └── gc_blob_normal.sqlite3.sql │ ├── pushed │ │ ├── artifact.go │ │ └── tag.go │ ├── scan │ │ ├── decorator.go │ │ ├── sbom.go │ │ └── vulnerability.go │ ├── transfer │ │ └── transfer.go │ └── webhook │ │ ├── helper.go │ │ └── webhook.go ├── dal │ ├── auth.go │ ├── auth_test.go │ ├── badger │ │ └── badger.go │ ├── cmd │ │ └── gen.go │ ├── dal.go │ ├── dal_test.go │ ├── dao │ │ ├── artifact.go │ │ ├── artifact_test.go │ │ ├── audit.go │ │ ├── audit_test.go │ │ ├── blob.go │ │ ├── blob_test.go │ │ ├── blobupload.go │ │ ├── blobupload_test.go │ │ ├── builder.go │ │ ├── builder_test.go │ │ ├── code_repository.go │ │ ├── code_repository_test.go │ │ ├── daemon.go │ │ ├── daemon_test.go │ │ ├── helper_test.go │ │ ├── mocks │ │ │ ├── artifact.go │ │ │ ├── artifact_factory.go │ │ │ ├── audit.go │ │ │ ├── audit_factory.go │ │ │ ├── blob.go │ │ │ ├── blob_factory.go │ │ │ ├── blobupload.go │ │ │ ├── blobupload_factory.go │ │ │ ├── builder.go │ │ │ ├── builder_factory.go │ │ │ ├── code_repository.go │ │ │ ├── code_repository_factory.go │ │ │ ├── daemon.go │ │ │ ├── daemon_factory.go │ │ │ ├── namespace.go │ │ │ ├── namespace_factory.go │ │ │ ├── namespace_member.go │ │ │ ├── namespace_member_factory.go │ │ │ ├── repository.go │ │ │ ├── repository_factory.go │ │ │ ├── setting.go │ │ │ ├── setting_factory.go │ │ │ ├── tag.go │ │ │ ├── tag_factory.go │ │ │ ├── user.go │ │ │ ├── user_factory.go │ │ │ ├── webhook.go │ │ │ ├── webhook_factory.go │ │ │ ├── workq.go │ │ │ └── workq_factory.go │ │ ├── namespace.go │ │ ├── namespace_member.go │ │ ├── namespace_test.go │ │ ├── option.go │ │ ├── repository.go │ │ ├── repository_test.go │ │ ├── setting.go │ │ ├── setting_test.go │ │ ├── tag.go │ │ ├── tag_test.go │ │ ├── user.go │ │ ├── user_test.go │ │ ├── webhook.go │ │ ├── webhook_test.go │ │ ├── workq.go │ │ └── workq_test.go │ ├── dig.go │ ├── migrate.go │ ├── migrations │ │ ├── mysql │ │ │ ├── 0001_initialize.down.sql │ │ │ ├── 0001_initialize.up.sql │ │ │ ├── 0002_upgrade.down.sql │ │ │ ├── 0002_upgrade.up.sql │ │ │ ├── 0003_upgrade.down.sql │ │ │ ├── 0003_upgrade.up.sql │ │ │ └── 0004_upgrade.down.sql │ │ ├── postgresql │ │ │ ├── 0001_initialize.down.sql │ │ │ ├── 0001_initialize.up.sql │ │ │ ├── 0002_upgrade.down.sql │ │ │ ├── 0002_upgrade.up.sql │ │ │ ├── 0003_upgrade.down.sql │ │ │ └── 0003_upgrade.up.sql │ │ └── sqlite3 │ │ │ ├── 0001_initialize.down.sql │ │ │ ├── 0001_initialize.up.sql │ │ │ ├── 0002_upgrade.down.sql │ │ │ ├── 0002_upgrade.up.sql │ │ │ ├── 0003_upgrade.down.sql │ │ │ └── 0003_upgrade.up.sql │ ├── models │ │ ├── artifact.go │ │ ├── audit.go │ │ ├── auth.go │ │ ├── blob.go │ │ ├── blob_upload.go │ │ ├── builder.go │ │ ├── code_repository.go │ │ ├── daemon.go │ │ ├── locker.go │ │ ├── namespace.go │ │ ├── namespace_member.go │ │ ├── repository.go │ │ ├── setting.go │ │ ├── tag.go │ │ ├── user.go │ │ ├── webhook.go │ │ └── workq.go │ ├── query │ │ ├── artifact_sboms.gen.go │ │ ├── artifact_vulnerabilities.gen.go │ │ ├── artifacts.gen.go │ │ ├── audits.gen.go │ │ ├── blob_uploads.gen.go │ │ ├── blobs.gen.go │ │ ├── builder_runners.gen.go │ │ ├── builders.gen.go │ │ ├── casbin_rules.gen.go │ │ ├── code_repositories.gen.go │ │ ├── code_repository_branches.gen.go │ │ ├── code_repository_clone_credentials.gen.go │ │ ├── code_repository_owners.gen.go │ │ ├── daemon_gc_artifact_records.gen.go │ │ ├── daemon_gc_artifact_rules.gen.go │ │ ├── daemon_gc_artifact_runners.gen.go │ │ ├── daemon_gc_blob_records.gen.go │ │ ├── daemon_gc_blob_rules.gen.go │ │ ├── daemon_gc_blob_runners.gen.go │ │ ├── daemon_gc_repository_records.gen.go │ │ ├── daemon_gc_repository_rules.gen.go │ │ ├── daemon_gc_repository_runners.gen.go │ │ ├── daemon_gc_tag_records.gen.go │ │ ├── daemon_gc_tag_rules.gen.go │ │ ├── daemon_gc_tag_runners.gen.go │ │ ├── gen.go │ │ ├── namespace_members.gen.go │ │ ├── namespaces.gen.go │ │ ├── repositories.gen.go │ │ ├── settings.gen.go │ │ ├── tags.gen.go │ │ ├── user_3rdparty.gen.go │ │ ├── user_recover_codes.gen.go │ │ ├── users.gen.go │ │ ├── webhook_logs.gen.go │ │ ├── webhooks.gen.go │ │ └── work_queues.gen.go │ ├── redis │ │ ├── redis.go │ │ └── redis_test.go │ └── retry.go ├── graceful │ ├── graceful.go │ └── graceful_test.go ├── inits │ ├── dig.go │ ├── inits.go │ ├── inits_test.go │ ├── signing.go │ ├── signing_test.go │ ├── user.go │ └── user_test.go ├── logger │ ├── glog.go │ ├── glog_test.go │ ├── logger.go │ └── logger_test.go ├── modules │ ├── cacher │ │ ├── badger │ │ │ └── badger.go │ │ ├── cacher.go │ │ ├── definition │ │ │ └── definition.go │ │ ├── inmemory │ │ │ ├── inmemory.go │ │ │ └── inmemory_test.go │ │ └── redis │ │ │ └── redis.go │ ├── locker │ │ ├── badger │ │ │ ├── badger.go │ │ │ └── badger_test.go │ │ ├── definition │ │ │ ├── definition.go │ │ │ └── mocks │ │ │ │ ├── lock.go │ │ │ │ └── locker.go │ │ ├── locker.go │ │ └── redis │ │ │ ├── redis.go │ │ │ └── redis_test.go │ ├── timewheel │ │ ├── timewheel.go │ │ └── timewheel_test.go │ └── workq │ │ ├── database │ │ ├── consumer.go │ │ └── producer.go │ │ ├── definition │ │ ├── definition.go │ │ └── mocks │ │ │ └── workq.go │ │ ├── inmemory │ │ ├── consumer.go │ │ ├── consumer_test.go │ │ ├── producer.go │ │ └── producer_test.go │ │ ├── kafka │ │ ├── config.go │ │ ├── consumer.go │ │ └── producer.go │ │ ├── redis │ │ ├── consumer.go │ │ ├── producer.go │ │ └── redis.go │ │ └── workq.go ├── server │ ├── handlers │ │ ├── apidocs │ │ │ ├── docs.go │ │ │ ├── swagger.json │ │ │ └── swagger.yaml │ │ ├── artifacts │ │ │ ├── artifacts_delete.go │ │ │ ├── artifacts_delete_test.go │ │ │ ├── artifacts_get.go │ │ │ ├── artifacts_get_test.go │ │ │ ├── artifacts_list.go │ │ │ ├── artifacts_list_test.go │ │ │ ├── handler.go │ │ │ └── handler_test.go │ │ ├── builders │ │ │ ├── builders_create.go │ │ │ ├── builders_runner_get.go │ │ │ ├── builders_runners_list.go │ │ │ ├── builders_runners_log.go │ │ │ ├── builders_runners_rerun.go │ │ │ ├── builders_runners_run.go │ │ │ ├── builders_runners_stop.go │ │ │ ├── builders_update.go │ │ │ ├── handler.go │ │ │ └── handler_test.go │ │ ├── caches │ │ │ ├── caches_create.go │ │ │ ├── caches_delete.go │ │ │ ├── caches_get.go │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ └── helper.go │ │ ├── coderepos │ │ │ ├── coderepos_branch.go │ │ │ ├── coderepos_branches.go │ │ │ ├── coderepos_get.go │ │ │ ├── coderepos_list.go │ │ │ ├── coderepos_owners_list.go │ │ │ ├── coderepos_providers.go │ │ │ ├── coderepos_resync.go │ │ │ ├── coderepos_user3rdparty.go │ │ │ ├── handler.go │ │ │ └── handler_test.go │ │ ├── daemons │ │ │ ├── daemons_gc_artifact.go │ │ │ ├── daemons_gc_blob.go │ │ │ ├── daemons_gc_repository.go │ │ │ ├── daemons_gc_tags.go │ │ │ ├── handler.go │ │ │ └── handler_test.go │ │ ├── distribution │ │ │ ├── base │ │ │ │ ├── handler.go │ │ │ │ ├── handler_test.go │ │ │ │ ├── healthy_get.go │ │ │ │ ├── healthy_get_test.go │ │ │ │ ├── repository_list.go │ │ │ │ ├── repository_list_test.go │ │ │ │ ├── tags_list.go │ │ │ │ └── tags_list_test.go │ │ │ ├── blob │ │ │ │ ├── blob_delete.go │ │ │ │ ├── blob_delete_test.go │ │ │ │ ├── blob_get.go │ │ │ │ ├── blob_head.go │ │ │ │ ├── blob_head_test.go │ │ │ │ ├── handler.go │ │ │ │ └── handler_test.go │ │ │ ├── clients │ │ │ │ ├── blobs.go │ │ │ │ ├── blobs_test.go │ │ │ │ ├── clients.go │ │ │ │ ├── clients_test.go │ │ │ │ ├── doc.go │ │ │ │ ├── manifest.go │ │ │ │ ├── manifest_test.go │ │ │ │ └── mocks │ │ │ │ │ ├── clients.go │ │ │ │ │ └── clients_factory.go │ │ │ ├── distribution.go │ │ │ ├── distribution_test.go │ │ │ ├── manifest │ │ │ │ ├── handler.go │ │ │ │ ├── handler_test.go │ │ │ │ ├── helper.go │ │ │ │ ├── helper_test.go │ │ │ │ ├── manifest_delete.go │ │ │ │ ├── manifest_delete_test.go │ │ │ │ ├── manifest_fallback.go │ │ │ │ ├── manifest_fallback_test.go │ │ │ │ ├── manifest_get.go │ │ │ │ ├── manifest_get_test.go │ │ │ │ ├── manifest_head.go │ │ │ │ ├── manifest_head_test.go │ │ │ │ ├── manifest_put.go │ │ │ │ ├── manifest_put_test.go │ │ │ │ └── manifest_referrer_get.go │ │ │ └── upload │ │ │ │ ├── handler.go │ │ │ │ ├── handler_test.go │ │ │ │ ├── upload_delete.go │ │ │ │ ├── upload_get.go │ │ │ │ ├── upload_patch.go │ │ │ │ ├── upload_post.go │ │ │ │ └── upload_put.go │ │ ├── handlers.go │ │ ├── handlers_test.go │ │ ├── namespaces │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── namespaces_create.go │ │ │ ├── namespaces_create_test.go │ │ │ ├── namespaces_delete.go │ │ │ ├── namespaces_delete_test.go │ │ │ ├── namespaces_get.go │ │ │ ├── namespaces_get_test.go │ │ │ ├── namespaces_list.go │ │ │ ├── namespaces_list_hot.go │ │ │ ├── namespaces_list_test.go │ │ │ ├── namespaces_members_add.go │ │ │ ├── namespaces_members_delete.go │ │ │ ├── namespaces_members_list.go │ │ │ ├── namespaces_members_self.go │ │ │ ├── namespaces_members_update.go │ │ │ ├── namespaces_update.go │ │ │ └── namespaces_update_test.go │ │ ├── oauth2 │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── oauth2_callback.go │ │ │ ├── oauth2_clientid.go │ │ │ ├── oauth2_clientid_test.go │ │ │ └── oauth2_redirect_callback.go │ │ ├── repositories │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── repositories_create.go │ │ │ ├── repositories_create_test.go │ │ │ ├── repositories_delete.go │ │ │ ├── repositories_delete_test.go │ │ │ ├── repositories_get.go │ │ │ ├── repositories_get_test.go │ │ │ ├── repositories_list.go │ │ │ ├── repositories_list_test.go │ │ │ ├── repositories_update.go │ │ │ └── repositories_update_test.go │ │ ├── systems │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── systems_config_get.go │ │ │ ├── systems_config_get_test.go │ │ │ ├── systems_endpoint_get.go │ │ │ ├── systems_endpoint_get_test.go │ │ │ ├── systems_version_get.go │ │ │ └── systems_version_get_test.go │ │ ├── tags │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── tags_delete.go │ │ │ ├── tags_delete_test.go │ │ │ ├── tags_get.go │ │ │ ├── tags_get_test.go │ │ │ ├── tags_list.go │ │ │ └── tags_list_test.go │ │ ├── tokens │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── tokens.go │ │ │ └── tokens_test.go │ │ ├── users │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── users_list.go │ │ │ ├── users_login.go │ │ │ ├── users_login_test.go │ │ │ ├── users_logout.go │ │ │ ├── users_logout_test.go │ │ │ ├── users_post.go │ │ │ ├── users_put.go │ │ │ ├── users_recover_password.go │ │ │ ├── users_recover_reset_password.go │ │ │ ├── users_reset_passsword.go │ │ │ ├── users_self_get.go │ │ │ ├── users_self_put.go │ │ │ ├── users_self_reset_password.go │ │ │ ├── users_signup.go │ │ │ └── users_signup_test.go │ │ ├── validators │ │ │ ├── handler.go │ │ │ ├── validators_cron.go │ │ │ ├── validators_password.go │ │ │ ├── validators_reference.go │ │ │ ├── validators_regexp.go │ │ │ └── validators_tag.go │ │ └── webhooks │ │ │ ├── handler.go │ │ │ ├── handler_test.go │ │ │ ├── webhooks_create.go │ │ │ ├── webhooks_delete.go │ │ │ ├── webhooks_get.go │ │ │ ├── webhooks_list.go │ │ │ ├── webhooks_log_delete.go │ │ │ ├── webhooks_log_get.go │ │ │ ├── webhooks_log_list.go │ │ │ ├── webhooks_log_resend.go │ │ │ ├── webhooks_ping.go │ │ │ └── webhooks_put.go │ ├── middlewares │ │ ├── authn │ │ │ ├── authn.go │ │ │ └── authn_test.go │ │ ├── authz │ │ │ └── authz.go │ │ ├── etag │ │ │ ├── etag.go │ │ │ └── etag_test.go │ │ ├── extractor │ │ │ ├── extractor.go │ │ │ └── extractor_test.go │ │ ├── healthz │ │ │ ├── healthz.go │ │ │ └── healthz_test.go │ │ └── redirect_repository.go │ └── validators │ │ ├── validators.go │ │ └── validators_test.go ├── signing │ ├── cosign │ │ ├── sign │ │ │ └── sign.go │ │ └── verify │ │ │ └── verify.go │ ├── definition │ │ ├── definition.go │ │ └── mocks │ │ │ ├── signing.go │ │ │ └── verifying.go │ └── signing.go ├── storage │ ├── cos │ │ ├── cos.go │ │ └── cos_test.go │ ├── filesystem │ │ ├── filesystem.go │ │ ├── filesystem_test.go │ │ └── test │ │ │ └── storage │ │ │ ├── unit-test-2 │ │ │ └── unit-test-path.fake │ ├── mocks │ │ ├── storage_driver.go │ │ └── storage_driver_factory.go │ ├── oss │ │ ├── oss.go │ │ └── oss_test.go │ ├── s3 │ │ ├── s3.go │ │ └── s3_test.go │ ├── storage.go │ └── storage_test.go ├── tests │ ├── config.go │ ├── echo.go │ ├── middleware.go │ ├── middleware_mysql.go │ ├── middleware_postgresql.go │ └── middleware_sqlite3.go ├── types │ ├── artifact.go │ ├── builder.go │ ├── cache.go │ ├── coderepos.go │ ├── common.go │ ├── daemon.go │ ├── enums │ │ ├── enums.go │ │ └── enums_enum.go │ ├── namespace.go │ ├── oauth2.go │ ├── repository.go │ ├── system.go │ ├── tag.go │ ├── user.go │ ├── validator.go │ └── webhook.go ├── utils │ ├── challenge │ │ ├── addr.go │ │ ├── authchallenge.go │ │ └── authchallenge_test.go │ ├── compress │ │ ├── compress.go │ │ ├── compress_test.go │ │ └── test.txt │ ├── counter │ │ ├── counter.go │ │ └── counter_test.go │ ├── crypt │ │ ├── crypt.go │ │ └── crypt_test.go │ ├── hash │ │ ├── ci.txt │ │ ├── doc.go │ │ ├── hash.go │ │ └── hash_test.go │ ├── imagerefs │ │ ├── README.md │ │ ├── reference.go │ │ └── reference_test.go │ ├── password │ │ ├── mocks │ │ │ └── password.go │ │ ├── password.go │ │ └── password_test.go │ ├── ptr │ │ ├── README.md │ │ ├── ptr.go │ │ └── ptr_test.go │ ├── reader │ │ ├── limit.go │ │ └── limit_test.go │ ├── serializer │ │ ├── serializer.go │ │ └── serializer_test.go │ ├── token │ │ ├── mocks │ │ │ └── token.go │ │ ├── token.go │ │ └── token_test.go │ ├── utils.go │ └── utils_test.go ├── version │ └── version.go └── xerrors │ ├── distribution.go │ ├── distribution_test.go │ ├── type.go │ ├── xerrors.go │ └── xerrors_test.go ├── scripts ├── run_all.sh ├── run_minio.sh ├── run_mysql.sh ├── run_postgres.sh └── run_redis.sh └── web ├── .yarnrc.yml ├── index.html ├── package.json ├── postcss.config.cjs ├── public ├── distros │ ├── alma.png │ ├── alpine.png │ ├── antix.png │ ├── arch.png │ ├── bunsenlabs.png │ ├── centos.png │ ├── clear.png │ ├── debian.png │ ├── deepin.png │ ├── elementary.png │ ├── endless.png │ ├── fedora.png │ ├── gentoo.png │ ├── kali.png │ ├── kaos.png │ ├── kubuntu.png │ ├── lite.png │ ├── mabox.png │ ├── manjaro.png │ ├── mint.png │ ├── nixos.png │ ├── pop.png │ ├── raspios.png │ ├── redhat.png │ ├── suse.png │ ├── ubuntu.png │ ├── void.png │ ├── windows.png │ ├── xubuntu.png │ └── zorin.png ├── sigma.svg └── title.svg ├── src ├── App.css ├── App.tsx ├── Settings.ts ├── components │ ├── Footer │ │ └── index.tsx │ ├── Header │ │ └── index.tsx │ ├── Menu │ │ ├── TableItemDropdown │ │ │ ├── index.css │ │ │ └── index.tsx │ │ └── index.tsx │ ├── Notification │ │ ├── index.css │ │ └── index.tsx │ ├── OrderHeader │ │ └── index.tsx │ ├── Pagination │ │ └── index.tsx │ ├── Quota │ │ └── index.tsx │ ├── QuotaSimple │ │ └── index.tsx │ └── svg │ │ ├── docker.tsx │ │ ├── helm.tsx │ │ └── sigma.tsx ├── index.css ├── interfaces │ ├── enums.ts │ └── index.ts ├── main.tsx ├── pages │ ├── Builder │ │ ├── RunnerList.tsx │ │ ├── RunnerLog.tsx │ │ └── Setup.tsx │ ├── CodeRepository │ │ ├── List.tsx │ │ └── index.tsx │ ├── DaemonTask │ │ ├── Records.tsx │ │ ├── Runners.tsx │ │ └── Tasks.tsx │ ├── Home │ │ └── index.tsx │ ├── Login │ │ ├── Callback.tsx │ │ ├── index.css │ │ └── index.tsx │ ├── Namespace │ │ ├── Member.tsx │ │ ├── Summary.tsx │ │ ├── index.css │ │ └── index.tsx │ ├── Repository │ │ ├── Summary.tsx │ │ ├── index.css │ │ └── index.tsx │ ├── Setting │ │ ├── Users.tsx │ │ └── index.tsx │ ├── Tag │ │ └── index.tsx │ └── Webhook │ │ ├── List.tsx │ │ └── Log.tsx ├── stores │ └── index.tsx ├── utils │ ├── calcUnit.ts │ ├── distros.ts │ ├── index.ts │ ├── refreshToken.ts │ ├── regex.ts │ └── request.ts └── vite-env.d.ts ├── tailwind.config.cjs ├── tsconfig.json ├── tsconfig.node.json ├── vite.config.ts ├── web.go └── yarn.lock /.chglog/CHANGELOG.tpl: -------------------------------------------------------------------------------- 1 | {{ range .Versions }} 2 | 3 | ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) 4 | 5 | {{ range .CommitGroups -}} 6 | ### {{ .Title }} 7 | 8 | {{ range .Commits -}} 9 | * {{ .Subject }} 10 | {{ end }} 11 | {{ end -}} 12 | 13 | {{- if .RevertCommits -}} 14 | ### Reverts 15 | 16 | {{ range .RevertCommits -}} 17 | * {{ .Revert.Header }} 18 | {{ end }} 19 | {{ end -}} 20 | 21 | {{- if .MergeCommits -}} 22 | ### Pull Requests 23 | 24 | {{ range .MergeCommits -}} 25 | * {{ .Header }} 26 | {{ end }} 27 | {{ end -}} 28 | 29 | {{- if .NoteGroups -}} 30 | {{ range .NoteGroups -}} 31 | ### {{ .Title }} 32 | 33 | {{ range .Notes }} 34 | {{ .Body }} 35 | {{ end }} 36 | {{ end -}} 37 | {{ end -}} 38 | {{ end -}} -------------------------------------------------------------------------------- /.chglog/config.yml: -------------------------------------------------------------------------------- 1 | style: github 2 | template: CHANGELOG.tpl 3 | info: 4 | title: CHANGELOG 5 | repository_url: https://github.com/go-sigma/sigma 6 | options: 7 | commits: 8 | filters: 9 | Type: 10 | - sparkles 11 | - bug 12 | - zap 13 | - recycle 14 | - pencil 15 | - arrow_up 16 | - green_heart 17 | - white_check_mark 18 | commit_groups: 19 | group_by: Type 20 | sort_by: Custom 21 | title_order: 22 | - sparkles 23 | - bug 24 | - zap 25 | - recycle 26 | - pencil 27 | - arrow_up 28 | - green_heart 29 | - white_check_mark 30 | title_maps: 31 | sparkles: Features 32 | bug: Bug Fixes 33 | zap: Performance Improvements 34 | recycle: Code Refactoring 35 | pencil: Docs 36 | arrow_up: Upgrade 37 | green_heart: CI 38 | white_check_mark: Unit Tests 39 | header: 40 | pattern: "^:(\\w*)\\:\\s(.*)$" 41 | pattern_maps: 42 | - Type 43 | - Subject 44 | notes: 45 | keywords: 46 | - BREAKING CHANGE 47 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | web/dist/ 3 | web/node_modules/ 4 | .github/ 5 | deploy/ 6 | docs/ 7 | e2e/ 8 | scripts/ 9 | assets/ 10 | -------------------------------------------------------------------------------- /.github/.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: "30...100" 5 | status: 6 | patch: 7 | default: 8 | threshold: 4% 9 | project: 10 | default: 11 | threshold: 4% 12 | ignore: 13 | - "./main.go" 14 | - "./web/" 15 | - "./cmd/" 16 | - "./pkg/cmds/" 17 | - "./pkg/tests/" 18 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - gh-readonly-queue/main/* 8 | - release-* 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: "0 0 * * *" 14 | 15 | jobs: 16 | analyze: 17 | name: analyze (${{ matrix.language }}) 18 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 19 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 20 | permissions: 21 | security-events: write 22 | 23 | strategy: 24 | fail-fast: false 25 | matrix: 26 | include: 27 | - language: go 28 | build-mode: manual 29 | steps: 30 | - name: Checkout repository 31 | uses: actions/checkout@v4 32 | with: 33 | fetch-depth: 0 34 | lfs: true 35 | - name: Initialize CodeQL 36 | uses: github/codeql-action/init@v3 37 | with: 38 | languages: ${{ matrix.language }} 39 | build-mode: ${{ matrix.build-mode }} 40 | - run: corepack enable 41 | - if: matrix.language == 'go' 42 | run: | 43 | cd web 44 | yarn install --immutable 45 | yarn build 46 | cd .. 47 | make build 48 | - name: Perform CodeQL Analysis 49 | uses: github/codeql-action/analyze@v3 50 | with: 51 | category: "/language:${{matrix.language}}" 52 | -------------------------------------------------------------------------------- /.github/workflows/local-build.yml: -------------------------------------------------------------------------------- 1 | name: Build CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - gh-readonly-queue/main/* 8 | pull_request: 9 | branches: 10 | - main 11 | 12 | jobs: 13 | local-build: 14 | name: local-build 15 | runs-on: ubuntu-22.04 16 | strategy: 17 | matrix: 18 | go: ["1.23"] 19 | node: ["20"] 20 | steps: 21 | - name: Checkout branch 22 | uses: actions/checkout@v4 23 | with: 24 | fetch-depth: 0 25 | lfs: true 26 | - name: Setup golang 27 | uses: actions/setup-go@v5 28 | with: 29 | go-version: ${{ matrix.go }} 30 | - run: corepack enable 31 | - name: Setup node 32 | uses: actions/setup-node@v4 33 | with: 34 | node-version: ${{ matrix.node }} 35 | cache: "yarn" 36 | cache-dependency-path: "web/yarn.lock" 37 | - name: Build server 38 | run: | 39 | cd web 40 | yarn install --immutable 41 | yarn build 42 | cd .. 43 | make build 44 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | go: "1.23" 3 | 4 | linters: 5 | enable: 6 | - cyclop 7 | - copyloopvar 8 | - gocritic 9 | - gosec 10 | - ineffassign 11 | - misspell 12 | - prealloc 13 | - unconvert 14 | - unparam 15 | - goimports 16 | - whitespace 17 | - gci 18 | - misspell 19 | - bidichk 20 | - unparam 21 | - unused 22 | - varnamelen 23 | - whitespace 24 | - asciicheck 25 | - bodyclose 26 | 27 | linters-settings: 28 | whitespace: 29 | multi-func: true 30 | cyclop: 31 | max-complexity: 50 32 | package-average: 50 33 | skip-tests: true 34 | gci: 35 | sections: 36 | - standard 37 | - blank 38 | - default 39 | - prefix(github.com/go-sigma/sigma) 40 | - dot 41 | varnamelen: 42 | max-distance: 6 43 | min-name-length: 1 44 | -------------------------------------------------------------------------------- /.hadolint.yaml: -------------------------------------------------------------------------------- 1 | ignored: 2 | - DL3018 3 | - DL4006 4 | - DL3003 5 | - SC2046 6 | - DL3047 7 | - DL3008 8 | - SC2155 9 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "no-inline-html": { 3 | "allowed_elements": [ 4 | "details", 5 | "summary", 6 | "strong", 7 | "p", 8 | "code", 9 | "em", 10 | "img", 11 | "pre", 12 | "ul", 13 | "li", 14 | "a", 15 | "sup", 16 | "b" 17 | ] 18 | }, 19 | "MD013": false, 20 | "MD033": false, 21 | "MD010": false, 22 | "MD041": false, 23 | "MD024": false, 24 | "MD022": false, 25 | "MD012": false 26 | } 27 | -------------------------------------------------------------------------------- /assets/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/assets/architecture.png -------------------------------------------------------------------------------- /assets/sigma-low.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/assets/sigma-low.png -------------------------------------------------------------------------------- /assets/sigma.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/assets/sigma.ai -------------------------------------------------------------------------------- /assets/sigma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/assets/sigma.png -------------------------------------------------------------------------------- /assets/sigma.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /assets/title.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/assets/title.ai -------------------------------------------------------------------------------- /bin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/bin/.gitkeep -------------------------------------------------------------------------------- /build/trivy.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VERSION=3.19 2 | 3 | FROM alpine:${ALPINE_VERSION} AS trivy 4 | 5 | ARG USE_MIRROR=false 6 | ARG WITH_TRIVY_DB=false 7 | ARG TRIVY_VERSION=0.55.2 8 | ARG TARGETOS TARGETARCH 9 | 10 | RUN set -eux && \ 11 | if [ "$USE_MIRROR" = true ]; then sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories; fi && \ 12 | apk add --no-cache wget && \ 13 | case "${TARGETARCH}" in \ 14 | amd64) export TRIVYARCH='64bit' ;; \ 15 | arm64) export TRIVYARCH='ARM64' ;; \ 16 | esac; \ 17 | export TRIVYOS=$(echo "${TARGETOS}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}') && \ 18 | wget --progress=dot:giga -O trivy_"${TRIVY_VERSION}"_"${TRIVYOS}"-"${TRIVYARCH}".tar.gz https://github.com/aquasecurity/trivy/releases/download/v"${TRIVY_VERSION}"/trivy_"${TRIVY_VERSION}"_"${TRIVYOS}"-"${TRIVYARCH}".tar.gz && \ 19 | tar -xzf trivy_"${TRIVY_VERSION}"_"${TRIVYOS}"-"${TRIVYARCH}".tar.gz && \ 20 | mv trivy /usr/local/bin/trivy && \ 21 | rm trivy_"${TRIVY_VERSION}"_"${TRIVYOS}"-"${TRIVYARCH}".tar.gz && \ 22 | mkdir -p /opt/trivy/ && \ 23 | trivy --cache-dir /opt/trivy/ image --download-java-db-only --no-progress --db-repository="tosone/trivy-java-db:1" && \ 24 | trivy --cache-dir /opt/trivy/ image --download-db-only --no-progress --db-repository="tosone/trivy-db:2" 25 | 26 | FROM scratch 27 | 28 | COPY --from=trivy /opt/trivy/ / 29 | -------------------------------------------------------------------------------- /build/web.Dockerfile: -------------------------------------------------------------------------------- 1 | ARG NODE_VERSION=20-alpine3.19 2 | ARG NGINX_VERSION=1.27.1-alpine 3 | 4 | FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS web-builder 5 | 6 | ARG USE_MIRROR=false 7 | 8 | RUN set -eux && \ 9 | if [ "$USE_MIRROR" = true ]; then sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories; fi && \ 10 | apk add --no-cache make bash ncurses build-base 11 | 12 | WORKDIR /web 13 | 14 | COPY ./web . 15 | 16 | RUN --mount=type=cache,target=/web/node_modules set -eux && corepack enable && yarn install --immutable && yarn build 17 | 18 | FROM nginx:1.27.1-alpine 19 | 20 | COPY --from=web-builder /web/dist /usr/share/nginx/html 21 | -------------------------------------------------------------------------------- /cmd/builder/tag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "bytes" 19 | "fmt" 20 | "text/template" 21 | 22 | "github.com/Masterminds/sprig/v3" 23 | ) 24 | 25 | // BuildTagOption ... 26 | type BuildTagOption struct { 27 | ScmBranch string 28 | ScmTag string 29 | ScmRef string 30 | } 31 | 32 | // BuildTag ... 33 | func BuildTag(tmpl string, option BuildTagOption) (string, error) { 34 | t, err := template.New("tag").Funcs(sprig.FuncMap()).Parse(tmpl) 35 | if err != nil { 36 | return "", fmt.Errorf("Template parse failed: %v", err) 37 | } 38 | var buffer bytes.Buffer 39 | err = t.Execute(&buffer, option) 40 | if err != nil { 41 | return "", fmt.Errorf("Execute template failed: %v", err) 42 | } 43 | return buffer.String(), nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/imports/apis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/server/handlers/apidocs" 19 | _ "github.com/go-sigma/sigma/pkg/server/handlers/artifacts" 20 | _ "github.com/go-sigma/sigma/pkg/server/handlers/builders" 21 | _ "github.com/go-sigma/sigma/pkg/server/handlers/caches" 22 | _ "github.com/go-sigma/sigma/pkg/server/handlers/coderepos" 23 | _ "github.com/go-sigma/sigma/pkg/server/handlers/daemons" 24 | _ "github.com/go-sigma/sigma/pkg/server/handlers/namespaces" 25 | _ "github.com/go-sigma/sigma/pkg/server/handlers/oauth2" 26 | _ "github.com/go-sigma/sigma/pkg/server/handlers/repositories" 27 | _ "github.com/go-sigma/sigma/pkg/server/handlers/systems" 28 | _ "github.com/go-sigma/sigma/pkg/server/handlers/tags" 29 | _ "github.com/go-sigma/sigma/pkg/server/handlers/tokens" 30 | _ "github.com/go-sigma/sigma/pkg/server/handlers/users" 31 | _ "github.com/go-sigma/sigma/pkg/server/handlers/validators" 32 | _ "github.com/go-sigma/sigma/pkg/server/handlers/webhooks" 33 | ) 34 | -------------------------------------------------------------------------------- /cmd/imports/builder.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/builder/docker" 19 | _ "github.com/go-sigma/sigma/pkg/builder/kubernetes" 20 | _ "github.com/go-sigma/sigma/pkg/builder/logger/database" 21 | _ "github.com/go-sigma/sigma/pkg/builder/logger/obs" 22 | _ "github.com/go-sigma/sigma/pkg/builder/podman" 23 | ) 24 | -------------------------------------------------------------------------------- /cmd/imports/cronjob.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/cronjob/builder" 19 | ) 20 | -------------------------------------------------------------------------------- /cmd/imports/daemon.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/daemon/builder" 19 | _ "github.com/go-sigma/sigma/pkg/daemon/coderepo" 20 | _ "github.com/go-sigma/sigma/pkg/daemon/gc" 21 | _ "github.com/go-sigma/sigma/pkg/daemon/pushed" 22 | _ "github.com/go-sigma/sigma/pkg/daemon/scan" 23 | _ "github.com/go-sigma/sigma/pkg/daemon/webhook" 24 | ) 25 | -------------------------------------------------------------------------------- /cmd/imports/distribution.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/server/handlers/distribution/base" 19 | _ "github.com/go-sigma/sigma/pkg/server/handlers/distribution/blob" 20 | _ "github.com/go-sigma/sigma/pkg/server/handlers/distribution/manifest" 21 | _ "github.com/go-sigma/sigma/pkg/server/handlers/distribution/upload" 22 | ) 23 | -------------------------------------------------------------------------------- /cmd/imports/mock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "go.uber.org/mock/mockgen/model" 19 | ) 20 | -------------------------------------------------------------------------------- /cmd/imports/oci.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/distribution/distribution/v3/manifest/manifestlist" 19 | _ "github.com/distribution/distribution/v3/manifest/ocischema" 20 | _ "github.com/distribution/distribution/v3/manifest/schema2" 21 | ) 22 | -------------------------------------------------------------------------------- /cmd/imports/storage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package imports 16 | 17 | import ( 18 | _ "github.com/go-sigma/sigma/pkg/storage/cos" 19 | _ "github.com/go-sigma/sigma/pkg/storage/filesystem" 20 | _ "github.com/go-sigma/sigma/pkg/storage/oss" 21 | _ "github.com/go-sigma/sigma/pkg/storage/s3" 22 | ) 23 | -------------------------------------------------------------------------------- /conf/sigma.test.io.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEOzCCAqOgAwIBAgIRAMSa+azDf179PIWCDSUUzSEwDQYJKoZIhvcNAQELBQAw 3 | ezEdMBsGA1UEChMUdmVjcHMgZGV2ZWxvcG1lbnQgQ0ExKTAnBgNVBAsMIGJ5dGVk 4 | YW5jZUBKNkpNMlhZMEMwIChCeXRlRGFuY2UpMS8wLQYDVQQDDCZ2ZWNwcyBieXRl 5 | ZGFuY2VASjZKTTJYWTBDMCAoQnl0ZURhbmNlKTAeFw0yMzA3MTgwODIyNDNaFw0y 6 | NTA3MTgwODIyNDNaMFMxJjAkBgNVBAoTHXZlY3BzIGRldmVsb3BtZW50IGNlcnRp 7 | ZmljYXRlMSkwJwYDVQQLDCBieXRlZGFuY2VASjZKTTJYWTBDMCAoQnl0ZURhbmNl 8 | KTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMB0HQYjvdkVpVaULh0p 9 | 3hK1gvPEq9gJVch6tqYgEeBeZzgH8vSvcf5QlYsYu0INrqO7aViL4IHKXUXLAHVh 10 | ZjhyS5fNeyhDlR4E0jyZ8eecZcZNg97AIQlS7lUhbvSeXFK3OWif1PO42UlazFQY 11 | WENDmlyQ41tt42q9+0nndO5BVvMUlC+LAT636PFaNZ/qnIuKVLvHjBK14SLcNk9j 12 | zy+2hwa3e2tRME6M4/mQiq3ysxhD/g0LCa/iFkCBOwCSQPkFy/3qijshdSlsnycf 13 | o7BfwWq4VgboFi2Wny5I9PkQoL745qQmCX8eSJNF0pMmJkA0E39MhestEC1jIkM/ 14 | aY8CAwEAAaNiMGAwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMB 15 | MB8GA1UdIwQYMBaAFFcvhmraLunznUpCYB5AQKa/8Od5MBgGA1UdEQQRMA+CDXNp 16 | Z21hLnRlc3QuaW8wDQYJKoZIhvcNAQELBQADggGBAAgs8aW+YIJMSGLDwslT+W4b 17 | LyOIbEKTQfQdUFijCgDTtmjcBsg2bB8gD7GpjxJ0vKqAfb+FdNL24zrnAQh+T9gH 18 | 1xGc94/kYPWpwXZxLqMcHKFsyH+q+oYZLds/Cy35RHAGkwM2wa9VWnB/ADVuhSHI 19 | 03CSGWfi8NtKljAPsC+yQ1FKjeD6/c/Vl5KVODbELyKJ/FOahQWqYiNTdAS/98r8 20 | Ju8zulv4BwI4E3yzrnTZBGcBLww7kW8Lkm4kQzVj0lEJAb1R1V4fH6M9MkFa+8C2 21 | 3Q+8x6uMbf7fU/PRs+Qpz/djJo4rqX6ubMy417byMOc/uVsFmG75QDs56fl7LFXH 22 | om9wUbEAw3BTcRNpk/OK+RuTFsvprgFHhPEWzWdyvH1Bn3NuyAonx2d3iI1OmcxT 23 | 9qX0Ewdbv51FOtZaSKB2vqnF69WA4k1sbd46A/tQvPn5fHeuvGiy6OeJNWJ3hdRB 24 | fkoogKFFrWil+0atZotXKY1gyffblZTA07XFT8lPDQ== 25 | -----END CERTIFICATE----- 26 | -------------------------------------------------------------------------------- /deploy/sigma/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /deploy/sigma/Chart.lock: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: redis 3 | repository: https://charts.bitnami.com/bitnami 4 | version: 20.1.3 5 | - name: minio 6 | repository: https://charts.bitnami.com/bitnami 7 | version: 14.7.8 8 | - name: mysql 9 | repository: https://charts.bitnami.com/bitnami 10 | version: 11.1.16 11 | - name: common 12 | repository: https://charts.bitnami.com/bitnami 13 | version: 2.23.0 14 | digest: sha256:4e84624bf97a56d365ab60c079ac19b0edd4a1299e98fa76390fb1e767557194 15 | generated: "2024-09-17T20:45:36.213184+08:00" 16 | -------------------------------------------------------------------------------- /deploy/sigma/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: sigma 3 | description: Sigma is a painless self-hosted all in one OCI artifact manager service. 4 | type: application 5 | version: 0.1.0 6 | appVersion: "1.3.0" 7 | icon: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iYSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOTAgMTkwIj4KICA8Y2lyY2xlIGN4PSI5NSIgY3k9Ijk1IiByPSI5NSIgc3R5bGU9ImZpbGw6ICNmOTlkMWM7Ii8+CiAgPGNpcmNsZSBjeD0iOTUiIGN5PSI5NSIgcj0iODUiIHN0eWxlPSJmaWxsOiAjY2Q0YjI3OyIvPgogIDxjaXJjbGUgY3g9Ijk1IiBjeT0iOTUiIHI9Ijc1IiBzdHlsZT0iZmlsbDogIzVjMmUwZTsiLz4KICA8cGF0aCBkPSJtNzEuMzIsMTI1Ljg4di01LjI4bDIzLjUyLTI5LjA5djQuOTlsLTIyLjU2LTMxLjU4di0zLjM2aDcuMDFsMjEuNiwzMC4yNC0yMy43MSwyOS45NS0yLjUtMy41NWgzOS41NWwtNS4yOCw0LjgsMy42NS0xNy4yOGg1Ljc2bC0uNzcsMjAuMTZoLTQ2LjI3Wm0zNi02NC4zMmw1LjI4LDQuOGgtMzcuMDV2LTQuOGg0MC40MWwuNzcsMTcuMDloLTUuNzZsLTMuNjUtMTcuMDlaIiBzdHlsZT0iZmlsbDogI2Y5OWQxYzsiLz4KPC9zdmc+ 8 | 9 | dependencies: 10 | - name: redis 11 | version: 20.1.3 12 | repository: https://charts.bitnami.com/bitnami 13 | condition: redis.enabled 14 | - name: minio 15 | version: 14.7.8 16 | repository: https://charts.bitnami.com/bitnami 17 | condition: minio.enabled 18 | - name: mysql 19 | version: 11.1.16 20 | repository: https://charts.bitnami.com/bitnami 21 | condition: mysql.enabled 22 | - name: common 23 | version: 2.23.0 24 | repository: https://charts.bitnami.com/bitnami 25 | -------------------------------------------------------------------------------- /deploy/sigma/templates/distribution/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "sigma.distribution" . | quote }} 6 | namespace: {{ .Release.Namespace | quote }} 7 | labels: 8 | {{- include "sigma.distribution.labels" . | nindent 4 }} 9 | spec: 10 | scaleTargetRef: 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | name: {{ include "sigma.distribution" . | quote }} 14 | minReplicas: {{ .Values.autoscaling.minReplicas }} 15 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 16 | metrics: 17 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 18 | - type: Resource 19 | resource: 20 | name: cpu 21 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 22 | {{- end }} 23 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 24 | - type: Resource 25 | resource: 26 | name: memory 27 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 28 | {{- end }} 29 | {{- end }} 30 | -------------------------------------------------------------------------------- /deploy/sigma/templates/distribution/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sigma.distribution" . | quote }} 5 | namespace: {{ .Release.Namespace | quote }} 6 | labels: 7 | {{- include "sigma.distribution.labels" . | nindent 4 }} 8 | spec: 9 | type: {{ .Values.service.type | quote }} 10 | ports: 11 | - port: {{ .Values.service.distribution.port }} 12 | targetPort: http 13 | protocol: TCP 14 | name: http 15 | selector: 16 | {{- include "sigma.distribution.labels" . | nindent 4 }} 17 | -------------------------------------------------------------------------------- /deploy/sigma/templates/namespace.yaml: -------------------------------------------------------------------------------- 1 | {{- if and .Values.config.daemon.builder.enabled ( eq .Values.config.daemon.builder.type "kubernetes" ) }} 2 | kind: Namespace 3 | apiVersion: v1 4 | metadata: 5 | name: {{ .Values.config.daemon.builder.kubernetes.namespace | quote }} 6 | labels: 7 | {{- include "sigma.labels" . | nindent 4 }} 8 | {{- end }} 9 | -------------------------------------------------------------------------------- /deploy/sigma/templates/sercret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: {{ printf "%s-secret" .Chart.Name }} 5 | namespace: {{ .Release.Namespace | quote }} 6 | labels: 7 | {{- include "sigma.labels" . | nindent 4 }} 8 | data: 9 | {{ $privateKey := (genPrivateKey "rsa" | b64enc) }} 10 | AUTH_JWT_PRIVATEKEY: {{ .Values.config.auth.jwt.privateKey | default $privateKey | quote }} 11 | AUTH_USER_PASSWORD: {{ (trimPrefix "sigma:" (htpasswd "sigma" (.Values.config.auth.user.password | default "sigma"))) | b64enc | quote }} 12 | -------------------------------------------------------------------------------- /deploy/sigma/templates/server/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "sigma.server" . | quote }} 6 | namespace: {{ .Release.Namespace | quote }} 7 | labels: 8 | {{- include "sigma.server.labels" . | nindent 4 }} 9 | spec: 10 | scaleTargetRef: 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | name: {{ include "sigma.server" . | quote }} 14 | minReplicas: {{ .Values.autoscaling.minReplicas }} 15 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 16 | metrics: 17 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 18 | - type: Resource 19 | resource: 20 | name: cpu 21 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 22 | {{- end }} 23 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 24 | - type: Resource 25 | resource: 26 | name: memory 27 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 28 | {{- end }} 29 | {{- end }} 30 | -------------------------------------------------------------------------------- /deploy/sigma/templates/server/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sigma.server" . | quote }} 5 | namespace: {{ .Release.Namespace | quote }} 6 | labels: 7 | {{- include "sigma.server.labels" . | nindent 4 }} 8 | spec: 9 | type: {{ .Values.service.type | quote }} 10 | ports: 11 | - port: {{ .Values.service.server.port }} 12 | targetPort: http 13 | protocol: TCP 14 | name: http 15 | selector: 16 | {{- include "sigma.server.labels" . | nindent 4 }} 17 | -------------------------------------------------------------------------------- /deploy/sigma/templates/web/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "sigma.web" . | quote }} 6 | namespace: {{ .Release.Namespace | quote }} 7 | labels: 8 | {{- include "sigma.web.labels" . | nindent 4 }} 9 | spec: 10 | scaleTargetRef: 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | name: {{ include "sigma.web" . | quote }} 14 | minReplicas: {{ .Values.autoscaling.minReplicas }} 15 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 16 | metrics: 17 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 18 | - type: Resource 19 | resource: 20 | name: cpu 21 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 22 | {{- end }} 23 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 24 | - type: Resource 25 | resource: 26 | name: memory 27 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 28 | {{- end }} 29 | {{- end }} 30 | -------------------------------------------------------------------------------- /deploy/sigma/templates/web/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sigma.web" . | quote }} 5 | namespace: {{ .Release.Namespace | quote }} 6 | labels: 7 | {{- include "sigma.web.labels" . | nindent 4 }} 8 | spec: 9 | type: {{ .Values.service.type | quote }} 10 | ports: 11 | - port: {{ .Values.service.web.port }} 12 | targetPort: http 13 | protocol: TCP 14 | name: http 15 | selector: 16 | {{- include "sigma.web.labels" . | nindent 4 }} 17 | -------------------------------------------------------------------------------- /deploy/sigma/templates/worker/hpa.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include "sigma.worker" . | quote }} 6 | namespace: {{ .Release.Namespace | quote }} 7 | labels: 8 | {{- include "sigma.worker.labels" . | nindent 4 }} 9 | spec: 10 | scaleTargetRef: 11 | apiVersion: apps/v1 12 | kind: Deployment 13 | name: {{ include "sigma.worker" . | quote }} 14 | minReplicas: {{ .Values.autoscaling.minReplicas }} 15 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 16 | metrics: 17 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 18 | - type: Resource 19 | resource: 20 | name: cpu 21 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 22 | {{- end }} 23 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 24 | - type: Resource 25 | resource: 26 | name: memory 27 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 28 | {{- end }} 29 | {{- end }} 30 | -------------------------------------------------------------------------------- /deploy/sigma/templates/worker/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include "sigma.worker" . | quote }} 5 | namespace: {{ .Release.Namespace | quote }} 6 | labels: 7 | {{- include "sigma.worker.labels" . | nindent 4 }} 8 | spec: 9 | type: {{ .Values.service.type | quote }} 10 | ports: 11 | - port: {{ .Values.service.worker.port }} 12 | targetPort: http 13 | protocol: TCP 14 | name: http 15 | selector: 16 | {{- include "sigma.worker.labels" . | nindent 4 }} 17 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /docs/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/blog/authors.yml: -------------------------------------------------------------------------------- 1 | tosone: 2 | name: tosone 3 | title: Maintainer of sigma 4 | url: https://github.com/tosone 5 | image_url: https://github.com/tosone.png 6 | -------------------------------------------------------------------------------- /docs/docs/cosign.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Sign the image 6 | -------------------------------------------------------------------------------- /docs/docs/push/apptainer.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Apptainer 3 | description: Push apptainer sif to sigma 4 | --- 5 | 6 | # Apptainer push to sigma 7 | 8 | ### Run apptainer container 9 | 10 | Apptainer just run on linux system, so we can run it in container like this: 11 | 12 | ``` bash 13 | docker run -it --rm ghcr.io/apptainer/apptainer:1.3.0-rc.1 bash 14 | ``` 15 | 16 | ### Pull a image and save it as a sif file. 17 | 18 | ``` bash 19 | apptainer build alpine.sif docker://alpine 20 | ``` 21 | 22 | ### Login and push sif file 23 | 24 | ``` bash 25 | apptainer registry login -u sigma docker://192.168.31.112:3000 26 | apptainer push alpine.sif oras://192.168.31.112:3000/library/alpine:tosone 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/docs/push/docker.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Docker 3 | description: Push image to sigma 4 | --- 5 | 6 | # Push image to sigma 7 | 8 | ### Push single image to sigma 9 | 10 | ``` bash 11 | docker pull redis:7 12 | docker tag redis:7 127.0.0.1:3000/library/redis:7 13 | docker push 127.0.0.1:3000/library/redis:7 14 | ``` 15 | 16 | ### Push multiarch image to sigma 17 | 18 | Create 'buildkit.toml' with content: 19 | 20 | ``` toml 21 | [registry."10.3.201.221:3000"] # replace it with your host ip 22 | http = true 23 | ``` 24 | 25 | Create buildx instance: 26 | 27 | ``` bash 28 | docker buildx create --use --config ./buildkit.toml 29 | ``` 30 | 31 | Create Dockerfile with content: 32 | 33 | ``` dockerfile 34 | FROM alpine:3.18 35 | ``` 36 | 37 | Push multiarch image to sigma: 38 | 39 | ``` bash 40 | docker buildx build --platform linux/amd64,linux/arm64 --tag 10.3.201.221:3000/library/alpine:3.18.0 --file alpine.Dockerfile --push . 41 | ``` 42 | -------------------------------------------------------------------------------- /docs/docs/push/helm.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: Helm 3 | description: Push helm chart to sigma 4 | --- 5 | 6 | # Push helm chart to sigma 7 | 8 | ### Generate a sample helm chart 9 | 10 | ``` bash 11 | helm create demo 12 | ``` 13 | 14 | This command will create 'demo' directory, and a sample helm chart in it. 15 | 16 | ``` bash 17 | helm package demo 18 | ``` 19 | 20 | Run this command outside the 'demo' directory, and you will get a file which named 'demo-0.1.0.tgz'. 21 | 22 | ### Push the helm chart to sigma 23 | 24 | Note: before helm version v3.13.0, it doesn't support push helm chart to OCI registry over HTTP, you must use HTTPS. 25 | You can see the v3.13.0 [release note](https://github.com/helm/helm/releases/tag/v3.13.0). 26 | 27 | Before helm version v3.13.0: 28 | 29 | ``` bash 30 | helm registry login --insecure -u sigma -p Admin@123 127.0.0.1:3000 31 | helm push demo-0.1.0.tgz oci://127.0.0.1:3000/library/demo --insecure-skip-tls-verify 32 | ``` 33 | 34 | After helm version v3.13.0: 35 | 36 | ``` bash 37 | helm registry login -u sigma -p Admin@123 127.0.0.1:3000 38 | helm push demo-0.1.0.tgz oci://127.0.0.1:3000/library/demo --plain-http 39 | ``` 40 | 41 | ### Pull the helm chart from sigma 42 | 43 | ``` bash 44 | # before v3.13.0 45 | # helm pull oci://127.0.0.1:3000/library/demo --version 0.1.0 --insecure-skip-tls-verify 46 | helm pull oci://127.0.0.1:3000/library/demo --version 0.1.0 --plain-http 47 | ``` 48 | -------------------------------------------------------------------------------- /docs/docs/quickstart.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Quick Start 6 | 7 | Let's discover **sigma in less than 3 minutes**. 8 | 9 | ## Getting Started 10 | 11 | Run sigma in Docker. If you want to use the builder, Docker version should be used the latest version. 12 | The builder will push image to server, so we should link the together, you should create network for them. 13 | And set the network name `daemon.builder.docker.network` in `config.yaml`. 14 | 15 | ``` bash 16 | # create network 17 | docker network create sigma 18 | # run the sigma in docker 19 | docker run --name sigma -v /home/admin/config:/etc/sigma \ 20 | -v /home/admin/storage:/var/lib/sigma \ 21 | -v /var/run/docker.sock:/var/run/docker.sock -p 443:3000 \ 22 | -d --net sigma ghcr.io/go-sigma/sigma:nightly-alpine 23 | ``` 24 | 25 | That's enough, now you got a service like docker hub or harbor. 26 | 27 | ### Push image to sigma 28 | 29 | ``` bash 30 | docker pull redis:7 31 | docker tag redis:7 127.0.0.1:3000/library/redis:7 32 | docker push 127.0.0.1:3000/library/redis:7 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/docs/sigma.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # What is sigma? 6 | 7 | Sigma is a painless self-hosted all in one software development service, it includes OCI artifact manager, garbage collection, namespace quota, multiarch artifact, OCI image build. It is similar to [Harbor](https://goharbor.io/), but [distribution](https://github.com/distribution/distribution) is implement by itself, all of the service can be startup with one command. 8 | -------------------------------------------------------------------------------- /docs/i18n/zh/docusaurus-plugin-content-blog/authors.yml: -------------------------------------------------------------------------------- 1 | tosone: 2 | name: tosone 3 | title: Maintainer of sigma 4 | url: https://github.com/tosone 5 | image_url: https://github.com/tosone.png 6 | -------------------------------------------------------------------------------- /docs/i18n/zh/docusaurus-plugin-content-blog/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "Blog", 4 | "description": "The title for the blog used in SEO" 5 | }, 6 | "description": { 7 | "message": "Blog", 8 | "description": "The description for the blog used in SEO" 9 | }, 10 | "sidebar.title": { 11 | "message": "Recent posts", 12 | "description": "The label for the left sidebar" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/i18n/zh/docusaurus-plugin-content-docs/current.json: -------------------------------------------------------------------------------- 1 | { 2 | "version.label": { 3 | "message": "Next", 4 | "description": "The label for version current" 5 | }, 6 | "sidebar.tutorialSidebar.category.Getting Started": { 7 | "message": "Getting Started", 8 | "description": "The label for category Getting Started in sidebar tutorialSidebar" 9 | }, 10 | "sidebar.tutorialSidebar.category.Push to sigma": { 11 | "message": "Push to sigma", 12 | "description": "The label for category Push to sigma in sidebar tutorialSidebar" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /docs/i18n/zh/docusaurus-theme-classic/navbar.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": { 3 | "message": "sigma", 4 | "description": "The title in the navbar" 5 | }, 6 | "logo.alt": { 7 | "message": "Sigma", 8 | "description": "The alt text of navbar logo" 9 | }, 10 | "item.label.Docs": { 11 | "message": "Docs", 12 | "description": "Navbar item with label Docs" 13 | }, 14 | "item.label.Blog": { 15 | "message": "Blog", 16 | "description": "Navbar item with label Blog" 17 | }, 18 | "item.label.GitHub": { 19 | "message": "GitHub", 20 | "description": "Navbar item with label GitHub" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sigma", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "clear": "docusaurus clear", 12 | "serve": "docusaurus serve", 13 | "write-translations": "docusaurus write-translations", 14 | "write-heading-ids": "docusaurus write-heading-ids", 15 | "typecheck": "tsc" 16 | }, 17 | "dependencies": { 18 | "@docusaurus/core": "^3.5.2", 19 | "@docusaurus/preset-classic": "^3.5.2", 20 | "@mdx-js/react": "^3.0.1", 21 | "docusaurus-plugin-sass": "^0.2.5", 22 | "prism-react-renderer": "^2.4.0", 23 | "react": "^18.3.1", 24 | "react-dom": "^18.3.1", 25 | "sass": "^1.78.0", 26 | "typed.js": "^2.1.0" 27 | }, 28 | "devDependencies": { 29 | "@docusaurus/module-type-aliases": "^3.5.2", 30 | "@docusaurus/tsconfig": "^3.5.2", 31 | "@tsconfig/docusaurus": "^2.0.3", 32 | "typescript": "^5.6.2" 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.5%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | }, 46 | "engines": { 47 | "node": ">=16.14" 48 | }, 49 | "packageManager": "yarn@4.1.1" 50 | } 51 | -------------------------------------------------------------------------------- /docs/sidebars.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 4 | const sidebars = { 5 | tutorialSidebar: [ 6 | 'sigma', 7 | { 8 | type: 'category', 9 | label: 'Getting Started', 10 | items: [ 11 | 'quickstart', 12 | ], 13 | }, 14 | 'configuration', 15 | { 16 | type: 'category', 17 | label: 'Push to sigma', 18 | items: [ 19 | 'push/docker', 20 | 'push/helm', 21 | 'push/apptainer', 22 | ], 23 | }, 24 | ], 25 | }; 26 | 27 | module.exports = sidebars; 28 | -------------------------------------------------------------------------------- /docs/src/components/Typed/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef, useEffect } from 'react'; 2 | import Typed, { type TypedOptions } from 'typed.js'; 3 | 4 | const ReactTyped = (props: TypedOptions) => { 5 | const typeTarget = useRef(null); 6 | const { strings, typeSpeed } = props; 7 | 8 | useEffect(() => { 9 | if (!typeTarget.current) { 10 | return; 11 | } 12 | 13 | const typed = new Typed(typeTarget.current, { 14 | strings: strings, 15 | typeSpeed: typeSpeed ?? 40, 16 | }); 17 | 18 | return () => { 19 | typed.destroy(); 20 | }; 21 | }, []); 22 | 23 | return ; 24 | }; 25 | 26 | export default ReactTyped; 27 | -------------------------------------------------------------------------------- /docs/src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Layout from '@theme/Layout'; 4 | import Hero from '@site/src/components/Hero'; 5 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 6 | 7 | export default function Home(): JSX.Element { 8 | const { siteConfig } = useDocusaurusContext(); 9 | return ( 10 | 13 | 14 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /docs/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /docs/src/svg/Apple/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Apple = () => ( 4 | 15 | 23 | 24 | ); 25 | 26 | export default Apple; 27 | -------------------------------------------------------------------------------- /docs/src/svg/ArrowRight/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ArrowRight = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 10 | 11 | ); 12 | 13 | export default ArrowRight; 14 | -------------------------------------------------------------------------------- /docs/src/svg/Azure/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Azure = () => ( 4 | 9 | 13 | 14 | ); 15 | 16 | export default Azure; 17 | -------------------------------------------------------------------------------- /docs/src/svg/CSharp/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const CSharp = ({ color = '#68217A', ...rest }: any) => ( 4 | 5 | 10 | 11 | ); 12 | 13 | export default CSharp; 14 | -------------------------------------------------------------------------------- /docs/src/svg/Close/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Close = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 10 | 11 | ); 12 | 13 | export default Close; 14 | -------------------------------------------------------------------------------- /docs/src/svg/CloudRun/google-cloud-run.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/src/svg/CloudRun/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const CloudRun = () => ( 4 | 10 | 14 | 18 | 22 | 23 | ); 24 | 25 | export default CloudRun; 26 | -------------------------------------------------------------------------------- /docs/src/svg/CreateBg/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const CreateBg = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ); 23 | 24 | export default CreateBg; 25 | -------------------------------------------------------------------------------- /docs/src/svg/Deno/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Deno = () => ( 4 | 9 | 13 | 17 | 18 | ); 19 | 20 | export default Deno; 21 | -------------------------------------------------------------------------------- /docs/src/svg/Develop/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Develop = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 6 | 13 | 17 | 18 | 19 | ); 20 | 21 | export default Develop; 22 | -------------------------------------------------------------------------------- /docs/src/svg/DevelopBg/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const DevelopBg = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 13 | 17 | 18 | 19 | 20 | ); 21 | 22 | export default DevelopBg; 23 | -------------------------------------------------------------------------------- /docs/src/svg/Dots/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Dots = ({ color, ...rest }: any) => ( 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ); 12 | 13 | export default Dots; 14 | -------------------------------------------------------------------------------- /docs/src/svg/Explore/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Explore = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 12 | 13 | 14 | 15 | ); 16 | 17 | export default Explore; 18 | -------------------------------------------------------------------------------- /docs/src/svg/ExploreBg/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ExploreBg = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | ); 26 | 27 | export default ExploreBg; 28 | -------------------------------------------------------------------------------- /docs/src/svg/GCP/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const GCP = () => ( 4 | 9 | 10 | 16 | 22 | 28 | 34 | 35 | 36 | ); 37 | 38 | export default GCP; 39 | -------------------------------------------------------------------------------- /docs/src/svg/Hamburger/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Hamburger = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 13 | 14 | 15 | 16 | ); 17 | 18 | export default Hamburger; 19 | -------------------------------------------------------------------------------- /docs/src/svg/Hero/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Hero = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | 12 | export default Hero; 13 | -------------------------------------------------------------------------------- /docs/src/svg/Heroku/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Heroku = () => ( 4 | 9 | 13 | 17 | 18 | ); 19 | 20 | export default Heroku; 21 | -------------------------------------------------------------------------------- /docs/src/svg/Java/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Java = ({ color = '#EA2D2E', ...rest }: any) => ( 4 | 5 | 10 | 11 | ); 12 | 13 | export default Java; 14 | -------------------------------------------------------------------------------- /docs/src/svg/Launchpad/launchpad-promo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/docs/src/svg/Launchpad/launchpad-promo.png -------------------------------------------------------------------------------- /docs/src/svg/Nodejs/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Nodejs = () => ( 4 | 9 | 13 | 17 | 18 | ); 19 | 20 | export default Nodejs; 21 | -------------------------------------------------------------------------------- /docs/src/svg/Operate/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Operate = () => ( 4 | 15 | 16 | 20 | 24 | 28 | 29 | 30 | ); 31 | 32 | export default Operate; 33 | -------------------------------------------------------------------------------- /docs/src/svg/OperateBg/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Operate = ({ color = '#161F31', ...rest }: any) => ( 4 | 5 | 12 | 13 | 14 | 15 | ); 16 | 17 | export default Operate; 18 | -------------------------------------------------------------------------------- /docs/src/svg/Php/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Php = () => ( 4 | 9 | 13 | 17 | 21 | 22 | 26 | 27 | 28 | ); 29 | 30 | export default Php; 31 | -------------------------------------------------------------------------------- /docs/src/svg/Python/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Python = ({ color = '#FFD845', ...rest }: any) => ( 4 | 5 | 10 | 11 | ); 12 | 13 | export default Python; 14 | -------------------------------------------------------------------------------- /docs/src/svg/Rectangles/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Rectangles = ({ color = '#1969FF', ...rest }: any) => ( 4 | 5 | 6 | 7 | 8 | 9 | ); 10 | 11 | export default Rectangles; 12 | -------------------------------------------------------------------------------- /docs/src/svg/Shape/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Shape = ({ color = '#465282', ...rest }: any) => ( 4 | 10 | 11 | 15 | 24 | 25 | 26 | 27 | 37 | 38 | ); 39 | 40 | export default Shape; 41 | -------------------------------------------------------------------------------- /docs/src/svg/Vercel/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Vercel = () => ( 4 | 10 | 16 | 17 | ); 18 | 19 | export default Vercel; 20 | -------------------------------------------------------------------------------- /docs/src/svg/Windows/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const Windows = () => ( 4 | 9 | 13 | 14 | ); 15 | 16 | export default Windows; 17 | -------------------------------------------------------------------------------- /docs/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/docs/static/.nojekyll -------------------------------------------------------------------------------- /docs/static/img/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/static/img/header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/docs/static/img/header.jpg -------------------------------------------------------------------------------- /docs/static/img/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@docusaurus/tsconfig", 3 | "compilerOptions": { 4 | "baseUrl": "." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/multiarch/alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.18.0 2 | -------------------------------------------------------------------------------- /e2e/multiarch/buildkit.toml: -------------------------------------------------------------------------------- 1 | [registry."192.168.31.198:3000"] 2 | http = true 3 | -------------------------------------------------------------------------------- /e2e/multiarch/cosign.key: -------------------------------------------------------------------------------- 1 | -----BEGIN ENCRYPTED SIGSTORE PRIVATE KEY----- 2 | eyJrZGYiOnsibmFtZSI6InNjcnlwdCIsInBhcmFtcyI6eyJOIjo2NTUzNiwiciI6 3 | OCwicCI6MX0sInNhbHQiOiJCUEJNY0E1MGdKK1FvWVJDZnVDT1RzU2hrSHQ3Snhw 4 | ellGWEdKSWdyM093PSJ9LCJjaXBoZXIiOnsibmFtZSI6Im5hY2wvc2VjcmV0Ym94 5 | Iiwibm9uY2UiOiJ4VE9qaC8rUEJwQ29jSkx4MXI5R2FIdlRRWUdIa3YvZSJ9LCJj 6 | aXBoZXJ0ZXh0IjoickJFeGVmekRJUjdoQ1p6QWRTWjh0OXMzQVBCVVRHMDUweHo0 7 | NUQxVDlaL0hqN3VrOEpVUGdna0d3aEhCWm82M0g3Q2grNEZNamdJdnI5d1NFUThm 8 | SU1CbmQ1emhTWHBhNElRbzB3dEgvb3duMlBtTDRrSHFqdWVQSmdGbjQrTkRXZzBQ 9 | bUVTMFhBQUQ5aWE0QWxWTVpzWExlblhDTDVET1VvVlFJUGVOMU5UNlNiMUFVaXRl 10 | UThpT0ZuTVUxSm83QXZjSjd4YStjRCs3S0E9PSJ9 11 | -----END ENCRYPTED SIGSTORE PRIVATE KEY----- 12 | -------------------------------------------------------------------------------- /e2e/multiarch/cosign.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUV5SViVARNtgyAP+WnOguji79aRq 3 | OXqW6WnoUk34nn2HpmEE3ChJvZS0MWsRs1JAUBXn20cYUySYe1W3DEMc2Q== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /e2e/multiarch/push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # docker buildx create --use --config ./buildkit.toml 4 | 5 | docker buildx build --sbom=true --platform linux/amd64,linux/arm64 --tag 192.168.31.198:3000/library/alpine:3.18.0 --file alpine.Dockerfile --push . 6 | 7 | cosign generate-key-pair 8 | 9 | env COSIGN_PASSWORD= cosign sign --tlog-upload=false --allow-http-registry --key cosign.key --recursive 192.168.31.198:3000/library/alpine@sha256:d780ea42ba737c40b6a7fcadd8b8e6f5dd4365fb2166053f132aafe3b6ac9bcd 10 | -------------------------------------------------------------------------------- /e2e/push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set +e 4 | 5 | TIMES=12 6 | while [ $TIMES -gt 0 ]; do 7 | STATUS=$(curl --insecure -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/healthz) 8 | if [ "$STATUS" -eq 200 ]; then 9 | break 10 | fi 11 | TIMES=$((TIMES - 1)) 12 | sleep 5 13 | done 14 | 15 | if [ $TIMES -eq 0 ]; then 16 | echo "sigma cannot be available within one minute." 17 | exit 1 18 | fi 19 | 20 | set -e 21 | 22 | docker pull hello-world:latest 23 | docker tag hello-world:latest 127.0.0.1:3000/library/hello-world:latest 24 | docker pull mysql:8 25 | docker tag mysql:8 127.0.0.1:3000/library/mysql:8 26 | 27 | docker login 127.0.0.1:3000 -u sigma -p Admin@123 28 | 29 | docker push 127.0.0.1:3000/library/hello-world:latest 30 | docker pull 127.0.0.1:3000/library/hello-world:latest 31 | docker push 127.0.0.1:3000/library/mysql:8 32 | docker pull 127.0.0.1:3000/library/mysql:8 33 | 34 | docker logs sigma 35 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "github.com/go-sigma/sigma/cmd" 18 | 19 | // @title sigma 20 | // @version 1.3.0 21 | 22 | // @contact.name sigma 23 | // @contact.url https://github.com/go-sigma/sigma 24 | 25 | // @license.name Apache 2.0 26 | // @license.url http://www.apache.org/licenses/LICENSE-2.0 27 | 28 | // @BasePath /api/v1 29 | 30 | // @securityDefinitions.basic BasicAuth 31 | // @in header 32 | // @name Authorization 33 | 34 | func main() { 35 | cmd.Execute() 36 | } 37 | -------------------------------------------------------------------------------- /pkg/auth/tag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package auth 16 | 17 | import ( 18 | "context" 19 | "errors" 20 | "fmt" 21 | 22 | "github.com/rs/zerolog/log" 23 | "gorm.io/gorm" 24 | 25 | "github.com/go-sigma/sigma/pkg/dal/models" 26 | "github.com/go-sigma/sigma/pkg/types/enums" 27 | ) 28 | 29 | // Tag ... 30 | func (s authService) Tag(user models.User, tagID int64, auth enums.Auth) (bool, error) { 31 | ctx := log.Logger.WithContext(context.Background()) 32 | 33 | tagService := s.tagServiceFactory.New() 34 | tagObj, err := tagService.GetByID(ctx, tagID) 35 | if err != nil { 36 | if !errors.Is(err, gorm.ErrRecordNotFound) { 37 | log.Error().Err(err).Int64("tagID", tagID).Msg("Get tag by id failed") 38 | return false, errors.Join(err, fmt.Errorf("Get tag by id(%d) failed", tagID)) 39 | } 40 | log.Error().Err(err).Int64("tagID", tagID).Msg("Get tag by id not found") 41 | return false, errors.Join(err, fmt.Errorf("Get tag by id(%d) not found", tagID)) 42 | } 43 | return s.Repository(user, tagObj.RepositoryID, auth) 44 | } 45 | -------------------------------------------------------------------------------- /pkg/builder/docker/docker_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package docker 16 | 17 | // import ( 18 | // "context" 19 | // "fmt" 20 | // "testing" 21 | // "time" 22 | 23 | // "github.com/stretchr/testify/assert" 24 | // ) 25 | 26 | // func TestStart(t *testing.T) { 27 | // var f = factory{} 28 | // i, err := f.New() 29 | // assert.NoError(t, err) 30 | 31 | // ctx := context.Background() 32 | // err = i.Start(ctx, "test") 33 | // assert.NoError(t, err) 34 | // time.Sleep(time.Second * 5) 35 | // fmt.Println(i.Stop(ctx, "test")) 36 | // time.Sleep(time.Hour) 37 | // } 38 | -------------------------------------------------------------------------------- /pkg/configs/configs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package configs 16 | 17 | import "github.com/go-sigma/sigma/pkg/utils/ptr" 18 | 19 | type checker func(cfg Configuration) error 20 | 21 | var checkers []checker 22 | 23 | // Initialize initializes the configs. 24 | func Initialize() error { 25 | defaultSettings() 26 | return nil 27 | } 28 | 29 | // CheckMiddleware ... 30 | func CheckMiddleware() error { 31 | for _, checker := range checkers { 32 | err := checker(ptr.To(configuration)) 33 | if err != nil { 34 | return err 35 | } 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /pkg/configs/configs_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package configs 16 | 17 | import ( 18 | "fmt" 19 | "testing" 20 | 21 | "github.com/stretchr/testify/assert" 22 | ) 23 | 24 | func errChecker(config Configuration) error { 25 | return fmt.Errorf("fake error") 26 | } 27 | 28 | func noErrChecker(config Configuration) error { 29 | return nil 30 | } 31 | 32 | func TestInitialize(t *testing.T) { 33 | checkers = make([]checker, 0) 34 | err := Initialize() 35 | assert.NoError(t, err) 36 | 37 | checkers = append(checkers, noErrChecker, errChecker) 38 | err = CheckMiddleware() 39 | assert.Error(t, err) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/configs/default_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package configs 16 | 17 | import "testing" 18 | 19 | func TestDefaultSettings(t *testing.T) { 20 | defaultSettings() 21 | } 22 | -------------------------------------------------------------------------------- /pkg/consts/regex.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package consts 16 | 17 | import "regexp" 18 | 19 | var ( 20 | // RegexUsername ... 21 | RegexUsername = regexp.MustCompile(`^[a-zA-Z0-9_@#$%-]+$`) 22 | // RegexEmail ... 23 | RegexEmail = regexp.MustCompile(`^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$`) 24 | ) 25 | -------------------------------------------------------------------------------- /pkg/consts/setting.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package consts 16 | 17 | const ( 18 | // SettingSignPrivateKey is the private key for signing 19 | SettingSignPrivateKey = "signing.private_key" 20 | // SettingSignPublicKey is the public key for signing 21 | SettingSignPublicKey = "signing.public_key" 22 | // SettingBaseimageDockerfileKey ... 23 | SettingBaseimageDockerfileKey = "baseimage.dockerfile" 24 | // SettingBaseimageBuilderKey ... 25 | SettingBaseimageBuilderKey = "baseimage.builder" 26 | ) 27 | -------------------------------------------------------------------------------- /pkg/cronjob/cronjob.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cronjob 16 | 17 | import "time" 18 | 19 | const ( 20 | // cronjobIterDuration each job iterate duration 21 | CronjobIterDuration = time.Second * 30 22 | // tickNextDuration tick the next runner if current get full of jobs 23 | TickNextDuration = time.Second * 3 24 | // maxJob each iterate get the maximum jobs 25 | MaxJob = 100 26 | ) 27 | 28 | // Starter ... 29 | var Starter []func() 30 | 31 | // Stopper ... 32 | var Stopper []func() 33 | 34 | // Initialize ... 35 | func Initialize() { 36 | for _, start := range Starter { 37 | start() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkg/daemon/gc/gc_repository_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package gc 16 | -------------------------------------------------------------------------------- /pkg/daemon/gc/gc_tag_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package gc 16 | -------------------------------------------------------------------------------- /pkg/daemon/transfer/transfer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package transfer 16 | -------------------------------------------------------------------------------- /pkg/dal/dao/builder_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dao_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | 22 | "github.com/go-sigma/sigma/pkg/dal/dao" 23 | "github.com/go-sigma/sigma/pkg/dal/query" 24 | ) 25 | 26 | func TestBuilderServiceFactory(t *testing.T) { 27 | f := dao.NewBuilderServiceFactory() 28 | require.NotNil(t, f.New()) 29 | require.NotNil(t, f.New(query.Q)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/dal/dao/code_repository_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dao_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | 22 | "github.com/go-sigma/sigma/pkg/dal/dao" 23 | "github.com/go-sigma/sigma/pkg/dal/query" 24 | ) 25 | 26 | func TestCodeRepositoryServiceFactory(t *testing.T) { 27 | f := dao.NewCodeRepositoryServiceFactory() 28 | require.NotNil(t, f.New()) 29 | require.NotNil(t, f.New(query.Q)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/dal/dao/daemon_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dao_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | 22 | "github.com/go-sigma/sigma/pkg/dal/dao" 23 | "github.com/go-sigma/sigma/pkg/dal/query" 24 | ) 25 | 26 | func TestDaemonServiceFactory(t *testing.T) { 27 | f := dao.NewDaemonServiceFactory() 28 | require.NotNil(t, f.New()) 29 | require.NotNil(t, f.New(query.Q)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/dal/dao/option.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dao 16 | 17 | type config struct { 18 | AuditUserID int64 19 | } 20 | 21 | // Option ... 22 | type Option func(*config) 23 | 24 | // WithAuditUser ... 25 | func WithAuditUser(userID int64) Option { 26 | return func(c *config) { 27 | c.AuditUserID = userID 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkg/dal/migrations/mysql/0002_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `artifact_artifacts` RENAME COLUMN `artifact_sub_id` TO `artifact_index_id`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/mysql/0002_upgrade.up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `artifact_artifacts` RENAME COLUMN `artifact_index_id` TO `artifact_sub_id`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/mysql/0003_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `lockers`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/mysql/0003_upgrade.up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `artifacts` 2 | ADD COLUMN `namespace_id` bigint NOT NULL AFTER `id`; 3 | 4 | ALTER TABLE `artifacts` 5 | ADD CONSTRAINT FOREIGN KEY (`namespace_id`) REFERENCES `namespaces` (`id`); 6 | 7 | -------------------------------------------------------------------------------- /pkg/dal/migrations/mysql/0004_upgrade.down.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/pkg/dal/migrations/mysql/0004_upgrade.down.sql -------------------------------------------------------------------------------- /pkg/dal/migrations/postgresql/0002_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE "artifact_artifacts" RENAME COLUMN "artifact_sub_id" TO "artifact_index_id"; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/postgresql/0002_upgrade.up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE "artifact_artifacts" RENAME COLUMN "artifact_index_id" TO "artifact_sub_id"; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/postgresql/0003_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS "lockers"; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/postgresql/0003_upgrade.up.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/pkg/dal/migrations/postgresql/0003_upgrade.up.sql -------------------------------------------------------------------------------- /pkg/dal/migrations/sqlite3/0002_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `artifact_artifacts` RENAME COLUMN `artifact_sub_id` TO `artifact_index_id`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/sqlite3/0002_upgrade.up.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `artifact_artifacts` RENAME COLUMN `artifact_index_id` TO `artifact_sub_id`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/sqlite3/0003_upgrade.down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `lockers`; 2 | 3 | -------------------------------------------------------------------------------- /pkg/dal/migrations/sqlite3/0003_upgrade.up.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/pkg/dal/migrations/sqlite3/0003_upgrade.up.sql -------------------------------------------------------------------------------- /pkg/dal/models/audit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | 20 | "github.com/go-sigma/sigma/pkg/types/enums" 21 | ) 22 | 23 | // Audit represents a audit 24 | type Audit struct { 25 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 26 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 27 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 28 | ID int64 `gorm:"primaryKey"` 29 | 30 | UserID int64 31 | NamespaceID *int64 32 | Action enums.AuditAction 33 | ResourceType enums.AuditResourceType 34 | Resource string 35 | ReqRaw []byte 36 | 37 | Namespace Namespace 38 | User User 39 | } 40 | -------------------------------------------------------------------------------- /pkg/dal/models/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | // CasbinRule represents a casbin rule. 18 | type CasbinRule struct { 19 | ID int64 `gorm:"primaryKey"` 20 | PType *string `gorm:"column:ptype"` 21 | V0 *string `gorm:"column:v0"` 22 | V1 *string `gorm:"column:v1"` 23 | V2 *string `gorm:"column:v2"` 24 | V3 *string `gorm:"column:v3"` 25 | V4 *string `gorm:"column:v4"` 26 | V5 *string `gorm:"column:v5"` 27 | } 28 | -------------------------------------------------------------------------------- /pkg/dal/models/blob.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/gen" 19 | "gorm.io/plugin/soft_delete" 20 | ) 21 | 22 | // Blob represents a blob 23 | type Blob struct { 24 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 25 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 26 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 27 | ID int64 `gorm:"primaryKey"` 28 | 29 | Digest string 30 | Size int64 31 | ContentType string 32 | 33 | LastPull int64 34 | PushedAt int64 `gorm:"autoCreateTime:milli"` 35 | PullTimes uint `gorm:"default:0"` 36 | 37 | Artifacts []*Artifact `gorm:"many2many:artifact_blobs;"` 38 | } 39 | 40 | // BlobAssociateWithArtifact ... 41 | type BlobAssociateWithArtifact interface { 42 | // SELECT blob_id FROM artifact_blobs WHERE blob_id in (@ids) 43 | BlobAssociateWithArtifact(ids []int64) (gen.M, error) 44 | } 45 | -------------------------------------------------------------------------------- /pkg/dal/models/blob_upload.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | ) 20 | 21 | type BlobUpload struct { 22 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 23 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 24 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 25 | ID int64 `gorm:"primaryKey"` 26 | 27 | PartNumber int32 28 | UploadID string 29 | Etag string 30 | Repository string 31 | FileID string 32 | Size int64 33 | } 34 | -------------------------------------------------------------------------------- /pkg/dal/models/locker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | ) 20 | 21 | // Locker locker 22 | type Locker struct { 23 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 24 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 25 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 26 | ID int64 `gorm:"primaryKey"` 27 | 28 | Key string 29 | Expire int64 30 | Value string 31 | } 32 | -------------------------------------------------------------------------------- /pkg/dal/models/namespace_member.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | 20 | "github.com/go-sigma/sigma/pkg/types/enums" 21 | ) 22 | 23 | // NamespaceMember represents namespace role 24 | type NamespaceMember struct { 25 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 26 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 27 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 28 | ID int64 `gorm:"primaryKey"` 29 | 30 | UserID int64 31 | User User 32 | 33 | NamespaceID int64 34 | Namespace Namespace 35 | 36 | Role enums.NamespaceRole 37 | } 38 | -------------------------------------------------------------------------------- /pkg/dal/models/setting.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | ) 20 | 21 | // Setting setting 22 | type Setting struct { 23 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 24 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 25 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 26 | ID int64 `gorm:"primaryKey"` 27 | 28 | Key string `gorm:"uniqueIndex,size:256"` 29 | Val []byte 30 | } 31 | -------------------------------------------------------------------------------- /pkg/dal/models/workq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package models 16 | 17 | import ( 18 | "gorm.io/plugin/soft_delete" 19 | 20 | "github.com/go-sigma/sigma/pkg/types/enums" 21 | ) 22 | 23 | // WorkQueue ... 24 | type WorkQueue struct { 25 | CreatedAt int64 `gorm:"autoCreateTime:milli"` 26 | UpdatedAt int64 `gorm:"autoUpdateTime:milli"` 27 | DeletedAt soft_delete.DeletedAt `gorm:"softDelete:milli"` 28 | ID int64 `gorm:"primaryKey"` 29 | 30 | Topic enums.Daemon 31 | Payload []byte 32 | Times int 33 | Version string 34 | Status enums.TaskCommonStatus `gorm:"default:Pending"` 35 | } 36 | -------------------------------------------------------------------------------- /pkg/dal/redis/redis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package redis 16 | 17 | import ( 18 | "context" 19 | "fmt" 20 | 21 | "github.com/redis/go-redis/v9" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/types/enums" 25 | ) 26 | 27 | // Client ... 28 | var Client redis.UniversalClient 29 | 30 | // New new redis instance 31 | func New(config configs.Configuration) (redis.UniversalClient, error) { 32 | if config.Redis.Type == enums.RedisTypeNone { 33 | return nil, nil 34 | } 35 | redisOpt, err := redis.ParseURL(config.Redis.URL) 36 | if err != nil { 37 | return nil, fmt.Errorf("redis.ParseURL error: %v", err) 38 | } 39 | redisCli := redis.NewClient(redisOpt) 40 | res, err := redisCli.Ping(context.Background()).Result() 41 | if err != nil { 42 | return nil, fmt.Errorf("redis ping error: %v", err) 43 | } 44 | if res != "PONG" { 45 | return nil, fmt.Errorf("redis ping should got PONG, real: %s", res) 46 | } 47 | return redisCli, nil 48 | } 49 | -------------------------------------------------------------------------------- /pkg/inits/inits.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package inits 16 | 17 | import ( 18 | "go.uber.org/dig" 19 | ) 20 | 21 | // inits inits for something before server started 22 | var inits = make(map[string]func(*dig.Container) error) 23 | 24 | // Initialize runs all registered inits. 25 | func Initialize(digCon *dig.Container) error { 26 | for _, init := range inits { 27 | err := init(digCon) 28 | if err != nil { 29 | return err 30 | } 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /pkg/logger/logger_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package logger 16 | 17 | import ( 18 | "fmt" 19 | "testing" 20 | 21 | "github.com/rs/zerolog" 22 | "github.com/rs/zerolog/log" 23 | ) 24 | 25 | func TestSetLevel(t *testing.T) { 26 | SetLevel("debug") 27 | log.Info().Str("x", "x").Msgf("log level set to %s", zerolog.GlobalLevel()) 28 | SetLevel("info") 29 | log.Error().Str("x", "x").Err(fmt.Errorf("hello")).Stack().Msgf("log level set to %s", zerolog.GlobalLevel()) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/modules/locker/locker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package locker 16 | 17 | import ( 18 | "go.uber.org/dig" 19 | 20 | "github.com/go-sigma/sigma/pkg/configs" 21 | "github.com/go-sigma/sigma/pkg/modules/locker/badger" 22 | "github.com/go-sigma/sigma/pkg/modules/locker/definition" 23 | "github.com/go-sigma/sigma/pkg/modules/locker/redis" 24 | "github.com/go-sigma/sigma/pkg/types/enums" 25 | "github.com/go-sigma/sigma/pkg/utils" 26 | ) 27 | 28 | // Locker ... 29 | var Locker definition.Locker 30 | 31 | // New ... 32 | func Initialize(digCon *dig.Container) (definition.Locker, error) { 33 | config := utils.MustGetObjFromDigCon[configs.Configuration](digCon) 34 | 35 | var err error 36 | switch config.Locker.Type { 37 | case enums.LockerTypeBadger: 38 | Locker, err = badger.New(digCon) 39 | case enums.LockerTypeRedis: 40 | Locker, err = redis.New(digCon) 41 | default: 42 | Locker, err = badger.New(digCon) 43 | } 44 | return Locker, err 45 | } 46 | -------------------------------------------------------------------------------- /pkg/modules/timewheel/timewheel_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package timewheel 16 | 17 | import ( 18 | "context" 19 | "sync/atomic" 20 | "testing" 21 | "time" 22 | 23 | "github.com/stretchr/testify/assert" 24 | ) 25 | 26 | func TestNewTimeWheel(t *testing.T) { 27 | var myNum int32 = 1 28 | tw := NewTimeWheel(context.Background()) 29 | tw.AddRunner(func(_ context.Context, _ TimeWheel) { 30 | atomic.AddInt32(&myNum, 1) 31 | }) 32 | tw.TickNext(time.Second) 33 | time.Sleep(time.Second * 2) 34 | tw.Stop() 35 | assert.Equal(t, int32(2), atomic.LoadInt32(&myNum)) 36 | } 37 | 38 | func TestNewTimeWheelWithMaxTicker(t *testing.T) { 39 | var myNum int32 = 1 40 | tw := NewTimeWheel(context.Background(), time.Second*2) 41 | tw.AddRunner(func(_ context.Context, _ TimeWheel) { 42 | atomic.AddInt32(&myNum, 1) 43 | }) 44 | tw.TickNext(time.Second) 45 | time.Sleep(time.Second * 3) 46 | tw.Stop() 47 | assert.Equal(t, int32(3), atomic.LoadInt32(&myNum)) 48 | } 49 | -------------------------------------------------------------------------------- /pkg/modules/workq/definition/definition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package definition 16 | 17 | import ( 18 | "context" 19 | "time" 20 | 21 | "github.com/go-sigma/sigma/pkg/dal/query" 22 | "github.com/go-sigma/sigma/pkg/types/enums" 23 | ) 24 | 25 | //go:generate mockgen -destination=mocks/workq.go -package=mocks github.com/go-sigma/sigma/pkg/modules/workq/definition WorkQueueProducer 26 | 27 | // Consumer ... 28 | type Consumer struct { 29 | Handler func(ctx context.Context, payload []byte) error 30 | Concurrency int 31 | MaxRetry int 32 | Timeout time.Duration 33 | } 34 | 35 | // ProducerOption ... 36 | type ProducerOption struct { 37 | Tx *query.Query 38 | } 39 | 40 | // WorkQueueProducer ... 41 | type WorkQueueProducer interface { 42 | // Produce ... 43 | Produce(ctx context.Context, topic enums.Daemon, payload any, option ProducerOption) error 44 | } 45 | -------------------------------------------------------------------------------- /pkg/modules/workq/inmemory/producer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package inmemory 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/go-sigma/sigma/pkg/configs" 21 | "github.com/go-sigma/sigma/pkg/dal/models" 22 | "github.com/go-sigma/sigma/pkg/modules/workq/definition" 23 | "github.com/go-sigma/sigma/pkg/types/enums" 24 | "github.com/go-sigma/sigma/pkg/utils" 25 | ) 26 | 27 | type producer struct{} 28 | 29 | // NewWorkQueueProducer ... 30 | func NewWorkQueueProducer(_ configs.Configuration, _ map[enums.Daemon]definition.Consumer) (definition.WorkQueueProducer, error) { 31 | p := &producer{} 32 | return p, nil 33 | } 34 | 35 | // Produce ... 36 | func (p *producer) Produce(ctx context.Context, topic enums.Daemon, payload any, _ definition.ProducerOption) error { 37 | wq := &models.WorkQueue{ 38 | Topic: topic, 39 | Payload: utils.MustMarshal(payload), 40 | } 41 | packs[topic] <- wq 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /pkg/modules/workq/inmemory/producer_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package inmemory 16 | 17 | import ( 18 | "context" 19 | "testing" 20 | 21 | "github.com/stretchr/testify/assert" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/dal/models" 25 | "github.com/go-sigma/sigma/pkg/modules/workq/definition" 26 | "github.com/go-sigma/sigma/pkg/types/enums" 27 | ) 28 | 29 | func TestProducer(t *testing.T) { 30 | producer, err := NewWorkQueueProducer(configs.Configuration{}, nil) 31 | assert.NoError(t, err) 32 | assert.NotNil(t, producer) 33 | 34 | packs[enums.DaemonBuilder] = make(chan *models.WorkQueue, 10) 35 | err = producer.Produce(context.Background(), enums.DaemonBuilder, "test", definition.ProducerOption{}) 36 | assert.NoError(t, err) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/modules/workq/kafka/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package kafka 16 | 17 | import ( 18 | "time" 19 | 20 | "github.com/IBM/sarama" 21 | 22 | "github.com/go-sigma/sigma/pkg/configs" 23 | ) 24 | 25 | // Config ... 26 | func Config(cfg configs.Configuration) *sarama.Config { 27 | config := sarama.NewConfig() 28 | config.Producer.Return.Successes = true 29 | config.Producer.RequiredAcks = sarama.WaitForAll 30 | config.Producer.Retry.Max = 5 31 | config.Consumer.Group.Session.Timeout = 10 * time.Second 32 | config.Consumer.Group.Heartbeat.Interval = 3 * time.Second 33 | return config 34 | } 35 | -------------------------------------------------------------------------------- /pkg/modules/workq/redis/redis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package redis 16 | 17 | // mux := asynq.NewServeMux() 18 | // for taskType, handler := range tasks { 19 | // topic, ok := topics[taskType] 20 | // if !ok { 21 | // return fmt.Errorf("topic for daemon task %q not found", taskType) 22 | // } 23 | // mux.HandleFunc(topic, handler) 24 | // } 25 | 26 | // go func() { 27 | // err := asyncSrv.Run(mux) 28 | // if err != nil { 29 | // log.Fatal().Err(err).Msg("srv.Run error") 30 | // } 31 | // }() 32 | -------------------------------------------------------------------------------- /pkg/server/handlers/caches/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package caches 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/tests" 24 | ) 25 | 26 | func TestFactory(t *testing.T) { 27 | digCon := dig.New() 28 | require.NoError(t, digCon.Provide(tests.NewEcho)) 29 | require.NoError(t, factory{}.Initialize(digCon)) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/server/handlers/caches/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package caches 16 | 17 | import ( 18 | "fmt" 19 | "strconv" 20 | 21 | "github.com/go-sigma/sigma/pkg/consts" 22 | "github.com/go-sigma/sigma/pkg/utils" 23 | "github.com/go-sigma/sigma/pkg/utils/hash" 24 | ) 25 | 26 | func (h *handler) genPath(id int64) string { 27 | return fmt.Sprintf("%s/%s", consts.DirCache, utils.DirWithSlash(hash.MustString(strconv.FormatInt(id, 10)))) 28 | } 29 | -------------------------------------------------------------------------------- /pkg/server/handlers/coderepos/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package coderepos 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/dal/dao" 24 | "github.com/go-sigma/sigma/pkg/tests" 25 | ) 26 | 27 | func TestFactory(t *testing.T) { 28 | digCon := dig.New() 29 | require.NoError(t, digCon.Provide(func() dao.NamespaceServiceFactory { return nil })) 30 | require.NoError(t, digCon.Provide(func() dao.RepositoryServiceFactory { return nil })) 31 | require.NoError(t, digCon.Provide(func() dao.AuditServiceFactory { return nil })) 32 | require.NoError(t, digCon.Provide(func() dao.BuilderServiceFactory { return nil })) 33 | require.NoError(t, digCon.Provide(func() dao.UserServiceFactory { return nil })) 34 | require.NoError(t, digCon.Provide(func() dao.CodeRepositoryServiceFactory { return nil })) 35 | require.NoError(t, digCon.Provide(tests.NewEcho)) 36 | require.NoError(t, factory{}.Initialize(digCon)) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/server/handlers/daemons/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package daemons 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/dal/dao" 24 | "github.com/go-sigma/sigma/pkg/tests" 25 | ) 26 | 27 | func TestFactory(t *testing.T) { 28 | digCon := dig.New() 29 | require.NoError(t, digCon.Provide(func() dao.DaemonServiceFactory { return nil })) 30 | require.NoError(t, digCon.Provide(tests.NewEcho)) 31 | require.NoError(t, factory{}.Initialize(digCon)) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/base/healthy_get.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package distribution 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/labstack/echo/v4" 21 | ) 22 | 23 | // GetHealthy handles the get healthy request 24 | func (h *handler) GetHealthy(c echo.Context) error { 25 | return c.NoContent(http.StatusOK) 26 | } 27 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/base/healthy_get_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package distribution 16 | 17 | // import ( 18 | // "net/http" 19 | // "net/http/httptest" 20 | // "testing" 21 | 22 | // "github.com/labstack/echo/v4" 23 | // "github.com/stretchr/testify/assert" 24 | // ) 25 | 26 | // func TestGetHealthy(t *testing.T) { 27 | // req := httptest.NewRequest(http.MethodGet, "/v2/", nil) 28 | // req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) 29 | // rec := httptest.NewRecorder() 30 | // c := echo.New().NewContext(req, rec) 31 | // f := &factory{} 32 | // err := f.Initialize(c) 33 | // assert.NoError(t, err) 34 | // assert.Equal(t, http.StatusOK, c.Response().Status) 35 | // } 36 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/blob/blob_delete_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package blob 16 | 17 | import "testing" 18 | 19 | func TestDeleteBlob(t *testing.T) { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/blob/blob_head_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package blob 16 | 17 | import "testing" 18 | 19 | func TestHeadBlob(t *testing.T) { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/clients/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // clients package contains the clients for the distribution service 16 | package clients 17 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/clients/manifest_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package clients 16 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/manifest/helper.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package manifest 16 | 17 | import "github.com/opencontainers/go-digest" 18 | 19 | // Refs image tag and digest 20 | type Refs struct { 21 | Tag string 22 | Digest digest.Digest 23 | } 24 | 25 | func (h *handler) parseRef(ref string) Refs { 26 | var refs = Refs{} 27 | 28 | digest, err := digest.Parse(ref) 29 | if err != nil { 30 | refs.Tag = ref 31 | } else { 32 | refs.Digest = digest 33 | } 34 | 35 | return refs 36 | } 37 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/manifest/helper_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package manifest 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/assert" 21 | ) 22 | 23 | func TestParseRef(t *testing.T) { 24 | h := &handler{} 25 | refs := h.parseRef("latest") 26 | assert.Equal(t, refs.Tag, "latest") 27 | 28 | refs = h.parseRef("sha256:f7d81d5be30e617068bf53a9b136400b13d91c0f54d097a72bf91127f43d0157") 29 | assert.Equal(t, refs.Digest.String(), "sha256:f7d81d5be30e617068bf53a9b136400b13d91c0f54d097a72bf91127f43d0157") 30 | } 31 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/upload/upload_delete.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package upload 16 | 17 | import "github.com/labstack/echo/v4" 18 | 19 | // DeleteUpload handles the delete upload request 20 | func (h *handler) DeleteUpload(ctx echo.Context) error { 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /pkg/server/handlers/distribution/upload/upload_get.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package upload 16 | 17 | import "github.com/labstack/echo/v4" 18 | 19 | // GetUpload handles the get upload request 20 | func (h *handler) GetUpload(ctx echo.Context) error { 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /pkg/server/handlers/oauth2/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package oauth2 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/dal/dao" 25 | "github.com/go-sigma/sigma/pkg/tests" 26 | "github.com/go-sigma/sigma/pkg/utils/token" 27 | ) 28 | 29 | func TestFactory(t *testing.T) { 30 | digCon := dig.New() 31 | require.NoError(t, digCon.Provide(func() configs.Configuration { return configs.Configuration{} })) 32 | require.NoError(t, digCon.Provide(func() token.Service { return nil })) 33 | require.NoError(t, digCon.Provide(func() dao.UserServiceFactory { return nil })) 34 | require.NoError(t, digCon.Provide(tests.NewEcho)) 35 | require.NoError(t, factory{}.Initialize(digCon)) 36 | } 37 | -------------------------------------------------------------------------------- /pkg/server/handlers/repositories/repositories_create_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package repositories 16 | -------------------------------------------------------------------------------- /pkg/server/handlers/repositories/repositories_get_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package repositories 16 | -------------------------------------------------------------------------------- /pkg/server/handlers/repositories/repositories_update_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package repositories 16 | -------------------------------------------------------------------------------- /pkg/server/handlers/systems/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package systems 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/tests" 25 | ) 26 | 27 | func TestFactory(t *testing.T) { 28 | digCon := dig.New() 29 | require.NoError(t, digCon.Provide(func() *configs.Configuration { return nil })) 30 | require.NoError(t, digCon.Provide(tests.NewEcho)) 31 | require.NoError(t, factory{}.Initialize(digCon)) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/server/handlers/systems/systems_config_get.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package systems 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/labstack/echo/v4" 21 | 22 | "github.com/go-sigma/sigma/pkg/types" 23 | ) 24 | 25 | // GetConfig handles the get config request 26 | // 27 | // @Summary Get config 28 | // @Tags System 29 | // @Accept json 30 | // @Produce json 31 | // @Router /systems/config [get] 32 | // @Success 200 {object} types.GetSystemConfigResponse 33 | func (h *handler) GetConfig(c echo.Context) error { 34 | return c.JSON(http.StatusOK, types.GetSystemConfigResponse{ 35 | Daemon: types.GetSystemConfigDaemon{ 36 | Builder: h.config.Daemon.Builder.Enabled, 37 | }, 38 | Anonymous: h.config.Auth.Anonymous.Enabled, 39 | OAuth2: types.GetSystemConfigOAuth2{ 40 | GitHub: h.config.Auth.Oauth2.Github.Enabled, 41 | GitLab: h.config.Auth.Oauth2.Gitlab.Enabled, 42 | }, 43 | }) 44 | } 45 | -------------------------------------------------------------------------------- /pkg/server/handlers/systems/systems_endpoint_get.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package systems 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/labstack/echo/v4" 21 | 22 | "github.com/go-sigma/sigma/pkg/types" 23 | ) 24 | 25 | // GetEndpoint handles the get endpoint request 26 | // 27 | // @Summary Get endpoint 28 | // @Tags System 29 | // @Accept json 30 | // @Produce json 31 | // @Router /systems/endpoint [get] 32 | // @Success 200 {object} types.GetSystemEndpointResponse 33 | func (h *handler) GetEndpoint(c echo.Context) error { 34 | return c.JSON(http.StatusOK, types.GetSystemEndpointResponse{ 35 | Endpoint: h.config.HTTP.Endpoint, 36 | }) 37 | } 38 | -------------------------------------------------------------------------------- /pkg/server/handlers/systems/systems_version_get.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package systems 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/labstack/echo/v4" 21 | 22 | "github.com/go-sigma/sigma/pkg/types" 23 | "github.com/go-sigma/sigma/pkg/version" 24 | ) 25 | 26 | // GetEndpoint handles the get version request 27 | // 28 | // @Summary Get version 29 | // @Tags System 30 | // @Accept json 31 | // @Produce json 32 | // @Router /systems/version [get] 33 | // @Success 200 {object} types.GetSystemVersionResponse 34 | func (h *handler) GetVersion(c echo.Context) error { 35 | return c.JSON(http.StatusOK, types.GetSystemVersionResponse{ 36 | Version: version.Version, 37 | GitHash: version.GitHash, 38 | BuildDate: version.BuildDate, 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/server/handlers/tags/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tag 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/dal/dao" 24 | "github.com/go-sigma/sigma/pkg/tests" 25 | ) 26 | 27 | func TestFactory(t *testing.T) { 28 | digCon := dig.New() 29 | require.NoError(t, digCon.Provide(func() dao.NamespaceServiceFactory { return nil })) 30 | require.NoError(t, digCon.Provide(func() dao.RepositoryServiceFactory { return nil })) 31 | require.NoError(t, digCon.Provide(func() dao.TagServiceFactory { return nil })) 32 | require.NoError(t, digCon.Provide(func() dao.ArtifactServiceFactory { return nil })) 33 | require.NoError(t, digCon.Provide(tests.NewEcho)) 34 | require.NoError(t, factory{}.Initialize(digCon)) 35 | } 36 | -------------------------------------------------------------------------------- /pkg/server/handlers/tags/tags_list_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tag 16 | -------------------------------------------------------------------------------- /pkg/server/handlers/tokens/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package token 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/tests" 25 | "github.com/go-sigma/sigma/pkg/utils/token" 26 | ) 27 | 28 | func TestFactory(t *testing.T) { 29 | digCon := dig.New() 30 | require.NoError(t, digCon.Provide(func() configs.Configuration { return configs.Configuration{} })) 31 | require.NoError(t, digCon.Provide(func() token.Service { return nil })) 32 | require.NoError(t, digCon.Provide(tests.NewEcho)) 33 | require.NoError(t, factory{}.Initialize(digCon)) 34 | } 35 | -------------------------------------------------------------------------------- /pkg/server/handlers/users/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package users 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/dal/dao" 25 | "github.com/go-sigma/sigma/pkg/tests" 26 | "github.com/go-sigma/sigma/pkg/utils/password" 27 | "github.com/go-sigma/sigma/pkg/utils/token" 28 | ) 29 | 30 | func TestFactory(t *testing.T) { 31 | digCon := dig.New() 32 | require.NoError(t, digCon.Provide(func() configs.Configuration { return configs.Configuration{} })) 33 | require.NoError(t, digCon.Provide(func() token.Service { return nil })) 34 | require.NoError(t, digCon.Provide(func() password.Service { return nil })) 35 | require.NoError(t, digCon.Provide(func() dao.UserServiceFactory { return nil })) 36 | require.NoError(t, digCon.Provide(tests.NewEcho)) 37 | require.NoError(t, factory{}.Initialize(digCon)) 38 | } 39 | -------------------------------------------------------------------------------- /pkg/server/handlers/webhooks/handler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package webhooks 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/stretchr/testify/require" 21 | "go.uber.org/dig" 22 | 23 | "github.com/go-sigma/sigma/pkg/auth" 24 | "github.com/go-sigma/sigma/pkg/dal/dao" 25 | "github.com/go-sigma/sigma/pkg/modules/workq/definition" 26 | "github.com/go-sigma/sigma/pkg/tests" 27 | ) 28 | 29 | func TestFactory(t *testing.T) { 30 | digCon := dig.New() 31 | require.NoError(t, digCon.Provide(func() dao.NamespaceServiceFactory { return nil })) 32 | require.NoError(t, digCon.Provide(func() dao.WebhookServiceFactory { return nil })) 33 | require.NoError(t, digCon.Provide(func() dao.AuditServiceFactory { return nil })) 34 | require.NoError(t, digCon.Provide(func() definition.WorkQueueProducer { return nil })) 35 | require.NoError(t, digCon.Provide(func() auth.AuthServiceFactory { return nil })) 36 | require.NoError(t, digCon.Provide(tests.NewEcho)) 37 | require.NoError(t, factory{}.Initialize(digCon)) 38 | } 39 | -------------------------------------------------------------------------------- /pkg/server/middlewares/healthz/healthz.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package healthz 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/labstack/echo/v4" 21 | 22 | "github.com/go-sigma/sigma/pkg/xerrors" 23 | ) 24 | 25 | // Resource something that need be health checked 26 | type Resource interface { 27 | HealthCheck() error // returns error if health check no passed 28 | } 29 | 30 | // Healthz create a health check middleware 31 | func Healthz(rs ...Resource) echo.MiddlewareFunc { 32 | return func(next echo.HandlerFunc) echo.HandlerFunc { 33 | return func(c echo.Context) error { 34 | if c.Request().URL.Path == "/healthz" && c.Request().Method == http.MethodGet { 35 | for _, r := range rs { 36 | if err := r.HealthCheck(); err != nil { 37 | return xerrors.NewHTTPError(c, xerrors.HTTPErrCodeInternalError, err.Error()) 38 | } 39 | } 40 | return c.String(http.StatusOK, "OK") 41 | } 42 | return next(c) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pkg/signing/cosign/verify/verify.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package verify 16 | -------------------------------------------------------------------------------- /pkg/signing/definition/definition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package definition 16 | 17 | import "context" 18 | 19 | //go:generate mockgen -destination=mocks/signing.go -package=mocks github.com/go-sigma/sigma/pkg/signing/definition Signing 20 | //go:generate mockgen -destination=mocks/verifying.go -package=mocks github.com/go-sigma/sigma/pkg/signing/definition Verifying 21 | 22 | // Signing ... 23 | type Signing interface { 24 | Sign(ctx context.Context, token, priKey, ref string) error 25 | } 26 | 27 | // Verifying ... 28 | type Verifying interface { 29 | Verify(ref, token string) error 30 | } 31 | -------------------------------------------------------------------------------- /pkg/signing/definition/mocks/signing.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: github.com/go-sigma/sigma/pkg/signing/definition (interfaces: Signing) 3 | 4 | // Package mocks is a generated GoMock package. 5 | package mocks 6 | 7 | import ( 8 | context "context" 9 | reflect "reflect" 10 | 11 | gomock "github.com/golang/mock/gomock" 12 | ) 13 | 14 | // MockSigning is a mock of Signing interface. 15 | type MockSigning struct { 16 | ctrl *gomock.Controller 17 | recorder *MockSigningMockRecorder 18 | } 19 | 20 | // MockSigningMockRecorder is the mock recorder for MockSigning. 21 | type MockSigningMockRecorder struct { 22 | mock *MockSigning 23 | } 24 | 25 | // NewMockSigning creates a new mock instance. 26 | func NewMockSigning(ctrl *gomock.Controller) *MockSigning { 27 | mock := &MockSigning{ctrl: ctrl} 28 | mock.recorder = &MockSigningMockRecorder{mock} 29 | return mock 30 | } 31 | 32 | // EXPECT returns an object that allows the caller to indicate expected use. 33 | func (m *MockSigning) EXPECT() *MockSigningMockRecorder { 34 | return m.recorder 35 | } 36 | 37 | // Sign mocks base method. 38 | func (m *MockSigning) Sign(arg0 context.Context, arg1, arg2, arg3 string) error { 39 | m.ctrl.T.Helper() 40 | ret := m.ctrl.Call(m, "Sign", arg0, arg1, arg2, arg3) 41 | ret0, _ := ret[0].(error) 42 | return ret0 43 | } 44 | 45 | // Sign indicates an expected call of Sign. 46 | func (mr *MockSigningMockRecorder) Sign(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { 47 | mr.mock.ctrl.T.Helper() 48 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sign", reflect.TypeOf((*MockSigning)(nil).Sign), arg0, arg1, arg2, arg3) 49 | } 50 | -------------------------------------------------------------------------------- /pkg/signing/definition/mocks/verifying.go: -------------------------------------------------------------------------------- 1 | // Code generated by MockGen. DO NOT EDIT. 2 | // Source: github.com/go-sigma/sigma/pkg/signing/definition (interfaces: Verifying) 3 | 4 | // Package mocks is a generated GoMock package. 5 | package mocks 6 | 7 | import ( 8 | reflect "reflect" 9 | 10 | gomock "github.com/golang/mock/gomock" 11 | ) 12 | 13 | // MockVerifying is a mock of Verifying interface. 14 | type MockVerifying struct { 15 | ctrl *gomock.Controller 16 | recorder *MockVerifyingMockRecorder 17 | } 18 | 19 | // MockVerifyingMockRecorder is the mock recorder for MockVerifying. 20 | type MockVerifyingMockRecorder struct { 21 | mock *MockVerifying 22 | } 23 | 24 | // NewMockVerifying creates a new mock instance. 25 | func NewMockVerifying(ctrl *gomock.Controller) *MockVerifying { 26 | mock := &MockVerifying{ctrl: ctrl} 27 | mock.recorder = &MockVerifyingMockRecorder{mock} 28 | return mock 29 | } 30 | 31 | // EXPECT returns an object that allows the caller to indicate expected use. 32 | func (m *MockVerifying) EXPECT() *MockVerifyingMockRecorder { 33 | return m.recorder 34 | } 35 | 36 | // Verify mocks base method. 37 | func (m *MockVerifying) Verify(arg0, arg1 string) error { 38 | m.ctrl.T.Helper() 39 | ret := m.ctrl.Call(m, "Verify", arg0, arg1) 40 | ret0, _ := ret[0].(error) 41 | return ret0 42 | } 43 | 44 | // Verify indicates an expected call of Verify. 45 | func (mr *MockVerifyingMockRecorder) Verify(arg0, arg1 interface{}) *gomock.Call { 46 | mr.mock.ctrl.T.Helper() 47 | return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verify", reflect.TypeOf((*MockVerifying)(nil).Verify), arg0, arg1) 48 | } 49 | -------------------------------------------------------------------------------- /pkg/signing/signing.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package signing 16 | 17 | import ( 18 | "github.com/go-sigma/sigma/pkg/signing/cosign/sign" 19 | "github.com/go-sigma/sigma/pkg/signing/definition" 20 | "github.com/go-sigma/sigma/pkg/types/enums" 21 | ) 22 | 23 | // Options ... 24 | type Options struct { 25 | Type enums.SigningType 26 | 27 | Http bool 28 | MultiArch bool 29 | } 30 | 31 | // NewSigning ... 32 | func NewSigning(opt Options) definition.Signing { 33 | switch opt.Type { 34 | case enums.SigningTypeCosign: 35 | return sign.New(opt.Http, opt.MultiArch) 36 | default: 37 | return sign.New(opt.Http, opt.MultiArch) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkg/storage/filesystem/test/storage/unit-test-2: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /pkg/storage/filesystem/test/storage/unit-test-path.fake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/pkg/storage/filesystem/test/storage/unit-test-path.fake -------------------------------------------------------------------------------- /pkg/tests/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tests 16 | 17 | import ( 18 | "os" 19 | "strings" 20 | 21 | "github.com/spf13/viper" 22 | 23 | "github.com/go-sigma/sigma/pkg/configs" 24 | "github.com/go-sigma/sigma/pkg/consts" 25 | "github.com/go-sigma/sigma/pkg/types/enums" 26 | ) 27 | 28 | // GetConfig gets the configuration from the environment variables 29 | func GetConfig() (*configs.Configuration, error) { 30 | viper.AutomaticEnv() 31 | viper.SetEnvPrefix(consts.AppName) 32 | viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) 33 | 34 | err := viper.Unmarshal(configs.GetConfiguration()) 35 | if err != nil { 36 | return nil, err 37 | } 38 | config := configs.GetConfiguration() 39 | badgerDir, err := os.MkdirTemp("", "badger") 40 | if err != nil { 41 | return nil, err 42 | } 43 | config.Badger.Path = badgerDir 44 | config.Badger.Enabled = true 45 | config.Locker.Type = enums.LockerTypeBadger 46 | 47 | return configs.GetConfiguration(), nil 48 | } 49 | -------------------------------------------------------------------------------- /pkg/tests/echo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tests 16 | 17 | import "github.com/labstack/echo/v4" 18 | 19 | // NewEcho ... 20 | func NewEcho() *echo.Echo { 21 | e := echo.New() 22 | e.HideBanner = true 23 | e.HidePort = true 24 | return e 25 | } 26 | -------------------------------------------------------------------------------- /pkg/types/cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | // CreateCacheRequest ... 18 | type CreateCacheRequest struct { 19 | BuilderID int64 `json:"builder_id" param:"builder_id" validate:"required,number" example:"10"` 20 | } 21 | 22 | // DeleteCacheRequest ... 23 | type DeleteCacheRequest struct { 24 | BuilderID int64 `json:"builder_id" param:"builder_id" validate:"required,number" example:"10"` 25 | } 26 | 27 | // GetCacheRequest ... 28 | type GetCacheRequest struct { 29 | BuilderID int64 `json:"builder_id" param:"builder_id" validate:"required,number" example:"10"` 30 | } 31 | -------------------------------------------------------------------------------- /pkg/types/common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import "github.com/go-sigma/sigma/pkg/types/enums" 18 | 19 | // CommonList is the common list struct 20 | type CommonList struct { 21 | Total int64 `json:"total" example:"1"` 22 | Items []any `json:"items"` 23 | } 24 | 25 | // Pagination is the pagination struct 26 | type Pagination struct { 27 | Page *int `json:"page" query:"page" example:"1"` 28 | Limit *int `json:"limit" query:"limit" example:"10"` 29 | } 30 | 31 | // Sortable is the sort struct 32 | type Sortable struct { 33 | Sort *string `json:"sort" query:"sort" example:"created_at"` 34 | Method *enums.SortMethod `json:"method" query:"method" example:"desc"` 35 | } 36 | -------------------------------------------------------------------------------- /pkg/types/validator.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | // GetValidatorReferenceRequest ... 18 | type GetValidatorReferenceRequest struct { 19 | Reference string `json:"reference" query:"reference" validate:"required"` 20 | } 21 | 22 | // GetValidatorTagRequest ... 23 | type GetValidatorTagRequest struct { 24 | Tag string `json:"tag" query:"tag" validate:"required"` 25 | } 26 | 27 | // ValidatePasswordRequest ... 28 | type ValidatePasswordRequest struct { 29 | Password string `json:"password" validate:"required" example:"Admin@123"` 30 | } 31 | 32 | // ValidateCronRequest ... 33 | type ValidateCronRequest struct { 34 | Cron string `json:"cron" validate:"required" example:"0 0 * * 6"` 35 | } 36 | 37 | // ValidateRegexpRequest ... 38 | type ValidateRegexpRequest struct { 39 | Regexp string `json:"regexp" validate:"required" example:"^v.*$"` 40 | } 41 | -------------------------------------------------------------------------------- /pkg/utils/challenge/addr.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package challenge 16 | 17 | import ( 18 | "net/url" 19 | "strings" 20 | ) 21 | 22 | // code: borrow from https://github.com/distribution/distribution: internal/client/auth/challenge 23 | 24 | // FROM: https://golang.org/src/net/http/http.go 25 | // Given a string of the form "host", "host:port", or "[ipv6::address]:port", 26 | // return true if the string includes a port. 27 | func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") } 28 | 29 | // FROM: http://golang.org/src/net/http/transport.go 30 | var portMap = map[string]string{ 31 | "http": "80", 32 | "https": "443", 33 | } 34 | 35 | // canonicalAddr returns url.Host but always with a ":port" suffix 36 | // FROM: http://golang.org/src/net/http/transport.go 37 | func canonicalAddr(url *url.URL) string { 38 | addr := url.Host 39 | if !hasPort(addr) { 40 | return addr + ":" + portMap[url.Scheme] 41 | } 42 | return addr 43 | } 44 | -------------------------------------------------------------------------------- /pkg/utils/compress/test.txt: -------------------------------------------------------------------------------- 1 | hello sigma!!! 2 | -------------------------------------------------------------------------------- /pkg/utils/hash/ci.txt: -------------------------------------------------------------------------------- 1 | hello world!!! 2 | -------------------------------------------------------------------------------- /pkg/utils/hash/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package hash 16 | -------------------------------------------------------------------------------- /pkg/utils/imagerefs/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # imagerefs 4 | 5 | ```go 6 | import "code.byted.org/epscp/common/imagerefs" 7 | ``` 8 | 9 | Package imagerefs \.\.\. 10 | 11 | ## Index 12 | 13 | - [func Normalized(name string) (string, error)](<#func-normalized>) 14 | - [func Parse(name string) (string, string, string, string, error)](<#func-parse>) 15 | - [type NamespacedRepo](<#type-namespacedrepo>) 16 | - [func MakeNRFromString(s string) *NamespacedRepo](<#func-makenrfromstring>) 17 | - [func (nr *NamespacedRepo) String() string](<#func-namespacedrepo-string>) 18 | 19 | 20 | ## func Normalized 21 | 22 | ```go 23 | func Normalized(name string) (string, error) 24 | ``` 25 | 26 | Normalized \.\.\. 27 | 28 | ## func Parse 29 | 30 | ```go 31 | func Parse(name string) (string, string, string, string, error) 32 | ``` 33 | 34 | Parse \.\.\. 35 | 36 | ## type NamespacedRepo 37 | 38 | NamespacedRepo consist of Namespace and Repository\, usually representing a concrete form of TargetItem 39 | 40 | ```go 41 | type NamespacedRepo struct { 42 | Namespace string `json:"namespace"` 43 | Repository string `json:"repository"` 44 | } 45 | ``` 46 | 47 | ### func MakeNRFromString 48 | 49 | ```go 50 | func MakeNRFromString(s string) *NamespacedRepo 51 | ``` 52 | 53 | MakeNRFromString make a namespaced repo from a string\. string should be in a format as "\{namespace\}/\{repo\}" 54 | 55 | ### func \(\*NamespacedRepo\) String 56 | 57 | ```go 58 | func (nr *NamespacedRepo) String() string 59 | ``` 60 | 61 | String \.\.\. 62 | 63 | 64 | 65 | Generated by [gomarkdoc]() 66 | -------------------------------------------------------------------------------- /pkg/utils/ptr/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ptr 4 | 5 | ```go 6 | import "code.byted.org/epscp/common/ptr" 7 | ``` 8 | 9 | Package ptr \.\.\. 10 | 11 | ## Index 12 | 13 | - [func Of[T any](v T) *T](<#func-of>) 14 | - [func To[T any](v *T) T](<#func-to>) 15 | - [func ToDef[T any](v *T, def T) T](<#func-todef>) 16 | 17 | 18 | ## func Of 19 | 20 | ```go 21 | func Of[T any](v T) *T 22 | ``` 23 | 24 | Of returns pointer to value\. 25 | 26 | ## func To 27 | 28 | ```go 29 | func To[T any](v *T) T 30 | ``` 31 | 32 | To returns the value of the pointer passed in or the default value if the pointer is nil\. 33 | 34 | ## func ToDef 35 | 36 | ```go 37 | func ToDef[T any](v *T, def T) T 38 | ``` 39 | 40 | ToDef returns the value of the int pointer passed in or default value if the pointer is nil\. 41 | 42 | 43 | 44 | Generated by [gomarkdoc]() 45 | -------------------------------------------------------------------------------- /pkg/utils/ptr/ptr.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package ptr ... 16 | package ptr 17 | 18 | // Of returns pointer to value. 19 | func Of[T any](v T) *T { 20 | return &v 21 | } 22 | 23 | // To returns the value of the pointer passed in or the default value if the pointer is nil. 24 | func To[T any](v *T) T { 25 | var zero T 26 | if v == nil { 27 | return zero 28 | } 29 | return *v 30 | } 31 | 32 | // ToDef returns the value of the int pointer passed in or default value if the pointer is nil. 33 | func ToDef[T any](v *T, def T) T { 34 | if v == nil { 35 | return def 36 | } 37 | return *v 38 | } 39 | -------------------------------------------------------------------------------- /pkg/utils/ptr/ptr_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ptr 16 | 17 | import ( 18 | "reflect" 19 | "testing" 20 | ) 21 | 22 | func equal(t *testing.T, expected, actual interface{}) { 23 | if !reflect.DeepEqual(expected, actual) { 24 | t.Errorf("Expected %#v, actual %#v", expected, actual) 25 | } 26 | } 27 | 28 | func TestOf(t *testing.T) { 29 | equal(t, int(10), *Of(10)) 30 | } 31 | 32 | func TestTo(t *testing.T) { 33 | equal(t, int(10), To(Of(10))) 34 | equal(t, int(0), To((*int)(nil))) 35 | } 36 | 37 | func TestToDef(t *testing.T) { 38 | equal(t, int(10), ToDef(Of(10), 0)) 39 | equal(t, int(5), ToDef(nil, 5)) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/utils/reader/limit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package reader 16 | 17 | import "io" 18 | 19 | // LimitReader returns a Reader that reads from r 20 | // but stops with EOF after n bytes. 21 | // The underlying implementation is a *LimitedReader. 22 | func LimitReader(r io.Reader, n int64) io.Reader { return &LimitedReader{r, n} } 23 | 24 | // A LimitedReader reads from R but limits the amount of 25 | // data returned to just N bytes. Each call to Read 26 | // updates N to reflect the new amount remaining. 27 | // Read returns EOF when N <= 0 or when the underlying R returns EOF. 28 | type LimitedReader struct { 29 | R io.Reader // underlying reader 30 | N int64 // max bytes remaining 31 | } 32 | 33 | func (l *LimitedReader) Read(p []byte) (n int, err error) { 34 | if l.N <= 0 { 35 | return 0, io.EOF 36 | } 37 | if int64(len(p)) > l.N { 38 | p = p[0:l.N] 39 | } 40 | n, err = l.R.Read(p) 41 | l.N -= int64(n) 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /pkg/utils/reader/limit_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package reader 16 | 17 | import ( 18 | "io" 19 | "strings" 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestLimitReader(t *testing.T) { 26 | originalReader := strings.NewReader("hello world") 27 | 28 | limitReader := LimitReader(originalReader, 5) 29 | data, err := io.ReadAll(limitReader) 30 | assert.NoError(t, err) 31 | assert.Equal(t, "hello", string(data)) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package version 16 | 17 | var ( 18 | // Version ... 19 | Version = "" 20 | // GitHash ... 21 | GitHash = "" 22 | // BuildDate ... 23 | BuildDate = "" 24 | ) 25 | -------------------------------------------------------------------------------- /pkg/xerrors/xerrors_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package xerrors 16 | 17 | import ( 18 | "bytes" 19 | "net/http" 20 | "net/http/httptest" 21 | "testing" 22 | 23 | "github.com/labstack/echo/v4" 24 | "github.com/stretchr/testify/assert" 25 | ) 26 | 27 | func TestNewHTTPError(t *testing.T) { 28 | e := echo.New() 29 | req := httptest.NewRequest(http.MethodPost, "/", bytes.NewBufferString(`{}`)) 30 | req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) 31 | req.SetBasicAuth("sigma", "sigma1") 32 | rec := httptest.NewRecorder() 33 | c := e.NewContext(req, rec) 34 | err := NewHTTPError(c, HTTPErrCodeBadRequest, "Bad Request") 35 | assert.NoError(t, err) 36 | 37 | e1 := HTTPErrCodeBadRequest.Detail("Bad Request") 38 | assert.Equal(t, e1.Description, "Bad Request") 39 | } 40 | -------------------------------------------------------------------------------- /scripts/run_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR=$(dirname "$0") 4 | 5 | echo "Starting minio..." 6 | "$SCRIPT_DIR/run_minio.sh" 7 | 8 | echo "Starting redis..." 9 | "$SCRIPT_DIR/run_redis.sh" 10 | 11 | echo "Starting mysql..." 12 | "$SCRIPT_DIR/run_mysql.sh" 13 | 14 | echo "Starting postgresql..." 15 | "$SCRIPT_DIR/run_postgres.sh" 16 | -------------------------------------------------------------------------------- /scripts/run_minio.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DOCKER=${DOCKER:-docker} 4 | 5 | "$DOCKER" run -p 9000:9000 -p 9001:9001 \ 6 | --name sigma-minio \ 7 | -e MINIO_ROOT_USER=sigma \ 8 | -e MINIO_ROOT_PASSWORD=sigma-sigma \ 9 | -e MINIO_REGION_NAME=cn-north-1 \ 10 | --rm -d \ 11 | --entrypoint "" \ 12 | --health-cmd "mc ready local || exit 1" \ 13 | --health-interval 10s \ 14 | --health-timeout 5s \ 15 | --health-retries 10 \ 16 | quay.io/minio/minio:RELEASE.2024-11-07T00-52-20Z \ 17 | sh -c 'mkdir -p /data/sigma && minio server /data --console-address ":9001"' 18 | -------------------------------------------------------------------------------- /scripts/run_mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DOCKER=${DOCKER:-docker} 4 | 5 | "$DOCKER" run -it \ 6 | --name sigma-mysql \ 7 | -e MYSQL_ROOT_PASSWORD=sigma \ 8 | -e MYSQL_DATABASE=sigma \ 9 | -e MYSQL_USER=sigma \ 10 | -e MYSQL_PASSWORD=sigma \ 11 | -p 3306:3306 -d --rm \ 12 | --health-cmd "mysqladmin -usigma -psigma ping || exit 1" \ 13 | --health-interval 10s \ 14 | --health-timeout 5s \ 15 | --health-retries 10 \ 16 | mysql:8.0 17 | -------------------------------------------------------------------------------- /scripts/run_postgres.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DOCKER=${DOCKER:-docker} 4 | 5 | "$DOCKER" run -it \ 6 | --name sigma-postgres \ 7 | -e POSTGRES_PASSWORD=sigma \ 8 | -e POSTGRES_USER=sigma \ 9 | -e POSTGRES_DB=sigma \ 10 | -p 5432:5432 -d --rm \ 11 | --health-cmd "pg_isready -U sigma -d sigma || exit 1" \ 12 | --health-interval 10s \ 13 | --health-timeout 5s \ 14 | --health-retries 10 \ 15 | postgres:15-alpine 16 | -------------------------------------------------------------------------------- /scripts/run_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DOCKER=${DOCKER:-docker} 4 | 5 | "$DOCKER" run \ 6 | --name sigma-redis \ 7 | -p 6379:6379 -d --rm \ 8 | --health-cmd "redis-cli -a sigma ping || exit 1" \ 9 | --health-interval 10s \ 10 | --health-timeout 5s \ 11 | --health-retries 10 \ 12 | redis:7-alpine --requirepass sigma 13 | -------------------------------------------------------------------------------- /web/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | sigma 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /web/postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | 'postcss-import': {}, 4 | 'tailwindcss/nesting': 'postcss-nesting', 5 | tailwindcss: {}, 6 | autoprefixer: {}, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /web/public/distros/alma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/alma.png -------------------------------------------------------------------------------- /web/public/distros/alpine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/alpine.png -------------------------------------------------------------------------------- /web/public/distros/antix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/antix.png -------------------------------------------------------------------------------- /web/public/distros/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/arch.png -------------------------------------------------------------------------------- /web/public/distros/bunsenlabs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/bunsenlabs.png -------------------------------------------------------------------------------- /web/public/distros/centos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/centos.png -------------------------------------------------------------------------------- /web/public/distros/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/clear.png -------------------------------------------------------------------------------- /web/public/distros/debian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/debian.png -------------------------------------------------------------------------------- /web/public/distros/deepin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/deepin.png -------------------------------------------------------------------------------- /web/public/distros/elementary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/elementary.png -------------------------------------------------------------------------------- /web/public/distros/endless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/endless.png -------------------------------------------------------------------------------- /web/public/distros/fedora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/fedora.png -------------------------------------------------------------------------------- /web/public/distros/gentoo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/gentoo.png -------------------------------------------------------------------------------- /web/public/distros/kali.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/kali.png -------------------------------------------------------------------------------- /web/public/distros/kaos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/kaos.png -------------------------------------------------------------------------------- /web/public/distros/kubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/kubuntu.png -------------------------------------------------------------------------------- /web/public/distros/lite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/lite.png -------------------------------------------------------------------------------- /web/public/distros/mabox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/mabox.png -------------------------------------------------------------------------------- /web/public/distros/manjaro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/manjaro.png -------------------------------------------------------------------------------- /web/public/distros/mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/mint.png -------------------------------------------------------------------------------- /web/public/distros/nixos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/nixos.png -------------------------------------------------------------------------------- /web/public/distros/pop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/pop.png -------------------------------------------------------------------------------- /web/public/distros/raspios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/raspios.png -------------------------------------------------------------------------------- /web/public/distros/redhat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/redhat.png -------------------------------------------------------------------------------- /web/public/distros/suse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/suse.png -------------------------------------------------------------------------------- /web/public/distros/ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/ubuntu.png -------------------------------------------------------------------------------- /web/public/distros/void.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/void.png -------------------------------------------------------------------------------- /web/public/distros/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/windows.png -------------------------------------------------------------------------------- /web/public/distros/xubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/xubuntu.png -------------------------------------------------------------------------------- /web/public/distros/zorin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-sigma/sigma/ad977eca27721414f2311fcdd7c7a5753d4b541a/web/public/distros/zorin.png -------------------------------------------------------------------------------- /web/public/sigma.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /web/src/App.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 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 | -------------------------------------------------------------------------------- /web/src/Settings.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default { 18 | // QuotaThreshold turn green when quota is less than this value 19 | QuotaThreshold: 0.8, 20 | PageSize: 20, 21 | MaxSizeLimit: 102400 * (1 << 40), 22 | AutoCompleteSize: 5, 23 | }; 24 | -------------------------------------------------------------------------------- /web/src/components/Header/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ReactNode } from 'react'; 18 | 19 | export default function Header({ title, breadcrumb, props }: { title: string, breadcrumb?: ReactNode, props?: ReactNode }) { 20 | return ( 21 |
22 |
23 |
24 |

{title}

25 |
26 |
27 | {props} 28 |
29 |
30 |
31 | {breadcrumb} 32 |
33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /web/src/components/Menu/TableItemDropdown/index.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 sigma 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 | .menu-action-top { 18 | margin-top: -7rem; 19 | } 20 | -------------------------------------------------------------------------------- /web/src/components/Notification/index.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 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 | .fake-toast { 18 | background-color: #fff0 !important; 19 | box-shadow: 0 0 #fff0 !important; 20 | margin-bottom: 0 !important; 21 | } 22 | -------------------------------------------------------------------------------- /web/src/components/QuotaSimple/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import humanFormat from 'human-format'; 18 | 19 | import Settings from "../../Settings"; 20 | 21 | export default function ({ current, limit }: { current: number, limit: number }) { 22 | const threshold = limit !== 0 ? (current / limit > 1 ? 1 : current / limit) : 0; 23 | 24 | return ( 25 |
26 | { 27 | limit === 0 ? ( 28 | <>{humanFormat(current)} 29 | ) : ( 30 | <> 31 |
32 | {humanFormat(current)} / {humanFormat(limit)} ( Settings.QuotaThreshold ? "text-red-700 dark:text-red-500" : "text-blue-700 dark:text-blue-500"}>{(current / limit * 100 > 100 ? 100 : current / limit * 100).toFixed(1)}%) 33 |
34 | 35 | ) 36 | } 37 |
38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /web/src/components/svg/sigma.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default function () { 18 | return ( 19 | 20 | 21 | 22 | 23 | 24 | 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /web/src/index.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 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 | @tailwind base; 18 | @tailwind components; 19 | @tailwind utilities; 20 | -------------------------------------------------------------------------------- /web/src/interfaces/enums.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2024 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export enum NamespaceRole { 18 | Admin = "NamespaceAdmin", 19 | Manager = "NamespaceManager", 20 | Reader = "NamespaceReader", 21 | } 22 | 23 | export enum UserRole { 24 | Root = "Root", 25 | Admin = "Admin", 26 | User = "User", 27 | Anonymous = "Anonymous", 28 | } 29 | 30 | export enum WebhookResourceType { 31 | Ping = "ping", 32 | Namespace = "namespace", 33 | Repository = "repository", 34 | Tag = "tag", 35 | Artifact = "artifact", 36 | Member = "member" 37 | } 38 | 39 | export enum WebhookAction { 40 | Create = "create", 41 | Update = "update", 42 | Delete = "delete", 43 | Add = "add", 44 | Remove = "remove", 45 | Pull = "pull", 46 | Push = "push" 47 | } 48 | -------------------------------------------------------------------------------- /web/src/main.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import 'react-toastify/dist/ReactToastify.css'; 18 | 19 | import './index.css'; 20 | 21 | import dayjs from 'dayjs'; 22 | import utc from 'dayjs/plugin/utc'; 23 | import timezone from 'dayjs/plugin/timezone'; 24 | import relativeTime from 'dayjs/plugin/relativeTime'; 25 | 26 | import ReactDOM from 'react-dom/client'; 27 | import { HashRouter as Router } from 'react-router-dom'; 28 | 29 | import App from './App'; 30 | 31 | dayjs.extend(utc); 32 | dayjs.extend(timezone); 33 | dayjs.extend(relativeTime); 34 | 35 | ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( 36 | 37 | 38 | 39 | ); 40 | -------------------------------------------------------------------------------- /web/src/stores/index.tsx: -------------------------------------------------------------------------------- 1 | import { create } from 'zustand'; 2 | 3 | interface BearState { 4 | bears: number 5 | increase: (by: number) => void 6 | } 7 | 8 | const useBearStore = create()((set) => ({ 9 | bears: 0, 10 | increase: (by) => set((state) => ({ bears: state.bears + by })), 11 | })); 12 | -------------------------------------------------------------------------------- /web/src/utils/calcUnit.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { ISizeWithUnit } from "../interfaces"; 18 | 19 | export default function (size: number): ISizeWithUnit { 20 | let unit = "MiB"; 21 | let result = 0; 22 | let m = (size / (1 << 20)); 23 | if (m < 1024) { 24 | unit = "MiB"; 25 | result = m; 26 | } else { 27 | m = (size / (1 << 30)); 28 | if (m < 1024) { 29 | unit = "GiB" 30 | result = m; 31 | } else { 32 | m = (size / (1 << 40)); 33 | unit = "TiB" 34 | result = m; 35 | } 36 | } 37 | return { 38 | unit: unit, 39 | size: result, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /web/src/utils/distros.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default function (name: string) { 18 | switch (name) { 19 | case "alpine": 20 | return "alpine.png"; 21 | case "debian": 22 | return "debian.png"; 23 | default: 24 | return ""; 25 | } 26 | } 27 | 28 | export function distroName(name: string) { 29 | switch (name) { 30 | case "alpine": 31 | return "Alpine"; 32 | case "ubuntu": 33 | return "Ubuntu"; 34 | case "centos": 35 | return "CentOs"; 36 | case "debian": 37 | return "Debian" 38 | default: 39 | return ""; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /web/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export function trimHTTP(str: string) { 18 | if (str.startsWith("http://")) { 19 | return str.substring(7); 20 | } else if (str.startsWith("https://")) { 21 | return str.substring(8); 22 | } 23 | return str; 24 | } 25 | -------------------------------------------------------------------------------- /web/src/utils/regex.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export default { 18 | Username: /^[a-zA-Z0-9_\-@#$%]+$/, 19 | Email: /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/, 20 | Password: /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/, 21 | }; 22 | -------------------------------------------------------------------------------- /web/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 sigma 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 | /// 18 | -------------------------------------------------------------------------------- /web/tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import("tailwindcss").Config} */ 2 | module.exports = { 3 | darkMode: "class", 4 | content: ["./src/**/*.{html,js,tsx,scss}", "./index.html", "node_modules/flowbite-react/lib/esm/**/*.js"], 5 | theme: { 6 | extend: {}, 7 | }, 8 | plugins: [ 9 | require("@tailwindcss/typography"), 10 | require("@tailwindcss/forms"), 11 | require("@tailwindcss/aspect-ratio"), 12 | require('flowbite/plugin'), 13 | ], 14 | } 15 | -------------------------------------------------------------------------------- /web/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "lib": [ 6 | "DOM", 7 | "DOM.Iterable", 8 | "ESNext" 9 | ], 10 | "allowJs": false, 11 | "skipLibCheck": true, 12 | "esModuleInterop": false, 13 | "allowSyntheticDefaultImports": true, 14 | "strict": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "module": "ESNext", 17 | "moduleResolution": "Node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ], 26 | "references": [ 27 | { 28 | "path": "./tsconfig.node.json" 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /web/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "module": "ESNext", 5 | "moduleResolution": "Node", 6 | "allowSyntheticDefaultImports": true 7 | }, 8 | "include": ["vite.config.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /web/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import react from '@vitejs/plugin-react-swc'; 3 | 4 | export default defineConfig({ 5 | plugins: [react()], 6 | build: { 7 | chunkSizeWarningLimit: 8192, 8 | minify: "terser", 9 | target: "esnext", 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /web/web.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 sigma 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package web 16 | 17 | import ( 18 | "embed" 19 | 20 | "github.com/labstack/echo/v4" 21 | ) 22 | 23 | var ( 24 | //go:embed all:dist 25 | dist embed.FS 26 | //go:embed dist/index.html 27 | indexHTML embed.FS 28 | distDirFS = echo.MustSubFS(dist, "dist") 29 | distIndexHtml = echo.MustSubFS(indexHTML, "dist") 30 | ) 31 | 32 | // RegisterHandlers ... 33 | func RegisterHandlers(e *echo.Echo) { 34 | e.FileFS("/", "index.html", distIndexHtml) 35 | e.StaticFS("/", distDirFS) 36 | } 37 | --------------------------------------------------------------------------------