This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The openapi-generator has a parameter to specify the default UserAgent for the generated code so we don't have to duplicate the metal-go UA in client projects. The generator also supports a package version parameter, but the value only gets written to the API.md doc, so client projects can't read the version. To work around this, `version.go` parses the default User-Agent to extract the package version.
- Loading branch information
Showing
5 changed files
with
37 additions
and
2 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
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,13 @@ | ||
package v1 | ||
|
||
import "strings" | ||
|
||
// Version of the metal-go package. The version is passed in as a parameter | ||
// to the generator, and we parse it out of the default UserAgent at runtime | ||
var Version = "(unused)" | ||
|
||
func init() { | ||
defaultConfig := NewConfiguration() | ||
defaultUserAgent := defaultConfig.UserAgent | ||
Version = defaultUserAgent[strings.Index(defaultUserAgent, "/")+1:] | ||
} |
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,19 @@ | ||
diff --git a/metal/v1/version.go b/metal/v1/version.go | ||
new file mode 100644 | ||
index 0000000..30f0c65 | ||
--- /dev/null | ||
+++ b/metal/v1/version.go | ||
@@ -0,0 +1,13 @@ | ||
+package v1 | ||
+ | ||
+import "strings" | ||
+ | ||
+// Version of the metal-go package. The version is passed in as a parameter | ||
+// to the generator, and we parse it out of the default UserAgent at runtime | ||
+var Version = "(unused)" | ||
+ | ||
+func init() { | ||
+ defaultConfig := NewConfiguration() | ||
+ defaultUserAgent := defaultConfig.UserAgent | ||
+ Version = defaultUserAgent[strings.Index(defaultUserAgent, "/")+1:] | ||
+} |