-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate User-Agent for DNS API clients (#2293)
- Loading branch information
Showing
18 changed files
with
278 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
const dnsBaseUserAgent = "goacme-lego/" | ||
|
||
const dnsSourceFile = "./providers/dns/internal/useragent/useragent.go" | ||
|
||
const dnsTemplate = `// Code generated by 'internal/useragent'; DO NOT EDIT. | ||
package useragent | ||
import ( | ||
"fmt" | ||
"net/http" | ||
"runtime" | ||
) | ||
const ( | ||
// ourUserAgent is the User-Agent of this underlying library package. | ||
ourUserAgent = "goacme-lego/{{ .version }}" | ||
// ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package. | ||
// values: detach|release | ||
// NOTE: Update this with each tagged release. | ||
ourUserAgentComment = "{{ .comment }}" | ||
) | ||
// Get builds and returns the User-Agent string. | ||
func Get() string { | ||
return fmt.Sprintf("%s (%s; %s; %s)", ourUserAgent, ourUserAgentComment, runtime.GOOS, runtime.GOARCH) | ||
} | ||
// SetHeader sets the User-Agent header. | ||
func SetHeader(h http.Header) { | ||
h.Set("User-Agent", Get()) | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
const senderBaseUserAgent = "xenolf-acme/" | ||
|
||
const senderSourceFile = "./acme/api/internal/sender/useragent.go" | ||
|
||
const senderTemplate = `// Code generated by 'internal/useragent'; DO NOT EDIT. | ||
package sender | ||
const ( | ||
// ourUserAgent is the User-Agent of this underlying library package. | ||
ourUserAgent = "xenolf-acme/{{ .version }}" | ||
// ourUserAgentComment is part of the UA comment linked to the version status of this underlying library package. | ||
// values: detach|release | ||
// NOTE: Update this with each tagged release. | ||
ourUserAgentComment = "{{ .comment }}" | ||
) | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.