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

Extract CLI code to separate package #1092

Closed
wants to merge 11 commits into from

Conversation

syndbg
Copy link

@syndbg syndbg commented Mar 29, 2018

Makes programmatic usage of consul-template
much easier without having to duplicate CLI code

@syndbg syndbg force-pushed the extra-cli-to-package branch from 100c68a to afde35e Compare March 29, 2018 15:14
@syndbg
Copy link
Author

syndbg commented Apr 3, 2018

Ping anyone? Perhaps @pearkes :)

@syndbg
Copy link
Author

syndbg commented Apr 20, 2018

Ping. Ping.

Any interest in merging this? :)

@pearkes
Copy link
Contributor

pearkes commented Apr 20, 2018

Thanks for the PR @syndbg -- I don't think we'll be able to take a look at this too soon given work going on elsewhere in Consul, but we can certainly leave it open until someone is able to invest time in taking a look!

syndbg added 11 commits April 22, 2019 21:13
`go mod init` is all that was executed
Last time this worked was e7889f2 - Aug 26, 2017
They're supposed to be env vars for any builds, not to produce multiple builds.
Makes programmatic usage of consul-template
much easier without having to duplicate CLI code
@syndbg syndbg force-pushed the extra-cli-to-package branch from afde35e to 881c76a Compare April 22, 2019 19:55
@eikenb
Copy link
Contributor

eikenb commented Aug 22, 2019

Hey @syndbg. I'm reviewing all the community PRs for inclusion in 0.22.0 and find this one interesting. I'm thinking about converting much of CT more into a library with front ends for consul template and envconsul, and this looks to be a step toward that. Any interest in rebasing/updating this PR for current master. Things have drifted a bit since you did this. Thanks.

@syndbg
Copy link
Author

syndbg commented Aug 22, 2019

Yes, sure.

@eikenb
Copy link
Contributor

eikenb commented Apr 22, 2020

Hey @syndbg,

Thanks for all the work you did on this but it looks like we're going a different route. We're going to be refactoring out all the core "library-worthy" functionality into a separate module.

Do you use it as a library? We have an internal document on the API for the library that we're using for discussion and I might be able to get you a copy (or at least cut-n-paste the api spec out) for review. I'm getting feedback from internal library users (both vault and nomad use consul-template as a library) but would love to get additional feedback from community members using it as a library.

Anyways. That work would seem to make this PR no longer useful and I was going to close it. I'll wait for a response first (as I tend to miss comments on closed items).

Thanks for the time and work you put in on this.

@syndbg
Copy link
Author

syndbg commented Apr 22, 2020

Thanks for all the work you did on this but it looks like we're going a different route. We're going to be refactoring out all the core "library-worthy" functionality into a separate module.

Sounds good.

Do you use it as a library? We have an internal document on the API for the library that we're using for discussion and I might be able to get you a copy (or at least cut-n-paste the api spec out) for review. I'm getting feedback from internal library users (both vault and nomad use consul-template as a library) but would love to get additional feedback from community members using it as a library.

We're using it as a library, but it's a very blackbox approach. We use the cli pkg to apply opinionated usage of consul-template.

We don't try to extend template functionality, re-use template functions, etc.

E.g production snippet

import (
	"flag"
	"io"
	"io/ioutil"

	"github.com/sumup-oss/go-pkgs/logger"
	"github.com/syndbg/consul-template/cli"
)

func RunConsulTemplateCLI(args []string, stdout, stderr io.Writer, consulTemplateConfigFilePath string) int {
        .......
	consulTemplateCLIinstance := cli.NewCLI(stdout, stderr)
	args = append(args, "-config", consulTemplateConfigFilePath)
	return consulTemplateCLIinstance.Run(args)
}

Anyways. That work would seem to make this PR no longer useful and I was going to close it. I'll wait for a response first (as I tend to miss comments on closed items).
Thanks for the time and work you put in on this.

No prob.

@eikenb
Copy link
Contributor

eikenb commented Apr 27, 2021

Hey @syndbg, thanks for the feedback and if you want to look at it the library I'm working on is public and can be found at https://github.com/hashicorp/hcat.

It is unreleased and still under heavy development but is coming along. We already use it in another project that is released, so it is working but will still undergo some significant changes. That is you might be interested in taking a look to see how it might fit your use case and submit any feature requests/issues you might have.

I created an issue there referring to your comments here so I wouldn't forget about this case.

hashicorp/hcat#49

Thanks again.

@eikenb eikenb closed this Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants