(configPath string)
| 621 | } |
| 622 | |
| 623 | func annotateConfig(configPath string) error { |
| 624 | annotatedConfig, err := os.ReadFile(configPath) |
| 625 | if err != nil { |
| 626 | panic(err) |
| 627 | } |
| 628 | |
| 629 | annotatedConfig = regexp.MustCompile("(?m)(\n\\s{2,6}name:.*)").ReplaceAll(annotatedConfig, []byte("")) |
| 630 | annotatedConfig = regexp.MustCompile("(?s)(\n deploy:.*)(\n dev:.*)(\nimages:)").ReplaceAll(annotatedConfig, []byte("$2$1$3")) |
| 631 | annotatedConfig = regexp.MustCompile("(?s)(\n imageSelector:.*?)(\n.*)(\n devImage:.*?)(\n)").ReplaceAll(annotatedConfig, []byte("$1$3$2$4")) |
| 632 | |
| 633 | configAnnotations := map[string]string{ |
| 634 | "(?m)^(pipelines:)": "\n# This is a list of `pipelines` that DevSpace can execute (you can define your own)\n$1", |
| 635 | "(?m)^( )(deploy:)": "$1# You can run this pipeline via `devspace deploy` (or `devspace run-pipeline deploy`)\n$1$2", |
| 636 | "(?m)^( )(dev:)": "$1# This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)\n$1$2", |
| 637 | "(?m)^(images:)": "\n# This is a list of `images` that DevSpace can build for this project\n# We recommend to skip image building during development (devspace dev) as much as possible\n$1", |
| 638 | "(?m)^(deployments:)": "\n# This is a list of `deployments` that DevSpace can create for this project\n$1", |
| 639 | "(?m)^( )(helm:)": "$1# This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations\n$1$2", |
| 640 | "(?m)^( )(chart:)": "$1# We are deploying this project with the Helm chart you provided\n$1$2", |
| 641 | "(?m)^( )(values:)": "$1# Under `values` we can define the values for this Helm chart used during `helm install/upgrade`\n$1# You may also use `valuesFiles` to load values from files, e.g. valuesFiles: [\"values.yaml\"]\n$1$2", |
| 642 | "(?m)^( )(kubectl:)": "$1# This deployment uses `kubectl` but you can also define `helm` deployments\n$1$2", |
| 643 | "(?m)^(dev:)": "\n# This is a list of `dev` containers that are based on the containers created by your deployments\n$1", |
| 644 | "(?m)^( )(imageSelector:)": "$1# Search for the container that runs this image\n$1$2", |
| 645 | "(?m)^( )(devImage:)": "$1# Replace the container image with this dev-optimized image (allows to skip image building during development)\n$1$2", |
| 646 | "(?m)^( )(sync:)": "$1# Sync files between the local filesystem and the development container\n$1$2", |
| 647 | "(?m)^( )(ports:)": "$1# Forward the following ports to be able access your application via localhost\n$1$2", |
| 648 | "(?m)^( )(open:)": "$1# Open the following URLs once they return an HTTP status code other than 502 or 503\n$1$2", |
| 649 | "(?m)^( )(terminal:)": "$1# Open a terminal and use the following command to start it\n$1$2", |
| 650 | "(?m)^( )(ssh:)": "$1# Inject a lightweight SSH server into the container (so your IDE can connect to the remote dev env)\n$1$2", |
| 651 | "(?m)^( )(proxyCommands:)": "$1# Make the following commands from my local machine available inside the dev container\n$1$2", |
| 652 | "(?m)^(commands:)": "\n# Use the `commands` section to define repeatable dev workflows for this project \n$1", |
| 653 | } |
| 654 | |
| 655 | for expr, replacement := range configAnnotations { |
| 656 | annotatedConfig = regexp.MustCompile(expr).ReplaceAll(annotatedConfig, []byte(replacement)) |
| 657 | } |
| 658 | |
| 659 | annotatedConfig = append(annotatedConfig, []byte(` |
| 660 | # Define dependencies to other projects with a devspace.yaml |
| 661 | # dependencies: |
| 662 | # api: |
| 663 | # git: https://... # Git-based dependencies |
| 664 | # tag: v1.0.0 |
| 665 | # ui: |
| 666 | # path: ./ui # Path-based dependencies (for monorepos) |
| 667 | `)...) |
| 668 | |
| 669 | err = os.WriteFile(configPath, annotatedConfig, os.ModePerm) |
| 670 | if err != nil { |
| 671 | return err |
| 672 | } |
| 673 | |
| 674 | return nil |
| 675 | } |
| 676 | |
| 677 | func (cmd *InitCmd) addDevConfig(config *latest.Config, imageName, image string, port int, languageHandler *generator.LanguageHandler) error { |
| 678 | if config.Dev == nil { |
no outgoing calls
no test coverage detected