Skip to content

Commit dc63452

Browse files
ishandhananitmc
authored andcommitted
nvcf: reorganization for clarity
1 parent 99cd47c commit dc63452

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

cmd/auth.go renamed to cmd/auth/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmd
1+
package auth
22

33
import (
44
"errors"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cmd
1+
package function
22

33
import (
44
"fmt"
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
package cmd
1+
package function
22

33
import (
4+
"encoding/json"
45
"fmt"
6+
"reflect"
57

68
"github.com/spf13/cobra"
79
"github.com/tmc/nvcf-go"
@@ -85,9 +87,23 @@ func functionCreateCmd() *cobra.Command {
8587
cmd.Flags().Int64Var(&healthPort, "health-port", 8080, "Health check port")
8688
cmd.Flags().StringVar(&healthTimeout, "health-timeout", "5s", "Health check timeout")
8789
cmd.Flags().Int64Var(&healthStatusCode, "health-status-code", 200, "Expected health check status code")
90+
// todo: handle this correctly
91+
cmd.Flags().Bool("deploy", false, "Create and deploy the function in one step")
8892

8993
cmd.MarkFlagRequired("name")
9094
cmd.MarkFlagRequired("inference-url")
9195

9296
return cmd
9397
}
98+
99+
func jsonMarshalUnmarshal(dest any, src any) error {
100+
// Validate dest is a pointer
101+
if reflect.ValueOf(dest).Kind() != reflect.Ptr {
102+
return fmt.Errorf("destination must be a pointer")
103+
}
104+
jsonData, err := json.Marshal(src)
105+
if err != nil {
106+
return err
107+
}
108+
return json.Unmarshal(jsonData, dest)
109+
}

cmd/marshaling.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
"github.com/spf13/cobra"
88
"github.com/tmc/nvcf/cmd"
9+
"github.com/tmc/nvcf/cmd/auth"
10+
"github.com/tmc/nvcf/cmd/function"
911
)
1012

1113
func main() {
@@ -22,11 +24,11 @@ func main() {
2224
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose output")
2325

2426
// Add commands
25-
rootCmd.AddCommand(cmd.FunctionCmd())
27+
rootCmd.AddCommand(function.FunctionCmd())
2628
// rootCmd.AddCommand(cmd.DeploymentCmd())
2729
// rootCmd.AddCommand(cmd.InvokeCmd())
2830
// rootCmd.AddCommand(cmd.AssetCmd())
29-
rootCmd.AddCommand(cmd.AuthCmd())
31+
rootCmd.AddCommand(auth.AuthCmd())
3032
// rootCmd.AddCommand(cmd.QueueCmd())
3133
// rootCmd.AddCommand(cmd.ClusterGroupCmd())
3234
// rootCmd.AddCommand(cmd.ConfigCmd())

0 commit comments

Comments
 (0)