Feat: add kompose client PoC (#1593)

* fix: support host port and protocol in functional tests

* feat: add kompose client with options

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* test: add options unit tests

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* feat: add partial convert options

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* feat: finish convert process

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* test: finish unit tests of the kompose client

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* remove unecessary changes

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* feat: add generate network policies to client

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

* update go mod

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>

---------

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
AhmedGrati
2023-08-24 11:38:21 +01:00
committed by GitHub
parent b83d4d4094
commit ea80734f91
12 changed files with 530 additions and 3 deletions
+7 -3
View File
@@ -22,6 +22,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime"
"os"
@@ -143,20 +144,22 @@ func ValidateFlags(args []string, cmd *cobra.Command, opt *kobject.ConvertOption
}
// ValidateComposeFile validates the compose file provided for conversion
func ValidateComposeFile(opt *kobject.ConvertOptions) {
func ValidateComposeFile(opt *kobject.ConvertOptions) error {
if len(opt.InputFiles) == 0 {
for _, name := range DefaultComposeFiles {
_, err := os.Stat(name)
if err != nil {
log.Debugf("'%s' not found: %v", name, err)
return err
} else {
opt.InputFiles = []string{name}
return
return nil
}
}
log.Fatal("No 'docker-compose' file found")
}
return nil
}
func validateControllers(opt *kobject.ConvertOptions) {
@@ -202,7 +205,7 @@ func validateControllers(opt *kobject.ConvertOptions) {
}
// Convert transforms docker compose or dab file to k8s objects
func Convert(opt kobject.ConvertOptions) {
func Convert(opt kobject.ConvertOptions) ([]runtime.Object, error) {
validateControllers(&opt)
// loader parses input from file into komposeObject.
@@ -236,6 +239,7 @@ func Convert(opt kobject.ConvertOptions) {
if err != nil {
log.Fatalf(err.Error())
}
return objects, err
}
// Convenience method to return the appropriate Transformer based on