MCPcopy Create free account
hub / github.com/encoder-run/operator / main

Function main

cmd/repositoryembedder/main.go:80–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78}
79
80func main() {
81 // Define flags
82 var storageId string
83 var repositoryId string
84 var modelId string
85
86 flag.StringVar(&storageId, "storageId", "", "Storage ID")
87 flag.StringVar(&repositoryId, "repositoryId", "", "Repository ID")
88 flag.StringVar(&modelId, "modelId", "", "Model ID")
89
90 // Parse flags
91 flag.Parse()
92
93 // Example usage of flags in the application logic
94 fmt.Printf("Using storage ID: %s\n", storageId)
95 fmt.Printf("Using repository ID: %s\n", repositoryId)
96 fmt.Printf("Using model ID: %s\n", modelId)
97
98 // Check if all required arguments are provided
99 if storageId == "" || repositoryId == "" || modelId == "" {
100 Warning("All arguments (storageId, repositoryId, modelId) are required.")
101 os.Exit(1)
102 }
103
104 // Get the kubernetes client.
105 c, err := defaultClient()
106 if err != nil {
107 CheckIfError(err)
108
109 }
110
111 // Get the namespace from the service account.
112 ns, err := namespace()
113 if err != nil {
114 CheckIfError(err)
115 }
116
117 // Get the repository by name.
118 repo := &v1alpha1.Repository{}
119 if err := c.Get(context.TODO(), client.ObjectKey{Name: repositoryId, Namespace: ns}, repo); err != nil {
120 CheckIfError(err)
121 }
122
123 // Get the storage by name.
124 st := &v1alpha1.Storage{}
125 if err := c.Get(context.TODO(), client.ObjectKey{Name: storageId, Namespace: ns}, st); err != nil {
126 CheckIfError(err)
127 }
128 // Initialize embClient
129 embClient := embedder.NewClient(modelId, ns)
130
131 // Repository URL for remote git repository
132 var url string
133 var branch string
134 switch repo.Spec.Type {
135 case v1alpha1.RepositoryTypeGithub:
136 url = repo.Spec.Github.URL
137 branch = repo.Spec.Github.Branch

Callers

nothing calls this directly

Calls 13

NewClientFunction · 0.92
WarningFunction · 0.85
defaultClientFunction · 0.85
CheckIfErrorFunction · 0.85
namespaceFunction · 0.85
redisStorageStorerFunction · 0.85
getRedisearchClientFunction · 0.85
createIndexFunction · 0.85
postgresStorageStorerFunction · 0.85
gitAuthFunction · 0.85
processRedisEmbeddingsFunction · 0.85

Tested by

no test coverage detected