Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate informational header at top of YAML file. #71

Merged
merged 2 commits into from
Oct 18, 2023
Merged

Conversation

mwhittaker
Copy link
Member

This PR changes weaver kube deploy to add an informational header at the top of every generated YAML file. It looks like this:

# This file was generated by "weaver kube" version (devel) for the following
# application:
#
#     app: collatz
#     version: 79f011d4
#     components:
#     - github.com/ServiceWeaver/weaver/Main
#     - github.com/ServiceWeaver/weaver/examples/collatz/Even
#     - github.com/ServiceWeaver/weaver/examples/collatz/Odd
#     listeners:
#     - collatz
#
# This file contains the following resources:
#
#     1. A Deployment for every group of components.
#     2. A HorizontalPodAutoscaler for every Deployment.
#     3. A Service for every listener.
#     4. Some Roles and RoleBindings to configure permissions.
#
# To deploy these resources, run:
#
#     kubectl apply -f /tmp/kube_79f011d4.yaml
#
# To view the deployed resources, run:
#
#     kubectl delete all --selector=version=79f011d4
...

@mwhittaker mwhittaker self-assigned this Oct 17, 2023
Copy link
Collaborator

@rgrandl rgrandl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks Michael

internal/impl/kube.go Show resolved Hide resolved
internal/impl/kube.go Show resolved Hide resolved
@@ -489,6 +495,82 @@ func GenerateYAMLs(image string, app *protos.AppConfig, depId string, cfg *KubeC
return nil
}

// header returns the informational header at the top of a generated YAML file.
func header(app *protos.AppConfig, cfg *KubeConfig, depId, filename string) (string, error) {
header := template.Must(template.New("header").Parse(`# This file was generated by "weaver kube" version {{.ToolVersion}} for the following
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking whether long term we should also provide more k8s stuff. E.g., for every deployment, stuff like cpu/memory request/limit, env variables set for the pods, min/max #replicas, volume mounts. Maybe for HPA, which rules apply. If someone takes a quick look at the header can get a good understanding of the high-level things that would happen if they deploy the yaml.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea to me! I'll do this in a future PR.

Copy link
Member Author

@mwhittaker mwhittaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Robert!

internal/impl/kube.go Show resolved Hide resolved
internal/impl/kube.go Show resolved Hide resolved
@@ -489,6 +495,82 @@ func GenerateYAMLs(image string, app *protos.AppConfig, depId string, cfg *KubeC
return nil
}

// header returns the informational header at the top of a generated YAML file.
func header(app *protos.AppConfig, cfg *KubeConfig, depId, filename string) (string, error) {
header := template.Must(template.New("header").Parse(`# This file was generated by "weaver kube" version {{.ToolVersion}} for the following
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea to me! I'll do this in a future PR.

Base automatically changed from legible_names to main October 18, 2023 16:12
This PR changes `weaver kube deploy` to add an informational header at
the top of every generated YAML file. It looks like this:

    # This file was generated by "weaver kube" version (devel) for the following
    # application:
    #
    #     app: collatz
    #     version: 79f011d4
    #     components:
    #     - github.com/ServiceWeaver/weaver/Main
    #     - github.com/ServiceWeaver/weaver/examples/collatz/Even
    #     - github.com/ServiceWeaver/weaver/examples/collatz/Odd
    #     listeners:
    #     - collatz
    #
    # This file contains the following resources:
    #
    #     1. A Deployment for every group of components.
    #     2. A HorizontalPodAutoscaler for every Deployment.
    #     3. A Service for every listener.
    #     4. Some Roles and RoleBindings to configure permissions.
    #
    # To deploy these resources, run:
    #
    #     kubectl apply -f /tmp/kube_79f011d4.yaml
    #
    # To view the deployed resources, run:
    #
    #
    #     kubectl delete all --selector=version=79f011d4
    ...
    # This file was generated by "weaver kube" version (devel) for the following
    # application:
    #
    #     app: collatz
    #     version: 8edb402a
    #     components groups:
    #     -
    #       - github.com/ServiceWeaver/weaver/Main
    #     -
    #       - github.com/ServiceWeaver/weaver/examples/collatz/Even
    #       - github.com/ServiceWeaver/weaver/examples/collatz/Odd
    #     listeners:
    #     - collatz (github.com/ServiceWeaver/weaver/Main)
    #
    # This file contains the following resources:
    #
    #     1. A Deployment for every group of components.
    #     2. A HorizontalPodAutoscaler for every Deployment.
    #     3. A Service for every listener.
    #     4. Some Roles and RoleBindings to configure permissions.
    #
    # To deploy these resources, run:
    #
    #     kubectl apply -f /tmp/kube_8edb402a.yaml
    #
    # To view the deployed resources, run:
    #
    #     kubectl get all --selector=version=8edb402a
    #
    # To delete the resources, run:
    #
    #     kubectl delete all --selector=version=8edb402a
@mwhittaker mwhittaker merged commit 9bf9917 into main Oct 18, 2023
9 of 10 checks passed
@mwhittaker mwhittaker deleted the header branch October 18, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants