diff --git a/CODEOWNERS b/CODEOWNERS index 7858591b0..8f712007d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -27,7 +27,6 @@ /hack/fetch-broken-e2e @katexochen /hack/gocoverage @katexochen /hack/oci-pin @malt3 -/hack/pseudo-version @malt3 /hack/qemu-metadata-api @daniel-weisse /hack/remove-tf-providers @katexochen /hack/terraform @3u13r diff --git a/bazel/toolchains/go_module_deps.bzl b/bazel/toolchains/go_module_deps.bzl index f7ef9f354..5b432222b 100644 --- a/bazel/toolchains/go_module_deps.bzl +++ b/bazel/toolchains/go_module_deps.bzl @@ -3667,14 +3667,6 @@ def go_dependencies(): sum = "h1:IIA2aBdXvfbIM+yl/eTnL4hb1XwdpvuQLglAix1gweE=", version = "v1.13.3", ) - go_repository( - name = "com_github_matryer_is", - build_file_generation = "on", - build_file_proto_mode = "disable_global", - importpath = "github.com/matryer/is", - sum = "h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=", - version = "v1.2.0", - ) go_repository( name = "com_github_mattn_go_colorable", @@ -3922,14 +3914,6 @@ def go_dependencies(): sum = "h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=", version = "v1.0.2", ) - go_repository( - name = "com_github_mmcloughlin_avo", - build_file_generation = "on", - build_file_proto_mode = "disable_global", - importpath = "github.com/mmcloughlin/avo", - sum = "h1:nAco9/aI9Lg2kiuROBY6BhCI/z0t5jEvJfjWbL8qXLU=", - version = "v0.5.0", - ) go_repository( name = "com_github_moby_ipvs", diff --git a/hack/go.mod b/hack/go.mod index 91c3e6996..5a0b5ea7d 100644 --- a/hack/go.mod +++ b/hack/go.mod @@ -42,7 +42,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/s3 v1.36.0 github.com/bazelbuild/buildtools v0.0.0-20230317132445-9c3c1fc0106e github.com/edgelesssys/constellation/v2 v2.6.0 - github.com/go-git/go-git/v5 v5.7.0 github.com/hexops/gotextdiff v1.0.3 github.com/spf13/afero v1.10.0 github.com/spf13/cobra v1.7.0 @@ -50,7 +49,6 @@ require ( go.uber.org/goleak v1.2.1 go.uber.org/zap v1.26.0 golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df - golang.org/x/mod v0.12.0 gopkg.in/yaml.v3 v3.0.1 libvirt.org/go/libvirt v1.9004.0 ) @@ -84,7 +82,6 @@ require ( github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect github.com/agext/levenshtein v1.2.1 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect @@ -129,15 +126,13 @@ require ( github.com/edgelesssys/go-azguestattestation v0.0.0-20230707101700-a683be600fcf // indirect github.com/edgelesssys/go-tdx-qpl v0.0.0-20230530085549-fd2878a4dead // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect - github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/color v1.15.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/go-chi/chi v4.1.2+incompatible // indirect github.com/go-errors/errors v1.4.2 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.4.1 // indirect + github.com/go-git/go-git/v5 v5.7.0 // indirect github.com/go-gorp/gorp/v3 v3.0.5 // indirect github.com/go-jose/go-jose/v3 v3.0.0 // indirect github.com/go-logr/logr v1.2.4 // indirect @@ -198,13 +193,11 @@ require ( github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.15 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmoiron/sqlx v1.3.5 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect @@ -239,7 +232,6 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pborman/uuid v1.2.1 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -260,14 +252,12 @@ require ( github.com/sigstore/rekor v1.2.2 // indirect github.com/sigstore/sigstore v1.7.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect - github.com/skeema/knownhosts v1.1.1 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/theupdateframework/go-tuf v0.5.2 // indirect github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect github.com/transparency-dev/merkle v0.0.2 // indirect github.com/vtolstov/go-ioctl v0.0.0-20151206205506-6be9cced4810 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect @@ -280,6 +270,7 @@ require ( go.starlark.net v0.0.0-20220223235035-243c74974e97 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.13.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.9.0 // indirect golang.org/x/sync v0.3.0 // indirect @@ -297,7 +288,6 @@ require ( google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect helm.sh/helm v2.17.0+incompatible // indirect helm.sh/helm/v3 v3.12.1 // indirect diff --git a/hack/go.sum b/hack/go.sum index 455b57cd8..75a9f0279 100644 --- a/hack/go.sum +++ b/hack/go.sum @@ -112,7 +112,6 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.10.0-rc.7 h1:HBytQPxcv8Oy4244zbQbe6hnOnx544eL5QPUqhJldz8= @@ -133,8 +132,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= @@ -293,8 +290,6 @@ github.com/edgelesssys/go-azguestattestation v0.0.0-20230707101700-a683be600fcf github.com/edgelesssys/go-azguestattestation v0.0.0-20230707101700-a683be600fcf/go.mod h1:T8Rv3qrCpUJZbKq49OA9tcC1ZbRkGtDxiafsj++LYIE= github.com/edgelesssys/go-tdx-qpl v0.0.0-20230530085549-fd2878a4dead h1:Q2TI34V/NCLGQQkdc0/KmPx/7ix9YnGDUQDT+gqvDw0= github.com/edgelesssys/go-tdx-qpl v0.0.0-20230530085549-fd2878a4dead/go.mod h1:IC72qyykUIWl0ZmSk53L4xbLCFDBEGZVaujUmPQOEyw= -github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 h1:RIB4cRk+lBqKK3Oy0r2gRX4ui7tuhiZq2SuTtTCi0/0= -github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -334,8 +329,6 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec= github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= @@ -344,8 +337,6 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= github.com/go-git/go-git/v5 v5.7.0 h1:t9AudWVLmqzlo+4bqdf7GY+46SUuRsx59SboFxkq2aE= github.com/go-git/go-git/v5 v5.7.0/go.mod h1:coJHKEOk5kUClpsNlXrUvPrDxY3w3gjHvhcZd8Fodw8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -757,8 +748,6 @@ github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -952,7 +941,6 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -1301,7 +1289,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1327,7 +1314,6 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/hack/pseudo-version/BUILD.bazel b/hack/pseudo-version/BUILD.bazel deleted file mode 100644 index fe4dd5665..000000000 --- a/hack/pseudo-version/BUILD.bazel +++ /dev/null @@ -1,34 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library") -load("//hack/pseudo-version:platforms.bzl", "platforms") - -go_library( - name = "pseudo-version_lib", - srcs = ["pseudo-version.go"], - importpath = "github.com/edgelesssys/constellation/v2/hack/pseudo-version", - visibility = ["//visibility:private"], - deps = [ - "//hack/pseudo-version/internal/git", - "//internal/logger", - "@org_golang_x_mod//module", - "@org_uber_go_zap//:zap", - "@org_uber_go_zap//zapcore", - ], -) - -go_binary( - name = "pseudo-version", - embed = [":pseudo-version_lib"], - # keep - pure = "on", - visibility = ["//visibility:public"], -) - -[ - go_cross_binary( - name = "pseudo_version_%s" % platform, - platform = "@io_bazel_rules_go//go/toolchain:" + platform, - target = ":pseudo-version", - visibility = ["//visibility:public"], - ) - for platform in platforms() -] diff --git a/hack/pseudo-version/internal/git/BUILD.bazel b/hack/pseudo-version/internal/git/BUILD.bazel deleted file mode 100644 index 7ac47a391..000000000 --- a/hack/pseudo-version/internal/git/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "git", - srcs = ["git.go"], - importpath = "github.com/edgelesssys/constellation/v2/hack/pseudo-version/internal/git", - visibility = ["//hack/pseudo-version:__subpackages__"], - deps = ["@com_github_go_git_go_git_v5//:go-git"], -) diff --git a/hack/pseudo-version/internal/git/git.go b/hack/pseudo-version/internal/git/git.go deleted file mode 100644 index a8b4ffe05..000000000 --- a/hack/pseudo-version/internal/git/git.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) Edgeless Systems GmbH - -SPDX-License-Identifier: AGPL-3.0-only -*/ - -package git - -import ( - "fmt" - "regexp" - "strings" - "time" - - git "github.com/go-git/go-git/v5" -) - -// Git represents a git repository. -type Git struct { - repo *git.Repository -} - -// New opens the git repository in current directory. -func New() (*Git, error) { - repo, err := git.PlainOpenWithOptions("", &git.PlainOpenOptions{DetectDotGit: true}) - return &Git{repo: repo}, err -} - -// Revision returns the current revision (HEAD) of the repository in the format used by go pseudo versions. -func (g *Git) Revision() (string, time.Time, error) { - commitRef, err := g.repo.Head() - if err != nil { - return "", time.Time{}, err - } - commit, err := g.repo.CommitObject(commitRef.Hash()) - if err != nil { - return "", time.Time{}, err - } - return commitRef.Hash().String()[:12], commit.Committer.When, nil -} - -// ParsedBranchName returns the name of the current branch. -// Special characters are replaced with "-", and the name is lowercased and trimmed to 49 characters. -// This makes sure that the branch name is usable as a GCP image name. -func (g *Git) ParsedBranchName() (string, error) { - commitRef, err := g.repo.Head() - if err != nil { - return "", err - } - - rxp, err := regexp.Compile("[^a-zA-Z0-9-]+") - if err != nil { - return "", err - } - - branch := strings.ToLower(rxp.ReplaceAllString(commitRef.Name().Short(), "-")) - if len(branch) > 49 { - branch = branch[:49] - } - - return strings.TrimSuffix(branch, "-"), nil -} - -// BranchName of current HEAD. -func (g *Git) BranchName() (string, error) { - commitRef, err := g.repo.Head() - if err != nil { - return "", err - } - return commitRef.Name().Short(), nil -} - -// Path returns the path of the git repository. -func (g *Git) Path() (string, error) { - worktree, err := g.repo.Worktree() - if err != nil { - return "", fmt.Errorf("failed to get worktree: %w", err) - } - return worktree.Filesystem.Root(), nil -} diff --git a/hack/pseudo-version/platforms.bzl b/hack/pseudo-version/platforms.bzl deleted file mode 100644 index d48a2ad4c..000000000 --- a/hack/pseudo-version/platforms.bzl +++ /dev/null @@ -1,9 +0,0 @@ -"""Platforms""" - -def platforms(): - return [ - "darwin_amd64", - "darwin_arm64", - "linux_amd64", - "linux_arm64", - ] diff --git a/hack/pseudo-version/pseudo-version.go b/hack/pseudo-version/pseudo-version.go deleted file mode 100644 index b3fb7e053..000000000 --- a/hack/pseudo-version/pseudo-version.go +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright (c) Edgeless Systems GmbH - -SPDX-License-Identifier: AGPL-3.0-only -*/ - -package main - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "strings" - "time" - - "github.com/edgelesssys/constellation/v2/hack/pseudo-version/internal/git" - "github.com/edgelesssys/constellation/v2/internal/logger" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "golang.org/x/mod/module" -) - -func main() { - printSemVer := flag.Bool("semantic-version", false, "Only print semantic version") - printTimestamp := flag.Bool("print-timestamp", false, "Only print timestamp") - timestampFormat := flag.String("timestamp-format", "20060102150405", "Timestamp format") - printBranch := flag.Bool("print-branch", false, "Only print branch name") - major := flag.String("major", "v0", "Optional major version") - base := flag.String("base", "", "Optional base version") - revisionTimestamp := flag.String("time", "", "Optional revision time") - revision := flag.String("revision", "", "Optional revision (git commit hash)") - skipV := flag.Bool("skip-v", false, "Skip 'v' prefix in version") - flag.Parse() - - log := logger.New(logger.JSONLog, zapcore.InfoLevel) - - gitc, err := git.New() - if err != nil { - log.With(zap.Error(err)).Fatalf("Failed to initialize git client") - } - - parsedBranch, err := gitc.ParsedBranchName() - if err != nil { - log.With(zap.Error(err)).Fatalf("Failed to get parsed branch name") - } - - if *base == "" { - rootPath, err := gitc.Path() - if err != nil { - log.With(zap.Error(err)).Fatalf("Failed to get git root path. Using default base version.") - } else { - versionTag, err := os.ReadFile(filepath.Join(rootPath, "version.txt")) - if err != nil { - log.With(zap.Error(err)).Warnf("Failed to read version.txt. Using default base version.") - } else { - *base = strings.TrimSpace(string(versionTag)) - } - } - } - - var headRevision string - var headTime time.Time - if *revisionTimestamp == "" || *revision == "" { - var err error - headRevision, headTime, err = gitc.Revision() - if err != nil { - log.With(zap.Error(err)).Fatalf("Failed to retrieve HEAD") - } - } - - if *revisionTimestamp != "" { - headTime, err := time.Parse("20060102150405", *revisionTimestamp) - if err != nil { - log.With(zap.Error(err)).With("time", headTime).Fatalf("Failed to parse revision timestamp") - } - } - - if *revision == "" { - *revision = headRevision - } - - version := module.PseudoVersion(*major, *base, headTime, *revision) - if *skipV { - version = strings.TrimPrefix(version, "v") - } - - switch { - case *printSemVer: - fmt.Println(*base) - case *printTimestamp: - fmt.Println(headTime.Format(*timestampFormat)) - case *printBranch: - fmt.Println(parsedBranch) - default: - if !strings.Contains(*base, "pre") { - // "v2.7.0" inside the version.txt will lead to "v2.7.0" as version - // "2.7.0" inside the version.txt will lead to "2.7.0" as version - if *skipV { - fmt.Println(strings.TrimPrefix(*base, "v")) - } else { - fmt.Println(*base) - } - } else { - // "v2.7.0-pre" inside the version.txt will lead to "v2.7.0-pre.0.20230313121936-bab76e8a9acf" as version - // "2.7.0-pre" inside the version.txt will lead to "v0.0.0-20230313121936-bab76e8a9acf" as version - fmt.Println(version) - } - } -} diff --git a/rfc/apis.md b/rfc/apis.md index a08f255b1..1ea71f3ab 100644 --- a/rfc/apis.md +++ b/rfc/apis.md @@ -55,7 +55,7 @@ The use of semantic versions and pseudo versions tries to match the versioning u consult the module reference of Go, especially the sections about [versions](https://go.dev/ref/mod#versions) and [pseudo-versions](https://go.dev/ref/mod#pseudo-versions). -The [pesudo-version tool](../hack/pseudo-version) can generate a valid pseudo-version for your current head. +The [workspace status tool](/tools/workspace_status.sh) can generate a valid pseudo-version for your current head. ### Consistent API path prefix of `ref` and `stream`