This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow import of github.com/kolide/fleet (#2213)
Previously a Go package attempting to import Fleet packages would run into an error like "server/kolide/emails.go:93:23: undefined: Asset". This commit refactors bindata asset handling to allow importing Fleet as a library without changing the typical developer experience.
- Loading branch information
Showing
15 changed files
with
179 additions
and
152 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
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 @@ | ||
// +build !full | ||
|
||
package bindata | ||
|
||
import "os" | ||
|
||
// This file contains placeholders for the asset functions that would normally | ||
// allow Fleet to retrieve assets and templates. Providing these placeholders | ||
// allows Fleet packages to be included as a library with `go get`. | ||
|
||
func Asset(name string) ([]byte, error) { | ||
panic("Assets may not be used when running Fleet as a library") | ||
} | ||
|
||
func AssetDir(name string) ([]string, error) { | ||
panic("Assets may not be used when running Fleet as a library") | ||
} | ||
|
||
func AssetInfo(name string) (os.FileInfo, error) { | ||
panic("Assets may not be used when running Fleet as a library") | ||
} |
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 was deleted.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package mail | ||
|
||
import ( | ||
"bytes" | ||
"html/template" | ||
|
||
"github.com/kolide/fleet/server/kolide" | ||
) | ||
|
||
// InviteMailer is used to build an email template for the invite email. | ||
type InviteMailer struct { | ||
*kolide.Invite | ||
BaseURL template.URL | ||
AssetURL template.URL | ||
InvitedByUsername string | ||
OrgName string | ||
} | ||
|
||
func (i *InviteMailer) Message() ([]byte, error) { | ||
t, err := getTemplate("server/mail/templates/invite_token.html") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var msg bytes.Buffer | ||
if err = t.Execute(&msg, i); err != nil { | ||
return nil, err | ||
} | ||
return msg.Bytes(), nil | ||
} |
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.