Skip to content

Commit

Permalink
in the middle of changes, merging to let eduardo merge
Browse files Browse the repository at this point in the history
Signed-off-by: Yee Hing Tong <[email protected]>
  • Loading branch information
wild-endeavor committed Oct 4, 2023
1 parent ebccc6a commit 579fe3d
Show file tree
Hide file tree
Showing 4 changed files with 643 additions and 4 deletions.
47 changes: 47 additions & 0 deletions flyteartifacts/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
package main

import (
"flag"
"fmt"
"github.com/flyteorg/flyte/flyteartifacts/pkg/configuration"
"github.com/flyteorg/flyte/flyteartifacts/pkg/server"
"github.com/flyteorg/flyte/flytestdlib/config"
"github.com/flyteorg/flyte/flytestdlib/config/viper"
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"google.golang.org/grpc"
"os"

"context"

_ "net/http/pprof" // Required to serve application.
)

var (
cfgFile string
configAccessor = viper.NewAccessor(config.Options{})
)

var serveCmd = &cobra.Command{
Use: "serve",
Short: "Launches the Flyte artifacts server",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
cfg := configuration.ApplicationConfig.GetConfig().(*configuration.ApplicationConfiguration)
fmt.Printf("cfg: [%+v]\n", cfg)
opts := make([]grpc.ServerOption, 0)
return server.Serve(ctx, opts...)
},
Expand All @@ -29,11 +43,44 @@ var RootCmd = &cobra.Command{
Long: `
To get started run the serve subcommand which will start a server on localhost:50051
`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return initConfig(cmd.Flags())
},
}

func init() {
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

// Add persistent flags - persistent flags persist through all sub-commands
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./artifact_config.yaml)")

// Allow viper to read the value of the flags
configAccessor.InitializePflags(RootCmd.PersistentFlags())

// Command information
RootCmd.AddCommand(serveCmd)

err := flag.CommandLine.Parse([]string{})
if err != nil {
fmt.Println(err)
os.Exit(-1)
}

}

func initConfig(flags *pflag.FlagSet) error {
fmt.Println("initConfig called")
configAccessor = viper.NewAccessor(config.Options{
SearchPaths: []string{cfgFile, ".", "/etc/flyte/config", "$GOPATH/src/github.com/flyteorg/flyte/flyteartifacts"},
StrictMode: false,
})

logger.Infof(context.TODO(), "Using config file: %v", configAccessor.ConfigFilesUsed())

configAccessor.InitializePflags(flags)
fmt.Println("initConfig finish")

return configAccessor.UpdateConfig(context.TODO())
}

func main() {
Expand Down
26 changes: 24 additions & 2 deletions flyteartifacts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,42 @@ module github.com/flyteorg/flyte/flyteartifacts
go 1.19

require (
github.com/flyteorg/flyte/flytestdlib v1.9.5
github.com/flyteorg/flyteidl v1.5.14-0.20230928230632-4854ce7ad143
github.com/golang/glog v1.1.0
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
google.golang.org/grpc v1.56.1

)

require (
github.com/flyteorg/flyteidl v1.5.14-0.20230928230632-4854ce7ad143 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.11.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.20.2 // indirect
)
Loading

0 comments on commit 579fe3d

Please sign in to comment.