-
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
f37e291
commit 647fb6c
Showing
11 changed files
with
93 additions
and
51 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 |
---|---|---|
|
@@ -46,6 +46,7 @@ jobs: | |
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
check-latest: true | ||
|
||
- name: Build | ||
run: make build | ||
|
@@ -80,6 +81,7 @@ jobs: | |
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
check-latest: true | ||
|
||
- name: Docker cache | ||
uses: ScribeMD/[email protected] | ||
|
@@ -135,6 +137,7 @@ jobs: | |
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
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] | ||
|
@@ -194,6 +198,7 @@ jobs: | |
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
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
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