Compare commits
6 Commits
95884e14d6
...
0c35993122
Author | SHA1 | Date | |
---|---|---|---|
|
0c35993122 | ||
|
3abf53ec6c | ||
|
19790f61e2 | ||
|
ebf9d3fc6d | ||
|
741d1a0ffe | ||
|
8632b02f0e |
6
Makefile
6
Makefile
@ -14,6 +14,12 @@ endif
|
|||||||
PUBLISH_REPO := "core/oc-deploy"
|
PUBLISH_REPO := "core/oc-deploy"
|
||||||
PUBLISH_BRANCH := main
|
PUBLISH_BRANCH := main
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo
|
||||||
|
@echo 'Usage:'
|
||||||
|
@echo ' make publish'
|
||||||
|
@echo ' make clean'
|
||||||
|
|
||||||
.PHONY: publish
|
.PHONY: publish
|
||||||
publish:
|
publish:
|
||||||
@echo Publication de : ${OC_VERSION}
|
@echo Publication de : ${OC_VERSION}
|
||||||
|
34
src/Makefile
34
src/Makefile
@ -11,6 +11,16 @@ BIN_DIR = ../bin/
|
|||||||
PLUGINS := $(wildcard ../plugins/*/*.go)
|
PLUGINS := $(wildcard ../plugins/*/*.go)
|
||||||
OBJS := ${PLUGINS:.go=.so}
|
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
|
%.so: %.go
|
||||||
go build -buildmode=plugin -o $@ $<
|
go build -buildmode=plugin -o $@ $<
|
||||||
|
|
||||||
@ -23,35 +33,44 @@ help:
|
|||||||
@echo ' make run BIN_OPTS=... Go run'
|
@echo ' make run BIN_OPTS=... Go run'
|
||||||
@echo ' make run_install BIN_OPTS=... Go run'
|
@echo ' make run_install BIN_OPTS=... Go run'
|
||||||
@echo ' make run_uninstall 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 BIN_OPTS=... exécutable'
|
||||||
@echo ' make exec_install BIN_OPTS=... exécutable'
|
@echo ' make exec_install BIN_OPTS=... exécutable'
|
||||||
@echo ' make exec_uninstall 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 test Test'
|
||||||
@echo ' make clean Clean the directory tree.'
|
@echo ' make clean Clean the directory tree.'
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
|
@echo ' DATE ${DATE}'
|
||||||
|
@echo ' GOVERSION ${GOVERSION}'
|
||||||
|
@echo ' VERSION ${VERSION}'
|
||||||
|
@echo
|
||||||
|
|
||||||
${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS)
|
${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS)
|
||||||
go build -o ${BIN_DIR}/${BIN_NAME}
|
go build -o ${BIN_DIR}/${BIN_NAME} -ldflags "${LDFLAGS}"
|
||||||
|
|
||||||
get-deps:
|
get-deps:
|
||||||
@go mod tidy
|
@go mod tidy
|
||||||
|
|
||||||
build: ${BIN_DIR}/${BIN_NAME}
|
build: ${BIN_DIR}/${BIN_NAME}
|
||||||
|
|
||||||
run: $(OBJS)
|
run:
|
||||||
@go run main.go ${BIN_OPTS}
|
@go run main.go ${BIN_OPTS}
|
||||||
|
|
||||||
run_generate: $(OBJS)
|
run_generate:
|
||||||
@go run main.go generate ${BIN_OPTS}
|
@go run main.go generate ${BIN_OPTS}
|
||||||
|
|
||||||
run_install: $(OBJS)
|
run_install:
|
||||||
@go run main.go install ${BIN_OPTS}
|
@go run main.go install ${BIN_OPTS}
|
||||||
|
|
||||||
run_uninstall: $(OBJS)
|
run_uninstall:
|
||||||
@go run main.go uninstall ${BIN_OPTS}
|
@go run main.go uninstall ${BIN_OPTS}
|
||||||
|
|
||||||
|
run_version:
|
||||||
|
@go run main.go version
|
||||||
|
|
||||||
exec: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
exec: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
||||||
@${BIN_DIR}/${BIN_NAME} ${BIN_OPTS}
|
@${BIN_DIR}/${BIN_NAME} ${BIN_OPTS}
|
||||||
|
|
||||||
@ -61,6 +80,9 @@ exec_install: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
|||||||
exec_uninstall: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
exec_uninstall: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
||||||
@${BIN_DIR}/${BIN_NAME} uninstall ${BIN_OPTS}
|
@${BIN_DIR}/${BIN_NAME} uninstall ${BIN_OPTS}
|
||||||
|
|
||||||
|
exec_version: ${BIN_DIR}/${BIN_NAME} $(OBJS)
|
||||||
|
@${BIN_DIR}/${BIN_NAME} version
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@test ! -e ${BIN_DIR}/${BIN_NAME} || rm ${BIN_DIR}/${BIN_NAME}
|
@test ! -e ${BIN_DIR}/${BIN_NAME} || rm ${BIN_DIR}/${BIN_NAME}
|
||||||
@test ! -e .coverage.out || rm .coverage.out
|
@test ! -e .coverage.out || rm .coverage.out
|
||||||
|
@ -24,6 +24,7 @@ func cobraInstallCmd() *cobra.Command {
|
|||||||
Long: `deploy Charts`,
|
Long: `deploy Charts`,
|
||||||
Args: cobra.MaximumNArgs(0),
|
Args: cobra.MaximumNArgs(0),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
log.Log().Info().Msg("oc-deploy :")
|
||||||
return InstallCmd(context, version, modules)
|
return InstallCmd(context, version, modules)
|
||||||
},
|
},
|
||||||
Example: "oc-deploy install --version 0.1.0 --context ex1",
|
Example: "oc-deploy install --version 0.1.0 --context ex1",
|
||||||
@ -37,6 +38,7 @@ func cobraUninstallCmd() *cobra.Command{
|
|||||||
Long: `Undeploy`,
|
Long: `Undeploy`,
|
||||||
Args: cobra.MaximumNArgs(0),
|
Args: cobra.MaximumNArgs(0),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
log.Log().Info().Msg("oc-deploy :")
|
||||||
return UninstallCmd(context)
|
return UninstallCmd(context)
|
||||||
},
|
},
|
||||||
Example: "oc-deploy uninstall --context ex1",
|
Example: "oc-deploy uninstall --context ex1",
|
||||||
@ -48,15 +50,29 @@ func cobraGenerateCmd() *cobra.Command{
|
|||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "generate",
|
Use: "generate",
|
||||||
Short: "generate",
|
Short: "generate",
|
||||||
Long: "Value",
|
Long: "generate",
|
||||||
Args: cobra.MaximumNArgs(0),
|
Args: cobra.MaximumNArgs(0),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
log.Log().Info().Msg("oc-deploy :")
|
||||||
return GenerateCmd(context, version)
|
return GenerateCmd(context, version)
|
||||||
},
|
},
|
||||||
Example: "oc-deploy generate --version 0.1.0 --context ex1",
|
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() {
|
func Execute() {
|
||||||
|
|
||||||
log.Log().Debug().Msg("Execute")
|
log.Log().Debug().Msg("Execute")
|
||||||
@ -66,6 +82,7 @@ func Execute() {
|
|||||||
var cmdInstall = cobraInstallCmd()
|
var cmdInstall = cobraInstallCmd()
|
||||||
var cmdUninstall = cobraUninstallCmd()
|
var cmdUninstall = cobraUninstallCmd()
|
||||||
var cmdGenerate = cobraGenerateCmd()
|
var cmdGenerate = cobraGenerateCmd()
|
||||||
|
var cmdVersion = cobraVersionCmd()
|
||||||
|
|
||||||
cmdInstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
|
cmdInstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
|
||||||
cmdInstall.Flags().StringVarP(&version, "version", "v", "latest", "Version")
|
cmdInstall.Flags().StringVarP(&version, "version", "v", "latest", "Version")
|
||||||
@ -79,6 +96,7 @@ func Execute() {
|
|||||||
rootCmd.AddCommand(cmdInstall)
|
rootCmd.AddCommand(cmdInstall)
|
||||||
rootCmd.AddCommand(cmdUninstall)
|
rootCmd.AddCommand(cmdUninstall)
|
||||||
rootCmd.AddCommand(cmdGenerate)
|
rootCmd.AddCommand(cmdGenerate)
|
||||||
|
rootCmd.AddCommand(cmdVersion)
|
||||||
|
|
||||||
cobra.CheckErr(rootCmd.Execute())
|
cobra.CheckErr(rootCmd.Execute())
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ func UninstallCmd(context string) error {
|
|||||||
log.Log().Fatal().Msg(" >> " + err.Error())
|
log.Log().Fatal().Msg(" >> " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj.SetCommands()
|
||||||
|
|
||||||
err = obj.K8s(context)
|
err = obj.K8s(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log().Fatal().Msg(" >> " + err.Error())
|
log.Log().Fatal().Msg(" >> " + err.Error())
|
||||||
|
15
src/cmd/versionlCmd.go
Normal file
15
src/cmd/versionlCmd.go
Normal 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
|
||||||
|
}
|
@ -163,11 +163,3 @@ func (this HelmCommand) chartExists(data HelmChart) (bool, error) {
|
|||||||
|
|
||||||
return res != "", nil
|
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
|
|
||||||
// }
|
|
@ -60,13 +60,15 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
for _, v := range this.charts {
|
for _, v := range this.charts {
|
||||||
|
repoName := v.Repository.Name
|
||||||
|
|
||||||
for _, v1 := range v.Charts {
|
for _, v1 := range v.Charts {
|
||||||
if len(modules) == 0 || utils.StringInSlice(v1.Name, modules) {
|
if len(modules) == 0 || utils.StringInSlice(v1.Name, modules) {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
this.installChart(v1)
|
this.installChart(repoName, v1)
|
||||||
} ()
|
} ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,12 +77,19 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
|
|||||||
return nil
|
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))
|
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,
|
data := helm.HelmChart{Name: chart.Name,
|
||||||
Chart: chart.Chart,
|
Chart: chartName,
|
||||||
Url: chart.Url,
|
Url: chart.Url,
|
||||||
Version: chart.Version,
|
Version: chart.Version,
|
||||||
Workspace: this.Workspace,
|
Workspace: this.Workspace,
|
||||||
|
@ -10,7 +10,6 @@ func main() {
|
|||||||
log.InitLog(".oc-deploy")
|
log.InitLog(".oc-deploy")
|
||||||
|
|
||||||
log.Log().Debug().Msg("Start")
|
log.Log().Debug().Msg("Start")
|
||||||
log.Log().Info().Msg("oc-deploy :")
|
|
||||||
|
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user