Skip to content

Commit 86424ea

Browse files
authored
Add version column and filtering to invocation history command (#21)
## PR Description: ### Summary This PR enhances the `kernel invoke history` command by adding support for displaying and filtering invocations by version. ### Changes - Added a "Version" column to the invocation history table output - Added `--version` flag to filter invocations by version - Updated kernel-go-sdk dependency from v0.11.4 to v0.11.5 ### New Features 1. **Version Column**: The invocation history table now displays the version of each invocation between the "Action" and "Status" columns 2. **Version Filtering**: Users can now filter invocations by version using the `--version` flag ### Usage Examples ```bash # Show all invocations with version column kernel invoke history # Filter by version only kernel invoke history --version v1.2.3 # Filter by app name only kernel invoke history --app myapp # Filter by both app name and version kernel invoke history --app myapp --version v1.2.3 ``` ### Implementation Details - Leverages the existing `Version` field from the SDK's `InvocationListResponse` struct - Uses the SDK's `Version` filter parameter in `InvocationListParams` - Maintains backward compatibility with existing usage patterns - Updates debug messages to reflect active filters ### Dependencies - Updated `github.com/onkernel/kernel-go-sdk` from v0.11.4 to v0.11.5 <img width="978" height="120" alt="image" src="https://github.com/user-attachments/assets/4e1aada8-e039-4aff-b535-d61f658ed235" />
1 parent e796437 commit 86424ea

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

cmd/invoke.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func init() {
3939

4040
invocationHistoryCmd.Flags().Int("limit", 100, "Max invocations to return (default 100)")
4141
invocationHistoryCmd.Flags().StringP("app", "a", "", "Filter by app name")
42+
invocationHistoryCmd.Flags().String("version", "", "Filter by invocation version")
4243
invokeCmd.AddCommand(invocationHistoryCmd)
4344
}
4445

@@ -209,6 +210,7 @@ func runInvocationHistory(cmd *cobra.Command, args []string) error {
209210

210211
lim, _ := cmd.Flags().GetInt("limit")
211212
appFilter, _ := cmd.Flags().GetString("app")
213+
versionFilter, _ := cmd.Flags().GetString("version")
212214

213215
// Build parameters for the API call
214216
params := kernel.InvocationListParams{
@@ -218,7 +220,20 @@ func runInvocationHistory(cmd *cobra.Command, args []string) error {
218220
// Only add app filter if specified
219221
if appFilter != "" {
220222
params.AppName = kernel.Opt(appFilter)
223+
}
224+
225+
// Only add version filter if specified
226+
if versionFilter != "" {
227+
params.Version = kernel.Opt(versionFilter)
228+
}
229+
230+
// Build debug message based on filters
231+
if appFilter != "" && versionFilter != "" {
232+
pterm.Debug.Printf("Listing invocations for app '%s' version '%s'...\n", appFilter, versionFilter)
233+
} else if appFilter != "" {
221234
pterm.Debug.Printf("Listing invocations for app '%s'...\n", appFilter)
235+
} else if versionFilter != "" {
236+
pterm.Debug.Printf("Listing invocations for version '%s'...\n", versionFilter)
222237
} else {
223238
pterm.Debug.Printf("Listing all invocations...\n")
224239
}
@@ -230,7 +245,7 @@ func runInvocationHistory(cmd *cobra.Command, args []string) error {
230245
return nil
231246
}
232247

233-
table := pterm.TableData{{"Invocation ID", "App Name", "Action", "Status", "Started At", "Duration", "Output"}}
248+
table := pterm.TableData{{"Invocation ID", "App Name", "Action", "Version", "Status", "Started At", "Duration", "Output"}}
234249

235250
for _, inv := range invocations.Items {
236251
started := util.FormatLocal(inv.StartedAt)
@@ -261,6 +276,7 @@ func runInvocationHistory(cmd *cobra.Command, args []string) error {
261276
inv.ID,
262277
inv.AppName,
263278
inv.ActionName,
279+
inv.Version,
264280
status,
265281
started,
266282
duration,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/charmbracelet/fang v0.2.0
99
github.com/golang-jwt/jwt/v5 v5.2.2
1010
github.com/joho/godotenv v1.5.1
11-
github.com/onkernel/kernel-go-sdk v0.11.4
11+
github.com/onkernel/kernel-go-sdk v0.11.5
1212
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1313
github.com/pterm/pterm v0.12.80
1414
github.com/samber/lo v1.51.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe
9191
github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
9292
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
9393
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
94-
github.com/onkernel/kernel-go-sdk v0.11.4 h1:vgDcPtldfEcRh+a1wlOSOY2bBWjxLFUwHqeXHHQ4OjM=
95-
github.com/onkernel/kernel-go-sdk v0.11.4/go.mod h1:MjUR92i8UPqjrmneyVykae6GuB3GGSmnQtnjf1v74Dc=
94+
github.com/onkernel/kernel-go-sdk v0.11.5 h1:LApX5A/Ful62LwNTW+srhi/3cx3W04pzgZ361PlDEAc=
95+
github.com/onkernel/kernel-go-sdk v0.11.5/go.mod h1:MjUR92i8UPqjrmneyVykae6GuB3GGSmnQtnjf1v74Dc=
9696
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
9797
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
9898
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

0 commit comments

Comments
 (0)