## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Reviewed-on: #73
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
115 lines
2.3 KiB
Go
115 lines
2.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var examplesCmd = &cobra.Command{
|
|
Use: "examples",
|
|
Short: "create examples",
|
|
Long: `...`,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
//filePathStr := "stackit/internal/services/postgresflexalpha/database/datasources_gen/database_data_source_gen.go"
|
|
//
|
|
//src, err := os.ReadFile(filePathStr)
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//
|
|
//i := interp.New(
|
|
// interp.Options{
|
|
// GoPath: "/home/henselinm/.asdf/installs/golang/1.25.6/packages",
|
|
// BuildTags: nil,
|
|
// Stdin: nil,
|
|
// Stdout: nil,
|
|
// Stderr: nil,
|
|
// Args: nil,
|
|
// Env: nil,
|
|
// SourcecodeFilesystem: nil,
|
|
// Unrestricted: false,
|
|
// },
|
|
//)
|
|
//err = i.Use(i.Symbols("github.com/hashicorp/terraform-plugin-framework-validators"))
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//err = i.Use(stdlib.Symbols)
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//_, err = i.Eval(string(src))
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//
|
|
//v, err := i.Eval("DatabaseDataSourceSchema")
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//
|
|
//bar := v.Interface().(func(string) string)
|
|
//
|
|
//r := bar("Kung")
|
|
//println(r)
|
|
//
|
|
//evalPath, err := i.EvalPath(filePathStr)
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//
|
|
//fmt.Printf("%+v\n", evalPath)
|
|
|
|
//_, err = i.Eval(`import "fmt"`)
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
//_, err = i.Eval(`func Hallo() { fmt.Println("Hi!") }`)
|
|
//if err != nil {
|
|
// return err
|
|
//}
|
|
|
|
//v = i.Symbols("Hallo")
|
|
|
|
// fmt.Println(v)
|
|
return workServices()
|
|
},
|
|
}
|
|
|
|
func workServices() error {
|
|
startPath := path.Join("stackit", "internal", "services")
|
|
|
|
services, err := os.ReadDir(startPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, entry := range services {
|
|
if !entry.IsDir() {
|
|
continue
|
|
}
|
|
resources, err := os.ReadDir(path.Join(startPath, entry.Name()))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, res := range resources {
|
|
if !res.IsDir() {
|
|
continue
|
|
}
|
|
fmt.Println("Gefunden:", startPath, "subdir", entry.Name(), "resource", res.Name())
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func NewExamplesCmd() *cobra.Command {
|
|
return examplesCmd
|
|
}
|
|
|
|
//func init() { // nolint: gochecknoinits
|
|
// examplesCmd.Flags().BoolVarP(&example, "example", "e", false, "example")
|
|
//}
|