-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Thomas Krampl <[email protected]>
- Loading branch information
1 parent
e5b39ed
commit fbc1372
Showing
11 changed files
with
636 additions
and
244 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
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,22 @@ | ||
package kolide_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/nais/device/internal/apiserver/kolide" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestJSONMarshal(t *testing.T) { | ||
c := &kolide.Cache[string, string]{} | ||
|
||
val, ok := c.Get("key") | ||
assert.False(t, ok) | ||
assert.Equal(t, "", val) | ||
|
||
c.Set("key", "value") | ||
actual, err := json.Marshal(c) | ||
assert.NoError(t, err) | ||
assert.Equal(t, `{"key":"value"}`, string(actual)) | ||
} |
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,41 @@ | ||
package controlplanecli | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/nais/device/internal/pb" | ||
"github.com/urfave/cli/v2" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
func GetKolideCache(c *cli.Context) error { | ||
conn, err := grpc.DialContext( | ||
c.Context, | ||
c.String(FlagAPIServer), | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
client := pb.NewAPIServerClient(conn) | ||
resp, err := client.GetKolideCache(c.Context, &pb.GetKolideCacheRequest{ | ||
Username: AdminUsername, | ||
Password: c.String(FlagAdminPassword), | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
out := struct { | ||
Devices json.RawMessage | ||
Checks json.RawMessage | ||
}{ | ||
Devices: resp.RawDevices, | ||
Checks: resp.RawChecks, | ||
} | ||
|
||
return json.NewEncoder(os.Stdout).Encode(out) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.