repo-scaffolding Plugin

This plugin bootstraps a GitHub or GitLab repo with scaffolding code for a web application.

Usage

The following content is an example of the “tool file”.

For more information on the main config, the tool file, and the var file of DevStream, see Core Concepts Overview and DevStream Configuration.

YAML

  1. tools:
  2. # name of the tool
  3. - name: repo-scaffolding
  4. # id of the tool instance
  5. instanceID: default
  6. # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  7. dependsOn: [ ]
  8. # options for the plugin
  9. options:
  10. # desinationRepo is the config for desination repo
  11. destinationRepo:
  12. # scm common field
  13. branch: YOUR_REPO_BRANCH
  14. token: YOUR_REPO_SCM_TOKEN
  15. # you can directly use the url of repo (git@gitlab.com/root/test-exmaple.git for example)
  16. url: YOUR_REPO_URL
  17. # or you can config detailed fields for this repo
  18. owner: YOUR_REPO_OWNER
  19. org: YOUR_REPO_ORG
  20. name: YOUR_REPO_NAME
  21. scmType: gitlab
  22. # you can config this field if you are using self-host gitlab
  23. baseURL: YOUR_SELF_HOST_GITLAB_URL
  24. # sourceRepo is the template repo location, support github only
  25. sourceRepo:
  26. # scm common field
  27. branch: YOUR_REPO_BRANCH
  28. token: YOUR_REPO_SCM_TOKEN
  29. # you can directly use the url of repo (git@github.com/root/test-exmaple.git for example)
  30. url: YOUR_REPO_URL
  31. # or you can config detailed fields for this repo
  32. owner: YOUR_REPO_OWNER
  33. org: YOUR_REPO_ORG
  34. name: YOUR_REPO_NAME
  35. scmType: github
  36. # this is used for template render
  37. vars:
  38. imageRepo: YOUR_DOCKERHUB_REPOSITORY

Notes:

  • If you run dtm delete, the repo will be completely removed.
  • If the Update interface is called, the repo will be completely removed and recreated.
  • For the repo-scaffolding plugin, we only need repo, delete_repo permission for the token.
  • destinationRepo config option represents codebase location; for more info, you can refer to SCM Config.
  • sourceRepo config option represents codebase location; for more info, you can refer to SCM Config.
  • if destinationRepo type is Gitlab, then Devstream supports config destinationRepo.visibility. This configuration is used to set the permissions of the new repository. The options are public, private, and internal.

vars

This configuration is used for template rendering, It has default variables listed below:

JSON

  1. {
  2. "AppName": destinationRepo.repo,
  3. "Repo": {
  4. "Name": destinationRepo.repo,
  5. "Owner": destinationRepo.owner
  6. }
  7. }

Outputs

This plugin has three outputs:

  • owner
  • repo
  • repoURL

Examples

official scaffolding repo config

These repositories are official scaffolding repo to use for sourceRepo config; You can use these repo directly or just create one for yourself.

languageorgrepo
Golangdevstream-iodtm-repo-scaffolding-golang-gin
Golangdevstream-iodtm-repo-scaffolding-golang-cli
Pythondevstream-iodtm-repo-scaffolding-python-flask
Javadevstream-iodtm-repo-scaffolding-java-springboot

Golang

YAML

  1. tools:
  2. - name: repo-scaffolding
  3. instanceID: golang-scaffolding
  4. options:
  5. destinationRepo:
  6. owner: test_owner
  7. org: ""
  8. name: dtm-test-golang
  9. branch: main
  10. scmType: github
  11. sourceRepo:
  12. org: devstream-io
  13. name: dtm-repo-scaffolding-golang-gin
  14. scmType: github
  15. vars:
  16. imageRepo: dtm-test/golang-repo

This config will create dtm-test-golang repo for user test_owner in GitHub, and the variable ImageRepo will be used for template rendering.

Golang CLI

YAML

  1. tools:
  2. - name: repo-scaffolding
  3. instanceID: golang-cli-scaffolding
  4. options:
  5. destinationRepo:
  6. owner: test_owner
  7. org: ""
  8. name: dtm-test-golang-cli
  9. branch: main
  10. scmType: github
  11. sourceRepo:
  12. org: devstream-io
  13. name: dtm-repo-scaffolding-golang-cli
  14. scmType: github

This config will create dtm-test-golang-cli repo for user test_owner in GitHub.

Java Spring

YAML

  1. tools:
  2. - name: repo-scaffolding
  3. instanceID: java-scaffolding
  4. options:
  5. destinationRepo:
  6. owner: test_owner
  7. org: ""
  8. name: dtm-test-java
  9. branch: main
  10. baseUrl: 127.0.0.1:30001
  11. visibility: public
  12. scmType: gitlab
  13. sourceRepo:
  14. org: devstream-io
  15. name: dtm-repo-scaffolding-java-springboot
  16. scmType: github

This config will create dtm-test-java repo for user test_owner in GitHub.