Skip to content

Commit

Permalink
small out fixes, changed hello-world env names for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Oct 19, 2023
1 parent 27e779a commit 944cf5b
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 18 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
GIT_COMMIT = $(shell git log -n 1 --format="%h" -- ./)
GIT_REF := $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)

BUILD_DIR = bin
REL_DIR = release

Expand All @@ -18,9 +15,9 @@ docs:

.PHONY: release
release: clean
GIT_COMMIT=$(GIT_COMMIT) GIT_REF=$(GIT_REF) ./build.sh darwin $(BUILD_DIR) $(REL_DIR)
GIT_COMMIT=$(GIT_COMMIT) GIT_REF=$(GIT_REF) ./build.sh linux $(BUILD_DIR) $(REL_DIR)
GIT_COMMIT=$(GIT_COMMIT) GIT_REF=$(GIT_REF) ./build.sh windows $(BUILD_DIR) $(REL_DIR)
./build.sh darwin $(BUILD_DIR) $(REL_DIR)
./build.sh linux $(BUILD_DIR) $(REL_DIR)
./build.sh windows $(BUILD_DIR) $(REL_DIR)

.PHONY: clean
clean:
Expand Down
20 changes: 17 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

set -e

export CGO_ENABLED=0
export GOARCH=amd64
git_commit=$(git log -n 1 --format="%h" -- ./)
git_ref=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)

export GOOS=${1:-"linux"}
build_dir=${2:-"bin"}
rel_dir=${3:-"release"}
GIT_REF=${4:-"$GIT_REF"}

GIT_COMMIT=${GIT_COMMIT:-"$git_commit"}
GIT_REF=${GIT_REF:-"$git_ref"}

export CGO_ENABLED=0
export GOARCH=amd64

if [ -z "${GIT_COMMIT}" ]; then
echo "Environment variable GIT_COMMIT must be set for release target"
exit 1
fi
if [ -z "${GIT_REF}" ]; then
echo "Environment variable GIT_REF must be set for release target"
exit 1
Expand All @@ -22,6 +31,9 @@ if [ "$GOOS" == "windows" ]; then
bin="fox.exe"
fi

echo "Creating Fox release package..."
echo "Git Commit: $GIT_COMMIT, Git Ref: $GIT_REF, Package: ${rel_dir}/${tar}"

go build \
-o "${build_dir}/${bin}" \
-ldflags " \
Expand All @@ -35,3 +47,5 @@ tar -czvf "${rel_dir}/${tar}" --transform='s,.*/,,' "${build_dir}/${bin}" LICENS
cd "${rel_dir}"
sha256sum "${tar}" >"${tar}.sha256sum"
)

echo "Fin."
1 change: 1 addition & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ func runDeploy(cmd *cobra.Command, args []string) {
d := r.Deploy(name)
// Makes output less cluttered.
d.ManagedFields = nil
log.InfoNewline()
log.Marshal(d)
}
1 change: 1 addition & 0 deletions cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func runPublish(cmd *cobra.Command, args []string) error {
d := r.Deploy(args[0])
// Makes output less cluttered.
d.ManagedFields = nil
log.InfoNewline()
log.Marshal(d)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ deploy, and release your KubeFox components.
func init() {
rootCmd.PersistentFlags().StringVarP(&cfg.Flags.RepoPath, "repo", "r", pwd(), "path of git repo")
rootCmd.PersistentFlags().StringVarP(&cfg.Flags.OutFormat, "output", "o", "yaml", `output format. One of: "json", "yaml"`)
rootCmd.PersistentFlags().BoolVarP(&cfg.Flags.Info, "info", "i", true, "enable info output")
rootCmd.PersistentFlags().BoolVarP(&cfg.Flags.Info, "info", "i", false, "enable info output")
rootCmd.PersistentFlags().BoolVarP(&cfg.Flags.Verbose, "verbose", "v", false, "enable verbose output")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubefox.xigxog.io/v1alpha1
kind: Environment
metadata:
name: dev-john
name: universe
spec:
vars:
who: John
who: Universe
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubefox.xigxog.io/v1alpha1
kind: Environment
metadata:
name: dev
name: world
spec:
vars:
who: World
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (cfg *Config) Setup() {
if kindOnly {
cfg.ContainerRegistry.Address = LocalRegistry
cfg.ContainerRegistry.Token = ""
cfg.Kind.ClusterName = utils.NamePrompt("Kind cluster", "kubefox", true)
cfg.Kind.ClusterName = utils.NamePrompt("Kind cluster", "kind", true)
cfg.Kind.AlwaysLoad = true
cfg.done()
return
Expand Down
9 changes: 7 additions & 2 deletions internal/repo/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/pkg/archive"
"github.com/moby/patternmatcher/ignorefile"
"github.com/xigxog/kubefox-cli/efs"
Expand Down Expand Up @@ -142,8 +143,12 @@ func (r *repo) KindLoad(img string) {
}

cmd := exec.Command("kind", "load", "docker-image", "--name="+kind, img)
if err := cmd.Run(); err != nil {

if out, err := cmd.CombinedOutput(); err != nil {
log.Error("%s", strings.TrimSpace(string(out)))
log.Error("Error loading component image into Kind: %v", err)
} else {
log.Verbose("%s", strings.TrimSpace(string(out)))
}
}

Expand All @@ -152,7 +157,7 @@ func (r *repo) GetRegAuth() string {
if r.cfg.GitHub.Token != "" {
token = r.cfg.GitHub.Token
}
authCfg, _ := json.Marshal(types.AuthConfig{
authCfg, _ := json.Marshal(registry.AuthConfig{
Username: "kubefox",
Password: token,
})
Expand Down
4 changes: 2 additions & 2 deletions internal/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (r *repo) GetRefName() string {
}

if gitRef.Name().IsBranch() {
return "branch/" + gitRef.Name().Short()
return gitRef.Name().String()
}

// find tag
Expand All @@ -144,7 +144,7 @@ func (r *repo) GetRefName() string {
}
tags.ForEach(func(tag *plumbing.Reference) error {
if gitRef.Hash() == tag.Hash() {
refName = "tag/" + tag.Name().Short()
refName = tag.Name().String()
}
return nil
})
Expand Down

0 comments on commit 944cf5b

Please sign in to comment.