Skip to content

Commit

Permalink
MINOR: move version.go to package version
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmatmati authored and oktalz committed Nov 13, 2023
1 parent dbf51c4 commit dfa899d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN mkdir -p /var/run/vars && \
git diff --quiet > /var/run/vars/GIT_MODIFIED2 || echo '.dirty' > /var/run/vars/GIT_MODIFIED2 && \
cat /var/run/vars/GIT_MODIFIED1 /var/run/vars/GIT_MODIFIED2 | tr -d '\n' > /var/run/vars/GIT_MODIFIED && \
CGO_ENABLED=0 go build \
-ldflags "-X main.GitRepo=$(cat /var/run/vars/GIT_REPO) -X main.GitTag=$(cat /var/run/vars/GIT_LAST_TAG) -X main.GitCommit=$(cat /var/run/vars/GIT_HEAD_COMMIT) -X main.GitDirty=$(cat /var/run/vars/GIT_MODIFIED) -X \"main.GitCommitDate=$(cat /var/run/vars/GIT_DATE_LAST_COMMIT)\"" \
-ldflags "-X pkg.version.GitRepo=$(cat /var/run/vars/GIT_REPO) -X pkg.version.GitTag=$(cat /var/run/vars/GIT_LAST_TAG) -X pkg.version.GitCommit=$(cat /var/run/vars/GIT_HEAD_COMMIT) -X pkg.version.GitDirty=$(cat /var/run/vars/GIT_MODIFIED) -X \"pkg.version.GitCommitDate=$(cat /var/run/vars/GIT_DATE_LAST_COMMIT)\"" \
-o fs/haproxy-ingress-controller .

FROM haproxytech/haproxy-alpine:2.8
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.pebble
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RUN mkdir -p /var/run/vars && \
git diff --quiet > /var/run/vars/GIT_MODIFIED2 || echo '.dirty' > /var/run/vars/GIT_MODIFIED2 && \
cat /var/run/vars/GIT_MODIFIED1 /var/run/vars/GIT_MODIFIED2 | tr -d '\n' > /var/run/vars/GIT_MODIFIED && \
CGO_ENABLED=0 go build \
-ldflags "-X main.GitRepo=$(cat /var/run/vars/GIT_REPO) -X main.GitTag=$(cat /var/run/vars/GIT_LAST_TAG) -X main.GitCommit=$(cat /var/run/vars/GIT_HEAD_COMMIT) -X main.GitDirty=$(cat /var/run/vars/GIT_MODIFIED) -X \"main.GitCommitDate=$(cat /var/run/vars/GIT_DATE_LAST_COMMIT)\"" \
-ldflags "-X pkg.version.GitRepo=$(cat /var/run/vars/GIT_REPO) -X pkg.version.GitTag=$(cat /var/run/vars/GIT_LAST_TAG) -X pkg.version.GitCommit=$(cat /var/run/vars/GIT_HEAD_COMMIT) -X pkg.version.GitDirty=$(cat /var/run/vars/GIT_MODIFIED) -X \"pkg.version.GitCommitDate=$(cat /var/run/vars/GIT_DATE_LAST_COMMIT)\"" \
-o fs/haproxy-ingress-controller .

FROM haproxytech/haproxy-alpine:2.8
Expand Down
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/haproxytech/kubernetes-ingress/pkg/k8s"
"github.com/haproxytech/kubernetes-ingress/pkg/store"
"github.com/haproxytech/kubernetes-ingress/pkg/utils"
"github.com/haproxytech/kubernetes-ingress/pkg/version"

_ "go.uber.org/automaxprocs"
)
Expand Down Expand Up @@ -138,9 +139,9 @@ func main() {

func logInfo(logger utils.Logger, osArgs utils.OSArgs) bool {
if len(osArgs.Version) > 0 {
fmt.Printf("HAProxy Ingress Controller %s %s%s", GitTag, GitCommit, GitDirty)
fmt.Printf("Build from: %s", GitRepo)
fmt.Printf("Git commit date: %s", GitCommitDate)
fmt.Printf("HAProxy Ingress Controller %s %s%s", version.GitTag, version.GitCommit, version.GitDirty)
fmt.Printf("Build from: %s", version.GitRepo)
fmt.Printf("Git commit date: %s", version.GitCommitDate)
if len(osArgs.Version) > 1 {
fmt.Printf("ConfigMap: %s", osArgs.ConfigMap)
fmt.Printf("Ingress class: %s", osArgs.IngressClass)
Expand All @@ -149,10 +150,10 @@ func logInfo(logger utils.Logger, osArgs utils.OSArgs) bool {
return true
}

logger.Print(IngressControllerInfo)
logger.Printf("HAProxy Ingress Controller %s %s%s", GitTag, GitCommit, GitDirty)
logger.Printf("Build from: %s", GitRepo)
logger.Printf("Git commit date: %s", GitCommitDate)
logger.Print(version.IngressControllerInfo)
logger.Printf("HAProxy Ingress Controller %s %s%s", version.GitTag, version.GitCommit, version.GitDirty)
logger.Printf("Build from: %s", version.GitRepo)
logger.Printf("Git commit date: %s", version.GitCommitDate)
logger.Printf("ConfigMap: %s", osArgs.ConfigMap)
logger.Printf("Ingress class: %s", osArgs.IngressClass)
logger.Printf("Empty Ingress class: %t", osArgs.EmptyIngressClass)
Expand Down
2 changes: 1 addition & 1 deletion version.go → pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package main
package version

// GitRepo ...
var GitRepo = ""
Expand Down

0 comments on commit dfa899d

Please sign in to comment.