├── .env.example ├── .github ├── CODEOWNERS ├── CONTRIBUTING.md ├── README.md ├── SUPPORT.md ├── renovate.json └── workflows │ ├── build.yml │ ├── codeql-analysis.yml │ ├── integration-test.yml │ ├── jsonschema.yml │ ├── prerelease.yml │ ├── publish.yml │ ├── reviewdog.yml │ ├── spec.yml │ ├── test.yml │ ├── validate-pr-title.yml │ └── validate.yml ├── .gitignore ├── .golangci.yml ├── DOCS.md ├── Dockerfile ├── Dockerfile-alpine ├── LICENSE ├── Makefile ├── NOTICE ├── api ├── admin │ ├── build.go │ ├── clean.go │ ├── deployment.go │ ├── doc.go │ ├── hook.go │ ├── repo.go │ ├── rotate_keys.go │ ├── secret.go │ ├── service.go │ ├── settings.go │ ├── step.go │ ├── user.go │ └── worker.go ├── auth │ ├── doc.go │ ├── get_token.go │ ├── login.go │ ├── logout.go │ ├── post_token.go │ ├── redirect.go │ ├── refresh.go │ ├── validate.go │ └── validate_oauth.go ├── badge.go ├── build │ ├── approve.go │ ├── auto_cancel.go │ ├── auto_cancel_test.go │ ├── cancel.go │ ├── clean.go │ ├── compile_publish.go │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── enqueue.go │ ├── executable.go │ ├── gatekeep.go │ ├── get.go │ ├── get_id.go │ ├── graph.go │ ├── id_request_token.go │ ├── id_token.go │ ├── list_org.go │ ├── list_repo.go │ ├── plan.go │ ├── restart.go │ ├── skip.go │ ├── skip_test.go │ ├── status.go │ ├── token.go │ └── update.go ├── dashboard │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list_user.go │ └── update.go ├── deployment │ ├── create.go │ ├── doc.go │ ├── get.go │ ├── get_config.go │ └── list.go ├── doc.go ├── health.go ├── hook │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ ├── redeliver.go │ └── update.go ├── jwks.go ├── log │ ├── create_service.go │ ├── create_step.go │ ├── delete_service.go │ ├── delete_step.go │ ├── doc.go │ ├── get_service.go │ ├── get_step.go │ ├── list_build.go │ ├── update_service.go │ └── update_step.go ├── metrics.go ├── oi_config.go ├── pagination.go ├── pipeline │ ├── compile.go │ ├── compile_test.go │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── expand.go │ ├── get.go │ ├── list.go │ ├── output.go │ ├── template.go │ ├── update.go │ └── validate.go ├── queue │ ├── doc.go │ └── queue.go ├── repo │ ├── chown.go │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ ├── list_org.go │ ├── repair.go │ ├── status.go │ └── update.go ├── schedule │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ └── update.go ├── scm │ ├── doc.go │ ├── sync.go │ └── sync_org.go ├── secret │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ └── update.go ├── service │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ ├── plan.go │ └── update.go ├── step │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ ├── plan.go │ └── update.go ├── types │ ├── actions │ │ ├── comment.go │ │ ├── comment_test.go │ │ ├── deploy.go │ │ ├── deploy_test.go │ │ ├── pull.go │ │ ├── pull_test.go │ │ ├── push.go │ │ ├── push_test.go │ │ ├── schedule.go │ │ └── schedule_test.go │ ├── build.go │ ├── build_executable.go │ ├── build_executable_test.go │ ├── build_test.go │ ├── dashboard.go │ ├── dashboard_repo.go │ ├── dashboard_repo_test.go │ ├── dashboard_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── error.go │ ├── error_test.go │ ├── events.go │ ├── events_test.go │ ├── executor.go │ ├── executor_test.go │ ├── hook.go │ ├── hook_test.go │ ├── log.go │ ├── log_test.go │ ├── oidc.go │ ├── pipeline.go │ ├── pipeline_test.go │ ├── queue_build.go │ ├── queue_build_test.go │ ├── queue_info.go │ ├── queue_info_test.go │ ├── repo.go │ ├── repo_test.go │ ├── schedule.go │ ├── schedule_test.go │ ├── secret.go │ ├── secret_test.go │ ├── service.go │ ├── service_test.go │ ├── settings │ │ ├── compiler.go │ │ ├── compiler_test.go │ │ ├── platform.go │ │ ├── platform_test.go │ │ ├── queue.go │ │ ├── queue_test.go │ │ ├── scm.go │ │ └── scm_test.go │ ├── step.go │ ├── step_test.go │ ├── string.go │ ├── string_test.go │ ├── template.go │ ├── template_test.go │ ├── token.go │ ├── token_test.go │ ├── user.go │ ├── user_test.go │ ├── worker.go │ └── worker_test.go ├── user │ ├── create.go │ ├── create_token.go │ ├── delete.go │ ├── delete_token.go │ ├── doc.go │ ├── get.go │ ├── get_current.go │ ├── get_source.go │ ├── list.go │ ├── update.go │ └── update_current.go ├── version.go ├── webhook │ ├── doc.go │ └── post.go └── worker │ ├── create.go │ ├── delete.go │ ├── doc.go │ ├── get.go │ ├── list.go │ ├── refresh.go │ └── update.go ├── cmd ├── jsonschema-gen │ └── main.go └── vela-server │ ├── cleanup.go │ ├── flags.go │ ├── flags_test.go │ ├── main.go │ ├── metadata.go │ ├── schedule.go │ ├── scm.go │ ├── secret.go │ ├── server.go │ └── token.go ├── codecov.yml ├── compiler ├── context.go ├── context_test.go ├── doc.go ├── engine.go ├── native │ ├── clone.go │ ├── clone_test.go │ ├── compile.go │ ├── compile_test.go │ ├── doc.go │ ├── environment.go │ ├── environment_test.go │ ├── expand.go │ ├── expand_test.go │ ├── initialize.go │ ├── initialize_test.go │ ├── native.go │ ├── native_test.go │ ├── parse.go │ ├── parse_test.go │ ├── script.go │ ├── script_test.go │ ├── settings.go │ ├── substitute.go │ ├── substitute_test.go │ ├── testdata │ │ ├── circular.yml │ │ ├── clone_false.yml │ │ ├── clone_replace.yml │ │ ├── clone_true.yml │ │ ├── deploy_template.yml │ │ ├── environment.yml │ │ ├── golang_inline_stages.yml │ │ ├── golang_inline_stages_env.yml │ │ ├── golang_inline_steps.yml │ │ ├── gradle.yml │ │ ├── inline_circular_template.yml │ │ ├── inline_nested_template.yml │ │ ├── inline_with_environment.yml │ │ ├── inline_with_golang.yml │ │ ├── inline_with_secrets.yml │ │ ├── inline_with_services.yml │ │ ├── inline_with_stages.yml │ │ ├── inline_with_stages_and_steps.yml │ │ ├── inline_with_stages_env.yml │ │ ├── inline_with_steps.yml │ │ ├── invalid.yml │ │ ├── invalid_type.yml │ │ ├── long_template.yml │ │ ├── maven.yml │ │ ├── metadata.yml │ │ ├── nested.yml │ │ ├── parameters.yml │ │ ├── pipeline_type.star │ │ ├── pipeline_type_default.yml │ │ ├── pipeline_type_go.yml │ │ ├── secrets.yml │ │ ├── services.yml │ │ ├── stage_inline_template.yml │ │ ├── stages.yml │ │ ├── stages_merged.yml │ │ ├── stages_name_conflict.yml │ │ ├── stages_name_conflict_purged.yml │ │ ├── stages_pipeline.yml │ │ ├── stages_pipeline_template.yml │ │ ├── starlark_inline_stages.star │ │ ├── starlark_inline_steps.star │ │ ├── step_inline_template.yml │ │ ├── steps.yml │ │ ├── steps_and_stages.yml │ │ ├── steps_merge_anchor.yml │ │ ├── steps_merge_anchor_1.yml │ │ ├── steps_name_conflict.yml │ │ ├── steps_name_conflict_purged.yml │ │ ├── steps_pipeline.yml │ │ ├── steps_pipeline_template.yml │ │ ├── template.star │ │ ├── template.yml │ │ ├── template_calls_itself.yml │ │ ├── template_calls_template.yml │ │ ├── template_name.yml │ │ ├── template_name_inline.yml │ │ └── template_name_template.yml │ ├── transform.go │ ├── transform_test.go │ ├── validate.go │ └── validate_test.go ├── registry │ ├── doc.go │ ├── github │ │ ├── doc.go │ │ ├── github.go │ │ ├── github_test.go │ │ ├── parse.go │ │ ├── parse_test.go │ │ ├── template.go │ │ ├── template_test.go │ │ └── testdata │ │ │ ├── template.json │ │ │ └── template.yml │ ├── registry.go │ └── source.go ├── template │ ├── doc.go │ ├── native │ │ ├── convert.go │ │ ├── convert_test.go │ │ ├── doc.go │ │ ├── render.go │ │ ├── render_test.go │ │ └── testdata │ │ │ ├── build │ │ │ ├── basic │ │ │ │ ├── build.yml │ │ │ │ └── want.yml │ │ │ ├── basic_stages │ │ │ │ ├── build.yml │ │ │ │ └── want.yml │ │ │ └── conditional │ │ │ │ ├── build.yml │ │ │ │ └── want.yml │ │ │ └── step │ │ │ ├── bad_ruleset_format.yml │ │ │ ├── basic │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ ├── conditional │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ ├── disallowed │ │ │ ├── tmpl_env.yml │ │ │ └── tmpl_expandenv.yml │ │ │ ├── invalid.yml │ │ │ ├── invalid_template.yml │ │ │ ├── invalid_variables.yml │ │ │ ├── loop_map │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ ├── loop_slice │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ ├── multiline │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ ├── to_yaml │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ │ │ └── with_vars_plat │ │ │ ├── step.yml │ │ │ ├── tmpl.yml │ │ │ └── want.yml │ ├── starlark │ │ ├── convert.go │ │ ├── convert_test.go │ │ ├── render.go │ │ ├── render_test.go │ │ ├── starlark.go │ │ ├── starlark_test.go │ │ └── testdata │ │ │ ├── build │ │ │ ├── basic │ │ │ │ ├── build.star │ │ │ │ └── want.yml │ │ │ ├── basic_stages │ │ │ │ ├── build.star │ │ │ │ └── want.yml │ │ │ ├── conditional │ │ │ │ ├── build.star │ │ │ │ └── want.yml │ │ │ ├── large │ │ │ │ ├── build.star │ │ │ │ └── want.yml │ │ │ └── with_struct │ │ │ │ ├── build.star │ │ │ │ └── want.yml │ │ │ └── step │ │ │ ├── basic │ │ │ ├── step.yml │ │ │ ├── template.py │ │ │ └── want.yml │ │ │ ├── cancel │ │ │ ├── step.yml │ │ │ └── template.star │ │ │ ├── with_method │ │ │ ├── step.yml │ │ │ ├── template.star │ │ │ └── want.yml │ │ │ ├── with_vars │ │ │ ├── step.yml │ │ │ ├── template.star │ │ │ └── want.yml │ │ │ └── with_vars_plat │ │ │ ├── step.yml │ │ │ ├── template.star │ │ │ └── want.yml │ └── template.go └── types │ ├── pipeline │ ├── build.go │ ├── build_test.go │ ├── container.go │ ├── container_test.go │ ├── context.go │ ├── context_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── doc.go │ ├── git.go │ ├── git_test.go │ ├── metadata.go │ ├── port.go │ ├── ruleset.go │ ├── ruleset_test.go │ ├── secret.go │ ├── secret_test.go │ ├── stage.go │ ├── stage_test.go │ ├── ulimit.go │ ├── volume.go │ ├── worker.go │ └── worker_test.go │ ├── raw │ ├── doc.go │ ├── map.go │ ├── map_test.go │ ├── slice.go │ ├── slice_test.go │ └── testdata │ │ ├── invalid.json │ │ ├── invalid.yml │ │ ├── invalid_2.json │ │ ├── invalid_2.yml │ │ ├── map.json │ │ ├── map.yml │ │ ├── slice.json │ │ ├── slice.yml │ │ ├── slice_map.json │ │ ├── slice_map.yml │ │ ├── string.json │ │ ├── string.yml │ │ ├── string_map.json │ │ └── string_map.yml │ └── yaml │ ├── buildkite │ ├── build.go │ ├── build_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── doc.go │ ├── git.go │ ├── git_test.go │ ├── metadata.go │ ├── metadata_test.go │ ├── ruleset.go │ ├── ruleset_test.go │ ├── secret.go │ ├── secret_test.go │ ├── service.go │ ├── service_test.go │ ├── stage.go │ ├── stage_test.go │ ├── step.go │ ├── step_test.go │ ├── template.go │ ├── template_test.go │ ├── testdata │ │ ├── build.yml │ │ ├── build │ │ │ └── validate │ │ │ │ ├── bad_pipeline0.yml │ │ │ │ ├── bad_pipeline1.yml │ │ │ │ ├── bad_version.yml │ │ │ │ └── step.yml │ │ ├── build_anchor_stage.yml │ │ ├── build_anchor_step.yml │ │ ├── build_empty_env.yml │ │ ├── build_with_deploy_config.yml │ │ ├── deploy_parameter.yml │ │ ├── invalid.yml │ │ ├── merge_anchor.yml │ │ ├── metadata.yml │ │ ├── metadata_env.yml │ │ ├── ruleset_advanced.yml │ │ ├── ruleset_op_match.yml │ │ ├── ruleset_regex.yml │ │ ├── ruleset_simple.yml │ │ ├── secret.yml │ │ ├── secret │ │ │ └── validate │ │ │ │ ├── no_name.yml │ │ │ │ ├── org.yml │ │ │ │ ├── org_bad_engine.yml │ │ │ │ ├── org_bad_key.yml │ │ │ │ ├── plugin.yml │ │ │ │ ├── plugin_bad_image.yml │ │ │ │ ├── plugin_bad_name.yml │ │ │ │ ├── repo.yml │ │ │ │ ├── repo_bad_engine.yml │ │ │ │ ├── repo_bad_key.yml │ │ │ │ ├── shared.yml │ │ │ │ ├── shared_bad_engine.yml │ │ │ │ └── shared_bad_key.yml │ │ ├── service.yml │ │ ├── service │ │ │ └── validate │ │ │ │ ├── bad_image.yml │ │ │ │ ├── minimal.yml │ │ │ │ ├── missing_image.yml │ │ │ │ └── missing_name.yml │ │ ├── service_nil.yml │ │ ├── stage.yml │ │ ├── stage │ │ │ └── validate │ │ │ │ ├── bad_image.yml │ │ │ │ ├── minimal.yml │ │ │ │ ├── missing.yml │ │ │ │ ├── missing_image.yml │ │ │ │ └── missing_name.yml │ │ ├── step.yml │ │ ├── step │ │ │ └── validate │ │ │ │ ├── bad_image.yml │ │ │ │ ├── minimal.yml │ │ │ │ ├── missing.yml │ │ │ │ ├── missing_image.yml │ │ │ │ └── missing_name.yml │ │ ├── step_malformed.yml │ │ ├── step_nil.yml │ │ ├── step_secret_slice.yml │ │ ├── step_secret_slice_invalid_no_source.yml │ │ ├── step_secret_slice_invalid_no_target.yml │ │ ├── step_secret_string.yml │ │ ├── template.yml │ │ ├── ulimit_colon_error.yml │ │ ├── ulimit_equal_error.yml │ │ ├── ulimit_hardlimit1_error.yml │ │ ├── ulimit_hardlimit2_error.yml │ │ ├── ulimit_slice.yml │ │ ├── ulimit_softlimit_error.yml │ │ ├── ulimit_string.yml │ │ ├── volume_error.yml │ │ ├── volume_slice.yml │ │ └── volume_string.yml │ ├── ulimit.go │ ├── ulimit_test.go │ ├── volume.go │ ├── volume_test.go │ ├── worker.go │ └── worker_test.go │ └── yaml │ ├── build.go │ ├── build_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── doc.go │ ├── git.go │ ├── git_test.go │ ├── metadata.go │ ├── metadata_test.go │ ├── ruleset.go │ ├── ruleset_test.go │ ├── secret.go │ ├── secret_test.go │ ├── service.go │ ├── service_test.go │ ├── stage.go │ ├── stage_test.go │ ├── step.go │ ├── step_test.go │ ├── template.go │ ├── template_test.go │ ├── testdata │ ├── build.yml │ ├── build │ │ └── validate │ │ │ ├── bad_pipeline0.yml │ │ │ ├── bad_pipeline1.yml │ │ │ ├── bad_version.yml │ │ │ └── step.yml │ ├── build_anchor_stage.yml │ ├── build_anchor_step.yml │ ├── build_empty_env.yml │ ├── build_with_deploy_config.yml │ ├── deploy_parameter.yml │ ├── invalid.yml │ ├── merge_anchor.yml │ ├── metadata.yml │ ├── metadata_env.yml │ ├── ruleset_advanced.yml │ ├── ruleset_collide.yml │ ├── ruleset_collide_adv.yml │ ├── ruleset_op_match.yml │ ├── ruleset_regex.yml │ ├── ruleset_simple.yml │ ├── ruleset_unknown_field.yml │ ├── secret.yml │ ├── secret │ │ └── validate │ │ │ ├── no_name.yml │ │ │ ├── org.yml │ │ │ ├── org_bad_engine.yml │ │ │ ├── org_bad_key.yml │ │ │ ├── plugin.yml │ │ │ ├── plugin_bad_image.yml │ │ │ ├── plugin_bad_name.yml │ │ │ ├── repo.yml │ │ │ ├── repo_bad_engine.yml │ │ │ ├── repo_bad_key.yml │ │ │ ├── shared.yml │ │ │ ├── shared_bad_engine.yml │ │ │ └── shared_bad_key.yml │ ├── service.yml │ ├── service │ │ └── validate │ │ │ ├── bad_image.yml │ │ │ ├── minimal.yml │ │ │ ├── missing_image.yml │ │ │ └── missing_name.yml │ ├── service_nil.yml │ ├── stage.yml │ ├── stage │ │ └── validate │ │ │ ├── bad_image.yml │ │ │ ├── minimal.yml │ │ │ ├── missing.yml │ │ │ ├── missing_image.yml │ │ │ └── missing_name.yml │ ├── step.yml │ ├── step │ │ └── validate │ │ │ ├── bad_image.yml │ │ │ ├── minimal.yml │ │ │ ├── missing.yml │ │ │ ├── missing_image.yml │ │ │ └── missing_name.yml │ ├── step_malformed.yml │ ├── step_nil.yml │ ├── step_secret_slice.yml │ ├── step_secret_slice_invalid_no_source.yml │ ├── step_secret_slice_invalid_no_target.yml │ ├── step_secret_string.yml │ ├── template.yml │ ├── ulimit_colon_error.yml │ ├── ulimit_equal_error.yml │ ├── ulimit_hardlimit1_error.yml │ ├── ulimit_hardlimit2_error.yml │ ├── ulimit_slice.yml │ ├── ulimit_softlimit_error.yml │ ├── ulimit_string.yml │ ├── volume_error.yml │ ├── volume_slice.yml │ └── volume_string.yml │ ├── ulimit.go │ ├── ulimit_test.go │ ├── volume.go │ ├── volume_test.go │ ├── worker.go │ └── worker_test.go ├── constants ├── action.go ├── allow_events.go ├── app_install.go ├── badge.go ├── compression.go ├── doc.go ├── driver.go ├── errors.go ├── event.go ├── limit.go ├── matcher.go ├── operator.go ├── permission.go ├── pipeline.go ├── pull.go ├── queue.go ├── repo.go ├── secret.go ├── status.go ├── table.go ├── token.go ├── visibility.go ├── worker_status.go └── workspace.go ├── database ├── build │ ├── build.go │ ├── build_test.go │ ├── clean.go │ ├── clean_test.go │ ├── count.go │ ├── count_deployment.go │ ├── count_deployment_test.go │ ├── count_org.go │ ├── count_org_test.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_status.go │ ├── count_status_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── last_repo.go │ ├── last_repo_test.go │ ├── list.go │ ├── list_dashboard.go │ ├── list_dashboard_test.go │ ├── list_org.go │ ├── list_org_test.go │ ├── list_pending_approval.go │ ├── list_pending_approval_test.go │ ├── list_pending_running.go │ ├── list_pending_running_repo.go │ ├── list_pending_running_repo_test.go │ ├── list_pending_running_test.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── close.go ├── close_test.go ├── context.go ├── context_test.go ├── dashboard │ ├── create.go │ ├── create_test.go │ ├── dashboard.go │ ├── dashboard_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_test.go │ ├── interface.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── database.go ├── database_test.go ├── deployment │ ├── count.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── get.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── doc.go ├── driver.go ├── driver_test.go ├── executable │ ├── clean.go │ ├── clean_test.go │ ├── create.go │ ├── create_test.go │ ├── executable.go │ ├── executable_test.go │ ├── interface.go │ ├── opts.go │ ├── opts_test.go │ ├── pop.go │ ├── pop_test.go │ ├── table.go │ └── table_test.go ├── flags.go ├── flags_test.go ├── hook │ ├── count.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_test.go │ ├── get_webhook.go │ ├── get_webhook_test.go │ ├── hook.go │ ├── hook_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── last_repo.go │ ├── last_repo_test.go │ ├── list.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── integration_test.go ├── interface.go ├── jwk │ ├── create.go │ ├── create_test.go │ ├── get.go │ ├── get_test.go │ ├── interface.go │ ├── jwk.go │ ├── jwk_test.go │ ├── list.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── rotate.go │ ├── rotate_test.go │ ├── table.go │ └── table_test.go ├── log │ ├── count.go │ ├── count_build.go │ ├── count_build_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_service.go │ ├── get_service_test.go │ ├── get_step.go │ ├── get_step_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_build.go │ ├── list_build_test.go │ ├── list_test.go │ ├── log.go │ ├── log_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── logger.go ├── logger_test.go ├── opts.go ├── opts_test.go ├── ping.go ├── ping_test.go ├── pipeline │ ├── count.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── pipeline.go │ ├── pipeline_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── repo │ ├── count.go │ ├── count_org.go │ ├── count_org_test.go │ ├── count_test.go │ ├── count_user.go │ ├── count_user_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_org.go │ ├── get_org_test.go │ ├── get_test.go │ ├── in_list.go │ ├── in_list_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_org.go │ ├── list_org_test.go │ ├── list_test.go │ ├── list_user.go │ ├── list_user_test.go │ ├── opts.go │ ├── opts_test.go │ ├── repo.go │ ├── repo_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── resource.go ├── resource_test.go ├── schedule │ ├── count.go │ ├── count_active.go │ ├── count_active_test.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_active.go │ ├── list_active_test.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── schedule.go │ ├── schedule_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── secret │ ├── count.go │ ├── count_org.go │ ├── count_org_test.go │ ├── count_repo.go │ ├── count_repo_test.go │ ├── count_team.go │ ├── count_team_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── fill_allowlist.go │ ├── fill_allowlist_test.go │ ├── fill_allowlists.go │ ├── fill_allowlists_test.go │ ├── get.go │ ├── get_org.go │ ├── get_org_test.go │ ├── get_repo.go │ ├── get_repo_test.go │ ├── get_team.go │ ├── get_team_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── insert_allowlist.go │ ├── insert_allowlist_test.go │ ├── interface.go │ ├── list.go │ ├── list_org.go │ ├── list_org_test.go │ ├── list_repo.go │ ├── list_repo_test.go │ ├── list_team.go │ ├── list_team_test.go │ ├── list_test.go │ ├── migrate_secrets.go │ ├── migrate_secrets_test.go │ ├── opts.go │ ├── opts_test.go │ ├── prune_allowlist.go │ ├── prune_allowlist_test.go │ ├── secret.go │ ├── secret_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── service │ ├── clean.go │ ├── clean_test.go │ ├── count.go │ ├── count_build.go │ ├── count_build_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_build.go │ ├── get_build_test.go │ ├── get_test.go │ ├── interface.go │ ├── list.go │ ├── list_build.go │ ├── list_build_test.go │ ├── list_image.go │ ├── list_image_test.go │ ├── list_status.go │ ├── list_status_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── service.go │ ├── service_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── settings │ ├── create.go │ ├── create_test.go │ ├── get.go │ ├── get_test.go │ ├── interface.go │ ├── opts.go │ ├── opts_test.go │ ├── settings.go │ ├── settings_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── step │ ├── clean.go │ ├── clean_test.go │ ├── count.go │ ├── count_build.go │ ├── count_build_test.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_build.go │ ├── get_build_test.go │ ├── get_test.go │ ├── interface.go │ ├── list.go │ ├── list_build.go │ ├── list_build_test.go │ ├── list_image.go │ ├── list_image_test.go │ ├── list_status.go │ ├── list_status_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── step.go │ ├── step_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ └── update_test.go ├── testutils │ ├── api_resources.go │ ├── mock_args.go │ └── mock_rows.go ├── types │ ├── build.go │ ├── build_executable.go │ ├── build_executable_test.go │ ├── build_test.go │ ├── dashboard.go │ ├── dashboard_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── hook.go │ ├── hook_test.go │ ├── jwk.go │ ├── jwk_test.go │ ├── log.go │ ├── log_test.go │ ├── pipeline.go │ ├── pipeline_test.go │ ├── queue_build.go │ ├── queue_build_test.go │ ├── repo.go │ ├── repo_test.go │ ├── schedule.go │ ├── schedule_test.go │ ├── secret.go │ ├── secret_allowlist.go │ ├── secret_allowlist_test.go │ ├── secret_test.go │ ├── service.go │ ├── service_test.go │ ├── settings.go │ ├── settings_test.go │ ├── step.go │ ├── step_test.go │ ├── user.go │ ├── user_test.go │ ├── worker.go │ └── worker_test.go ├── user │ ├── count.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_name.go │ ├── get_name_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_lite.go │ ├── list_lite_test.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ ├── update_test.go │ ├── user.go │ └── user_test.go ├── validate.go ├── validate_test.go └── worker │ ├── count.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── get.go │ ├── get_hostname.go │ ├── get_hostname_test.go │ ├── get_test.go │ ├── index.go │ ├── index_test.go │ ├── interface.go │ ├── list.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── table.go │ ├── table_test.go │ ├── update.go │ ├── update_test.go │ ├── worker.go │ └── worker_test.go ├── docker-compose.yml ├── go.mod ├── go.sum ├── internal ├── image │ ├── doc.go │ ├── image.go │ └── image_test.go ├── metadata.go ├── testdata │ ├── buildkite.yml │ ├── buildkite_new_version.yml │ ├── go-yaml.yml │ ├── invalid.yml │ ├── no_version.yml │ ├── top_level_anchor.yml │ └── top_level_anchor_legacy.yml ├── token │ ├── compose.go │ ├── compose_test.go │ ├── generate_rsa.go │ ├── manager.go │ ├── mint.go │ ├── mint_test.go │ ├── parse.go │ ├── parse_test.go │ ├── refresh.go │ └── refresh_test.go ├── webhook.go ├── webhook_test.go ├── yaml.go └── yaml_test.go ├── mock └── server │ ├── authentication.go │ ├── build.go │ ├── build_test.go │ ├── dashboard.go │ ├── dashboard_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── hook.go │ ├── hook_test.go │ ├── log.go │ ├── log_test.go │ ├── pipeline.go │ ├── pipeline_test.go │ ├── repo.go │ ├── repo_test.go │ ├── rotate_keys.go │ ├── schedule.go │ ├── schedule_test.go │ ├── scm.go │ ├── secret.go │ ├── secret_test.go │ ├── server.go │ ├── service.go │ ├── service_test.go │ ├── settings.go │ ├── settings_test.go │ ├── step.go │ ├── step_test.go │ ├── user.go │ ├── user_test.go │ ├── worker.go │ └── worker_test.go ├── queue ├── context.go ├── context_test.go ├── doc.go ├── flags.go ├── flags_test.go ├── models │ ├── item.go │ └── item_test.go ├── queue.go ├── queue_test.go ├── redis │ ├── doc.go │ ├── driver.go │ ├── driver_test.go │ ├── length.go │ ├── length_test.go │ ├── opts.go │ ├── opts_test.go │ ├── ping.go │ ├── ping_test.go │ ├── pop.go │ ├── pop_test.go │ ├── push.go │ ├── push_test.go │ ├── redis.go │ ├── redis_test.go │ ├── route.go │ ├── route_length.go │ ├── route_length_test.go │ ├── route_test.go │ └── settings.go ├── service.go ├── setup.go └── setup_test.go ├── random └── random.go ├── router ├── admin.go ├── build.go ├── dashboard.go ├── deployment.go ├── doc.go ├── hook.go ├── log.go ├── middleware │ ├── app_webhook_secret.go │ ├── app_webhook_secret_test.go │ ├── auth │ │ ├── auth.go │ │ ├── auth_test.go │ │ └── doc.go │ ├── build │ │ ├── build.go │ │ ├── build_test.go │ │ ├── context.go │ │ ├── context_test.go │ │ └── doc.go │ ├── claims │ │ ├── claims.go │ │ ├── claims_test.go │ │ ├── context.go │ │ ├── context_test.go │ │ └── doc.go │ ├── cli.go │ ├── cli │ │ ├── context.go │ │ ├── context_test.go │ │ └── doc.go │ ├── cli_test.go │ ├── compiler.go │ ├── compiler_test.go │ ├── dashboard │ │ ├── context.go │ │ ├── context_test.go │ │ ├── dashboard.go │ │ ├── dashboard_test.go │ │ └── doc.go │ ├── database.go │ ├── database_test.go │ ├── default_build_limit.go │ ├── default_build_limit_test.go │ ├── default_repo_settings.go │ ├── default_repo_settings_test.go │ ├── default_timeout.go │ ├── default_timeout_test.go │ ├── doc.go │ ├── executors │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── executor_test.go │ │ └── executors.go │ ├── header.go │ ├── header_test.go │ ├── hook │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── hook.go │ │ └── hook_test.go │ ├── logger.go │ ├── logger_test.go │ ├── max_build_limit.go │ ├── max_build_limit_test.go │ ├── metadata.go │ ├── metadata_test.go │ ├── org │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── org.go │ │ └── org_test.go │ ├── payload.go │ ├── payload_test.go │ ├── perm │ │ ├── doc.go │ │ ├── perm.go │ │ └── perm_test.go │ ├── pipeline │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── pipeline.go │ │ ├── pipeline_test.go │ │ └── testdata │ │ │ └── yml.json │ ├── queue.go │ ├── queue_test.go │ ├── repo │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── repo.go │ │ └── repo_test.go │ ├── schedule │ │ ├── context.go │ │ ├── context_test.go │ │ └── schedule.go │ ├── schedule_frequency.go │ ├── schedule_frequency_test.go │ ├── scm.go │ ├── scm_test.go │ ├── secret.go │ ├── secret_test.go │ ├── secure_cookie.go │ ├── secure_cookie_test.go │ ├── service │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── service.go │ │ └── service_test.go │ ├── settings.go │ ├── settings │ │ ├── context.go │ │ ├── context_test.go │ │ └── doc.go │ ├── settings_test.go │ ├── signing.go │ ├── signing_test.go │ ├── step │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── step.go │ │ └── step_test.go │ ├── token_manager.go │ ├── token_manager_test.go │ ├── tracing.go │ ├── tracing │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── tracing.go │ │ └── tracing_test.go │ ├── tracing_test.go │ ├── user │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── user.go │ │ └── user_test.go │ ├── webhook_validation.go │ ├── webhook_validation_test.go │ ├── worker.go │ ├── worker │ │ ├── context.go │ │ ├── context_test.go │ │ ├── doc.go │ │ ├── worker.go │ │ └── worker_test.go │ └── worker_test.go ├── pipeline.go ├── queue.go ├── repo.go ├── router.go ├── schedule.go ├── scm.go ├── search.go ├── secret.go ├── service.go ├── step.go ├── user.go └── worker.go ├── schema ├── pipeline.go ├── pipeline_test.go └── testdata │ └── pipeline │ ├── fail │ ├── image_and_template.yml │ ├── invalid_prop.yml │ ├── invalid_pull.yml │ ├── missing_name.yml │ ├── ruleset_invalid_matcher.yml │ ├── ruleset_invalid_status.yml │ ├── ruleset_invalid_values.yml │ └── stages_and_steps.yml │ └── pass │ ├── basic.yml │ ├── complex.yml │ ├── ruleset_if.yml │ ├── ruleset_path.yml │ ├── ruleset_status.yml │ └── stages.yml ├── scm ├── context.go ├── context_test.go ├── doc.go ├── flags.go ├── flags_test.go ├── github │ ├── access.go │ ├── access_test.go │ ├── app_install.go │ ├── app_permissions.go │ ├── app_permissions_test.go │ ├── app_transport.go │ ├── app_transport_test.go │ ├── authentication.go │ ├── authentication_test.go │ ├── changeset.go │ ├── changeset_test.go │ ├── deployment.go │ ├── deployment_test.go │ ├── doc.go │ ├── driver.go │ ├── driver_test.go │ ├── github.go │ ├── github_client.go │ ├── github_client_test.go │ ├── github_test.go │ ├── opts.go │ ├── opts_test.go │ ├── org.go │ ├── org_test.go │ ├── repo.go │ ├── repo_test.go │ ├── settings.go │ ├── testdata │ │ ├── branch.json │ │ ├── delivery_summaries.json │ │ ├── deployment.json │ │ ├── deployments.json │ │ ├── get_org.json │ │ ├── get_pull_request.json │ │ ├── get_repo.json │ │ ├── hook.json │ │ ├── hooks.json │ │ ├── hooks │ │ │ ├── custom_property_values.json │ │ │ ├── deployment.json │ │ │ ├── deployment_commit.json │ │ │ ├── deployment_unexpected_json_payload.json │ │ │ ├── deployment_unexpected_text_payload.json │ │ │ ├── installation_created.json │ │ │ ├── installation_deleted.json │ │ │ ├── installation_repositories_added.json │ │ │ ├── installation_repositories_removed.json │ │ │ ├── issue_comment_created.json │ │ │ ├── issue_comment_deleted.json │ │ │ ├── issue_comment_pr.json │ │ │ ├── pull_request.json │ │ │ ├── pull_request_closed_action.json │ │ │ ├── pull_request_closed_state.json │ │ │ ├── pull_request_edited_while_labeled.json │ │ │ ├── pull_request_fork.json │ │ │ ├── pull_request_fork_same-repo.json │ │ │ ├── pull_request_labeled.json │ │ │ ├── pull_request_unlabeled.json │ │ │ ├── push.json │ │ │ ├── push_delete_branch.json │ │ │ ├── push_delete_tag.json │ │ │ ├── push_no_sender.json │ │ │ ├── repository_archived.json │ │ │ ├── repository_edited.json │ │ │ ├── repository_publicized.json │ │ │ ├── repository_rename.json │ │ │ └── repository_transferred.json │ │ ├── hooks_multi.json │ │ ├── installation_repositories.json │ │ ├── installations.json │ │ ├── installations_access_tokens.json │ │ ├── list_contributors.json │ │ ├── listchanges.json │ │ ├── listchangespr.json │ │ ├── listuserrepos.json │ │ ├── listuserrepos_ineligible.json │ │ ├── login.json │ │ ├── org_admin.json │ │ ├── org_member.json │ │ ├── org_pending.json │ │ ├── pipeline.star │ │ ├── pipeline.yml │ │ ├── py.json │ │ ├── repo_admin.json │ │ ├── star.json │ │ ├── status.json │ │ ├── team_admin.json │ │ ├── team_member.json │ │ ├── token.json │ │ ├── user.json │ │ ├── user_teams.json │ │ ├── yaml.json │ │ ├── yml.json │ │ └── yml_bad_encoding.json │ ├── user.go │ ├── webhook.go │ └── webhook_test.go ├── scm.go ├── scm_test.go ├── service.go ├── setup.go └── setup_test.go ├── secret ├── context.go ├── context_test.go ├── doc.go ├── flags.go ├── native │ ├── count.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── doc.go │ ├── driver.go │ ├── driver_test.go │ ├── get.go │ ├── get_test.go │ ├── list.go │ ├── list_test.go │ ├── native.go │ ├── native_test.go │ ├── opts.go │ ├── opts_test.go │ ├── update.go │ └── update_test.go ├── secret.go ├── secret_test.go ├── service.go ├── setup.go ├── setup_test.go └── vault │ ├── count.go │ ├── count_test.go │ ├── create.go │ ├── create_test.go │ ├── delete.go │ ├── delete_test.go │ ├── doc.go │ ├── driver.go │ ├── driver_test.go │ ├── get.go │ ├── get_test.go │ ├── list.go │ ├── list_test.go │ ├── opts.go │ ├── opts_test.go │ ├── refresh.go │ ├── refresh_test.go │ ├── testdata │ ├── refresh │ │ ├── auth-response-error-nil-secret.json │ │ ├── auth-response-error-no-auth-values.json │ │ ├── auth-response-error-role-not-found.json │ │ ├── auth-response-success.json │ │ ├── metadata-response-1.json │ │ ├── secret-response-1.json │ │ └── secret-response-error-not-found.json │ ├── v1 │ │ ├── empty_list.json │ │ ├── invalid_list.json │ │ ├── invalid_repo.json │ │ ├── list.json │ │ ├── org.json │ │ ├── repo.json │ │ └── shared.json │ └── v2 │ │ ├── empty_list.json │ │ ├── invalid_list.json │ │ ├── invalid_repo.json │ │ ├── list.json │ │ ├── org.json │ │ ├── repo.json │ │ └── shared.json │ ├── update.go │ ├── update_test.go │ ├── vault.go │ └── vault_test.go ├── tracing ├── config.go ├── flags.go ├── sampler.go ├── sampler_test.go └── tracer.go ├── util ├── compression.go ├── compression_test.go ├── encryption.go ├── encryption_test.go ├── util.go └── util_test.go └── version ├── metadata.go ├── metadata_test.go ├── version.go └── version_test.go /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in the repo. 2 | * @go-vela/admins 3 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "local>go-vela/renovate-config" 5 | ], 6 | "customManagers": [ 7 | { 8 | "customType": "regex", 9 | "description": "Update docker images in go files", 10 | "fileMatch": [ 11 | "^cmd/vela-server/.+\\.go$" 12 | ], 13 | "matchStrings": [ 14 | "\"(?.*?):(?[^\"]*?)@(?sha256:[a-f0-9]+)\",? // renovate: container" 15 | ], 16 | "datasourceTemplate": "docker" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # name of the action 2 | name: build 3 | 4 | # trigger on pull_request or push events 5 | on: 6 | pull_request: 7 | push: 8 | 9 | permissions: 10 | contents: read 11 | 12 | # pipeline to execute 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: clone 19 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 20 | 21 | - name: install go 22 | uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 23 | with: 24 | # use version from go.mod file 25 | go-version-file: "go.mod" 26 | cache: true 27 | check-latest: true 28 | 29 | - name: build 30 | run: | 31 | make build 32 | -------------------------------------------------------------------------------- /.github/workflows/validate-pr-title.yml: -------------------------------------------------------------------------------- 1 | # name of the action 2 | name: validate PR title 3 | 4 | # trigger on pull_request events of the opened & edited type. 5 | on: 6 | pull_request: 7 | types: [opened, synchronize, edited, reopened] 8 | 9 | permissions: 10 | contents: read 11 | 12 | # pipeline to execute 13 | jobs: 14 | validate: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: validate title 19 | env: 20 | TITLE: ${{ github.event.pull_request.title }} 21 | run: | 22 | echo "$TITLE" | grep -Eq '^(feat|fix|chore|refactor|enhance|test|docs)(\(.*\)|)!?:\s.+$' && (echo "Pass"; exit 0) || (echo "Incorrect Format. Please see https://go-vela.github.io/docs/community/contributing_guidelines/#development-workflow"; exit 1) 23 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | FROM alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c as certs 4 | 5 | RUN apk add --update --no-cache ca-certificates 6 | 7 | FROM scratch 8 | 9 | COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 10 | 11 | EXPOSE 8080 12 | 13 | ENV GODEBUG=netdns=go 14 | 15 | ADD release/vela-server /bin/ 16 | 17 | CMD ["/bin/vela-server"] 18 | -------------------------------------------------------------------------------- /Dockerfile-alpine: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | FROM alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c 4 | 5 | RUN apk add --update --no-cache ca-certificates 6 | 7 | EXPOSE 8080 8 | 9 | ENV GODEBUG=netdns=go 10 | 11 | ADD release/vela-server /bin/ 12 | 13 | CMD ["/bin/vela-server"] 14 | -------------------------------------------------------------------------------- /api/admin/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package admin provides the admin handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/admin" 8 | package admin 9 | -------------------------------------------------------------------------------- /api/auth/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package auth provides the auth handlers (authenticate, login, ...) for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/auth" 8 | package auth 9 | -------------------------------------------------------------------------------- /api/build/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package build provides the build handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/build" 8 | package build 9 | -------------------------------------------------------------------------------- /api/dashboard/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package dashboard provides the dashboard handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/dashboard" 8 | package dashboard 9 | -------------------------------------------------------------------------------- /api/deployment/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package deployment provides the deployment handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/deployment" 8 | package deployment 9 | -------------------------------------------------------------------------------- /api/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package api provides the handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api" 8 | package api 9 | -------------------------------------------------------------------------------- /api/health.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package api 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // swagger:operation GET /health base Health 12 | // 13 | // Check the Vela API health 14 | // 15 | // --- 16 | // produces: 17 | // - application/json 18 | // parameters: 19 | // responses: 20 | // '200': 21 | // description: Successfully 'ping'-ed Vela API 22 | // schema: 23 | // type: string 24 | 25 | // Health represents the API handler to 26 | // report the health status for Vela. 27 | func Health(c *gin.Context) { 28 | c.JSON(http.StatusOK, "ok") 29 | } 30 | -------------------------------------------------------------------------------- /api/hook/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package hook provides the hook handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/hook" 8 | package hook 9 | -------------------------------------------------------------------------------- /api/log/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package log provides the log handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/log" 8 | package log 9 | -------------------------------------------------------------------------------- /api/pipeline/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package pipeline provides the pipeline handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/pipeline" 8 | package pipeline 9 | -------------------------------------------------------------------------------- /api/queue/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package queue provides the queue handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/queue" 8 | package queue 9 | -------------------------------------------------------------------------------- /api/repo/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package repo provides the repo handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/repo" 8 | package repo 9 | -------------------------------------------------------------------------------- /api/schedule/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package schedule provides the schedule handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/schedule" 8 | package schedule 9 | -------------------------------------------------------------------------------- /api/scm/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package scm provides the scm handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/scm" 8 | package scm 9 | -------------------------------------------------------------------------------- /api/secret/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package secret provides the secret handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/secret" 8 | package secret 9 | -------------------------------------------------------------------------------- /api/service/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package service provides the service handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/service" 8 | package service 9 | -------------------------------------------------------------------------------- /api/step/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package step provides the step handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/step" 8 | package step 9 | -------------------------------------------------------------------------------- /api/types/error.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package types 4 | 5 | import "fmt" 6 | 7 | // Error is the json error message from the server for a given http response. 8 | // 9 | // swagger:model Error 10 | type Error struct { 11 | Message *string `json:"error"` 12 | } 13 | 14 | func (e *Error) String() string { 15 | return fmt.Sprintf("%+v", *e) 16 | } 17 | -------------------------------------------------------------------------------- /api/types/error_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package types 4 | 5 | import ( 6 | "fmt" 7 | "reflect" 8 | "testing" 9 | ) 10 | 11 | func TestResp_String(t *testing.T) { 12 | // setup types 13 | str := "foo" 14 | e := &Error{ 15 | Message: &str, 16 | } 17 | want := fmt.Sprintf("%+v", *e) 18 | 19 | // run test 20 | got := e.String() 21 | 22 | if !reflect.DeepEqual(got, want) { 23 | t.Errorf("String is %v, want %v", got, want) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/user/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package user provides the user handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/user" 8 | package user 9 | -------------------------------------------------------------------------------- /api/version.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package api 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gin-gonic/gin" 9 | 10 | "github.com/go-vela/server/version" 11 | ) 12 | 13 | // swagger:operation GET /version base Version 14 | // 15 | // Get the Vela API version 16 | // 17 | // --- 18 | // produces: 19 | // - application/json 20 | // parameters: 21 | // responses: 22 | // '200': 23 | // description: Successfully retrieved the Vela API version 24 | // schema: 25 | // "$ref": "#/definitions/Version" 26 | 27 | // Version represents the API handler to 28 | // report the version number for Vela. 29 | func Version(c *gin.Context) { 30 | c.JSON(http.StatusOK, version.New()) 31 | } 32 | -------------------------------------------------------------------------------- /api/webhook/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package webhook provides the webhook handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/webhook" 8 | package webhook 9 | -------------------------------------------------------------------------------- /api/worker/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package worker provides the worker handlers for the Vela API. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/api/worker" 8 | package worker 9 | -------------------------------------------------------------------------------- /cmd/jsonschema-gen/main.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | //go:build ignore 4 | 5 | package main 6 | 7 | import ( 8 | "encoding/json" 9 | "fmt" 10 | 11 | "github.com/sirupsen/logrus" 12 | 13 | "github.com/go-vela/server/schema" 14 | ) 15 | 16 | func main() { 17 | js, err := schema.NewPipelineSchema() 18 | if err != nil { 19 | logrus.Fatal("schema generation failed:", err) 20 | } 21 | 22 | // output json 23 | j, err := json.MarshalIndent(js, "", " ") 24 | if err != nil { 25 | logrus.Fatal(err) 26 | } 27 | 28 | fmt.Printf("%s\n", j) 29 | } 30 | -------------------------------------------------------------------------------- /compiler/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package compiler provides the ability for Vela to 4 | // reconstruct a yaml configuration into an executable 5 | // pipeline. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/compiler" 10 | package compiler 11 | -------------------------------------------------------------------------------- /compiler/native/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package native provides the ability for Vela to 4 | // reconstruct a yaml configuration into an executable 5 | // pipeline. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/compiler/native" 10 | package native 11 | -------------------------------------------------------------------------------- /compiler/native/settings.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package native 4 | 5 | import ( 6 | "github.com/go-vela/server/api/types/settings" 7 | ) 8 | 9 | // GetSettings retrieves the api settings type. 10 | func (c *Client) GetSettings() settings.Compiler { 11 | return c.Compiler 12 | } 13 | 14 | // SetSettings sets the api settings type. 15 | func (c *Client) SetSettings(s *settings.Platform) { 16 | if s != nil { 17 | c.SetCloneImage(s.GetCloneImage()) 18 | c.SetTemplateDepth(s.GetTemplateDepth()) 19 | c.SetStarlarkExecLimit(s.GetStarlarkExecLimit()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /compiler/native/testdata/circular.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | render_inline: true 3 | template: true 4 | 5 | templates: 6 | - name: bad 7 | source: github.example.com/github/octocat/inline_circular_template.yml 8 | type: github 9 | 10 | stages: 11 | test: 12 | steps: 13 | - name: test 14 | image: alpine 15 | commands: 16 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/clone_false.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | metadata: 4 | clone: false 5 | 6 | steps: 7 | - name: foo 8 | parameters: 9 | registry: foo 10 | image: alpine 11 | pull: true 12 | -------------------------------------------------------------------------------- /compiler/native/testdata/clone_replace.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | metadata: 4 | clone: false 5 | 6 | steps: 7 | - name: clone 8 | image: target/vela-git-slim:v0.12.0 9 | parameters: 10 | depth: 5 11 | pull: always 12 | 13 | - name: foo 14 | parameters: 15 | registry: foo 16 | image: alpine 17 | pull: true 18 | -------------------------------------------------------------------------------- /compiler/native/testdata/clone_true.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | metadata: 4 | clone: true 5 | 6 | steps: 7 | - name: foo 8 | parameters: 9 | registry: foo 10 | image: alpine 11 | pull: true 12 | -------------------------------------------------------------------------------- /compiler/native/testdata/deploy_template.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | deployment: 5 | targets: 6 | - dev 7 | - prod 8 | - stage 9 | 10 | parameters: 11 | region: 12 | description: cluster region to deploy 13 | required: true 14 | type: string 15 | options: 16 | {{- range .regions }} 17 | - {{ . }} 18 | {{- end }} 19 | 20 | cluster_count: 21 | description: number of clusters to deploy to 22 | required: false 23 | type: integer 24 | min: 1 25 | max: 10 -------------------------------------------------------------------------------- /compiler/native/testdata/environment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | environment: 3 | FOO: "Hello, foo!" -------------------------------------------------------------------------------- /compiler/native/testdata/golang_inline_stages.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$stageList := list "foo" "bar" "star" -}} 4 | 5 | stages: 6 | {{range $stage := $stageList -}} 7 | {{ $stage }}: 8 | steps: 9 | - name: {{ $stage }} 10 | image: {{ default "alpine" $.image }} 11 | ruleset: 12 | event: tag 13 | tag: v* 14 | commands: 15 | - echo hello from {{ $stage }} 16 | {{ end }} -------------------------------------------------------------------------------- /compiler/native/testdata/golang_inline_stages_env.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | environment: 4 | DONT: break 5 | 6 | {{$stageList := list "foo" "bar" "star" -}} 7 | 8 | stages: 9 | {{range $stage := $stageList -}} 10 | {{ $stage }}: 11 | steps: 12 | - name: {{ $stage }} 13 | image: {{ default "alpine" $.image }} 14 | ruleset: 15 | event: tag 16 | tag: v* 17 | commands: 18 | - echo hello from {{ $stage }} 19 | {{ end }} -------------------------------------------------------------------------------- /compiler/native/testdata/golang_inline_steps.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$stepList := list "foo" "bar" "star" -}} 4 | 5 | steps: 6 | {{range $step := $stepList -}} 7 | - name: {{ $step }} 8 | image: alpine 9 | commands: 10 | - echo hello from {{ $step }} 11 | {{ end }} -------------------------------------------------------------------------------- /compiler/native/testdata/inline_circular_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: nested 8 | source: github.example.com/github/octocat/circular.yml 9 | type: github 10 | vars: 11 | image: golang:latest 12 | 13 | stages: 14 | test: 15 | steps: 16 | - name: test 17 | image: alpine 18 | commands: 19 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/inline_nested_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: nested 8 | source: github.example.com/github/octocat/nested.yml 9 | type: github 10 | vars: 11 | image: golang:latest 12 | 13 | stages: 14 | test: 15 | steps: 16 | - name: test 17 | image: alpine 18 | commands: 19 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_environment.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | environment: 4 | HELLO: "Hello, Vela!" 5 | 6 | metadata: 7 | render_inline: true 8 | 9 | templates: 10 | - name: golang 11 | source: github.example.com/github/octocat/environment.yml 12 | format: golang 13 | type: github 14 | 15 | steps: 16 | - name: test 17 | image: alpine 18 | parameters: 19 | first: "foo" -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_golang.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages.yml 9 | format: golang 10 | type: github 11 | vars: 12 | image: golang:latest 13 | - name: starlark 14 | source: github.example.com/github/octocat/starlark_inline_stages.star 15 | format: starlark 16 | type: github 17 | 18 | {{$stageList := list "foo" "bar" "star" -}} 19 | 20 | stages: 21 | {{range $stage := $stageList -}} 22 | {{ $stage }}: 23 | steps: 24 | - name: {{ $stage }} 25 | image: alpine 26 | commands: 27 | - echo from inline {{ $stage }} 28 | {{ end }} -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_secrets.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | secrets: 4 | - name: foo_username 5 | key: org/repo/foo/username 6 | engine: native 7 | type: repo 8 | 9 | metadata: 10 | render_inline: true 11 | 12 | templates: 13 | - name: golang 14 | source: github.example.com/github/octocat/secrets.yml 15 | format: golang 16 | type: github 17 | 18 | steps: 19 | - name: test 20 | image: alpine 21 | commands: 22 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_services.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | services: 4 | - name: postgres 5 | image: postgres:latest 6 | 7 | metadata: 8 | render_inline: true 9 | 10 | templates: 11 | - name: golang 12 | source: github.example.com/github/octocat/services.yml 13 | format: golang 14 | type: github 15 | 16 | steps: 17 | - name: test 18 | image: alpine 19 | commands: 20 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_stages.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages.yml 9 | format: golang 10 | type: github 11 | vars: 12 | image: golang:latest 13 | - name: starlark 14 | source: github.example.com/github/octocat/starlark_inline_stages.star 15 | format: starlark 16 | type: github 17 | 18 | stages: 19 | test: 20 | steps: 21 | - name: test 22 | image: alpine 23 | commands: 24 | - echo from inline 25 | - name: ruleset 26 | image: alpine 27 | ruleset: 28 | event: push 29 | branch: main 30 | commands: 31 | - echo from inline ruleset -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_stages_and_steps.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages.yml 9 | format: golang 10 | type: github 11 | - name: starlark 12 | source: github.example.com/github/octocat/starlark_inline_steps.star 13 | format: starlark 14 | type: github 15 | 16 | stages: 17 | test: 18 | steps: 19 | - name: test 20 | image: alpine 21 | commands: 22 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/inline_with_stages_env.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages_env.yml 9 | format: golang 10 | type: github 11 | vars: 12 | image: golang:latest 13 | 14 | stages: 15 | test: 16 | steps: 17 | - name: test 18 | image: alpine 19 | commands: 20 | - echo from inline 21 | - name: ruleset 22 | image: alpine 23 | ruleset: 24 | event: push 25 | branch: main 26 | commands: 27 | - echo from inline ruleset -------------------------------------------------------------------------------- /compiler/native/testdata/invalid.yml: -------------------------------------------------------------------------------- 1 | --- 2 | !@#$%^&*() -------------------------------------------------------------------------------- /compiler/native/testdata/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | template: false 6 | -------------------------------------------------------------------------------- /compiler/native/testdata/nested.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | render_inline: true 3 | template: true 4 | 5 | templates: 6 | - name: golang 7 | source: github.example.com/github/octocat/golang_inline_stages.yml 8 | format: golang 9 | type: github 10 | vars: 11 | image: golang:latest 12 | - name: starlark 13 | source: github.example.com/github/octocat/starlark_inline_stages.star 14 | format: starlark 15 | type: github 16 | 17 | stages: 18 | test: 19 | steps: 20 | - name: test 21 | image: alpine 22 | commands: 23 | - echo from inline -------------------------------------------------------------------------------- /compiler/native/testdata/parameters.yml: -------------------------------------------------------------------------------- 1 | --- 2 | steps: 3 | - name: docker 4 | image: plugins/docker:18.09 5 | parameters: 6 | registry: index.docker.io 7 | repo: github/octocat 8 | tags: 9 | - latest 10 | - dev 11 | pull: true 12 | secrets: [ docker_username, docker_password ] 13 | -------------------------------------------------------------------------------- /compiler/native/testdata/pipeline_type.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | image = "alpine" 3 | 4 | return { 5 | 'version': '1', 6 | 'steps': [ 7 | { 8 | "name": "foo", 9 | "image": image, 10 | "parameters": { 11 | "registry": "foo" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /compiler/native/testdata/pipeline_type_default.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | steps: 5 | - name: foo 6 | parameters: 7 | registry: foo 8 | image: alpine 9 | -------------------------------------------------------------------------------- /compiler/native/testdata/pipeline_type_go.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$image := "alpine"}} 4 | 5 | steps: 6 | - name: foo 7 | parameters: 8 | registry: foo 9 | image: {{ $image }} 10 | -------------------------------------------------------------------------------- /compiler/native/testdata/secrets.yml: -------------------------------------------------------------------------------- 1 | --- 2 | secrets: 3 | # Repo secrets 4 | - name: docker_username 5 | key: org/repo/docker/username 6 | engine: native 7 | type: repo 8 | 9 | - name: docker_password 10 | key: org/repo/docker/password 11 | engine: vault 12 | type: repo 13 | 14 | # Org secrets 15 | - name: docker_username 16 | key: org/docker/username 17 | engine: native 18 | type: org 19 | 20 | - name: docker_password 21 | key: org/docker/password 22 | engine: vault 23 | type: org 24 | 25 | # Shared secrets 26 | - name: docker_username 27 | key: org/team/docker/username 28 | engine: native 29 | type: shared 30 | 31 | - name: docker_password 32 | key: org/team/docker/password 33 | engine: vault 34 | type: shared 35 | -------------------------------------------------------------------------------- /compiler/native/testdata/services.yml: -------------------------------------------------------------------------------- 1 | --- 2 | services: 3 | - name: cache 4 | image: redis 5 | - name: database 6 | image: mongo -------------------------------------------------------------------------------- /compiler/native/testdata/stage_inline_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages.yml 9 | format: golang 10 | type: github 11 | vars: 12 | image: golang:latest 13 | 14 | stages: 15 | test: 16 | steps: 17 | - name: golang 18 | template: 19 | name: golang 20 | vars: 21 | image: golang:latest -------------------------------------------------------------------------------- /compiler/native/testdata/stages_name_conflict.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | three_word_key: 5 | steps: 6 | - name: build 7 | image: alpine 8 | commands: 9 | - echo "Building..." 10 | three: 11 | steps: 12 | - name: word_key_build 13 | image: alpine 14 | commands: 15 | - echo "Building..." -------------------------------------------------------------------------------- /compiler/native/testdata/stages_name_conflict_purged.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | three_word_key: 5 | steps: 6 | - name: build 7 | image: alpine 8 | ruleset: 9 | event: pull_request 10 | commands: 11 | - echo "Building..." 12 | three: 13 | steps: 14 | - name: word_key_build 15 | image: alpine 16 | commands: 17 | - echo "Building..." -------------------------------------------------------------------------------- /compiler/native/testdata/starlark_inline_stages.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | stageNames = ["foo", "bar"] 3 | 4 | stages = {} 5 | 6 | for name in stageNames: 7 | stages[name] = stage(name) 8 | 9 | return { 10 | 'version': '1', 11 | 'stages': stages 12 | } 13 | 14 | def stage(word): 15 | return { 16 | "steps": [ 17 | { 18 | "name": "build_%s" % word, 19 | "image": "alpine", 20 | 'commands': [ 21 | "echo hello from %s" % word 22 | ] 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /compiler/native/testdata/starlark_inline_steps.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | stepNames = ["foo", "bar"] 3 | 4 | steps = [] 5 | 6 | for name in stepNames: 7 | steps.append( 8 | { 9 | "name": "build_%s" % name, 10 | "image": "alpine", 11 | 'commands': [ 12 | "echo hello from %s" % name 13 | ] 14 | } 15 | ) 16 | 17 | return { 18 | 'version': '1', 19 | 'steps': steps 20 | } -------------------------------------------------------------------------------- /compiler/native/testdata/step_inline_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | render_inline: true 5 | 6 | templates: 7 | - name: golang 8 | source: github.example.com/github/octocat/golang_inline_stages.yml 9 | format: golang 10 | type: github 11 | vars: 12 | image: golang:latest 13 | 14 | steps: 15 | - name: golang 16 | template: 17 | name: golang 18 | vars: 19 | image: golang:latest -------------------------------------------------------------------------------- /compiler/native/testdata/steps_name_conflict.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: build 5 | image: alpine 6 | commands: 7 | - echo "Building..." 8 | - name: test 9 | image: alpine 10 | commands: 11 | - echo "Testing..." 12 | - name: build 13 | image: alpine 14 | commands: 15 | - echo "Building...again?" -------------------------------------------------------------------------------- /compiler/native/testdata/steps_name_conflict_purged.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: build 5 | image: alpine 6 | commands: 7 | - echo "Building..." 8 | - name: test 9 | image: alpine 10 | commands: 11 | - echo "Testing..." 12 | - name: build 13 | image: alpine 14 | ruleset: 15 | event: pull_request 16 | commands: 17 | - echo "Building...again?" -------------------------------------------------------------------------------- /compiler/native/testdata/template.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | return { 3 | 'version': '1', 4 | 'environment': { 5 | 'star': 'test3', 6 | 'bar': 'test4', 7 | }, 8 | 'steps': [ 9 | { 10 | 'name': 'build', 11 | 'image': 'golang:latest', 12 | 'commands': [ 13 | 'go build', 14 | 'go test', 15 | ] 16 | }, 17 | ], 18 | } 19 | -------------------------------------------------------------------------------- /compiler/native/testdata/template.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: install 6 | commands: 7 | - ./gradlew downloadDependencies 8 | environment: {{ .environment }} 9 | image: {{ .image }} 10 | {{ .pull_policy }} 11 | 12 | - name: test 13 | commands: 14 | - ./gradlew check 15 | environment: {{ .environment }} 16 | image: {{ .image }} 17 | {{ .pull_policy }} 18 | 19 | - name: build 20 | commands: 21 | - ./gradlew build 22 | environment: {{ .environment }} 23 | image: {{ .image }} 24 | {{ .pull_policy }} 25 | -------------------------------------------------------------------------------- /compiler/native/testdata/template_calls_itself.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | templates: 4 | - name: test 5 | source: github.example.com/bad/design/template_calls_itself.yml 6 | type: github 7 | 8 | steps: 9 | - name: call template 10 | template: 11 | name: test 12 | -------------------------------------------------------------------------------- /compiler/native/testdata/template_calls_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | templates: 4 | - name: test 5 | source: github.example.com/foo/bar/long_template.yml 6 | type: github 7 | 8 | steps: 9 | - name: call template 10 | template: 11 | name: test 12 | vars: 13 | image: openjdk:latest 14 | environment: "{ GRADLE_USER_HOME: .gradle, GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false }" 15 | pull_policy: "pull: true" 16 | -------------------------------------------------------------------------------- /compiler/native/testdata/template_name.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | template: false 6 | 7 | templates: 8 | - name: inline_templatename 9 | source: github.example.com/github/octocat/template_name_template.yml 10 | type: github 11 | 12 | steps: 13 | - name: sample 14 | template: 15 | name: inline_templatename 16 | 17 | -------------------------------------------------------------------------------- /compiler/native/testdata/template_name_inline.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | template: false 6 | render_inline: true 7 | 8 | templates: 9 | - name: inline_templatename 10 | source: github.example.com/github/octocat/template_name_template.yml 11 | type: github 12 | -------------------------------------------------------------------------------- /compiler/native/testdata/template_name_template.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: hello 6 | image: {{ vela "template_name" }} 7 | commands: 8 | - echo {{ vela "template_name" }} 9 | -------------------------------------------------------------------------------- /compiler/registry/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package registry provides the ability for Vela to 4 | // integrate with different supported Template registries. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/compiler/registry" 9 | package registry 10 | -------------------------------------------------------------------------------- /compiler/registry/github/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package github provides the ability for Vela to 4 | // integrate with GitHub or GitHub Enterprise as a 5 | // template registry. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/compiler/registry/github" 10 | package github 11 | -------------------------------------------------------------------------------- /compiler/registry/github/testdata/template.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: get_dependencies 6 | plugin: {{ .image }} 7 | {{ .pull_policy }} 8 | environment: {{ .environment }} 9 | commands: 10 | - ./gradlew downloadDependencies 11 | 12 | - name: test 13 | plugin: {{ .image }} 14 | {{ .pull_policy }} 15 | environment: {{ .environment }} 16 | commands: 17 | - ./gradlew check 18 | 19 | - name: build 20 | plugin: {{ .image }} 21 | {{ .pull_policy }} 22 | environment: {{ .environment }} 23 | commands: 24 | - ./gradlew build distTar 25 | -------------------------------------------------------------------------------- /compiler/registry/registry.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package registry 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | ) 10 | 11 | // Service represents the interface for Vela integrating 12 | // with the different supported template registries. 13 | type Service interface { 14 | // Parse defines a function that creates the 15 | // registry source object from a template path. 16 | Parse(string) (*Source, error) 17 | 18 | // Template defines a function that captures the 19 | // templated pipeline configuration from a repo. 20 | Template(context.Context, *api.User, *Source) ([]byte, error) 21 | } 22 | -------------------------------------------------------------------------------- /compiler/registry/source.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package registry 4 | 5 | // Source represents a registry object 6 | // for retrieving templates. 7 | type Source struct { 8 | Host string 9 | Org string 10 | Repo string 11 | Name string 12 | Ref string 13 | } 14 | -------------------------------------------------------------------------------- /compiler/template/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package template provides the ability for Vela to 4 | // render a templated yaml configuration into an 5 | // executable pipeline. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/template" 10 | package template 11 | -------------------------------------------------------------------------------- /compiler/template/native/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package native provides the ability for Vela to 4 | // render a templated yaml configuration into an 5 | // executable pipeline. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/compiler/template/native" 10 | package native 11 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/basic/build.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$steplist := list "foo" "bar" "star"}} 4 | 5 | steps: 6 | {{range $step := $steplist}} 7 | - name: {{ $step }} 8 | image: alpine 9 | commands: 10 | - echo hello from {{ $step }} 11 | {{ end }} -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/basic/want.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: foo 5 | image: alpine 6 | pull: not_present 7 | commands: 8 | - echo hello from foo 9 | - name: bar 10 | image: alpine 11 | pull: not_present 12 | commands: 13 | - echo hello from bar 14 | - name: star 15 | image: alpine 16 | pull: not_present 17 | commands: 18 | - echo hello from star -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/basic_stages/build.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$stageList := list "foo" "bar" "star" -}} 4 | 5 | stages: 6 | {{range $stage := $stageList -}} 7 | {{ $stage }}: 8 | steps: 9 | - name: {{ $stage }} 10 | image: alpine 11 | commands: 12 | - echo hello from {{ $stage }} 13 | {{ end }} 14 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/basic_stages/want.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | foo: 5 | steps: 6 | - name: foo 7 | image: alpine 8 | commands: 9 | - echo hello from foo 10 | needs: [ "clone" ] 11 | pull: not_present 12 | 13 | bar: 14 | steps: 15 | - name: bar 16 | image: alpine 17 | commands: 18 | - echo hello from bar 19 | needs: [ "clone" ] 20 | pull: not_present 21 | 22 | star: 23 | steps: 24 | - name: star 25 | image: alpine 26 | commands: 27 | - echo hello from star 28 | needs: [ "clone" ] 29 | pull: not_present 30 | 31 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/conditional/build.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | {{$br := vela "vela_build_branch"}} 4 | {{$image := "golang:latest"}} 5 | 6 | steps: 7 | 8 | {{ if (eq $br "main") }} 9 | 10 | - name: install 11 | commands: 12 | - go get ./... 13 | image: {{ $image }} 14 | ruleset: 15 | event: [ push, pull_request ] 16 | 17 | {{ end }} 18 | 19 | - name: test 20 | commands: 21 | - go test ./... 22 | image: {{ $image }} 23 | ruleset: 24 | event: [ push, pull_request ] 25 | 26 | - name: build 27 | commands: 28 | - go build 29 | environment: 30 | CGO_ENABLED: '0' 31 | GOOS: linux 32 | image: {{ $image }} 33 | ruleset: 34 | event: [ push, pull_request ] 35 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/build/conditional/want.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | steps: 3 | - name: install 4 | commands: 5 | - go get ./... 6 | image: golang:latest 7 | ruleset: 8 | event: [ push, pull_request ] 9 | 10 | - name: test 11 | commands: 12 | - go test ./... 13 | image: golang:latest 14 | ruleset: 15 | event: [ push, pull_request ] 16 | 17 | - name: build 18 | commands: 19 | - go build 20 | environment: 21 | CGO_ENABLED: '0' 22 | GOOS: linux 23 | image: golang:latest 24 | ruleset: 25 | event: [ push, pull_request ] 26 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/bad_ruleset_format.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: install 6 | commands: 7 | - go get ./... 8 | image: {{ .image }} 9 | {{ .pull_policy }} 10 | ruleset: 11 | # double bracket causes [["push", "tag"]] 12 | event: [{{ default "push" .event }}] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/basic/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | image: golang:latest 7 | pull_policy: "pull: true" 8 | event: [tag, push] 9 | 10 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/basic/tmpl.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: install 6 | commands: 7 | - go get ./... 8 | image: {{ .image }} 9 | {{ .pull_policy }} 10 | ruleset: 11 | event: [ push, pull_request ] 12 | 13 | - name: test 14 | commands: 15 | - go test ./... 16 | image: {{ .image }} 17 | {{ .pull_policy }} 18 | ruleset: 19 | event: [ push, pull_request ] 20 | 21 | - name: build 22 | commands: 23 | - go build 24 | environment: 25 | CGO_ENABLED: '0' 26 | GOOS: linux 27 | image: {{ .image }} 28 | {{ .pull_policy }} 29 | ruleset: 30 | event: [ push, pull_request ] 31 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/basic/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_install 3 | commands: 4 | - go get ./... 5 | image: golang:latest 6 | pull: true 7 | ruleset: 8 | event: [ push, pull_request ] 9 | 10 | - name: sample_test 11 | commands: 12 | - go test ./... 13 | image: golang:latest 14 | pull: true 15 | ruleset: 16 | event: [ push, pull_request ] 17 | 18 | - name: sample_build 19 | commands: 20 | - go build 21 | environment: 22 | CGO_ENABLED: '0' 23 | GOOS: linux 24 | image: golang:latest 25 | pull: true 26 | ruleset: 27 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/conditional/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | image: golang:latest 7 | pull_policy: "pull: true" 8 | branch: main 9 | 10 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/conditional/tmpl.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | {{$br := .branch}} 5 | 6 | steps: 7 | 8 | {{ if (eq $br "main") }} 9 | 10 | - name: install 11 | commands: 12 | - go get ./... 13 | image: {{ .image }} 14 | {{ .pull_policy }} 15 | ruleset: 16 | event: [ push, pull_request ] 17 | 18 | {{ end }} 19 | 20 | - name: test 21 | commands: 22 | - go test ./... 23 | image: {{ .image }} 24 | {{ .pull_policy }} 25 | ruleset: 26 | event: [ push, pull_request ] 27 | 28 | - name: build 29 | commands: 30 | - go build 31 | environment: 32 | CGO_ENABLED: '0' 33 | GOOS: linux 34 | image: {{ .image }} 35 | {{ .pull_policy }} 36 | ruleset: 37 | event: [ push, pull_request ] 38 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/conditional/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_install 3 | commands: 4 | - go get ./... 5 | image: golang:latest 6 | pull: true 7 | ruleset: 8 | event: [ push, pull_request ] 9 | 10 | - name: sample_test 11 | commands: 12 | - go test ./... 13 | image: golang:latest 14 | pull: true 15 | ruleset: 16 | event: [ push, pull_request ] 17 | 18 | - name: sample_build 19 | commands: 20 | - go build 21 | environment: 22 | CGO_ENABLED: '0' 23 | GOOS: linux 24 | image: golang:latest 25 | pull: true 26 | ruleset: 27 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/disallowed/tmpl_env.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: echo 6 | commands: 7 | - echo {{ env "VELA_SOURCE_CLIENT" }} 8 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/disallowed/tmpl_expandenv.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: echo 6 | commands: 7 | - echo {{ expandenv "Your client id is set to $VELA_SOURCE_CLIENT" }} 8 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/invalid.yml: -------------------------------------------------------------------------------- 1 | --- 2 | !@#$%^&*() -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/invalid_template.yml: -------------------------------------------------------------------------------- 1 | --- 2 | {{ foobar }} 3 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/invalid_variables.yml: -------------------------------------------------------------------------------- 1 | --- 2 | {{template "foobar"}} 3 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/loop_map/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | pull_policy: "pull: true" 7 | # loop over map of images 8 | images: 9 | latest: golang:latest 10 | 11 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/loop_map/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_install 3 | commands: 4 | - go get ./... 5 | image: golang:latest 6 | pull: true 7 | ruleset: 8 | event: [ push, pull_request ] 9 | 10 | - name: sample_test_latest 11 | commands: 12 | - go test ./... 13 | image: golang:latest 14 | pull: true 15 | ruleset: 16 | event: [ push, pull_request ] 17 | 18 | - name: sample_build 19 | commands: 20 | - go build 21 | environment: 22 | CGO_ENABLED: '0' 23 | GOOS: linux 24 | image: golang:latest 25 | pull: true 26 | ruleset: 27 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/loop_slice/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | pull_policy: "pull: true" 7 | # loop over slice of images 8 | images: [ golang:latest, golang:1.12, golang:1.13 ] 9 | 10 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/multiline/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | test: | 7 | - name: test 8 | commands: 9 | - go test ./... 10 | image: golang:latest 11 | pull: true 12 | ruleset: 13 | event: [ push, pull_request ] 14 | 15 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/multiline/tmpl.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: install 6 | commands: 7 | - go get ./... 8 | image: golang:latest 9 | pull: true 10 | ruleset: 11 | event: [ push, pull_request ] 12 | 13 | {{ .test }} 14 | 15 | - name: build 16 | commands: 17 | - go build 18 | environment: 19 | CGO_ENABLED: '0' 20 | GOOS: linux 21 | image: golang:latest 22 | pull: true 23 | ruleset: 24 | event: [ push, pull_request ] 25 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/multiline/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_install 3 | commands: 4 | - go get ./... 5 | image: golang:latest 6 | pull: true 7 | ruleset: 8 | event: [ push, pull_request ] 9 | 10 | - name: sample_test 11 | commands: 12 | - go test ./... 13 | image: golang:latest 14 | pull: true 15 | ruleset: 16 | event: [ push, pull_request ] 17 | 18 | - name: sample_build 19 | commands: 20 | - go build 21 | environment: 22 | CGO_ENABLED: '0' 23 | GOOS: linux 24 | image: golang:latest 25 | pull: true 26 | ruleset: 27 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/to_yaml/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | ruleset: 7 | event: [push, pull_request] 8 | branch: [main] 9 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/to_yaml/tmpl.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: install 6 | commands: 7 | - test 8 | image: alpine 9 | ruleset: 10 | {{- toYaml .ruleset | nindent 6 }} 11 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/to_yaml/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_install 3 | commands: 4 | - test 5 | image: alpine 6 | ruleset: 7 | event: [ push, pull_request ] 8 | branch: [ main ] 9 | -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/with_vars_plat/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/with_vars_plat/tmpl.yml: -------------------------------------------------------------------------------- 1 | metadata: 2 | template: true 3 | 4 | steps: 5 | - name: test 6 | commands: 7 | - echo {{ vela "repo_full_name" }} 8 | - echo {{ vela "REPO_FULL_NAME" }} 9 | - echo {{ vela "vela_repo_full_name" }} 10 | - echo {{ vela "VELA_REPO_FULL_NAME" }} 11 | - echo {{ vela "non_existent" }} 12 | image: alpine 13 | pull: true 14 | ruleset: 15 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/native/testdata/step/with_vars_plat/want.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample_test 3 | commands: 4 | - echo octocat/hello-world 5 | - echo octocat/hello-world 6 | - echo octocat/hello-world 7 | - echo octocat/hello-world 8 | - echo 9 | image: alpine 10 | pull: true 11 | ruleset: 12 | event: [ push, pull_request ] -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/basic/build.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | stepNames = ["foo", "bar", "star"] 3 | 4 | steps = [] 5 | 6 | for name in stepNames: 7 | steps.append(step(name)) 8 | 9 | return { 10 | 'version': '1', 11 | 'steps': steps 12 | } 13 | 14 | def step(word): 15 | return { 16 | "name": "build_%s" % word, 17 | "image": "alpine:latest", 18 | 'commands': [ 19 | "echo %s" % word 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/basic/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: build_foo 4 | image: alpine:latest 5 | commands: 6 | - echo foo 7 | 8 | - name: build_bar 9 | image: alpine:latest 10 | commands: 11 | - echo bar 12 | 13 | - name: build_star 14 | image: alpine:latest 15 | commands: 16 | - echo star 17 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/basic_stages/build.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | stageNames = ["foo", "bar", "star"] 3 | 4 | stages = {} 5 | 6 | for name in stageNames: 7 | stages[name] = stage(name) 8 | 9 | return { 10 | 'version': '1', 11 | 'stages': stages 12 | } 13 | 14 | def stage(word): 15 | return { 16 | "steps": [ 17 | { 18 | "name": "build_%s" % word, 19 | "image": "alpine:latest", 20 | 'commands': [ 21 | "echo hello from %s" % word 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/basic_stages/want.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | foo: 5 | steps: 6 | - name: build_foo 7 | image: alpine:latest 8 | commands: 9 | - echo hello from foo 10 | needs: [ "clone" ] 11 | pull: not_present 12 | 13 | bar: 14 | steps: 15 | - name: build_bar 16 | image: alpine:latest 17 | commands: 18 | - echo hello from bar 19 | needs: [ "clone" ] 20 | pull: not_present 21 | 22 | star: 23 | steps: 24 | - name: build_star 25 | image: alpine:latest 26 | commands: 27 | - echo hello from star 28 | needs: [ "clone" ] 29 | pull: not_present 30 | 31 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/conditional/build.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | stepNames = ["foo", "bar", "star"] 3 | 4 | steps = [] 5 | 6 | for name in stepNames: 7 | if name == "foo" and ctx["vela"]["build"]["branch"] == "main": 8 | steps.append(step(name)) 9 | 10 | return { 11 | 'version': '1', 12 | 'steps': steps 13 | } 14 | 15 | def step(word): 16 | return { 17 | "name": "build_%s" % word, 18 | "image": "alpine:latest", 19 | 'commands': [ 20 | "echo %s" % word 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/conditional/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: build_foo 4 | image: alpine:latest 5 | commands: 6 | - echo foo 7 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/with_struct/build.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | step_list = [ 3 | struct(name="foo"), 4 | struct(name="bar"), 5 | struct(name="star") 6 | ] 7 | 8 | steps = [] 9 | 10 | for step in step_list: 11 | steps.append(build_step(step)) 12 | 13 | return { 14 | 'version': '1', 15 | 'steps': steps 16 | } 17 | 18 | def build_step(step): 19 | return { 20 | "name": "build_%s" % step.name, 21 | "image": "alpine:latest", 22 | 'commands': [ 23 | "echo %s" % step.name 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/build/with_struct/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: build_foo 4 | image: alpine:latest 5 | commands: 6 | - echo foo 7 | 8 | - name: build_bar 9 | image: alpine:latest 10 | commands: 11 | - echo bar 12 | 13 | - name: build_star 14 | image: alpine:latest 15 | commands: 16 | - echo star 17 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/basic/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: golang 5 | vars: 6 | image: golang:latest 7 | pull_policy: "pull: true" -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/basic/template.py: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | return { 3 | 'version': '1', 4 | 'steps': [ 5 | { 6 | 'name': 'build', 7 | 'image': 'golang:latest', 8 | 'commands': [ 9 | 'go build', 10 | 'go test', 11 | ] 12 | }, 13 | ], 14 | } -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/basic/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: sample_build 4 | image: golang:latest 5 | commands: 6 | - go build 7 | - go test -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/cancel/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: echo 5 | vars: 6 | image: golang:latest 7 | pull_policy: "pull: true" -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/cancel/template.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | foo = ''; 3 | for i in range(1, 100000): 4 | foo = foo 5 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_method/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: echo 5 | vars: 6 | image: golang:latest 7 | pull_policy: "pull: true" -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_method/template.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | return { 3 | 'version': '1', 4 | 'steps': [ 5 | step('foo'), 6 | step('bar') 7 | ], 8 | } 9 | 10 | def step(word): 11 | return { 12 | "name": "build_%s" % word, 13 | "image": "alpine:latest", 14 | 'commands': [ 15 | "echo %s" % word 16 | ] 17 | } -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_method/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: sample_build_foo 4 | image: alpine:latest 5 | commands: 6 | - echo foo 7 | 8 | - name: sample_build_bar 9 | image: alpine:latest 10 | commands: 11 | - echo bar -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: build 5 | vars: 6 | tags: [latest, "1.14", "1.15"] 7 | pull_policy: always 8 | commands: 9 | test: "go test ./..." 10 | build: "go test ./..." -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars/template.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | steps = [step(x, ctx["vars"]["pull_policy"], ctx["vars"]["commands"]) for x in ctx["vars"]["tags"]] 3 | 4 | pipeline = { 5 | 'version': '1', 6 | 'steps': steps, 7 | } 8 | 9 | return pipeline 10 | 11 | def step(tag, pull_policy, commands): 12 | return { 13 | "name": "build %s" % tag, 14 | "image": "golang:%s" % tag, 15 | "pull": pull_policy, 16 | 'commands': commands.values(), 17 | } 18 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars/want.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | steps: 3 | - name: sample_build latest 4 | image: golang:latest 5 | pull: always 6 | commands: 7 | - go test ./... 8 | - go test ./... 9 | 10 | - name: sample_build 1.14 11 | image: golang:1.14 12 | pull: always 13 | commands: 14 | - go test ./... 15 | - go test ./... 16 | 17 | - name: sample_build 1.15 18 | image: golang:1.15 19 | pull: always 20 | commands: 21 | - go test ./... 22 | - go test ./... -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars_plat/step.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: sample 3 | template: 4 | name: echo 5 | vars: 6 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars_plat/template.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | return { 3 | 'version': '1', 4 | 'steps': [ 5 | step(ctx["vela"]["repo"]["full_name"]), 6 | ], 7 | } 8 | 9 | def step(full_name): 10 | return { 11 | "name": "echo %s" % full_name, 12 | "image": "alpine:latest", 13 | 'commands': [ 14 | "echo %s" % full_name 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /compiler/template/starlark/testdata/step/with_vars_plat/want.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | steps: 3 | - name: sample_echo octocat/hello-world 4 | image: alpine:latest 5 | commands: 6 | - echo octocat/hello-world -------------------------------------------------------------------------------- /compiler/template/template.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package template 4 | 5 | import "github.com/go-vela/server/compiler/types/yaml/yaml" 6 | 7 | // Engine represents the interface for Vela integrating 8 | // with the different supported template engines. 9 | type Engine interface { 10 | // RenderBuild defines a function that combines 11 | // the template with the build. 12 | RenderBuild(template string, step *yaml.Step) (yaml.StepSlice, error) 13 | // Render defines a function that combines 14 | // the template with the step. 15 | Render(template string, step *yaml.Step) (yaml.StepSlice, error) 16 | } 17 | -------------------------------------------------------------------------------- /compiler/types/pipeline/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package pipeline provides the defined pipeline types for Vela. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/compiler/types/pipeline" 8 | package pipeline 9 | -------------------------------------------------------------------------------- /compiler/types/pipeline/git_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | import "testing" 6 | 7 | func TestPipeline_Git_Empty(t *testing.T) { 8 | // setup tests 9 | tests := []struct { 10 | git *Git 11 | want bool 12 | }{ 13 | { 14 | git: &Git{&Token{Repositories: []string{}}}, 15 | want: false, 16 | }, 17 | { 18 | git: new(Git), 19 | want: true, 20 | }, 21 | } 22 | 23 | // run tests 24 | for _, test := range tests { 25 | got := test.git.Empty() 26 | 27 | if got != test.want { 28 | t.Errorf("Empty is %v, want %t", got, test.want) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /compiler/types/pipeline/port.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | type ( 6 | // PortSlice is the pipeline representation 7 | // of the ports for a step in a pipeline. 8 | PortSlice []*Port 9 | 10 | // Port is the pipeline representation 11 | // of a port for a step in a pipeline. 12 | // 13 | // swagger:model PipelinePort 14 | Port struct { 15 | Port int `json:"port,omitempty" yaml:"port,omitempty"` 16 | Host int `json:"host,omitempty" yaml:"host,omitempty"` 17 | Protocol string `json:"protocol,omitempty" yaml:"protocol,omitempty"` 18 | } 19 | ) 20 | -------------------------------------------------------------------------------- /compiler/types/pipeline/ulimit.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | type ( 6 | // UlimitSlice is the pipeline representation of 7 | // the ulimits block for a step in a pipeline. 8 | // 9 | // swagger:model PipelineUlimitSlice 10 | UlimitSlice []*Ulimit 11 | 12 | // Ulimit is the pipeline representation of a ulimit 13 | // from the ulimits block for a step in a pipeline. 14 | // 15 | // swagger:model PipelineUlimit 16 | Ulimit struct { 17 | Name string `json:"name,omitempty" yaml:"name,omitempty"` 18 | Soft int64 `json:"soft,omitempty" yaml:"soft,omitempty"` 19 | Hard int64 `json:"hard,omitempty" yaml:"hard,omitempty"` 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /compiler/types/pipeline/volume.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | type ( 6 | // VolumeSlice is the pipeline representation of 7 | // the volumes block for a step in a pipeline. 8 | // 9 | // swagger:model PipelineVolumeSlice 10 | VolumeSlice []*Volume 11 | 12 | // Volume is the pipeline representation of a volume 13 | // from a volumes block for a step in a pipeline. 14 | // 15 | // swagger:model PipelineVolume 16 | Volume struct { 17 | Source string `json:"source,omitempty" yaml:"source,omitempty"` 18 | Destination string `json:"destination,omitempty" yaml:"destination,omitempty"` 19 | AccessMode string `json:"access_mode,omitempty" yaml:"access_mode,omitempty"` 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /compiler/types/pipeline/worker.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | // Worker is the yaml representation of the worker block for a pipeline. 6 | // 7 | // swagger:model PipelineWorker 8 | type Worker struct { 9 | Flavor string `json:"flavor,omitempty" yaml:"flavor,omitempty"` 10 | Platform string `json:"platform,omitempty" yaml:"platform,omitempty"` 11 | } 12 | 13 | // Empty returns true if the provided worker is empty. 14 | func (w *Worker) Empty() bool { 15 | // return true if every worker field is empty 16 | if len(w.Flavor) == 0 && 17 | len(w.Platform) == 0 { 18 | return true 19 | } 20 | 21 | // return false if any of the worker fields are provided 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /compiler/types/pipeline/worker_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | import "testing" 6 | 7 | func TestPipeline_Worker_Empty(t *testing.T) { 8 | // setup tests 9 | tests := []struct { 10 | worker *Worker 11 | want bool 12 | }{ 13 | { 14 | worker: &Worker{Flavor: "foo"}, 15 | want: false, 16 | }, 17 | { 18 | worker: new(Worker), 19 | want: true, 20 | }, 21 | } 22 | 23 | // run tests 24 | for _, test := range tests { 25 | got := test.worker.Empty() 26 | 27 | if got != test.want { 28 | t.Errorf("Empty is %v, want %t", got, test.want) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /compiler/types/raw/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package raw provides the defined raw types for Vela. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/compiler/types/raw" 8 | package raw 9 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": { 3 | "bar": "foobar" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/invalid.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: 3 | bar: foobar 4 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/invalid_2.json: -------------------------------------------------------------------------------- 1 | "foo: bar" 2 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/invalid_2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 'foo: bar' 3 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/map.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "bar" 3 | } 4 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/map.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: bar 3 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/slice.json: -------------------------------------------------------------------------------- 1 | [ "foo", "bar" ] 2 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo, bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/slice_map.json: -------------------------------------------------------------------------------- 1 | [ "foo=bar" ] 2 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/slice_map.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/string.json: -------------------------------------------------------------------------------- 1 | "foo" 2 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo 3 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/string_map.json: -------------------------------------------------------------------------------- 1 | "foo=bar" 2 | -------------------------------------------------------------------------------- /compiler/types/raw/testdata/string_map.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo=bar 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // package buildkite provides the defined yaml types for Vela. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/compiler/types/yaml/yaml" 8 | package buildkite 9 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/build/validate/bad_pipeline0.yml: -------------------------------------------------------------------------------- 1 | version: 1 -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/build/validate/bad_pipeline1.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | steps: 3 | stages: -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/build/validate/bad_version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | steps: -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/build_empty_env.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | template: false 6 | environment: [] 7 | 8 | environment: 9 | HELLO: "Hello, Global Message" 10 | 11 | worker: 12 | flavor: 16cpu8gb 13 | platform: gcp 14 | 15 | steps: 16 | - name: install 17 | commands: 18 | - ./gradlew downloadDependencies 19 | environment: 20 | GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false 21 | GRADLE_USER_HOME: .gradle 22 | image: openjdk:latest 23 | pull: true 24 | ruleset: 25 | event: [ push, pull_request ] 26 | volumes: [ /foo:/bar:ro ] 27 | ulimits: [ foo=1024:2048 ] -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/deploy_parameter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: 3 | description: bar 4 | required: true 5 | type: string 6 | options: 7 | - baz 8 | hello: 9 | description: baz 10 | required: false 11 | type: string -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/invalid.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: bar 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | template: false 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/metadata_env.yml: -------------------------------------------------------------------------------- 1 | --- 2 | template: false 3 | environment: [ steps ] 4 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ruleset_advanced.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: [ main ] 4 | event: push 5 | tag: "^refs/tags/(\\d+\\.)+\\d+$" 6 | unless: 7 | event: 8 | - deployment 9 | - pull_request 10 | - comment 11 | - schedule 12 | path: [ foo.txt, /foo/bar.txt ] 13 | matcher: regexp 14 | operator: or 15 | continue: true -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ruleset_op_match.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: [ main ] 4 | event: push 5 | tag: "^refs/tags/(\\d+\\.)+\\d+$" 6 | matcher: regexp 7 | operator: and 8 | unless: 9 | event: 10 | - deployment 11 | - pull_request 12 | - comment 13 | - schedule 14 | path: [ foo.txt, /foo/bar.txt ] 15 | matcher: filepath 16 | operator: or 17 | continue: true -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ruleset_regex.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: main 4 | event: tag 5 | tag: [ "^refs/tags/(\\d+\\.)+\\d+$" ] 6 | operator: and 7 | matcher: regex 8 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ruleset_simple.yml: -------------------------------------------------------------------------------- 1 | --- 2 | branch: main 3 | comment: "test comment" 4 | continue: true 5 | event: push 6 | instance: vela-server 7 | label: bug 8 | path: foo.txt 9 | repo: github/octocat 10 | sender: octocat 11 | status: success 12 | tag: v0.1.0 13 | target: production 14 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/no_name.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | # Declarative repository secret definition. 3 | - key: github/ocotocat/foob 4 | engine: native 5 | type: repo 6 | - key: github/ocotocat 7 | engine: native 8 | type: org 9 | - key: github/octokitties/foobar 10 | engine: native 11 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/org.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/foobar 4 | engine: native 5 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/org_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | key: github/foobar 4 | type: org 5 | 6 | - name: foobar 7 | key: github/foobar 8 | engine: badengine 9 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/org_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: org 5 | 6 | - name: foobar 7 | key: github 8 | engine: native 9 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/plugin.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | name: vault secrets 4 | image: target/vela/secret-vault:latest 5 | parameters: 6 | items: 7 | - source: secret/vela/dev/docker 8 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/plugin_bad_image.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | name: vault secrets 4 | parameters: 5 | items: 6 | - source: secret/vela/dev/docker 7 | path: docker 8 | 9 | - origin: 10 | name: vault secrets 11 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 12 | parameters: 13 | items: 14 | - source: secret/vela/dev/docker 15 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/plugin_bad_name.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | image: target/vela/secret-vault:latest 4 | parameters: 5 | items: 6 | - source: secret/vela/dev/docker 7 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/repo.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | # Implicit native secret definition. 3 | - name: foo 4 | 5 | # Declarative repository secret definition. 6 | - name: foob 7 | key: github/ocotocat/foob 8 | engine: native 9 | type: repo 10 | - name: foo_bar 11 | key: github/ocotocat/foo/bar 12 | engine: native 13 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/repo_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/ocotocat/foobar 4 | engine: badengine 5 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/repo_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: repo 5 | 6 | - name: bar 7 | key: github/ocotocat 8 | engine: native 9 | type: repo 10 | 11 | - name: foobar 12 | key: github 13 | engine: native 14 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/shared.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/ocotokitties/foo 4 | engine: native 5 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/shared_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | key: github/ocotokitties/foo 4 | type: shared 5 | 6 | - name: foobar 7 | key: github/ocotokitties/foo 8 | engine: badengine 9 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/secret/validate/shared_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: shared 5 | 6 | - name: foobar 7 | key: github/ocotokitties 8 | engine: native 9 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: postgres 3 | image: postgres:latest 4 | environment: 5 | POSTGRES_DB: foo 6 | ports: 7 | - "5432:5432" 8 | 9 | - name: mysql 10 | image: mysql:latest 11 | environment: 12 | MYSQL_DATABASE: foo 13 | ports: 14 | - "3061:3061" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: badimage 3 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: postgres 3 | image: postgres:latest 4 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: postgres -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - image: postgres:latest -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/service_nil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/stage/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | badimage: 3 | steps: 4 | - name: badimage 5 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 6 | commands: 7 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/stage/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | image: alpine:latest 6 | commands: 7 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/stage/validate/missing.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/stage/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | commands: 6 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/stage/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - image: alpine:latest 5 | commands: 6 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: badimage 3 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 4 | commands: 5 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | image: alpine:latest 4 | commands: 5 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step/validate/missing.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | commands: 4 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - image: alpine:latest 3 | commands: 4 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_malformed.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Testing 3 | environment: 4 | - 'This: Shouldnt Panic' 5 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_nil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_secret_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: foo 3 | target: bar 4 | - source: hello 5 | target: world 6 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_secret_slice_invalid_no_source.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - target: foo -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_secret_slice_invalid_no_target.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: foo -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/step_secret_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo, hello ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/template.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: docker_build 3 | source: github.com/go-vela/atlas/stable/docker_create 4 | type: github 5 | - name: docker_build 6 | source: github.com/go-vela/atlas/stable/docker_build 7 | format: go 8 | type: github 9 | - name: docker_publish 10 | source: github.com/go-vela/atlas/stable/docker_publish 11 | format: starlark 12 | type: github 13 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_colon_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar:1024:2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_equal_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024=2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_hardlimit1_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar:1024 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_hardlimit2_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024:bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: foo 3 | soft: 1024 4 | - name: bar 5 | soft: 1024 6 | hard: 2048 7 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_softlimit_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/ulimit_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024, bar=1024:2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/volume_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ /foo:/bar:/foo:bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/volume_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: /foo 3 | - source: /foo 4 | destination: /bar 5 | - source: /foo 6 | destination: /foobar 7 | access_mode: ro 8 | -------------------------------------------------------------------------------- /compiler/types/yaml/buildkite/testdata/volume_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ /foo, /foo:/bar, /foo:/foobar:ro ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // package yaml provides the defined yaml types for Vela. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/compiler/types/yaml/yaml" 8 | package yaml 9 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/build/validate/bad_pipeline0.yml: -------------------------------------------------------------------------------- 1 | version: 1 -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/build/validate/bad_pipeline1.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | steps: 3 | stages: -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/build/validate/bad_version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | steps: -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/build_empty_env.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | template: false 6 | environment: [] 7 | 8 | environment: 9 | HELLO: "Hello, Global Message" 10 | 11 | worker: 12 | flavor: 16cpu8gb 13 | platform: gcp 14 | 15 | steps: 16 | - name: install 17 | commands: 18 | - ./gradlew downloadDependencies 19 | environment: 20 | GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false 21 | GRADLE_USER_HOME: .gradle 22 | image: openjdk:latest 23 | pull: true 24 | ruleset: 25 | event: [ push, pull_request ] 26 | volumes: [ /foo:/bar:ro ] 27 | ulimits: [ foo=1024:2048 ] -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/deploy_parameter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: 3 | description: bar 4 | required: true 5 | type: string 6 | options: 7 | - baz 8 | hello: 9 | description: baz 10 | required: false 11 | type: string -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/invalid.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: bar 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | template: false 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/metadata_env.yml: -------------------------------------------------------------------------------- 1 | --- 2 | template: false 3 | environment: [ steps ] 4 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_advanced.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: [ main ] 4 | event: push 5 | tag: "^refs/tags/(\\d+\\.)+\\d+$" 6 | eval: 'foo == "bar"' 7 | unless: 8 | event: 9 | - deployment 10 | - pull_request 11 | - comment 12 | - schedule 13 | path: [ foo.txt, /foo/bar.txt ] 14 | matcher: regexp 15 | operator: or 16 | continue: true -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_collide.yml: -------------------------------------------------------------------------------- 1 | --- 2 | branch: main 3 | branch: 4 | event: push -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_collide_adv.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | event: push 4 | branch: main 5 | event: 6 | unless: 7 | tag: v3* 8 | matcher: filepath -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_op_match.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: [ main ] 4 | event: push 5 | tag: "^refs/tags/(\\d+\\.)+\\d+$" 6 | matcher: regexp 7 | operator: and 8 | unless: 9 | event: 10 | - deployment 11 | - pull_request 12 | - comment 13 | - schedule 14 | path: [ foo.txt, /foo/bar.txt ] 15 | matcher: filepath 16 | operator: or 17 | continue: true -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_regex.yml: -------------------------------------------------------------------------------- 1 | --- 2 | if: 3 | branch: main 4 | event: tag 5 | tag: [ "^refs/tags/(\\d+\\.)+\\d+$" ] 6 | operator: and 7 | matcher: regex 8 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_simple.yml: -------------------------------------------------------------------------------- 1 | --- 2 | branch: main 3 | comment: "test comment" 4 | continue: true 5 | event: push 6 | instance: vela-server 7 | label: bug 8 | path: foo.txt 9 | repo: github/octocat 10 | sender: octocat 11 | status: success 12 | tag: v0.1.0 13 | target: production 14 | eval: 'foo == "bar"' 15 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ruleset_unknown_field.yml: -------------------------------------------------------------------------------- 1 | --- 2 | event: push 3 | branch: main 4 | user: octocat -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/no_name.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | # Declarative repository secret definition. 3 | - key: github/ocotocat/foob 4 | engine: native 5 | type: repo 6 | - key: github/ocotocat 7 | engine: native 8 | type: org 9 | - key: github/octokitties/foobar 10 | engine: native 11 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/org.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/foobar 4 | engine: native 5 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/org_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | key: github/foobar 4 | type: org 5 | 6 | - name: foobar 7 | key: github/foobar 8 | engine: badengine 9 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/org_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: org 5 | 6 | - name: foobar 7 | key: github 8 | engine: native 9 | type: org -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/plugin.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | name: vault secrets 4 | image: target/vela/secret-vault:latest 5 | parameters: 6 | items: 7 | - source: secret/vela/dev/docker 8 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/plugin_bad_image.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | name: vault secrets 4 | parameters: 5 | items: 6 | - source: secret/vela/dev/docker 7 | path: docker 8 | 9 | - origin: 10 | name: vault secrets 11 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 12 | parameters: 13 | items: 14 | - source: secret/vela/dev/docker 15 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/plugin_bad_name.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - origin: 3 | image: target/vela/secret-vault:latest 4 | parameters: 5 | items: 6 | - source: secret/vela/dev/docker 7 | path: docker -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/repo.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | # Implicit native secret definition. 3 | - name: foo 4 | 5 | # Declarative repository secret definition. 6 | - name: foob 7 | key: github/ocotocat/foob 8 | engine: native 9 | type: repo 10 | - name: foo_bar 11 | key: github/ocotocat/foo/bar 12 | engine: native 13 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/repo_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/ocotocat/foobar 4 | engine: badengine 5 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/repo_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: repo 5 | 6 | - name: bar 7 | key: github/ocotocat 8 | engine: native 9 | type: repo 10 | 11 | - name: foobar 12 | key: github 13 | engine: native 14 | type: repo -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/shared.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foobar 3 | key: github/ocotokitties/foo 4 | engine: native 5 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/shared_bad_engine.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | key: github/ocotokitties/foo 4 | type: shared 5 | 6 | - name: foobar 7 | key: github/ocotokitties/foo 8 | engine: badengine 9 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/secret/validate/shared_bad_key.yml: -------------------------------------------------------------------------------- 1 | secrets: 2 | - name: foo 3 | engine: native 4 | type: shared 5 | 6 | - name: foobar 7 | key: github/ocotokitties 8 | engine: native 9 | type: shared -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: postgres 3 | image: postgres:latest 4 | environment: 5 | POSTGRES_DB: foo 6 | ports: 7 | - "5432:5432" 8 | 9 | - name: mysql 10 | image: mysql:latest 11 | environment: 12 | MYSQL_DATABASE: foo 13 | ports: 14 | - "3061:3061" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: badimage 3 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: postgres 3 | image: postgres:latest 4 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - name: postgres -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | services: 2 | - image: postgres:latest -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/service_nil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/stage/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | badimage: 3 | steps: 4 | - name: badimage 5 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 6 | commands: 7 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/stage/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | image: alpine:latest 6 | commands: 7 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/stage/validate/missing.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/stage/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - name: hello 5 | commands: 6 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/stage/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | hello: 3 | steps: 4 | - image: alpine:latest 5 | commands: 6 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step/validate/bad_image.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: badimage 3 | image: bazel/:java:3240943c9ea3f72db51bea0a2428e83f3c5fa1312e19af017d026f9bcf70f84b 4 | commands: 5 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step/validate/minimal.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | image: alpine:latest 4 | commands: 5 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step/validate/missing.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | image: alpine:latest -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step/validate/missing_image.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: hello 3 | commands: 4 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step/validate/missing_name.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - image: alpine:latest 3 | commands: 4 | - echo "hello vela" -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_malformed.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Testing 3 | environment: 4 | - 'This: Shouldnt Panic' 5 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_nil.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_secret_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: foo 3 | target: bar 4 | - source: hello 5 | target: world 6 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_secret_slice_invalid_no_source.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - target: foo -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_secret_slice_invalid_no_target.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: foo -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/step_secret_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo, hello ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/template.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: docker_build 3 | source: github.com/go-vela/atlas/stable/docker_create 4 | type: github 5 | - name: docker_build 6 | source: github.com/go-vela/atlas/stable/docker_build 7 | format: go 8 | type: github 9 | - name: docker_publish 10 | source: github.com/go-vela/atlas/stable/docker_publish 11 | format: starlark 12 | type: github 13 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_colon_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar:1024:2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_equal_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024=2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_hardlimit1_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar:1024 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_hardlimit2_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024:bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: foo 3 | soft: 1024 4 | - name: bar 5 | soft: 1024 6 | hard: 2048 7 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_softlimit_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/ulimit_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ foo=1024, bar=1024:2048 ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/volume_error.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ /foo:/bar:/foo:bar ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/volume_slice.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - source: /foo 3 | - source: /foo 4 | destination: /bar 5 | - source: /foo 6 | destination: /foobar 7 | access_mode: ro 8 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/testdata/volume_string.yml: -------------------------------------------------------------------------------- 1 | --- 2 | [ /foo, /foo:/bar, /foo:/foobar:ro ] 3 | -------------------------------------------------------------------------------- /compiler/types/yaml/yaml/worker_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package yaml 4 | 5 | import ( 6 | "reflect" 7 | "testing" 8 | 9 | "github.com/go-vela/server/compiler/types/pipeline" 10 | ) 11 | 12 | func TestYaml_Worker_ToPipeline(t *testing.T) { 13 | // setup tests 14 | tests := []struct { 15 | worker *Worker 16 | want *pipeline.Worker 17 | }{ 18 | { 19 | worker: &Worker{ 20 | Flavor: "8cpu16gb", 21 | Platform: "gcp", 22 | }, 23 | want: &pipeline.Worker{ 24 | Flavor: "8cpu16gb", 25 | Platform: "gcp", 26 | }, 27 | }, 28 | } 29 | 30 | // run tests 31 | for _, test := range tests { 32 | got := test.worker.ToPipeline() 33 | 34 | if !reflect.DeepEqual(got, test.want) { 35 | t.Errorf("ToPipeline is %v, want %v", got, test.want) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /constants/app_install.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // App Install vars. 4 | package constants 5 | 6 | const ( 7 | // GitHub App install repositories selection when "all" repositories are selected. 8 | AppInstallRepositoriesSelectionAll = "all" 9 | // GitHub App install repositories selection when a subset of repositories are selected. 10 | AppInstallRepositoriesSelectionSelected = "selected" 11 | ) 12 | 13 | const ( 14 | // GitHub App install setup_action type 'install'. 15 | AppInstallSetupActionInstall = "install" 16 | // GitHub App install event type 'created'. 17 | AppInstallCreated = "created" 18 | // GitHub App install event type 'deleted'. 19 | AppInstallDeleted = "deleted" 20 | ) 21 | -------------------------------------------------------------------------------- /constants/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package constants provides the defined constant types for Vela. 4 | // 5 | // Usage: 6 | // 7 | // import "github.com/go-vela/server/constants" 8 | package constants 9 | -------------------------------------------------------------------------------- /constants/errors.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Error messages for the Vela API. 6 | const ( 7 | // ErrorEmptyDuration defines the error message for a duration calculation without a started value. 8 | ErrorEmptyDuration = "..." 9 | 10 | // ErrorMock defines the error message returned by mock API functions. 11 | ErrorMock = "error" 12 | ) 13 | -------------------------------------------------------------------------------- /constants/matcher.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Ruleset matchers. 6 | const ( 7 | // MatcherFilepath defines the ruleset type for the filepath matcher. 8 | MatcherFilepath = "filepath" 9 | 10 | // MatcherRegex defines the ruleset type for the regex matcher. 11 | MatcherRegex = "regexp" 12 | ) 13 | -------------------------------------------------------------------------------- /constants/operator.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Ruleset operators. 6 | const ( 7 | // OperatorAnd defines the ruleset type for the and operator. 8 | OperatorAnd = "and" 9 | 10 | // OperatorOr defines the ruleset type for the or operator. 11 | OperatorOr = "or" 12 | ) 13 | -------------------------------------------------------------------------------- /constants/permission.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Permissions. 6 | const ( 7 | PermissionAdmin = "admin" 8 | 9 | PermissionWrite = "write" 10 | 11 | PermissionRead = "read" 12 | 13 | PermissionNone = "none" 14 | ) 15 | -------------------------------------------------------------------------------- /constants/pipeline.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Pipeline types. 6 | const ( 7 | // PipelineStages defines the type for a pipeline with stages. 8 | PipelineStage = "stages" 9 | 10 | // PipelineStep defines the type for a pipeline with steps. 11 | PipelineStep = "steps" 12 | 13 | // PipelineTemplate defines the type for a pipeline as a template. 14 | PipelineTemplate = "template" 15 | ) 16 | -------------------------------------------------------------------------------- /constants/pull.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Service and step pull policies. 6 | const ( 7 | // PullAlways defines the pull policy type for 8 | // a service or step to always pull an image. 9 | PullAlways = "always" 10 | 11 | // PullNotPresent defines the pull policy type for 12 | // a service or step to only pull an image if it doesn't exist. 13 | PullNotPresent = "not_present" 14 | 15 | // PullOnStart defines the pull policy type for 16 | // a service or step to only pull an image before the container starts. 17 | PullOnStart = "on_start" 18 | 19 | // PullNever defines the pull policy type for 20 | // a service or step to never pull an image. 21 | PullNever = "never" 22 | ) 23 | -------------------------------------------------------------------------------- /constants/queue.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Queue types. 6 | const ( 7 | // DefaultRoute defines the default route all workers listen on. 8 | DefaultRoute = "vela" 9 | ) 10 | -------------------------------------------------------------------------------- /constants/visibility.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Repo visibility types. 6 | const ( 7 | // VisibilityPublic defines the visibility type for allowing any 8 | // users in Vela to access their repo regardless of the access 9 | // defined in the source control system. 10 | VisibilityPublic = "public" 11 | 12 | // VisibilityPrivate defines the visibility type for only allowing 13 | // users in Vela with pre-defined access in the source control 14 | // system to access their repo. 15 | VisibilityPrivate = "private" 16 | ) 17 | -------------------------------------------------------------------------------- /constants/worker_status.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Worker statuses. 6 | const ( 7 | // WorkerStatusIdle defines the status for a worker 8 | // where worker RunningBuildIDs.length = 0. 9 | WorkerStatusIdle = "idle" 10 | 11 | // WorkerStatusAvailable defines the status type for a worker in an available state, 12 | // where worker RunningBuildIDs.length > 0 and < worker BuildLimit. 13 | WorkerStatusAvailable = "available" 14 | 15 | // WorkerStatusBusy defines the status type for a worker in an unavailable state, 16 | // where worker BuildLimit == worker RunningBuildIDs.length. 17 | WorkerStatusBusy = "busy" 18 | 19 | // WorkerStatusError defines the status for a worker in an error state. 20 | WorkerStatusError = "error" 21 | ) 22 | -------------------------------------------------------------------------------- /constants/workspace.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package constants 4 | 5 | // Service and Step workspace paths. 6 | const ( 7 | // WorkspaceDefault defines the default workspace path for a service or a step. 8 | WorkspaceDefault = "/vela/src" 9 | 10 | // WorkspaceMount defines the mount workspace path for a service or a step. 11 | WorkspaceMount = "/vela" 12 | ) 13 | -------------------------------------------------------------------------------- /database/build/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package build 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountBuilds gets the count of all builds from the database. 12 | func (e *Engine) CountBuilds(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all builds") 14 | 15 | // variable to store query results 16 | var b int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableBuild). 22 | Count(&b). 23 | Error 24 | 25 | return b, err 26 | } 27 | -------------------------------------------------------------------------------- /database/build/count_status.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package build 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountBuildsForStatus gets the count of builds by status from the database. 12 | func (e *Engine) CountBuildsForStatus(ctx context.Context, status string, filters map[string]interface{}) (int64, error) { 13 | e.logger.Tracef("getting count of builds for status %s", status) 14 | 15 | // variable to store query results 16 | var b int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableBuild). 22 | Where("status = ?", status). 23 | Where(filters). 24 | Count(&b). 25 | Error 26 | 27 | return b, err 28 | } 29 | -------------------------------------------------------------------------------- /database/build/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package build 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteBuild deletes an existing build from the database. 16 | func (e *Engine) DeleteBuild(ctx context.Context, b *api.Build) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "build": b.GetNumber(), 19 | }).Tracef("deleting build %d", b.GetNumber()) 20 | 21 | build := types.BuildFromAPI(b) 22 | 23 | // send query to the database 24 | return e.client. 25 | WithContext(ctx). 26 | Table(constants.TableBuild). 27 | Delete(build). 28 | Error 29 | } 30 | -------------------------------------------------------------------------------- /database/close.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package database 4 | 5 | // Close stops and terminates the connection to the database. 6 | func (e *engine) Close() error { 7 | e.logger.Tracef("closing connection to the %s database", e.Driver()) 8 | 9 | // capture database/sql database from gorm.io/gorm database 10 | _sql, err := e.client.DB() 11 | if err != nil { 12 | return err 13 | } 14 | 15 | return _sql.Close() 16 | } 17 | -------------------------------------------------------------------------------- /database/dashboard/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package dashboard 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteDashboard deletes an existing dashboard from the database. 16 | func (e *Engine) DeleteDashboard(ctx context.Context, d *api.Dashboard) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "dashboard": d.GetID(), 19 | }).Tracef("deleting dashboard %s", d.GetID()) 20 | 21 | dashboard := types.DashboardFromAPI(d) 22 | 23 | // send query to the database 24 | return e.client. 25 | WithContext(ctx). 26 | Table(constants.TableDashboard). 27 | Delete(dashboard). 28 | Error 29 | } 30 | -------------------------------------------------------------------------------- /database/deployment/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package deployment 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountDeployments gets the count of all deployments from the database. 12 | func (e *Engine) CountDeployments(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all deployments") 14 | 15 | // variable to store query results 16 | var d int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableDeployment). 22 | Count(&d). 23 | Error 24 | 25 | return d, err 26 | } 27 | -------------------------------------------------------------------------------- /database/deployment/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package deployment 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateRepoIDIndex represents a query to create an 9 | // index on the deployments table for the repo_id column. 10 | CreateRepoIDIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | deployments_repo_id 14 | ON deployments (repo_id); 15 | ` 16 | ) 17 | 18 | // CreateDeploymetsIndexes creates the indexes for the deployments table in the database. 19 | func (e *Engine) CreateDeploymentIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for deployments table") 21 | 22 | // create the repo_id column index for the deployments table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateRepoIDIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package database provides the ability for Vela to 4 | // integrate with different supported SQL backends. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/database" 9 | package database 10 | -------------------------------------------------------------------------------- /database/driver.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package database 4 | 5 | // Driver outputs the configured database driver. 6 | func (e *engine) Driver() string { 7 | return e.config.Driver 8 | } 9 | -------------------------------------------------------------------------------- /database/hook/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package hook 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountHooks gets the count of all hooks from the database. 12 | func (e *Engine) CountHooks(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all hooks") 14 | 15 | // variable to store query results 16 | var h int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableHook). 22 | Count(&h). 23 | Error 24 | 25 | return h, err 26 | } 27 | -------------------------------------------------------------------------------- /database/hook/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package hook 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteHook deletes an existing hook from the database. 16 | func (e *Engine) DeleteHook(ctx context.Context, h *api.Hook) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "hook": h.GetNumber(), 19 | }).Tracef("deleting hook %d", h.GetNumber()) 20 | 21 | hook := types.HookFromAPI(h) 22 | 23 | // send query to the database 24 | return e.client. 25 | WithContext(ctx). 26 | Table(constants.TableHook). 27 | Delete(hook). 28 | Error 29 | } 30 | -------------------------------------------------------------------------------- /database/hook/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package hook 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateRepoIDIndex represents a query to create an 9 | // index on the hooks table for the repo_id column. 10 | CreateRepoIDIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | hooks_repo_id 14 | ON hooks (repo_id); 15 | ` 16 | ) 17 | 18 | // CreateHookIndexes creates the indexes for the hooks table in the database. 19 | func (e *Engine) CreateHookIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for hooks table") 21 | 22 | // create the repo_id column index for the hooks table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateRepoIDIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/log/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package log 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountLogs gets the count of all logs from the database. 12 | func (e *Engine) CountLogs(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all logs") 14 | 15 | // variable to store query results 16 | var l int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableLog). 22 | Count(&l). 23 | Error 24 | 25 | return l, err 26 | } 27 | -------------------------------------------------------------------------------- /database/log/count_build.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package log 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | "github.com/go-vela/server/constants" 10 | ) 11 | 12 | // CountLogsForBuild gets the count of logs by build ID from the database. 13 | func (e *Engine) CountLogsForBuild(ctx context.Context, b *api.Build) (int64, error) { 14 | e.logger.Tracef("getting count of logs for build %d", b.GetID()) 15 | 16 | // variable to store query results 17 | var l int64 18 | 19 | // send query to the database and store result in variable 20 | err := e.client. 21 | WithContext(ctx). 22 | Table(constants.TableLog). 23 | Where("build_id = ?", b.GetID()). 24 | Count(&l). 25 | Error 26 | 27 | return l, err 28 | } 29 | -------------------------------------------------------------------------------- /database/log/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package log 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateBuildIDIndex represents a query to create an 9 | // index on the logs table for the build_id column. 10 | CreateBuildIDIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | logs_build_id 14 | ON logs (build_id); 15 | ` 16 | ) 17 | 18 | // CreateLogIndexes creates the indexes for the logs table in the database. 19 | func (e *Engine) CreateLogIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for logs table") 21 | 22 | // create the build_id column index for the logs table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateBuildIDIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/pipeline/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountPipelines gets the count of all pipelines from the database. 12 | func (e *Engine) CountPipelines(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all pipelines") 14 | 15 | // variable to store query results 16 | var p int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TablePipeline). 22 | Count(&p). 23 | Error 24 | 25 | return p, err 26 | } 27 | -------------------------------------------------------------------------------- /database/pipeline/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeletePipeline deletes an existing pipeline from the database. 16 | func (e *Engine) DeletePipeline(ctx context.Context, p *api.Pipeline) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "pipeline": p.GetCommit(), 19 | }).Tracef("deleting pipeline %s", p.GetCommit()) 20 | 21 | pipeline := types.PipelineFromAPI(p) 22 | 23 | // send query to the database 24 | return e.client. 25 | WithContext(ctx). 26 | Table(constants.TablePipeline). 27 | Delete(pipeline). 28 | Error 29 | } 30 | -------------------------------------------------------------------------------- /database/pipeline/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package pipeline 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateRepoIDIndex represents a query to create an 9 | // index on the pipelines table for the repo_id column. 10 | CreateRepoIDIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | pipelines_repo_id 14 | ON pipelines (repo_id); 15 | ` 16 | ) 17 | 18 | // CreatePipelineIndexes creates the indexes for the pipelines table in the database. 19 | func (e *Engine) CreatePipelineIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for pipelines table in the database") 21 | 22 | // create the repo_id column index for the pipelines table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateRepoIDIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/repo/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package repo 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountRepos gets the count of all repos from the database. 12 | func (e *Engine) CountRepos(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all repos") 14 | 15 | // variable to store query results 16 | var r int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableRepo). 22 | Count(&r). 23 | Error 24 | 25 | return r, err 26 | } 27 | -------------------------------------------------------------------------------- /database/repo/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package repo 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateOrgNameIndex represents a query to create an 9 | // index on the repos table for the org and name columns. 10 | CreateOrgNameIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | repos_org_name 14 | ON repos (org, name); 15 | ` 16 | ) 17 | 18 | // CreateRepoIndexes creates the indexes for the repos table in the database. 19 | func (e *Engine) CreateRepoIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for repos table") 21 | 22 | // create the org and name columns index for the repos table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateOrgNameIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/schedule/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package schedule 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountSchedules gets the count of all schedules from the database. 12 | func (e *Engine) CountSchedules(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all schedules") 14 | 15 | // variable to store query results 16 | var s int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableSchedule). 22 | Count(&s). 23 | Error 24 | 25 | return s, err 26 | } 27 | -------------------------------------------------------------------------------- /database/schedule/count_active.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package schedule 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountActiveSchedules gets the count of all active schedules from the database. 12 | func (e *Engine) CountActiveSchedules(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all active schedules") 14 | 15 | // variable to store query results 16 | var s int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableSchedule). 22 | Where("active = ?", true). 23 | Count(&s). 24 | Error 25 | 26 | return s, err 27 | } 28 | -------------------------------------------------------------------------------- /database/schedule/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package schedule 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateRepoIDIndex represents a query to create an 9 | // index on the schedules table for the repo_id column. 10 | CreateRepoIDIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | schedules_repo_id 14 | ON schedules (repo_id); 15 | ` 16 | ) 17 | 18 | // CreateScheduleIndexes creates the indexes for the schedules table in the database. 19 | func (e *Engine) CreateScheduleIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for schedules table in the database") 21 | 22 | // create the repo_id column index for the schedules table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateRepoIDIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/secret/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package secret 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountSecrets gets the count of all secrets from the database. 12 | func (e *Engine) CountSecrets(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all secrets") 14 | 15 | // variable to store query results 16 | var s int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableSecret). 22 | Count(&s). 23 | Error 24 | 25 | return s, err 26 | } 27 | -------------------------------------------------------------------------------- /database/service/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package service 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountServices gets the count of all services from the database. 12 | func (e *Engine) CountServices(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all services") 14 | 15 | // variable to store query results 16 | var s int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableService). 22 | Count(&s). 23 | Error 24 | 25 | return s, err 26 | } 27 | -------------------------------------------------------------------------------- /database/service/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package service 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteService deletes an existing service from the database. 16 | func (e *Engine) DeleteService(ctx context.Context, s *api.Service) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "service": s.GetNumber(), 19 | }).Tracef("deleting service %s", s.GetName()) 20 | 21 | service := types.ServiceFromAPI(s) 22 | 23 | // send query to the database 24 | return e.client. 25 | WithContext(ctx). 26 | Table(constants.TableService). 27 | Delete(service). 28 | Error 29 | } 30 | -------------------------------------------------------------------------------- /database/settings/get.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package settings 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/api/types/settings" 9 | "github.com/go-vela/server/database/types" 10 | ) 11 | 12 | // GetSettings gets platform settings from the database. 13 | func (e *Engine) GetSettings(ctx context.Context) (*settings.Platform, error) { 14 | e.logger.Trace("getting platform settings") 15 | 16 | // variable to store query results 17 | s := new(types.Platform) 18 | 19 | // send query to the database and store result in variable 20 | err := e.client. 21 | WithContext(ctx). 22 | Table(TableSettings). 23 | Where("id = ?", 1). 24 | Take(s). 25 | Error 26 | if err != nil { 27 | return nil, err 28 | } 29 | 30 | // return the settings 31 | return s.ToAPI(), nil 32 | } 33 | -------------------------------------------------------------------------------- /database/step/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package step 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountSteps gets the count of all steps from the database. 12 | func (e *Engine) CountSteps(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all steps") 14 | 15 | // variable to store query results 16 | var s int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableStep). 22 | Count(&s). 23 | Error 24 | 25 | return s, err 26 | } 27 | -------------------------------------------------------------------------------- /database/step/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package step 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteStep deletes an existing step from the database. 16 | func (e *Engine) DeleteStep(ctx context.Context, s *api.Step) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "step": s.GetNumber(), 19 | }).Tracef("deleting step %s", s.GetName()) 20 | 21 | // cast the API type to database type 22 | step := types.StepFromAPI(s) 23 | 24 | // send query to the database 25 | return e.client. 26 | WithContext(ctx). 27 | Table(constants.TableStep). 28 | Delete(step). 29 | Error 30 | } 31 | -------------------------------------------------------------------------------- /database/step/get.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package step 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | "github.com/go-vela/server/constants" 10 | "github.com/go-vela/server/database/types" 11 | ) 12 | 13 | // GetStep gets a step by ID from the database. 14 | func (e *Engine) GetStep(ctx context.Context, id int64) (*api.Step, error) { 15 | e.logger.Tracef("getting step %d", id) 16 | 17 | // variable to store query results 18 | s := new(types.Step) 19 | 20 | // send query to the database and store result in variable 21 | err := e.client. 22 | WithContext(ctx). 23 | Table(constants.TableStep). 24 | Where("id = ?", id). 25 | Take(s). 26 | Error 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | return s.ToAPI(), nil 32 | } 33 | -------------------------------------------------------------------------------- /database/user/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package user 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountUsers gets the count of all users from the database. 12 | func (e *Engine) CountUsers(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all users") 14 | 15 | // variable to store query results 16 | var u int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableUser). 22 | Count(&u). 23 | Error 24 | 25 | return u, err 26 | } 27 | -------------------------------------------------------------------------------- /database/user/delete.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package user 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/sirupsen/logrus" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | "github.com/go-vela/server/constants" 12 | "github.com/go-vela/server/database/types" 13 | ) 14 | 15 | // DeleteUser deletes an existing user from the database. 16 | func (e *Engine) DeleteUser(ctx context.Context, u *api.User) error { 17 | e.logger.WithFields(logrus.Fields{ 18 | "user": u.GetName(), 19 | }).Tracef("deleting user %s", u.GetName()) 20 | 21 | // cast the API type to database type 22 | user := types.UserFromAPI(u) 23 | 24 | // send query to the database 25 | return e.client. 26 | WithContext(ctx). 27 | Table(constants.TableUser). 28 | Delete(user). 29 | Error 30 | } 31 | -------------------------------------------------------------------------------- /database/user/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package user 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateUserRefreshIndex represents a query to create an 9 | // index on the users table for the refresh_token column. 10 | CreateUserRefreshIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | users_refresh 14 | ON users (refresh_token); 15 | ` 16 | ) 17 | 18 | // CreateUserIndexes creates the indexes for the users table in the database. 19 | func (e *Engine) CreateUserIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for users table") 21 | 22 | // create the refresh_token column index for the users table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateUserRefreshIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /database/worker/count.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package worker 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/go-vela/server/constants" 9 | ) 10 | 11 | // CountWorkers gets the count of all workers from the database. 12 | func (e *Engine) CountWorkers(ctx context.Context) (int64, error) { 13 | e.logger.Tracef("getting count of all workers") 14 | 15 | // variable to store query results 16 | var w int64 17 | 18 | // send query to the database and store result in variable 19 | err := e.client. 20 | WithContext(ctx). 21 | Table(constants.TableWorker). 22 | Count(&w). 23 | Error 24 | 25 | return w, err 26 | } 27 | -------------------------------------------------------------------------------- /database/worker/index.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package worker 4 | 5 | import "context" 6 | 7 | const ( 8 | // CreateHostnameAddressIndex represents a query to create an 9 | // index on the workers table for the hostname and address columns. 10 | CreateHostnameAddressIndex = ` 11 | CREATE INDEX 12 | IF NOT EXISTS 13 | workers_hostname_address 14 | ON workers (hostname, address); 15 | ` 16 | ) 17 | 18 | // CreateWorkerIndexes creates the indexes for the workers table in the database. 19 | func (e *Engine) CreateWorkerIndexes(ctx context.Context) error { 20 | e.logger.Tracef("creating indexes for workers table") 21 | 22 | // create the hostname and address columns index for the workers table 23 | return e.client. 24 | WithContext(ctx). 25 | Exec(CreateHostnameAddressIndex).Error 26 | } 27 | -------------------------------------------------------------------------------- /internal/image/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package image provides the ability for Vela to manage 4 | // and manipulate images. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/internal/image" 9 | package image 10 | -------------------------------------------------------------------------------- /internal/testdata/buildkite.yml: -------------------------------------------------------------------------------- 1 | version: "legacy" 2 | 3 | aliases: 4 | images: 5 | alpine: &alpine-image 6 | image: alpine:latest 7 | 8 | env: 9 | dev-env: &dev-parameters 10 | parameters: 11 | REGION: dev 12 | 13 | steps: 14 | - name: example 15 | <<: *alpine-image 16 | <<: *dev-parameters 17 | commands: 18 | - echo $REGION -------------------------------------------------------------------------------- /internal/testdata/buildkite_new_version.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | aliases: 4 | images: 5 | alpine: &alpine-image 6 | image: alpine:latest 7 | 8 | env: 9 | dev-env: &dev-parameters 10 | parameters: 11 | REGION: dev 12 | 13 | steps: 14 | - name: example 15 | <<: *alpine-image 16 | <<: *dev-parameters 17 | commands: 18 | - echo $REGION -------------------------------------------------------------------------------- /internal/testdata/go-yaml.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | aliases: 4 | images: 5 | alpine: &alpine-image 6 | image: alpine:latest 7 | 8 | env: 9 | dev-env: &dev-parameters 10 | parameters: 11 | REGION: dev 12 | 13 | steps: 14 | - name: example 15 | <<: 16 | - *alpine-image 17 | - *dev-parameters 18 | commands: 19 | - echo $REGION 20 | -------------------------------------------------------------------------------- /internal/testdata/invalid.yml: -------------------------------------------------------------------------------- 1 | - sliceNodeA 2 | - sliceNodeB -------------------------------------------------------------------------------- /internal/testdata/no_version.yml: -------------------------------------------------------------------------------- 1 | aliases: 2 | images: 3 | alpine: &alpine-image 4 | image: alpine:latest 5 | 6 | env: 7 | dev-env: &dev-parameters 8 | parameters: 9 | REGION: dev 10 | 11 | steps: 12 | - name: example 13 | <<: 14 | - *alpine-image 15 | - *dev-parameters 16 | commands: 17 | - echo $REGION -------------------------------------------------------------------------------- /internal/testdata/top_level_anchor.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | <<: &alpine-image 4 | image: alpine:latest 5 | 6 | <<: &dev-parameters 7 | parameters: 8 | REGION: dev 9 | 10 | steps: 11 | - name: example 12 | <<: 13 | - *alpine-image 14 | - *dev-parameters 15 | commands: 16 | - echo $REGION -------------------------------------------------------------------------------- /internal/testdata/top_level_anchor_legacy.yml: -------------------------------------------------------------------------------- 1 | version: "legacy" 2 | 3 | <<: &alpine-image 4 | image: alpine:latest 5 | 6 | <<: &dev-parameters 7 | parameters: 8 | REGION: dev 9 | 10 | steps: 11 | - name: example 12 | <<: 13 | - *alpine-image 14 | - *dev-parameters 15 | commands: 16 | - echo $REGION -------------------------------------------------------------------------------- /mock/server/build_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestBuild_ActiveBuildResp(t *testing.T) { 14 | testBuild := api.Build{} 15 | 16 | err := json.Unmarshal([]byte(BuildResp), &testBuild) 17 | if err != nil { 18 | t.Errorf("error unmarshaling build: %v", err) 19 | } 20 | 21 | tBuild := reflect.TypeOf(testBuild) 22 | 23 | for i := 0; i < tBuild.NumField(); i++ { 24 | if reflect.ValueOf(testBuild).Field(i).IsNil() { 25 | t.Errorf("BuildResp missing field %s", tBuild.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/deployment_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestDeployment_ActiveDeploymentResp(t *testing.T) { 14 | testDeployment := api.Deployment{} 15 | 16 | err := json.Unmarshal([]byte(DeploymentResp), &testDeployment) 17 | if err != nil { 18 | t.Errorf("error unmarshaling deployment: %v", err) 19 | } 20 | 21 | tDeployment := reflect.TypeOf(testDeployment) 22 | 23 | for i := 0; i < tDeployment.NumField(); i++ { 24 | if reflect.ValueOf(testDeployment).Field(i).IsNil() { 25 | t.Errorf("DeploymentResp missing field %s", tDeployment.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/hook_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestHook_ActiveHookResp(t *testing.T) { 14 | testHook := api.Hook{} 15 | 16 | err := json.Unmarshal([]byte(HookResp), &testHook) 17 | if err != nil { 18 | t.Errorf("error unmarshaling hook: %v", err) 19 | } 20 | 21 | tHook := reflect.TypeOf(testHook) 22 | 23 | for i := 0; i < tHook.NumField(); i++ { 24 | if reflect.ValueOf(testHook).Field(i).IsNil() { 25 | t.Errorf("HookResp missing field %s", tHook.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/log_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestLog_ActiveLogResp(t *testing.T) { 14 | testLog := api.Log{} 15 | 16 | err := json.Unmarshal([]byte(LogResp), &testLog) 17 | if err != nil { 18 | t.Errorf("error unmarshaling log: %v", err) 19 | } 20 | 21 | tLog := reflect.TypeOf(testLog) 22 | 23 | for i := 0; i < tLog.NumField(); i++ { 24 | if reflect.ValueOf(testLog).Field(i).IsNil() { 25 | t.Errorf("LogResp missing field %s", tLog.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/pipeline_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestPipeline_ActivePipelineResp(t *testing.T) { 14 | testPipeline := api.Pipeline{} 15 | 16 | err := json.Unmarshal([]byte(PipelineResp), &testPipeline) 17 | if err != nil { 18 | t.Errorf("error unmarshaling pipeline: %v", err) 19 | } 20 | 21 | tPipeline := reflect.TypeOf(testPipeline) 22 | 23 | for i := 0; i < tPipeline.NumField(); i++ { 24 | if reflect.ValueOf(testPipeline).Field(i).IsNil() { 25 | t.Errorf("PipelineResp missing field %s", tPipeline.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/repo_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestRepo_ActiveRepoResp(t *testing.T) { 14 | testRepo := api.Repo{} 15 | 16 | err := json.Unmarshal([]byte(RepoResp), &testRepo) 17 | if err != nil { 18 | t.Errorf("error unmarshaling repo: %v", err) 19 | } 20 | 21 | tRepo := reflect.TypeOf(testRepo) 22 | 23 | for i := 0; i < tRepo.NumField(); i++ { 24 | if tRepo.Field(i).Name == "Hash" { 25 | continue 26 | } 27 | if reflect.ValueOf(testRepo).Field(i).IsNil() { 28 | t.Errorf("RepoResp missing field %s", tRepo.Field(i).Name) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mock/server/rotate_keys.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/gin-gonic/gin" 10 | 11 | api "github.com/go-vela/server/api/types" 12 | "github.com/go-vela/server/router/middleware/auth" 13 | ) 14 | 15 | // rotateKeys returns success message. Pass `invalid` to auth header to test 401 error. 16 | func rotateKeys(c *gin.Context) { 17 | tkn, _ := auth.RetrieveAccessToken(c.Request) 18 | 19 | if strings.EqualFold(tkn, "invalid") { 20 | data := "unauthorized" 21 | c.AbortWithStatusJSON(http.StatusUnauthorized, api.Error{Message: &data}) 22 | 23 | return 24 | } 25 | 26 | c.JSON(http.StatusOK, "keys rotated successfully") 27 | } 28 | -------------------------------------------------------------------------------- /mock/server/schedule_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestSchedule_ActiveScheduleResp(t *testing.T) { 14 | testSchedule := api.Schedule{} 15 | 16 | err := json.Unmarshal([]byte(ScheduleResp), &testSchedule) 17 | if err != nil { 18 | t.Errorf("error unmarshaling schedule: %v", err) 19 | } 20 | 21 | tSchedule := reflect.TypeOf(testSchedule) 22 | 23 | for i := 0; i < tSchedule.NumField(); i++ { 24 | if reflect.ValueOf(testSchedule).Field(i).IsNil() { 25 | t.Errorf("ScheduleResp missing field %s", tSchedule.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/secret_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestSecret_ActiveSecretResp(t *testing.T) { 14 | testSecret := api.Secret{} 15 | 16 | err := json.Unmarshal([]byte(SecretResp), &testSecret) 17 | if err != nil { 18 | t.Errorf("error unmarshaling secret: %v", err) 19 | } 20 | 21 | tSecret := reflect.TypeOf(testSecret) 22 | 23 | for i := 0; i < tSecret.NumField(); i++ { 24 | if reflect.ValueOf(testSecret).Field(i).IsNil() { 25 | t.Errorf("SecretResp missing field %s", tSecret.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/service_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestService_ActiveServiceResp(t *testing.T) { 14 | testService := api.Service{} 15 | 16 | err := json.Unmarshal([]byte(ServiceResp), &testService) 17 | if err != nil { 18 | t.Errorf("error unmarshaling service: %v", err) 19 | } 20 | 21 | tService := reflect.TypeOf(testService) 22 | 23 | for i := 0; i < tService.NumField(); i++ { 24 | if reflect.ValueOf(testService).Field(i).IsNil() { 25 | t.Errorf("ServiceResp missing field %s", tService.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/step_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestStep_ActiveStepResp(t *testing.T) { 14 | testStep := api.Step{} 15 | 16 | err := json.Unmarshal([]byte(StepResp), &testStep) 17 | if err != nil { 18 | t.Errorf("error unmarshaling step: %v", err) 19 | } 20 | 21 | tStep := reflect.TypeOf(testStep) 22 | 23 | for i := 0; i < tStep.NumField(); i++ { 24 | if reflect.ValueOf(testStep).Field(i).IsNil() { 25 | t.Errorf("StepResp missing field %s", tStep.Field(i).Name) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mock/server/user_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package server 4 | 5 | import ( 6 | "encoding/json" 7 | "reflect" 8 | "testing" 9 | 10 | api "github.com/go-vela/server/api/types" 11 | ) 12 | 13 | func TestUser_ActiveUserResp(t *testing.T) { 14 | testUser := api.User{} 15 | 16 | err := json.Unmarshal([]byte(UserResp), &testUser) 17 | if err != nil { 18 | t.Errorf("error unmarshaling user: %v", err) 19 | } 20 | 21 | tUser := reflect.TypeOf(testUser) 22 | 23 | for i := 0; i < tUser.NumField(); i++ { 24 | if tUser.Field(i).Name == "Token" || tUser.Field(i).Name == "RefreshToken" || tUser.Field(i).Name == "Hash" { 25 | continue 26 | } 27 | if reflect.ValueOf(testUser).Field(i).IsNil() { 28 | t.Errorf("UserResp missing field %s", tUser.Field(i).Name) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /queue/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package queue provides the ability for Vela to integrate 4 | // with different supported Queue backends. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/queue" 9 | package queue 10 | -------------------------------------------------------------------------------- /queue/redis/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package redis provides the ability for Vela to 4 | // integrate with a Redis server as a queue backend. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/queue/redis" 9 | package redis 10 | -------------------------------------------------------------------------------- /queue/redis/driver.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package redis 4 | 5 | import "github.com/go-vela/server/constants" 6 | 7 | // Driver outputs the configured queue driver. 8 | func (c *Client) Driver() string { 9 | return constants.DriverRedis 10 | } 11 | -------------------------------------------------------------------------------- /queue/redis/length.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package redis 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | // Length tallies all items present in the configured routes in the queue. 10 | func (c *Client) Length(ctx context.Context) (int64, error) { 11 | c.Logger.Tracef("reading length of all configured routes in queue") 12 | 13 | total := int64(0) 14 | 15 | for _, channel := range c.GetRoutes() { 16 | items, err := c.Redis.LLen(ctx, channel).Result() 17 | if err != nil { 18 | return 0, err 19 | } 20 | 21 | total += items 22 | } 23 | 24 | return total, nil 25 | } 26 | -------------------------------------------------------------------------------- /queue/redis/ping.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package redis 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | // Ping contacts the queue to test its connection. 10 | func (c *Client) Ping(ctx context.Context) error { 11 | // send ping request to client 12 | err := c.Redis.Ping(ctx).Err() 13 | if err != nil { 14 | c.Logger.Debugf("unable to ping Redis queue.") 15 | return err 16 | } 17 | 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /queue/redis/route_length.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package redis 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | // RouteLength returns count of all items present in the given route. 10 | func (c *Client) RouteLength(ctx context.Context, channel string) (int64, error) { 11 | c.Logger.Tracef("reading length of all configured routes in queue") 12 | 13 | items, err := c.Redis.LLen(ctx, channel).Result() 14 | if err != nil { 15 | return 0, err 16 | } 17 | 18 | return items, nil 19 | } 20 | -------------------------------------------------------------------------------- /queue/redis/settings.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package redis 4 | 5 | import ( 6 | "github.com/go-vela/server/api/types/settings" 7 | ) 8 | 9 | // GetSettings retrieves the api settings type in the Engine. 10 | func (c *Client) GetSettings() settings.Queue { 11 | return c.Queue 12 | } 13 | 14 | // SetSettings sets the api settings type in the Engine. 15 | func (c *Client) SetSettings(s *settings.Platform) { 16 | if s != nil { 17 | c.SetRoutes(s.GetRoutes()) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /router/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package router provides the routing engine for Vela 4 | // to serve and process API requests. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/router" 9 | package router 10 | -------------------------------------------------------------------------------- /router/middleware/app_webhook_secret.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // AppWebhookSecret is a middleware function that attaches the Vela GH app secret used for 10 | // validating incoming app install webhooks to the context of every http.Request. 11 | func AppWebhookSecret(secret string) gin.HandlerFunc { 12 | return func(c *gin.Context) { 13 | c.Set("app-webhook-secret", secret) 14 | c.Next() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /router/middleware/auth/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package token provides the ability for inserting 4 | // Vela token resources into or extracting Vela token 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/auth" 10 | package auth 11 | -------------------------------------------------------------------------------- /router/middleware/build/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package build provides the ability for inserting 4 | // Vela build resources into or extracting Vela build 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/build" 10 | package build 11 | -------------------------------------------------------------------------------- /router/middleware/claims/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package claims provides the ability for inserting 4 | // token claims resources into or extracting token claims 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/claims" 10 | package claims 11 | -------------------------------------------------------------------------------- /router/middleware/cli.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | "github.com/urfave/cli/v3" 8 | 9 | cliMiddleware "github.com/go-vela/server/router/middleware/cli" 10 | ) 11 | 12 | // CLI is a middleware function that attaches the cli client 13 | // to the context of every http.Request. 14 | func CLI(cliCmd *cli.Command) gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | cliMiddleware.ToContext(c, cliCmd) 17 | 18 | c.Next() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /router/middleware/cli/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package cli 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/urfave/cli/v3" 9 | ) 10 | 11 | const key = "cli" 12 | 13 | // Setter defines a context that enables setting values. 14 | type Setter interface { 15 | Set(string, interface{}) 16 | } 17 | 18 | // FromContext returns the cli command associated with this context. 19 | func FromContext(c context.Context) *cli.Command { 20 | value := c.Value(key) 21 | if value == nil { 22 | return nil 23 | } 24 | 25 | s, ok := value.(*cli.Command) 26 | if !ok { 27 | return nil 28 | } 29 | 30 | return s 31 | } 32 | 33 | // ToContext adds the cli command to this context if it supports 34 | // the Setter interface. 35 | func ToContext(c Setter, s *cli.Command) { 36 | c.Set(key, s) 37 | } 38 | -------------------------------------------------------------------------------- /router/middleware/cli/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package cli provides the ability for inserting 4 | // Vela cli resources into or extracting Vela cli 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/cli" 10 | package cli 11 | -------------------------------------------------------------------------------- /router/middleware/compiler.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/compiler" 9 | "github.com/go-vela/server/router/middleware/settings" 10 | ) 11 | 12 | // Compiler is a middleware function that initializes the compiler and 13 | // attaches to the context of every http.Request. 14 | func Compiler(comp compiler.Engine) gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | s := settings.FromContext(c) 17 | comp.SetSettings(s) 18 | 19 | compiler.WithGinContext(c, comp) 20 | 21 | c.Next() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /router/middleware/dashboard/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package dashboard provides the ability for inserting 4 | // Vela dashboard resources into or extracting Vela dashboard 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/dashboard" 10 | package dashboard 11 | -------------------------------------------------------------------------------- /router/middleware/database.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/database" 9 | ) 10 | 11 | // Database is a middleware function that initializes the database and 12 | // attaches to the context of every http.Request. 13 | func Database(d database.Interface) gin.HandlerFunc { 14 | return func(c *gin.Context) { 15 | database.ToContext(c, d) 16 | c.Next() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/middleware/default_build_limit.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // DefaultBuildLimit is a middleware function that attaches the defaultLimit 10 | // to enable the server to override the default build limit. 11 | func DefaultBuildLimit(defaultBuildLimit int32) gin.HandlerFunc { 12 | return func(c *gin.Context) { 13 | c.Set("defaultBuildLimit", defaultBuildLimit) 14 | c.Next() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /router/middleware/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package middleware provides the ability for injecting Vela 4 | // resources into the middleware chain for the API. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/router/middleware" 9 | package middleware 10 | -------------------------------------------------------------------------------- /router/middleware/executors/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package executors provides the ability for inserting 4 | // Vela executors resources into or extracting Vela build 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/executor" 10 | package executors 11 | -------------------------------------------------------------------------------- /router/middleware/executors/executor_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package executors 4 | 5 | import ( 6 | "reflect" 7 | "testing" 8 | 9 | "github.com/gin-gonic/gin" 10 | 11 | api "github.com/go-vela/server/api/types" 12 | ) 13 | 14 | func TestExecutors_Retrieve(t *testing.T) { 15 | // setup types 16 | eID := int64(1) 17 | e := api.Executor{ID: &eID} 18 | want := []api.Executor{e} 19 | 20 | // setup context 21 | gin.SetMode(gin.TestMode) 22 | 23 | context, _ := gin.CreateTestContext(nil) 24 | ToContext(context, want) 25 | 26 | // run test 27 | got := Retrieve(context) 28 | 29 | if !reflect.DeepEqual(got, want) { 30 | t.Errorf("Retrieve is %v, want %v", got, want) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /router/middleware/hook/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package hook 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | ) 10 | 11 | const key = "hook" 12 | 13 | // Setter defines a context that enables setting values. 14 | type Setter interface { 15 | Set(string, interface{}) 16 | } 17 | 18 | // FromContext returns the hook associated with this context. 19 | func FromContext(c context.Context) *api.Hook { 20 | value := c.Value(key) 21 | if value == nil { 22 | return nil 23 | } 24 | 25 | r, ok := value.(*api.Hook) 26 | if !ok { 27 | return nil 28 | } 29 | 30 | return r 31 | } 32 | 33 | // ToContext adds the hook to this context if it supports 34 | // the Setter interface. 35 | func ToContext(c Setter, h *api.Hook) { 36 | c.Set(key, h) 37 | } 38 | -------------------------------------------------------------------------------- /router/middleware/hook/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package hook provides the ability for inserting 4 | // Vela hook resources into or extracting Vela hook 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/hook" 10 | package hook 11 | -------------------------------------------------------------------------------- /router/middleware/max_build_limit.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // MaxBuildLimit is a middleware function that attaches the defaultLimit 10 | // to enable the server to override the max build limit. 11 | func MaxBuildLimit(maxBuildLimit int32) gin.HandlerFunc { 12 | return func(c *gin.Context) { 13 | c.Set("maxBuildLimit", maxBuildLimit) 14 | c.Next() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /router/middleware/metadata.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/internal" 9 | ) 10 | 11 | // Metadata is a middleware function that attaches the metadata 12 | // to the context of every http.Request. 13 | func Metadata(m *internal.Metadata) gin.HandlerFunc { 14 | return func(c *gin.Context) { 15 | c.Set("metadata", m) 16 | c.Next() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/middleware/org/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package org 4 | 5 | import ( 6 | "context" 7 | ) 8 | 9 | const key = "org" 10 | 11 | // Setter defines a context that enables setting values. 12 | type Setter interface { 13 | Set(string, interface{}) 14 | } 15 | 16 | // FromContext returns the Org associated with this context. 17 | func FromContext(c context.Context) string { 18 | value := c.Value(key) 19 | if value == nil { 20 | return "" 21 | } 22 | 23 | o, ok := value.(string) 24 | if !ok { 25 | return "" 26 | } 27 | 28 | return o 29 | } 30 | 31 | // ToContext adds the Org to this context if it supports 32 | // the Setter interface. 33 | func ToContext(c Setter, o string) { 34 | c.Set(key, o) 35 | } 36 | -------------------------------------------------------------------------------- /router/middleware/org/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package org provides the ability for inserting 4 | // Vela org resources into or extracting Vela org 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/org" 10 | package org 11 | -------------------------------------------------------------------------------- /router/middleware/payload.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "bytes" 7 | "encoding/json" 8 | "io" 9 | 10 | "github.com/gin-gonic/gin" 11 | ) 12 | 13 | // Payload is a middleware function that captures the user provided json body 14 | // and attaches it to the context of every http.Request to be logged. 15 | func Payload() gin.HandlerFunc { 16 | return func(c *gin.Context) { 17 | // bind JSON payload from request to be added to context 18 | var payload interface{} 19 | _ = c.BindJSON(&payload) 20 | 21 | body, _ := json.Marshal(&payload) 22 | 23 | c.Set("payload", payload) 24 | 25 | c.Request.Body = io.NopCloser(bytes.NewBuffer(body)) 26 | 27 | c.Next() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /router/middleware/perm/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package perm provides the ability for validating the access 4 | // control to Vela resources in the middleware chain for the API. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/router/middleware/perm" 9 | package perm 10 | -------------------------------------------------------------------------------- /router/middleware/pipeline/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package pipeline provides the ability for inserting 4 | // Vela pipeline resources into or extracting Vela pipeline 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/pipeline" 10 | package pipeline 11 | -------------------------------------------------------------------------------- /router/middleware/queue.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/queue" 9 | "github.com/go-vela/server/router/middleware/settings" 10 | ) 11 | 12 | // Queue is a middleware function that initializes the queue and 13 | // attaches to the context of every http.Request. 14 | func Queue(q queue.Service) gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | s := settings.FromContext(c) 17 | q.SetSettings(s) 18 | 19 | queue.WithGinContext(c, q) 20 | 21 | c.Next() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /router/middleware/repo/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package repo 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | ) 10 | 11 | const key = "repo" 12 | 13 | // Setter defines a context that enables setting values. 14 | type Setter interface { 15 | Set(string, interface{}) 16 | } 17 | 18 | // FromContext returns the Repo associated with this context. 19 | func FromContext(c context.Context) *api.Repo { 20 | value := c.Value(key) 21 | if value == nil { 22 | return nil 23 | } 24 | 25 | r, ok := value.(*api.Repo) 26 | if !ok { 27 | return nil 28 | } 29 | 30 | return r 31 | } 32 | 33 | // ToContext adds the Repo to this context if it supports 34 | // the Setter interface. 35 | func ToContext(c Setter, r *api.Repo) { 36 | c.Set(key, r) 37 | } 38 | -------------------------------------------------------------------------------- /router/middleware/repo/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package repo provides the ability for inserting 4 | // Vela repo resources into or extracting Vela repo 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/repo" 10 | package repo 11 | -------------------------------------------------------------------------------- /router/middleware/schedule_frequency.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // ScheduleFrequency is a middleware function that attaches the scheduleminimumfrequency used 12 | // to limit the frequency which schedules can be run within the system. 13 | func ScheduleFrequency(scheduleFrequency time.Duration) gin.HandlerFunc { 14 | return func(c *gin.Context) { 15 | c.Set("scheduleminimumfrequency", scheduleFrequency) 16 | c.Next() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/middleware/scm.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/router/middleware/settings" 9 | "github.com/go-vela/server/scm" 10 | ) 11 | 12 | // Scm is a middleware function that initializes the scm and 13 | // attaches to the context of every http.Request. 14 | func Scm(scmService scm.Service) gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | s := settings.FromContext(c) 17 | scmService.SetSettings(s) 18 | 19 | scm.WithGinContext(c, scmService) 20 | 21 | c.Next() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /router/middleware/secure_cookie.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // SecureCookie determines whether or not incoming webhooks are validated coming from Github 10 | // This is primarily intended for local development. 11 | func SecureCookie(secure bool) gin.HandlerFunc { 12 | return func(c *gin.Context) { 13 | c.Set("securecookie", secure) 14 | c.Next() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /router/middleware/service/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package service provides the ability for inserting 4 | // Vela service resources into or extracting Vela service 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/service" 10 | package service 11 | -------------------------------------------------------------------------------- /router/middleware/settings.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/api/types/settings" 9 | sMiddleware "github.com/go-vela/server/router/middleware/settings" 10 | ) 11 | 12 | // Settings is a middleware function that attaches settings 13 | // to the context of every http.Request. 14 | func Settings(s *settings.Platform) gin.HandlerFunc { 15 | return func(c *gin.Context) { 16 | sMiddleware.ToContext(c, s) 17 | 18 | c.Next() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /router/middleware/settings/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package settings provides the ability for inserting 4 | // Vela settings resources into or extracting Vela settings 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/settings" 10 | package settings 11 | -------------------------------------------------------------------------------- /router/middleware/step/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package step 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | ) 10 | 11 | const key = "step" 12 | 13 | // Setter defines a context that enables setting values. 14 | type Setter interface { 15 | Set(string, interface{}) 16 | } 17 | 18 | // FromContext returns the Step associated with this context. 19 | func FromContext(c context.Context) *api.Step { 20 | value := c.Value(key) 21 | if value == nil { 22 | return nil 23 | } 24 | 25 | s, ok := value.(*api.Step) 26 | if !ok { 27 | return nil 28 | } 29 | 30 | return s 31 | } 32 | 33 | // ToContext adds the Step to this context if it supports 34 | // the Setter interface. 35 | func ToContext(c Setter, s *api.Step) { 36 | c.Set(key, s) 37 | } 38 | -------------------------------------------------------------------------------- /router/middleware/step/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package step provides the ability for inserting 4 | // Vela step resources into or extracting Vela step 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/step" 10 | package step 11 | -------------------------------------------------------------------------------- /router/middleware/token_manager.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/internal/token" 9 | ) 10 | 11 | // TokenManager is a middleware function that attaches the token manager 12 | // to the context of every http.Request. 13 | func TokenManager(m *token.Manager) gin.HandlerFunc { 14 | return func(c *gin.Context) { 15 | c.Set("token-manager", m) 16 | c.Next() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/middleware/tracing/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package tracing provides the ability for inserting 4 | // or extracting the Vela OTEL tracing client 5 | // from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/tracing" 10 | package tracing 11 | -------------------------------------------------------------------------------- /router/middleware/tracing/tracing.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package tracing 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | "github.com/sirupsen/logrus" 8 | 9 | "github.com/go-vela/server/tracing" 10 | ) 11 | 12 | // Retrieve gets the value in the given context. 13 | func Retrieve(c *gin.Context) *tracing.Client { 14 | return FromContext(c) 15 | } 16 | 17 | // Establish sets the value in the given context. 18 | func Establish() gin.HandlerFunc { 19 | return func(c *gin.Context) { 20 | l := c.MustGet("logger").(*logrus.Entry) 21 | tc := Retrieve(c) 22 | 23 | l.Debugf("reading tracing client from context") 24 | 25 | ToContext(c, tc) 26 | c.Next() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /router/middleware/user/context.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package user 4 | 5 | import ( 6 | "context" 7 | 8 | api "github.com/go-vela/server/api/types" 9 | ) 10 | 11 | const key = "user" 12 | 13 | // Setter defines a context that enables setting values. 14 | type Setter interface { 15 | Set(string, interface{}) 16 | } 17 | 18 | // FromContext returns the User associated with this context. 19 | func FromContext(c context.Context) *api.User { 20 | value := c.Value(key) 21 | if value == nil { 22 | return nil 23 | } 24 | 25 | u, ok := value.(*api.User) 26 | if !ok { 27 | return nil 28 | } 29 | 30 | return u 31 | } 32 | 33 | // ToContext adds the User to this context if it supports 34 | // the Setter interface. 35 | func ToContext(c Setter, u *api.User) { 36 | c.Set(key, u) 37 | } 38 | -------------------------------------------------------------------------------- /router/middleware/user/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package user provides the ability for inserting 4 | // Vela user resources into or extracting Vela user 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/user" 10 | package user 11 | -------------------------------------------------------------------------------- /router/middleware/webhook_validation.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // WebhookValidation determines whether or not incoming webhooks are validated coming from Github 10 | // This is primarily intended for local development. 11 | func WebhookValidation(validate bool) gin.HandlerFunc { 12 | return func(c *gin.Context) { 13 | c.Set("webhookvalidation", validate) 14 | c.Next() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /router/middleware/worker.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package middleware 4 | 5 | import ( 6 | "time" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // Worker is a middleware function that attaches the worker interval 12 | // to determine which workers are active. 13 | func Worker(duration time.Duration) gin.HandlerFunc { 14 | return func(c *gin.Context) { 15 | c.Set("worker_active_interval", duration) 16 | c.Next() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /router/middleware/worker/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package worker provides the ability for inserting 4 | // Vela worker resources into or extracting Vela worker 5 | // resources from the middleware chain for the API. 6 | // 7 | // Usage: 8 | // 9 | // import "github.com/go-vela/server/router/middleware/worker" 10 | package worker 11 | -------------------------------------------------------------------------------- /router/queue.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package router 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/api/queue" 9 | "github.com/go-vela/server/router/middleware/perm" 10 | ) 11 | 12 | // QueueHandlers is a function that extends the provided base router group 13 | // with the API handlers for queue registration functionality. 14 | // 15 | // GET /api/v1/queue/info . 16 | func QueueHandlers(base *gin.RouterGroup) { 17 | // Queue endpoints 18 | _queue := base.Group("/queue") 19 | { 20 | _queue.GET("/info", perm.MustWorkerRegisterToken(), queue.Info) 21 | } // end of queue endpoints 22 | } 23 | -------------------------------------------------------------------------------- /router/search.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package router 4 | 5 | import ( 6 | "github.com/gin-gonic/gin" 7 | 8 | "github.com/go-vela/server/api/build" 9 | ) 10 | 11 | // SearchHandlers is a function that extends the provided base router group 12 | // with the API handlers for resource search functionality. 13 | // 14 | // GET /api/v1/search/builds/:id . 15 | func SearchHandlers(base *gin.RouterGroup) { 16 | // Search endpoints 17 | search := base.Group("/search") 18 | { 19 | // Build endpoint 20 | b := search.Group("/builds") 21 | { 22 | b.GET("/:id", build.GetBuildByID) 23 | } 24 | } // end of search endpoints 25 | } 26 | -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/image_and_template.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: deploy 5 | image: alpine 6 | template: 7 | name: deploy-template -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/invalid_prop.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | metadata: 4 | auto_cancel: 5 | invalid_key: true 6 | 7 | steps: 8 | - name: test 9 | image: alpine 10 | commands: 11 | - echo "Hello World" 12 | -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/invalid_pull.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: build 5 | pull: sometimes 6 | image: alpine 7 | commands: 8 | - echo "Hello World" 9 | -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/missing_name.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | test: 5 | steps: 6 | - image: alpine 7 | commands: 8 | - npm test -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/ruleset_invalid_matcher.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: test 5 | image: python 6 | ruleset: 7 | matcher: invalid_matcher 8 | branch: [main] -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/ruleset_invalid_status.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: deploy 5 | image: alpine 6 | ruleset: 7 | if: 8 | status: [pending] 9 | unless: 10 | branch: main -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/ruleset_invalid_values.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: build 5 | image: node 6 | ruleset: 7 | if: 8 | event: invalid_event 9 | operator: invalid -------------------------------------------------------------------------------- /schema/testdata/pipeline/fail/stages_and_steps.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | test: 5 | steps: 6 | - name: test 7 | image: alpine:latest 8 | commands: 9 | - echo "hello world" 10 | 11 | steps: 12 | - name: test 13 | image: alpine:latest 14 | commands: 15 | - echo "hello world" 16 | -------------------------------------------------------------------------------- /schema/testdata/pipeline/pass/basic.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: test 5 | image: alpine:latest 6 | commands: 7 | - echo "hello world" 8 | -------------------------------------------------------------------------------- /schema/testdata/pipeline/pass/ruleset_if.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: deploy 5 | image: alpine 6 | ruleset: 7 | if: 8 | event: [deployment, push] 9 | branch: main 10 | operator: and -------------------------------------------------------------------------------- /schema/testdata/pipeline/pass/ruleset_path.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: test 5 | image: golang 6 | ruleset: 7 | branch: feature/* 8 | event: pull_request 9 | path: ["src/*/*.go"] 10 | matcher: filepath -------------------------------------------------------------------------------- /schema/testdata/pipeline/pass/ruleset_status.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | steps: 4 | - name: notify 5 | image: slack 6 | ruleset: 7 | unless: 8 | status: success 9 | continue: true -------------------------------------------------------------------------------- /schema/testdata/pipeline/pass/stages.yml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | 3 | stages: 4 | test: 5 | steps: 6 | - name: test 7 | image: alpine:latest 8 | commands: 9 | - echo "hello world" 10 | - name: test2 11 | image: alpine:latest 12 | commands: 13 | - echo "hello world" 14 | 15 | test2: 16 | steps: 17 | - name: test 18 | image: alpine:latest 19 | commands: 20 | - echo "hello world" -------------------------------------------------------------------------------- /scm/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // package scm provides the ability for Vela to integrate 4 | // with different supported SCM providers. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/scm" 9 | package scm 10 | -------------------------------------------------------------------------------- /scm/github/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package github provides the ability for Vela to 4 | // integrate with GitHub or GitHub Enterprise as a scm provider. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/scm/github" 9 | package github 10 | -------------------------------------------------------------------------------- /scm/github/driver.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package github 4 | 5 | import "github.com/go-vela/server/constants" 6 | 7 | // Driver outputs the configured scm driver. 8 | func (c *Client) Driver() string { 9 | return constants.DriverGithub 10 | } 11 | -------------------------------------------------------------------------------- /scm/github/settings.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package github 4 | 5 | import ( 6 | "github.com/go-vela/server/api/types/settings" 7 | ) 8 | 9 | // GetSettings retrieves the api settings type in the Engine. 10 | func (c *Client) GetSettings() settings.SCM { 11 | return c.SCM 12 | } 13 | 14 | // SetSettings sets the api settings type in the Engine. 15 | func (c *Client) SetSettings(s *settings.Platform) { 16 | if s != nil { 17 | c.SetRepoRoleMap(s.GetRepoRoleMap()) 18 | c.SetOrgRoleMap(s.GetOrgRoleMap()) 19 | c.SetTeamRoleMap(s.GetTeamRoleMap()) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /scm/github/testdata/hook.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1, 3 | "url": "https://api.github.com/repos/foo/bar/hooks/1", 4 | "test_url": "https://api.github.com/repos/foo/bar/hooks/1/test", 5 | "ping_url": "https://api.github.com/repos/foo/bar/hooks/1/pings", 6 | "name": "web", 7 | "events": [ 8 | "push", 9 | "pull_request", 10 | "deployment" 11 | ], 12 | "active": true, 13 | "config": { 14 | "url": "https://foo.bar.com/webhook", 15 | "content_type": "form" 16 | }, 17 | "updated_at": "2011-09-06T20:39:23Z", 18 | "created_at": "2011-09-06T17:26:27Z" 19 | } 20 | -------------------------------------------------------------------------------- /scm/github/testdata/hooks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "url": "https://api.github.com/repos/foo/bar/hooks/1", 5 | "test_url": "https://api.github.com/repos/foo/bar/hooks/1/test", 6 | "ping_url": "https://api.github.com/repos/foo/bar/hooks/1/pings", 7 | "name": "web", 8 | "events": [ 9 | "push", 10 | "pull_request", 11 | "deployment" 12 | ], 13 | "active": true, 14 | "config": { 15 | "url": "https://foo.bar.com/webhook", 16 | "content_type": "form" 17 | }, 18 | "updated_at": "2011-09-06T20:39:23Z", 19 | "created_at": "2011-09-06T17:26:27Z" 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /scm/github/testdata/listchangespr.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "sha": "bbcd538c8e72b8c175046e27cc8f907076331401", 4 | "filename": "file1.txt", 5 | "status": "added", 6 | "additions": 103, 7 | "deletions": 21, 8 | "changes": 124, 9 | "blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt", 10 | "raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt", 11 | "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e", 12 | "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test" 13 | } 14 | ] -------------------------------------------------------------------------------- /scm/github/testdata/login.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "foo", 3 | "password": "bar", 4 | "otp": "123456", 5 | "token": "foobar" 6 | } 7 | -------------------------------------------------------------------------------- /scm/github/testdata/pipeline.star: -------------------------------------------------------------------------------- 1 | def main(ctx): 2 | return { 3 | 'version': '1', 4 | 'steps': [ 5 | { 6 | 'name': 'build', 7 | 'image': 'golang:latest', 8 | 'commands': [ 9 | 'go build', 10 | 'go test', 11 | ] 12 | }, 13 | ], 14 | } 15 | -------------------------------------------------------------------------------- /scm/github/testdata/pipeline.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "1" 3 | 4 | metadata: 5 | os: linux 6 | 7 | steps: 8 | - name: build 9 | image: openjdk:latest 10 | pull: true 11 | environment: 12 | GRADLE_USER_HOME: .gradle 13 | GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.workers.max=1 -Dorg.gradle.parallel=false 14 | commands: 15 | - ./gradlew build distTar 16 | -------------------------------------------------------------------------------- /scm/github/testdata/team_admin.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://api.github.com/teams/1/memberships/octocat", 3 | "role": "maintainer", 4 | "state": "active" 5 | } 6 | -------------------------------------------------------------------------------- /scm/github/testdata/team_member.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://api.github.com/teams/1/memberships/octocat", 3 | "role": "member", 4 | "state": "active" 5 | } 6 | -------------------------------------------------------------------------------- /scm/github/testdata/token.json: -------------------------------------------------------------------------------- 1 | { 2 | "access_token": "foo", 3 | "token_type": "bar", 4 | "refresh_token": "foobar" 5 | } 6 | -------------------------------------------------------------------------------- /scm/github/user.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package github 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | 9 | "github.com/sirupsen/logrus" 10 | ) 11 | 12 | // GetUserID captures the user's scm id. 13 | func (c *Client) GetUserID(ctx context.Context, name string, token string) (string, error) { 14 | c.Logger.WithFields(logrus.Fields{ 15 | "user": name, 16 | }).Tracef("capturing SCM user id for %s", name) 17 | 18 | // create GitHub OAuth client with user's token 19 | client := c.newOAuthTokenClient(ctx, token) 20 | 21 | // send API call to capture user 22 | user, _, err := client.Users.Get(ctx, name) 23 | if err != nil { 24 | return "", err 25 | } 26 | 27 | return fmt.Sprint(user.GetID()), nil 28 | } 29 | -------------------------------------------------------------------------------- /secret/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package secret provides the ability for Vela to integrate 4 | // with different supported Secret backends. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/secret" 9 | package secret 10 | -------------------------------------------------------------------------------- /secret/native/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package native provides the ability for Vela to 4 | // integrate with the Database as a secret backend. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/secret/native" 9 | package native 10 | -------------------------------------------------------------------------------- /secret/native/driver.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package native 4 | 5 | import "github.com/go-vela/server/constants" 6 | 7 | // Driver outputs the configured secret driver. 8 | func (c *Client) Driver() string { 9 | return constants.DriverNative 10 | } 11 | -------------------------------------------------------------------------------- /secret/native/driver_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package native 4 | 5 | import ( 6 | "reflect" 7 | "testing" 8 | 9 | "github.com/go-vela/server/constants" 10 | "github.com/go-vela/server/database" 11 | ) 12 | 13 | func TestNative_Driver(t *testing.T) { 14 | // setup types 15 | db, err := database.NewTest() 16 | if err != nil { 17 | t.Errorf("unable to create database service: %v", err) 18 | } 19 | defer db.Close() 20 | 21 | want := constants.DriverNative 22 | 23 | _service, err := New( 24 | WithDatabase(db), 25 | ) 26 | if err != nil { 27 | t.Errorf("unable to create secret service: %v", err) 28 | } 29 | 30 | // run test 31 | got := _service.Driver() 32 | 33 | if !reflect.DeepEqual(got, want) { 34 | t.Errorf("Driver is %v, want %v", got, want) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /secret/vault/doc.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | // Package vault provides the ability for Vela to 4 | // integrate with HashiCorp Vault as a secret backend. 5 | // 6 | // Usage: 7 | // 8 | // import "github.com/go-vela/server/secret/vault" 9 | package vault 10 | -------------------------------------------------------------------------------- /secret/vault/driver.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package vault 4 | 5 | import "github.com/go-vela/server/constants" 6 | 7 | // Driver outputs the configured secret driver. 8 | func (c *Client) Driver() string { 9 | return constants.DriverVault 10 | } 11 | -------------------------------------------------------------------------------- /secret/vault/testdata/refresh/auth-response-error-nil-secret.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "91db0695-a6db-7ffe-bb0c-ab7a6cc416ff", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": null, 7 | "wrap_info": null, 8 | "warnings": null, 9 | "auth": { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /secret/vault/testdata/refresh/auth-response-error-no-auth-values.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | "didn't supply required authentication values" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /secret/vault/testdata/refresh/auth-response-error-role-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | "entry for role vault-syncer-role-training not found" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /secret/vault/testdata/refresh/secret-response-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "39260cbf-5d03-36fa-005a-50c46ecba869", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": { 7 | "data": { 8 | "api-token": "hello-12345", 9 | "db-password": "password" 10 | }, 11 | "metadata": { 12 | "created_time": "2020-04-23T20:03:54.340461533Z", 13 | "deletion_time": "", 14 | "destroyed": false, 15 | "version": 2 16 | } 17 | }, 18 | "wrap_info": null, 19 | "warnings": null, 20 | "auth": null 21 | } 22 | -------------------------------------------------------------------------------- /secret/vault/testdata/refresh/secret-response-error-not-found.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [] 3 | } 4 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/empty_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": {}, 7 | "wrap_info": null, 8 | "warnings": null, 9 | "auth": null 10 | } 11 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/invalid_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": { 7 | "keys": [1] 8 | }, 9 | "wrap_info": null, 10 | "warnings": null, 11 | "auth": null 12 | } 13 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/invalid_repo.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 2764800, 6 | "data": { 7 | "events": [ 8 | "foo", 9 | "bar" 10 | ], 11 | "images": [ 12 | "foo", 13 | "bar" 14 | ], 15 | "name": "foob", 16 | "org": "foo", 17 | "repo": "bar", 18 | "value": "barf" 19 | }, 20 | "wrap_info": null, 21 | "warnings": null, 22 | "auth": null 23 | } 24 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": { 7 | "keys": ["foob"] 8 | }, 9 | "wrap_info": null, 10 | "warnings": null, 11 | "auth": null 12 | } 13 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/org.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 2764800, 6 | "data": { 7 | "events": [ 8 | "foo", 9 | "bar" 10 | ], 11 | "images": [ 12 | "foo", 13 | "bar" 14 | ], 15 | "name": "bar", 16 | "org": "foo", 17 | "repo": "*", 18 | "type": "org", 19 | "value": "baz", 20 | "allow_command": true, 21 | "allow_substitution": true, 22 | "allow_events": 1, 23 | "created_at": 1563474077, 24 | "created_by": "octocat", 25 | "updated_at": 1563474079, 26 | "updated_by": "octocat2" 27 | }, 28 | "wrap_info": null, 29 | "warnings": null, 30 | "auth": null 31 | } 32 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/repo.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 2764800, 6 | "data": { 7 | "events": ["foo", "bar"], 8 | "images": ["foo", "bar"], 9 | "name": "baz", 10 | "org": "foo", 11 | "repo": "bar", 12 | "type": "repo", 13 | "value": "foob", 14 | "allow_command": true, 15 | "allow_substitution": true, 16 | "allow_events": 3, 17 | "created_at": 1563474077, 18 | "created_by": "octocat", 19 | "updated_at": 1563474079, 20 | "updated_by": "octocat2" 21 | }, 22 | "wrap_info": null, 23 | "warnings": null, 24 | "auth": null 25 | } 26 | -------------------------------------------------------------------------------- /secret/vault/testdata/v1/shared.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 2764800, 6 | "data": { 7 | "events": ["foo", "bar"], 8 | "images": ["foo", "bar"], 9 | "name": "baz", 10 | "org": "foo", 11 | "team": "bar", 12 | "type": "shared", 13 | "value": "foob", 14 | "allow_command": false, 15 | "allow_substitution": false, 16 | "repo_allowlist": ["github/octocat", "github/octokitty"], 17 | "allow_events": 1, 18 | "created_at": 1563474077, 19 | "created_by": "octocat", 20 | "updated_at": 1563474079, 21 | "updated_by": "octocat2" 22 | }, 23 | "wrap_info": null, 24 | "warnings": null, 25 | "auth": null 26 | } 27 | -------------------------------------------------------------------------------- /secret/vault/testdata/v2/empty_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "renewable": false, 5 | "lease_duration": 0, 6 | "data": {}, 7 | "warnings": null 8 | } 9 | -------------------------------------------------------------------------------- /secret/vault/testdata/v2/invalid_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "keys": [1] 4 | } 5 | } -------------------------------------------------------------------------------- /secret/vault/testdata/v2/invalid_repo.json: -------------------------------------------------------------------------------- 1 | { 2 | "request_id": "f83426b1-b0c1-d1f5-d660-35a303186047", 3 | "lease_id": "", 4 | "lease_duration": 2764800, 5 | "renewable": false, 6 | "data": { 7 | "data": { 8 | "events": [ 9 | "foo", 10 | "bar" 11 | ], 12 | "images": [ 13 | "foo", 14 | "bar" 15 | ], 16 | "name": "baz", 17 | "org": "foo", 18 | "repo": "bar", 19 | "value": "foob" 20 | }, 21 | "metadata": { 22 | "created_time": "2020-08-14T15:43:44.3462581Z", 23 | "deletion_time": "", 24 | "destroyed": false, 25 | "version": 1 26 | } 27 | }, 28 | "warnings": null 29 | } -------------------------------------------------------------------------------- /secret/vault/testdata/v2/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": { 3 | "keys": ["foob"] 4 | } 5 | } -------------------------------------------------------------------------------- /version/metadata_test.go: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package version 4 | 5 | import ( 6 | "fmt" 7 | "reflect" 8 | "testing" 9 | ) 10 | 11 | func TestVersion_Metadata_String(t *testing.T) { 12 | // setup types 13 | m := &Metadata{ 14 | Architecture: "amd64", 15 | BuildDate: "1970-1-1T00:00:00Z", 16 | Compiler: "gc", 17 | GitCommit: "abcdef123456789", 18 | GoVersion: "1.19.0", 19 | OperatingSystem: "linux", 20 | } 21 | 22 | want := fmt.Sprintf( 23 | metaFormat, 24 | m.Architecture, 25 | m.BuildDate, 26 | m.Compiler, 27 | m.GitCommit, 28 | m.GoVersion, 29 | m.OperatingSystem, 30 | ) 31 | 32 | // run test 33 | got := m.String() 34 | 35 | if !reflect.DeepEqual(got, want) { 36 | t.Errorf("String is %v, want %v", got, want) 37 | } 38 | } 39 | --------------------------------------------------------------------------------