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

feat: adds a func environment command #1761

Merged
merged 5 commits into from
May 31, 2023

Conversation

lance
Copy link
Member

@lance lance commented May 25, 2023

Changes

  • 🎁 Adds func environment to print the current function execution environment as JSON.

See: #1676

/kind enhancement

Example output
./func environment
{
  "Version": "v0.0.0",
  "GitRevision": "8a546005",
  "BuildDate": "20230530T212036Z",
  "SpecVersion": "0.35.0",
  "SocatImage": "quay.io/boson/alpine-socat:1.7.4.3-r1-non-root",
  "TarImage": "quay.io/boson/alpine-socat:1.7.4.3-r1-non-root",
  "Languages": [
    "go",
    "node",
    "python",
    "quarkus",
    "rust",
    "springboot",
    "typescript"
  ],
  "Templates": {
    "go": [
      "cloudevents",
      "http"
    ],
    "node": [
      "cloudevents",
      "http"
    ],
    "python": [
      "cloudevents",
      "flask",
      "http",
      "wsgi"
    ],
    "quarkus": [
      "cloudevents",
      "http"
    ],
    "rust": [
      "cloudevents",
      "http"
    ],
    "springboot": [
      "cloudevents",
      "http"
    ],
    "typescript": [
      "cloudevents",
      "http"
    ]
  },
  "Environment": [
    "FUNC_REGISTRY=quay.io/lanceball"
  ],
  "Cluster": "https://127.0.0.1:61315",
  "Defaults": {
    "Builder": "pack",
    "Confirm": false,
    "Language": "",
    "Namespace": "default",
    "Registry": "",
    "Verbose": false
  }
}

Release Note

Adds `func environment` to print the current function execution environment as JSON.

Adds `func environment` to print the current function execution
environment as JSON.

See: knative#1676

Signed-off-by: Lance Ball <lball@redhat.com>
@knative-prow knative-prow bot added kind/enhancement size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 25, 2023
@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2023
Signed-off-by: Lance Ball <lball@redhat.com>
@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Patch coverage: 21.35% and project coverage change: +1.93 🎉

Comparison is base (2656a7e) 60.34% compared to head (0e95f6a) 62.27%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1761      +/-   ##
==========================================
+ Coverage   60.34%   62.27%   +1.93%     
==========================================
  Files          98      100       +2     
  Lines       13205    13311     +106     
==========================================
+ Hits         7969     8290     +321     
+ Misses       4456     4226     -230     
- Partials      780      795      +15     
Flag Coverage Δ
e2e-test 37.95% <21.35%> (-0.14%) ⬇️
e2e-test-oncluster 33.51% <21.35%> (-0.10%) ⬇️
e2e-test-oncluster-runtime 28.81% <21.35%> (?)
e2e-test-runtime-go 27.37% <21.35%> (?)
e2e-test-runtime-node 28.53% <21.35%> (?)
e2e-test-runtime-python 28.53% <21.35%> (?)
e2e-test-runtime-quarkus 28.66% <21.35%> (?)
e2e-test-runtime-springboot 27.61% <21.35%> (?)
e2e-test-runtime-typescript 28.66% <21.35%> (?)
integration-tests 47.98% <21.35%> (?)
unit-tests-macos-latest 49.29% <21.35%> (?)
unit-tests-ubuntu-latest 50.08% <21.35%> (?)
unit-tests-windows-latest 49.34% <21.35%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/environment.go 20.58% <20.58%> (ø)
cmd/root.go 79.56% <100.00%> (+0.08%) ⬆️

... and 19 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lance
Copy link
Member Author

lance commented May 25, 2023

The code style errors are catching the SuggestFor values which are deliberately misspelled.

/override "style / Golang / Lint"

@knative-prow
Copy link

knative-prow bot commented May 25, 2023

@lance: Overrode contexts on behalf of lance: style / Golang / Lint

In response to this:

The code style errors are catching the SuggestFor values which are deliberately misspelled.

/override "style / Golang / Lint"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

lance added 2 commits May 26, 2023 11:43
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
@lance
Copy link
Member Author

lance commented May 26, 2023

/override "style / suggester / shell"
/override "style / suggester / yaml"
/override "style / suggester / github_actions"

@knative-prow
Copy link

knative-prow bot commented May 26, 2023

@lance: Overrode contexts on behalf of lance: style / suggester / github_actions, style / suggester / shell, style / suggester / yaml

In response to this:

/override "style / suggester / shell"
/override "style / suggester / yaml"
/override "style / suggester / github_actions"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lkingland
Copy link
Member

This /lgtm!

/hold for anyone else to perhaps comment, but seems to me this is a great place to start iterating if we think of anything else to add, etc.

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 30, 2023
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 30, 2023
cmd/environment.go Outdated Show resolved Hide resolved
@jrangelramos
Copy link
Contributor

it looks good to me. Maybe one very small cosmetic suggestion would be not printing null.. i.e. when no func env var is defined.
Currently it prints

"Environment": null,

what about?

"Environment": [],

but this is cosmetic..

@jrangelramos
Copy link
Contributor

jrangelramos commented May 30, 2023

It might be a bit late for this PR (maybe for another).. but what about a -o [json|yaml|human|jsonpath] option?
That would be cool seeing this in other formats (more human readable) following kn, podman, oc` and other cli standards..

For example, an human readable could look like
$ ./func environment -o human
* Build and Version Info
  Func Version     : v0.0.0
  Build / Git Rev  : fefea2b6
  Spec Version     : 0.35.0

* Images 
  SocatImage       : quay.io/boson/alpine-socat:1.7.4.3-r1-non-root
  TarImage         : quay.io/boson/alpine-socat:1.7.4.3-r1-non-root

* Environment Variables
  FUNC_REGISTRY    : quay.io/lanceball

Target Cluster     : https://127.0.0.1:61315

* CLI Defaults
  Builder          : pack
  Confirm          : false
  Language         : 
  Namespace        : default
  Registry         : 
  Verbose Mode     : false

* Supported Runtimes
  go, node, python, quarkus, rust, springboot, typescript

* Templates
  go          cloudevents, http
  python      cloudevents, http
  quarkus     cloudevents, http
  springboot  cloudevents, http
  rust        cloudevents, http
  typescript  cloudevents, http
  node        cloudevents, http

Signed-off-by: Lance Ball <lball@redhat.com>
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label May 30, 2023
@lance
Copy link
Member Author

lance commented May 30, 2023

@jrangelramos I assumed that would follow in a subsequent PR and have that as a TODO here: https://github.com/knative/func/pull/1761/files#diff-307b508c3eb9b3182cd02cbf3b681ab8f07937ce80be379fdd361bc9c5387d80R154

Seems like it could be a good-first-issue, no?

@lance
Copy link
Member Author

lance commented May 30, 2023

@jrangelramos @matejvasek thanks for the feedback; I've incorporated it (for additional output formats, I will create an Issue).

@matejvasek
Copy link
Contributor

/approve
/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 30, 2023
@knative-prow
Copy link

knative-prow bot commented May 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance, lkingland, matejvasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [lance,lkingland,matejvasek]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@matejvasek
Copy link
Contributor

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 30, 2023
@matejvasek
Copy link
Contributor

@lance you need to override the linter.

@lance
Copy link
Member Author

lance commented May 31, 2023

/override "style / Golang / Lint

@knative-prow
Copy link

knative-prow bot commented May 31, 2023

@lance: Overrode contexts on behalf of lance: style / Golang / Lint

In response to this:

/override "style / Golang / Lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot merged commit fea4a72 into knative:main May 31, 2023
@lance
Copy link
Member Author

lance commented Jul 5, 2023

/cherry-pick release-1.10

@knative-prow-robot
Copy link

@lance: new pull request created: #1848

In response to this:

/cherry-pick release-1.10

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants