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

Allow apps to provide extra information to version command #11690

Closed
4 tasks
jhernandezb opened this issue Apr 19, 2022 · 2 comments · Fixed by #18063
Closed
4 tasks

Allow apps to provide extra information to version command #11690

jhernandezb opened this issue Apr 19, 2022 · 2 comments · Fixed by #18063
Assignees

Comments

@jhernandezb
Copy link

jhernandezb commented Apr 19, 2022

Summary

Allow apps to provide extra information to version command

[appd] version --long
..
..
wasmvm : v1.0.0-beta.11

Problem Definition

Currently the information comes from this method

func NewInfo() Info {
which contains a predefined struct and there is no way to add extra information.

Build tags don't work for runtime information like CosmWasm VM providing it's version through the dynamic library

CosmWasm/wasmvm#314

Proposal

Add an optional field to the Info struct that can be injected outside as cobra context.

// ExtraInfo contains a set of extra information provided by apps
type ExtraInfo map[string]string

// Info defines the application version information.
type Info struct {
	Name             string     `json:"name" yaml:"name"`
	AppName          string     `json:"server_name" yaml:"server_name"`
	Version          string     `json:"version" yaml:"version"`
	GitCommit        string     `json:"commit" yaml:"commit"`
	BuildTags        string     `json:"build_tags" yaml:"build_tags"`
	GoVersion        string     `json:"go" yaml:"go"`
	BuildDeps        []buildDep `json:"build_deps" yaml:"build_deps"`
	CosmosSdkVersion string     `json:"cosmos_sdk_version" yaml:"cosmos_sdk_version"`
        ExtraInfo        *ExtraInfo `json:"extra_info" yaml:"extra_info"`
} 

// VersionCommand ...
// The context must be set from the root command as PersistentPreRun
RunE: func(cmd *cobra.Command, _ []string) error {
	verInfo := NewInfo()

	if long, _ := cmd.Flags().GetBool(flagLong); !long {
	cmd.Println(verInfo.Version)
	return nil
	}
	extraInfo := extraInfoFromContext(cmd)
	...
},

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

Yup, I totally support this. Great idea! Is this something you're interested in helping with?

@jhernandezb
Copy link
Author

Yup, I totally support this. Great idea! Is this something you're interested in helping with?

Yes, I can make a PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants