Compare commits

...

6 Commits

Author SHA1 Message Date
admju
0c35993122 Version 2024-09-18 09:09:21 +00:00
admju
3abf53ec6c version 2024-09-18 08:59:28 +00:00
admju
19790f61e2 Correction chart via repo 2024-09-18 08:41:47 +00:00
admju
ebf9d3fc6d Supp code commentée 2024-09-18 08:41:16 +00:00
admju
741d1a0ffe Correction 2024-09-18 08:40:53 +00:00
admju
8632b02f0e Aide 2024-09-18 08:40:33 +00:00
8 changed files with 82 additions and 19 deletions

View File

@ -14,6 +14,12 @@ endif
PUBLISH_REPO := "core/oc-deploy"
PUBLISH_BRANCH := main
help:
@echo
@echo 'Usage:'
@echo ' make publish'
@echo ' make clean'
.PHONY: publish
publish:
@echo Publication de : ${OC_VERSION}

View File

@ -11,6 +11,16 @@ BIN_DIR = ../bin/
PLUGINS := $(wildcard ../plugins/*/*.go)
OBJS := ${PLUGINS:.go=.so}
##################
DATE := $(shell date)
GOVERSION := $(shell go version)
VERSION := $(shell git describe --tags --abbrev=8 --dirty --always --long)
PREFIX := "oc-deploy/version"
LDFLAGS := -X '${PREFIX}.Version=${VERSION}'
##################
%.so: %.go
go build -buildmode=plugin -o $@ $<
@ -23,35 +33,44 @@ help:
@echo ' make run BIN_OPTS=... Go run'
@echo ' make run_install BIN_OPTS=... Go run'
@echo ' make run_uninstall BIN_OPTS=... Go run'
@echo ' make run_version Go run'
@echo ' make exec BIN_OPTS=... exécutable'
@echo ' make exec_install BIN_OPTS=... exécutable'
@echo ' make exec_uninstall BIN_OPTS=... exécutable'
@echo ' make test Test.'
@echo ' make exec_version exécutable'
@echo ' make test Test'
@echo ' make clean Clean the directory tree.'
@echo
@echo ' DATE ${DATE}'
@echo ' GOVERSION ${GOVERSION}'
@echo ' VERSION ${VERSION}'
@echo
${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS)
go build -o ${BIN_DIR}/${BIN_NAME}
go build -o ${BIN_DIR}/${BIN_NAME} -ldflags "${LDFLAGS}"
get-deps:
@go mod tidy
build: ${BIN_DIR}/${BIN_NAME}
run: $(OBJS)
run:
@go run main.go ${BIN_OPTS}
run_generate: $(OBJS)
run_generate:
@go run main.go generate ${BIN_OPTS}
run_install: $(OBJS)
run_install:
@go run main.go install ${BIN_OPTS}
run_uninstall: $(OBJS)
run_uninstall:
@go run main.go uninstall ${BIN_OPTS}
run_version:
@go run main.go version
exec: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} ${BIN_OPTS}
@ -61,6 +80,9 @@ exec_install: ${BIN_DIR}/${BIN_NAME} $(OBJS)
exec_uninstall: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} uninstall ${BIN_OPTS}
exec_version: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} version
clean:
@test ! -e ${BIN_DIR}/${BIN_NAME} || rm ${BIN_DIR}/${BIN_NAME}
@test ! -e .coverage.out || rm .coverage.out

View File

@ -24,6 +24,7 @@ func cobraInstallCmd() *cobra.Command {
Long: `deploy Charts`,
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
log.Log().Info().Msg("oc-deploy :")
return InstallCmd(context, version, modules)
},
Example: "oc-deploy install --version 0.1.0 --context ex1",
@ -37,6 +38,7 @@ func cobraUninstallCmd() *cobra.Command{
Long: `Undeploy`,
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
log.Log().Info().Msg("oc-deploy :")
return UninstallCmd(context)
},
Example: "oc-deploy uninstall --context ex1",
@ -48,15 +50,29 @@ func cobraGenerateCmd() *cobra.Command{
return &cobra.Command{
Use: "generate",
Short: "generate",
Long: "Value",
Long: "generate",
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
log.Log().Info().Msg("oc-deploy :")
return GenerateCmd(context, version)
},
Example: "oc-deploy generate --version 0.1.0 --context ex1",
}
}
func cobraVersionCmd() *cobra.Command{
return &cobra.Command{
Use: "version",
Short: "version",
Long: "Get Version",
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return VersionCmd()
},
Example: "oc-deploy version",
}
}
func Execute() {
log.Log().Debug().Msg("Execute")
@ -66,6 +82,7 @@ func Execute() {
var cmdInstall = cobraInstallCmd()
var cmdUninstall = cobraUninstallCmd()
var cmdGenerate = cobraGenerateCmd()
var cmdVersion = cobraVersionCmd()
cmdInstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
cmdInstall.Flags().StringVarP(&version, "version", "v", "latest", "Version")
@ -79,6 +96,7 @@ func Execute() {
rootCmd.AddCommand(cmdInstall)
rootCmd.AddCommand(cmdUninstall)
rootCmd.AddCommand(cmdGenerate)
rootCmd.AddCommand(cmdVersion)
cobra.CheckErr(rootCmd.Execute())

View File

@ -31,6 +31,8 @@ func UninstallCmd(context string) error {
log.Log().Fatal().Msg(" >> " + err.Error())
}
obj.SetCommands()
err = obj.K8s(context)
if err != nil {
log.Log().Fatal().Msg(" >> " + err.Error())

15
src/cmd/versionlCmd.go Normal file
View File

@ -0,0 +1,15 @@
package cmd
import (
"fmt"
log "oc-deploy/log_wrapper"
)
func VersionCmd() error {
version := "0.1.0"
log.Log().Debug().Msg(fmt.Sprintf("Version : %s", version))
fmt.Println(version)
return nil
}

View File

@ -163,11 +163,3 @@ func (this HelmCommand) chartExists(data HelmChart) (bool, error) {
return res != "", nil
}
// func (this HelmChart) GetRessources() (map[string]string, error) {
// hs := HelmStatus{Name: this.Name}
// hs.New(this.Bin)
// data, _ := hs.getRessources()
// return data, nil
// }

View File

@ -60,13 +60,15 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
var wg sync.WaitGroup
for _, v := range this.charts {
repoName := v.Repository.Name
for _, v1 := range v.Charts {
if len(modules) == 0 || utils.StringInSlice(v1.Name, modules) {
wg.Add(1)
go func() {
defer wg.Done()
this.installChart(v1)
this.installChart(repoName, v1)
} ()
}
}
@ -75,12 +77,19 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
return nil
}
func (this *InstallClass) installChart(chart chart.ChartData) {
func (this *InstallClass) installChart(repoName string, chart chart.ChartData) {
log.Log().Info().Msg(fmt.Sprintf(" << Chart : %s ", chart.Name))
chartName := chart.Chart
if chartName == "" {
chartName = chart.Name
}
if repoName != "" {
chartName = fmt.Sprintf("%s/%s", repoName, chartName)
}
data := helm.HelmChart{Name: chart.Name,
Chart: chart.Chart,
Chart: chartName,
Url: chart.Url,
Version: chart.Version,
Workspace: this.Workspace,

View File

@ -10,7 +10,6 @@ func main() {
log.InitLog(".oc-deploy")
log.Log().Debug().Msg("Start")
log.Log().Info().Msg("oc-deploy :")
cmd.Execute()