-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support byovpc and clean up list filtering
- Loading branch information
1 parent
4c79ecb
commit b16ad05
Showing
12 changed files
with
99 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,8 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
|
||
- name: Build | ||
run: make build | ||
|
@@ -79,7 +80,8 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
|
||
- name: Docker cache | ||
uses: ScribeMD/[email protected] | ||
|
@@ -134,7 +136,8 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
|
||
- name: Docker cache | ||
uses: ScribeMD/[email protected] | ||
|
@@ -156,6 +159,7 @@ jobs: | |
with: | ||
name: logs | ||
path: .logs/* | ||
overwrite: true | ||
|
||
chainsaw-test: | ||
needs: [go-build-test, docker-build] | ||
|
@@ -193,7 +197,8 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
go-version-file: 'go.mod' | ||
check-latest: true | ||
|
||
- name: Docker cache | ||
uses: ScribeMD/[email protected] | ||
|
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
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
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,45 @@ | ||
package util | ||
|
||
import ( | ||
"encoding/json" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// Filter holds the fields used for filtering results from the Linode API. | ||
// | ||
// The fields within Filter are prioritized so that only the most-specific | ||
// field is present when Filter is marshaled to JSON. | ||
type Filter struct { | ||
ID *int // Filter on the resource's ID (most specific). | ||
Label string // Filter on the resource's label. | ||
Tags []string // Filter resources by their tags (least specific). | ||
} | ||
|
||
// MarshalJSON returns a JSON-encoded representation of a [Filter]. | ||
// The resulting encoded value will have exactly 1 (one) field present. | ||
// See [Filter] for details on the value precedence. | ||
func (f Filter) MarshalJSON() ([]byte, error) { | ||
filter := make(map[string]string, 1) | ||
switch { | ||
case f.ID != nil: | ||
filter["id"] = strconv.Itoa(*f.ID) | ||
case f.Label != "": | ||
filter["label"] = f.Label | ||
case len(f.Tags) != 0: | ||
filter["tags"] = strings.Join(f.Tags, ",") | ||
} | ||
|
||
return json.Marshal(filter) | ||
} | ||
|
||
// String returns the string representation of the encoded value from | ||
// [Filter.MarshalJSON]. | ||
func (f Filter) String() string { | ||
p, err := f.MarshalJSON() | ||
if err != nil { | ||
panic("this should not have failed") | ||
} | ||
|
||
return string(p) | ||
} |
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