feat: testing (#34)
## 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: #34
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
c22e758b2c
commit
32e41d8b44
24 changed files with 858 additions and 2431 deletions
|
|
@ -39,17 +39,15 @@ type version struct {
|
|||
}
|
||||
|
||||
type Builder struct {
|
||||
SkipClone bool
|
||||
SkipCleanup bool
|
||||
SkipClone bool
|
||||
SkipCleanup bool
|
||||
PackagesOnly bool
|
||||
}
|
||||
|
||||
func (b *Builder) Build() error {
|
||||
slog.Info("Starting Builder")
|
||||
|
||||
slog.Info(" ... Checking needed commands available")
|
||||
err := checkCommands([]string{"tfplugingen-framework", "tfplugingen-openapi"})
|
||||
if err != nil {
|
||||
return err
|
||||
if b.PackagesOnly {
|
||||
slog.Info(" >>> only generating pkg_gen <<<")
|
||||
}
|
||||
|
||||
root, err := getRoot()
|
||||
|
|
@ -61,13 +59,23 @@ func (b *Builder) Build() error {
|
|||
}
|
||||
slog.Info(" ... using root directory", "dir", *root)
|
||||
|
||||
if !b.SkipCleanup {
|
||||
slog.Info("Cleaning up old generator directory")
|
||||
err = os.RemoveAll(path.Join(*root, GEN_REPO_NAME))
|
||||
if !b.PackagesOnly {
|
||||
slog.Info(" ... Checking needed commands available")
|
||||
err := checkCommands([]string{"tfplugingen-framework", "tfplugingen-openapi"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !b.SkipCleanup {
|
||||
slog.Info("Cleaning up old packages directory")
|
||||
err = os.RemoveAll(path.Join(*root, "pkg_gen"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !b.SkipCleanup && !b.PackagesOnly {
|
||||
slog.Info("Cleaning up old packages directory")
|
||||
err = os.RemoveAll(path.Join(*root, "pkg_gen"))
|
||||
if err != nil {
|
||||
|
|
@ -211,24 +219,26 @@ func (b *Builder) Build() error {
|
|||
}
|
||||
}
|
||||
|
||||
slog.Info("Generating service boilerplate")
|
||||
err = generateServiceFiles(*root, path.Join(*root, GEN_REPO_NAME))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !b.PackagesOnly {
|
||||
slog.Info("Generating service boilerplate")
|
||||
err = generateServiceFiles(*root, path.Join(*root, GEN_REPO_NAME))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
slog.Info("Copying all service files")
|
||||
err = CopyDirectory(
|
||||
path.Join(*root, "generated", "internal", "services"),
|
||||
path.Join(*root, "stackit", "internal", "services"),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
slog.Info("Copying all service files")
|
||||
err = CopyDirectory(
|
||||
path.Join(*root, "generated", "internal", "services"),
|
||||
path.Join(*root, "stackit", "internal", "services"),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = createBoilerplate(*root, path.Join(*root, "stackit", "internal", "services"))
|
||||
if err != nil {
|
||||
return err
|
||||
err = createBoilerplate(*root, path.Join(*root, "stackit", "internal", "services"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !b.SkipCleanup {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
skipCleanup bool
|
||||
skipClone bool
|
||||
skipCleanup bool
|
||||
skipClone bool
|
||||
packagesOnly bool
|
||||
)
|
||||
|
||||
var buildCmd = &cobra.Command{
|
||||
|
|
@ -16,8 +17,9 @@ var buildCmd = &cobra.Command{
|
|||
Long: `...`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
b := build.Builder{
|
||||
SkipClone: skipClone,
|
||||
SkipCleanup: skipCleanup,
|
||||
SkipClone: skipClone,
|
||||
SkipCleanup: skipCleanup,
|
||||
PackagesOnly: packagesOnly,
|
||||
}
|
||||
return b.Build()
|
||||
},
|
||||
|
|
@ -30,4 +32,5 @@ func NewBuildCmd() *cobra.Command {
|
|||
func init() { // nolint: gochecknoinits
|
||||
buildCmd.Flags().BoolVarP(&skipCleanup, "skip-clean", "c", false, "Skip cleanup steps")
|
||||
buildCmd.Flags().BoolVarP(&skipClone, "skip-clone", "g", false, "Skip cloning from git")
|
||||
buildCmd.Flags().BoolVarP(&packagesOnly, "packages-only", "p", false, "Only generate packages")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue