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

Adding in customized user-agent #69

Merged
merged 2 commits into from
Sep 19, 2017
Merged

Adding in customized user-agent #69

merged 2 commits into from
Sep 19, 2017

Conversation

jrnt30
Copy link
Contributor

@jrnt30 jrnt30 commented Sep 7, 2017

Fixes #14

Adding in custom user-agent that includes more relevant data from Ark.

@heptibot
Copy link

heptibot commented Sep 7, 2017

Can one of the admins verify this patch?

Makefile Outdated

all: cbuild container

cbuild:
$(DOCKER) run --rm -v $(ROOT_DIR):$(BUILDMNT) $(EXTRA_MNTS) -w $(BUILDMNT) -e SKIP_TESTS=$(SKIP_TESTS) $(BUILD_IMAGE) /bin/sh -c 'make local verify test'

container: cbuild
$(DOCKER) build -t $(REGISTRY)/$(PROJECT):latest -t $(REGISTRY)/$(PROJECT):$(VERSION) .
$(DOCKER) build -t $(REGISTRY)/$(PROJECT):latest -t $(REGISTRY)/$(PROJECT):$(VERSION) -t $(REGISTRY)/$(PROJECT):$(GIT_SHA) .
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to tag with the sha

Makefile Outdated

container-local: $(BINARIES)
$(DOCKER) build -t $(REGISTRY)/$(PROJECT):latest -t $(REGISTRY)/$(PROJECT):$(VERSION) .
$(DOCKER) build -t $(REGISTRY)/$(PROJECT):latest -t $(REGISTRY)/$(PROJECT):$(VERSION) -t $(REGISTRY)/$(PROJECT):$(GIT_SHA) .
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to tag with the sha

@ncdc
Copy link
Contributor

ncdc commented Sep 7, 2017

add to whitelist

@ncdc ncdc added this to the v0.5.0 milestone Sep 13, 2017
Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
return clientConfig, nil
}

// buildUserAgent builds a User-Agent string from given args.
func buildUserAgent(command, version, os, arch, commit string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have buildinfo.GitTreeState, could you have it so the commit portion of the user agent string appends -dirty if it's dirty?

@ncdc ncdc assigned ncdc and skriss Sep 15, 2017
@ncdc
Copy link
Contributor

ncdc commented Sep 15, 2017

@skriss ptal

Copy link

@davecheney davecheney left a comment

Choose a reason for hiding this comment

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

LGTM

@davecheney
Copy link

No test, even for the user agent string generation?

var kubeconfig string

var command = &cobra.Command{
Use: "server",
Short: "Run the ark server",
Long: "Run the ark server",
Run: func(c *cobra.Command, args []string) {
s, err := newServer(kubeconfig)
s, err := newServer(kubeconfig, baseName+"-server")
Copy link
Member

Choose a reason for hiding this comment

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

nit: you could just use c.Parent().Name() and c.Name() to construct this rather than passing in the baseName and hardcoding "server"

@skriss
Copy link
Member

skriss commented Sep 18, 2017

otherwise LGTM, thanks!

@ncdc
Copy link
Contributor

ncdc commented Sep 18, 2017 via email

@skriss
Copy link
Member

skriss commented Sep 18, 2017

yeah, sure, should be super-quick.

Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
@jrnt30
Copy link
Contributor Author

jrnt30 commented Sep 18, 2017

I don't know of a good way of "unit testing" the whole agent string without a lot of mocking for things like K8 context, etc. so I added in tests for the suffix & the agent. I think that meets your expectations.

I went back and forth on something trivial, but curious your thoughts: I waffled between having buildinfo.FormattedGitSHA(), buildinfo.FormattedGitSHA(sha, state string), and simply the client.formattedGitSHA(sha, state string).

In the end I went with centralizing it all into the buildinfo and keeping the signature simple and using the "globals".

Thoughts on how you would have approached it?

@skriss
Copy link
Member

skriss commented Sep 18, 2017

Updates LGTM.

Personally I probably would've either done it the way you did, or just put the logic inside the buildUserAgent function. Obviously if there's another part of the code that could use this logic, the former would be better.

@ncdc ncdc merged commit 024f655 into vmware-tanzu:master Sep 19, 2017
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.

5 participants