From 356c6b8450f50ae5e1caa938b5361ebf83cc671e Mon Sep 17 00:00:00 2001 From: Michal Mazur Date: Wed, 27 Mar 2024 13:05:37 +0000 Subject: [PATCH 1/7] DXE-3579 Changelog boilerplate and adapt to fixed release notes --- CHANGELOG.md | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1426c17..b420c6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,53 @@ # Release Notes +## Version X.XX.X (Month XX, XXXX) + +### Features/Enhancements + + + + + + + + + + + + + +### Bug fixes + + + + + + + + + + + +### Deprecations + + + + + + + + + + + ## Version 1.13.0 (March 26, 2024) ### Features/Enhancements * General * Updated minimal required terraform version to 1.0 - * Migrate to go 1.21 -* Appsec + * Migrated to go 1.21 +* APPSEC * Added support to export `akamai_appsec_penalty_box_conditions` for the specified policy * Added support to export `akamai_appsec_eval_penalty_box_conditions` for the specified policy * Cloudlets @@ -28,7 +68,7 @@ ### Deprecations * APPSEC - * Exclude the deprecated `akamai_appsec_selected_hostnames` resource from the `export-appsec` command. Use exported `akamai_appsec_configuration` instead + * Excluded the deprecated `akamai_appsec_selected_hostnames` resource from the `export-appsec` command. Exported `akamai_appsec_configuration` should be used instead ## Version 1.12.0 (February 19, 2024) From 3587a42e906f6971c67d739ffacc62e558e80b70 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Tue, 2 Apr 2024 09:28:50 +0000 Subject: [PATCH 2/7] DXE-3643 IVM - add support for new transformation SmartCrop --- CHANGELOG.md | 2 ++ .../imaging/templates/policy_image.gen.tmpl | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b420c6f..91383c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ +* Image and Video Manager + * Added handling of `SmartCrop` transformation when exporting image with `policy-as-hcl` flag diff --git a/pkg/providers/imaging/templates/policy_image.gen.tmpl b/pkg/providers/imaging/templates/policy_image.gen.tmpl index fc342d3..77fc8ed 100644 --- a/pkg/providers/imaging/templates/policy_image.gen.tmpl +++ b/pkg/providers/imaging/templates/policy_image.gen.tmpl @@ -30,6 +30,7 @@ {{- if eq .Transformation "Rotate"}}{{- template "Rotate" .}}{{- end}} {{- if eq .Transformation "Scale"}}{{- template "Scale" .}}{{- end}} {{- if eq .Transformation "Shear"}}{{- template "Shear" .}}{{- end}} + {{- if eq .Transformation "SmartCrop"}}{{- template "SmartCrop" .}}{{- end}} {{- if eq .Transformation "Trim"}}{{- template "Trim" .}}{{- end}} {{- if eq .Transformation "UnsharpMask"}}{{- template "UnsharpMask" .}}{{- end}} {{- end}} @@ -1119,6 +1120,37 @@ } {{- end}} {{- /*// ShearTransformation */}} +{{- /*// SmartCrop */}} +{{- define "SmartCrop"}}smart_crop { +{{- with .Debug}} + {{""}} + {{- if .Value}}debug = {{.Value}}{{end}} + {{- if .Name}}debug_var = "{{.Name}}"{{end}} +{{- end}} +{{- with .Height}} + {{""}} + {{- if .Value}}height = {{.Value}}{{end}} + {{- if .Name}}height_var = "{{.Name}}"{{end}} +{{- end}} +{{- with .Sloppy}} + {{""}} + {{- if .Value}}sloppy = {{.Value}}{{end}} + {{- if .Name}}sloppy_var = "{{.Name}}"{{end}} +{{- end}} +{{- with .Style}} + {{""}} + {{- if .Value}}style = "{{.Value}}"{{end}} + {{- if .Name}}style_var = "{{.Name}}"{{end}} +{{- end}} +{{- with .Width}} + {{""}} + {{- if .Value}}width = {{.Value}}{{end}} + {{- if .Name}}width_var = "{{.Name}}"{{end}} +{{- end}} +} +{{- end}} +{{- /*// SmartCropStyle */}} +{{- /*// SmartCropTransformation */}} {{- /*// TextImageType */}} {{- define "TextImageType"}}text_image { {{- with .Fill}} From 407924898a7bcc3e0c13a8978f43a2ca719b7b28 Mon Sep 17 00:00:00 2001 From: Dawid Dzhafarov Date: Thu, 4 Apr 2024 08:46:07 +0000 Subject: [PATCH 3/7] DXE-3521 Add go mod tidy to the build --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cd5ddf0..4e277dd 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml COVERAGE_HTML = $(COVERAGE_DIR)/index.html .PHONY: all -all: clean fmt-check lint terraform-fmt terraform-lint coverage create-junit-report create-coverage-files clean-tools +all: clean tidy fmt-check lint terraform-fmt terraform-lint coverage create-junit-report create-coverage-files clean-tools .PHONY: test test: ; $(info $(M) Running tests...) ## Run all unit tests @@ -63,6 +63,10 @@ create-coverage-files: | $(GOCOV) $(GOCOVXML); $(info $(M) Creating coverage fil @$(GOCMD) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML) @$(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML) +.PHONY: tidy +tidy: ; $(info $(M) Running go mod tidy...) @ + @$(GOMODTIDY) + .PHONY: lint lint: | $(GOLANGCILINT); $(info $(M) Running linter...) @ ## Run golangci-lint on all source files @$(BIN)/golangci-lint run @@ -104,7 +108,7 @@ validate-testdata: ; $(info $(M) Validating testdata agains terraform-provider-a release: ; $(info $(M) Generating release binaries and signatures...) @ ## Generate release binaries @./scripts/build.sh -.PHONY: ; clean +.PHONY: clean clean: ; $(info $(M) Removing 'tools' directory and test results...) @ ## Cleanup installed packages and test reports @rm -rf $(BIN) @rm -rf $(BIN)/test/tests.* $(BIN)/test/coverage From a7f60bef19313da9264cea6d47716ea7a92c1873 Mon Sep 17 00:00:00 2001 From: Shristi Singh Date: Fri, 5 Apr 2024 10:03:19 +0000 Subject: [PATCH 4/7] DXE-1865 Resolve CLI vulnerabilities Merge in DEVEXP/cli-terraform from feature/DXE-1865 to develop --- CHANGELOG.md | 2 ++ go.mod | 2 +- go.sum | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91383c3..30471a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ +* General + * Updated various dependencies * Image and Video Manager * Added handling of `SmartCrop` transformation when exporting image with `policy-as-hcl` flag diff --git a/go.mod b/go.mod index 93939d7..bf80159 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( ) require ( - github.com/AlecAivazis/survey/v2 v2.3.5 // indirect + github.com/AlecAivazis/survey/v2 v2.3.7 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/agext/levenshtein v1.2.1 // indirect diff --git a/go.sum b/go.sum index b9468e8..f84b78a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/AlecAivazis/survey/v2 v2.3.5 h1:A8cYupsAZkjaUmhtTYv3sSqc7LO5mp1XDfqe5E/9wRQ= github.com/AlecAivazis/survey/v2 v2.3.5/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI= +github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= +github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= @@ -144,6 +146,7 @@ github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/X github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= @@ -154,15 +157,21 @@ go.uber.org/ratelimit v0.2.0 h1:UQE2Bgi7p2B85uP5dC2bbRtig0C+OeNRnNEafLjsLPA= go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6mUg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -172,20 +181,30 @@ golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 1a7b8ef1c8ebe68921e7802c3a5cfb4bd15ce998 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Thu, 11 Apr 2024 14:08:19 +0200 Subject: [PATCH 5/7] DXE-3751 Release cli-terraform 1.14.0 --- CHANGELOG.md | 36 +- cli.json | 2 +- go.mod | 2 +- go.sum | 8 +- pkg/providers/imaging/templates/imaging.tmpl | 2 +- .../json/image_no_policies/imaging.tf | 2 +- .../testdata/json/image_policies/imaging.tf | 2 +- .../json/image_policies_as_hcl/imaging.tf | 2 +- .../json/image_policies_diff_prod/imaging.tf | 2 +- .../json/image_policies_jsondir/imaging.tf | 2 +- .../testdata/json/video_policies/imaging.tf | 2 +- .../json/video_policies_as_hcl/imaging.tf | 2 +- .../json/video_policies_diff_prod/imaging.tf | 2 +- .../json/video_policies_jsondir/imaging.tf | 2 +- .../testdata/only_policy_set/imaging.tf | 2 +- .../testdata/with_image_policies/imaging.tf | 2 +- .../with_image_policies_as_hcl/imaging.tf | 2 +- .../imaging.tf | 2 +- .../imaging.tf | 2 +- .../testdata/with_video_policies/imaging.tf | 2 +- .../with_video_policies_as_hcl/imaging.tf | 2 +- scripts/semtag | 627 ++++++++++++++++++ 22 files changed, 649 insertions(+), 60 deletions(-) create mode 100755 scripts/semtag diff --git a/CHANGELOG.md b/CHANGELOG.md index 30471a1..5757433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,49 +1,15 @@ # Release Notes -## Version X.XX.X (Month XX, XXXX) +## Version 1.14.0 (April 17, 2024) ### Features/Enhancements - - - - - * General * Updated various dependencies * Image and Video Manager * Added handling of `SmartCrop` transformation when exporting image with `policy-as-hcl` flag - - - - - -### Bug fixes - - - - - - - - - - - -### Deprecations - - - - - - - - - - - ## Version 1.13.0 (March 26, 2024) ### Features/Enhancements diff --git a/cli.json b/cli.json index 26e5ebc..a98cee4 100644 --- a/cli.json +++ b/cli.json @@ -5,7 +5,7 @@ "commands": [ { "name": "terraform", - "version": "1.13.0", + "version": "1.14.0", "description": "Administer and Manage Akamai Terraform configurations", "bin": "https://github.com/akamai/cli-terraform/releases/download/v{{.Version}}/akamai-{{.Name}}-{{.Version}}-{{.OS}}{{.Arch}}{{.BinSuffix}}", "auto-complete": true, diff --git a/go.mod b/go.mod index bf80159..97889da 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/akamai/cli-terraform go 1.21 require ( - github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.0.0 + github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.1.0 github.com/akamai/cli v1.5.6 github.com/fatih/color v1.13.0 github.com/hashicorp/hcl/v2 v2.11.1 diff --git a/go.sum b/go.sum index f84b78a..0a07bcb 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/AlecAivazis/survey/v2 v2.3.5 h1:A8cYupsAZkjaUmhtTYv3sSqc7LO5mp1XDfqe5E/9wRQ= -github.com/AlecAivazis/survey/v2 v2.3.5/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -11,8 +9,8 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.0.0 h1:6/5z5SK2NvSsgu19vHfh2lurMPaE9fwvSB/VIBizFRo= -github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.0.0/go.mod h1:ytNNwwgBIEeWJJCWy57vbkkEaYiCxWrYU68B/F0Gi5g= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.1.0 h1:peKT873AjrueDF69cYQolgE2ehxCpOw/8py4F43iU/M= +github.com/akamai/AkamaiOPEN-edgegrid-golang/v8 v8.1.0/go.mod h1:ytNNwwgBIEeWJJCWy57vbkkEaYiCxWrYU68B/F0Gi5g= github.com/akamai/cli v1.5.6 h1:L/QsSqligFRhMD+tKJoX9cwqbHnmojfqXw64HUfp6gk= github.com/akamai/cli v1.5.6/go.mod h1:PwHrS8f2vh1Kns2Hl1rtfMCq90ZfYLXI81zRGDTkMRs= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= @@ -183,13 +181,11 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= diff --git a/pkg/providers/imaging/templates/imaging.tmpl b/pkg/providers/imaging/templates/imaging.tmpl index 74003c7..1123e61 100644 --- a/pkg/providers/imaging/templates/imaging.tmpl +++ b/pkg/providers/imaging/templates/imaging.tmpl @@ -3,7 +3,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/image_no_policies/imaging.tf b/pkg/providers/imaging/testdata/json/image_no_policies/imaging.tf index 2ec22d2..d018de4 100644 --- a/pkg/providers/imaging/testdata/json/image_no_policies/imaging.tf +++ b/pkg/providers/imaging/testdata/json/image_no_policies/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/image_policies/imaging.tf b/pkg/providers/imaging/testdata/json/image_policies/imaging.tf index 11258e4..d5ddd74 100644 --- a/pkg/providers/imaging/testdata/json/image_policies/imaging.tf +++ b/pkg/providers/imaging/testdata/json/image_policies/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/image_policies_as_hcl/imaging.tf b/pkg/providers/imaging/testdata/json/image_policies_as_hcl/imaging.tf index 9ef3011..18b953c 100644 --- a/pkg/providers/imaging/testdata/json/image_policies_as_hcl/imaging.tf +++ b/pkg/providers/imaging/testdata/json/image_policies_as_hcl/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/image_policies_diff_prod/imaging.tf b/pkg/providers/imaging/testdata/json/image_policies_diff_prod/imaging.tf index 34df89a..d5d1b3c 100644 --- a/pkg/providers/imaging/testdata/json/image_policies_diff_prod/imaging.tf +++ b/pkg/providers/imaging/testdata/json/image_policies_diff_prod/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/image_policies_jsondir/imaging.tf b/pkg/providers/imaging/testdata/json/image_policies_jsondir/imaging.tf index 1be88ca..7d7f692 100644 --- a/pkg/providers/imaging/testdata/json/image_policies_jsondir/imaging.tf +++ b/pkg/providers/imaging/testdata/json/image_policies_jsondir/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/video_policies/imaging.tf b/pkg/providers/imaging/testdata/json/video_policies/imaging.tf index 5fe69b5..204a2f5 100644 --- a/pkg/providers/imaging/testdata/json/video_policies/imaging.tf +++ b/pkg/providers/imaging/testdata/json/video_policies/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/video_policies_as_hcl/imaging.tf b/pkg/providers/imaging/testdata/json/video_policies_as_hcl/imaging.tf index 9a2fcbe..52467c8 100644 --- a/pkg/providers/imaging/testdata/json/video_policies_as_hcl/imaging.tf +++ b/pkg/providers/imaging/testdata/json/video_policies_as_hcl/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/video_policies_diff_prod/imaging.tf b/pkg/providers/imaging/testdata/json/video_policies_diff_prod/imaging.tf index 48a7f29..a464048 100644 --- a/pkg/providers/imaging/testdata/json/video_policies_diff_prod/imaging.tf +++ b/pkg/providers/imaging/testdata/json/video_policies_diff_prod/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/json/video_policies_jsondir/imaging.tf b/pkg/providers/imaging/testdata/json/video_policies_jsondir/imaging.tf index 43a67e2..c1c6789 100644 --- a/pkg/providers/imaging/testdata/json/video_policies_jsondir/imaging.tf +++ b/pkg/providers/imaging/testdata/json/video_policies_jsondir/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/only_policy_set/imaging.tf b/pkg/providers/imaging/testdata/only_policy_set/imaging.tf index 2ec22d2..d018de4 100644 --- a/pkg/providers/imaging/testdata/only_policy_set/imaging.tf +++ b/pkg/providers/imaging/testdata/only_policy_set/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_image_policies/imaging.tf b/pkg/providers/imaging/testdata/with_image_policies/imaging.tf index 671766e..63bd42a 100644 --- a/pkg/providers/imaging/testdata/with_image_policies/imaging.tf +++ b/pkg/providers/imaging/testdata/with_image_policies/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_image_policies_as_hcl/imaging.tf b/pkg/providers/imaging/testdata/with_image_policies_as_hcl/imaging.tf index 3681b90..deb4930 100644 --- a/pkg/providers/imaging/testdata/with_image_policies_as_hcl/imaging.tf +++ b/pkg/providers/imaging/testdata/with_image_policies_as_hcl/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_image_policies_as_hcl_empty/imaging.tf b/pkg/providers/imaging/testdata/with_image_policies_as_hcl_empty/imaging.tf index 7edf502..32ed2ed 100644 --- a/pkg/providers/imaging/testdata/with_image_policies_as_hcl_empty/imaging.tf +++ b/pkg/providers/imaging/testdata/with_image_policies_as_hcl_empty/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_image_policies_as_hcl_with_imagetype/imaging.tf b/pkg/providers/imaging/testdata/with_image_policies_as_hcl_with_imagetype/imaging.tf index 0d65c2f..10f005b 100644 --- a/pkg/providers/imaging/testdata/with_image_policies_as_hcl_with_imagetype/imaging.tf +++ b/pkg/providers/imaging/testdata/with_image_policies_as_hcl_with_imagetype/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_video_policies/imaging.tf b/pkg/providers/imaging/testdata/with_video_policies/imaging.tf index 141d041..6990691 100644 --- a/pkg/providers/imaging/testdata/with_video_policies/imaging.tf +++ b/pkg/providers/imaging/testdata/with_video_policies/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/pkg/providers/imaging/testdata/with_video_policies_as_hcl/imaging.tf b/pkg/providers/imaging/testdata/with_video_policies_as_hcl/imaging.tf index 3614072..2d0bbf3 100644 --- a/pkg/providers/imaging/testdata/with_video_policies_as_hcl/imaging.tf +++ b/pkg/providers/imaging/testdata/with_video_policies_as_hcl/imaging.tf @@ -2,7 +2,7 @@ terraform { required_providers { akamai = { source = "akamai/akamai" - version = ">= 2.0.0" + version = ">= 6.1.0" } } required_version = ">= 1.0" diff --git a/scripts/semtag b/scripts/semtag new file mode 100755 index 0000000..8f00927 --- /dev/null +++ b/scripts/semtag @@ -0,0 +1,627 @@ +#!/usr/bin/env bash +# this file has semantic versioning script from https://github.com/pnikosis/semtag + +PROG=semtag +PROG_VERSION="v0.1.0" + +SEMVER_REGEX="^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" +IDENTIFIER_REGEX="^\-([0-9A-Za-z-]+)\.([0-9A-Za-z-]+)*$" + +# Global variables +FIRST_VERSION="v0.0.0" +finalversion=$FIRST_VERSION +lastversion=$FIRST_VERSION +hasversiontag="false" +scope="patch" +displayonly="false" +forcetag="false" +forcedversion= +versionname= +identifier= + +HELP="\ +Usage: + $PROG + $PROG getlast + $PROG getfinal + $PROG (final|alpha|beta|candidate) [-s (major|minor|patch|auto) | -o] + $PROG --help + $PROG --version +Options: + -s The scope that must be increased, can be major, minor or patch. + The resulting version will match X.Y.Z(-PRERELEASE)(+BUILD) + where X, Y and Z are positive integers, PRERELEASE is an optionnal + string composed of alphanumeric characters describing if the build is + a release candidate, alpha or beta version, with a number. + BUILD is also an optional string composed of alphanumeric + characters and hyphens. + Setting the scope as 'auto', the script will chose the scope between + 'minor' and 'patch', depending on the amount of lines added (<10% will + choose patch). + -v Specifies manually the version to be tagged, must be a valid semantic version + in the format X.Y.Z where X, Y and Z are positive integers. + -o Output the version only, shows the bumped version, but doesn't tag. + -f Forces to tag, even if there are unstaged or uncommited changes. +Commands: + --help Print this help message. + --version Prints the program's version. + get Returns both current final version and last tagged version. + getlast Returns the latest tagged version. + getfinal Returns the latest tagged final version. + getcurrent Returns the current version, based on the latest one, if there are uncommited or + unstaged changes, they will be reflected in the version, adding the number of + pending commits, current branch and commit hash. + final Tags the current build as a final version, this only can be done on the master branch. + candidate Tags the current build as a release candidate, the tag will contain all + the commits from the last final version. + alpha Tags the current build as an alpha version, the tag will contain all + the commits from the last final version. + beta Tags the current build as a beta version, the tag will contain all + the commits from the last final version." + +# Commands and options +ACTION="getlast" +ACTION="$1" +shift + +# We get the parameters +while getopts "v:s:of" opt; do + case $opt in + v) + forcedversion="$OPTARG" + ;; + s) + scope="$OPTARG" + ;; + o) + displayonly="true" + ;; + f) + forcetag="true" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +# Gets a string with the version and returns an array of maximum size of 5 with all the parts of the sematinc version +# $1 The string containing the version in semantic format +# $2 The variable to store the result array: +# position 0: major number +# position 1: minor number +# position 2: patch number +# position 3: identifier (or prerelease identifier) +# position 4: build info +function explode_version { + local __version=$1 + local __result=$2 + if [[ $__version =~ $SEMVER_REGEX ]] ; then + local __major=${BASH_REMATCH[1]} + local __minor=${BASH_REMATCH[2]} + local __patch=${BASH_REMATCH[3]} + local __prere=${BASH_REMATCH[4]} + local __build=${BASH_REMATCH[5]} + eval "$__result=(\"$__major\" \"$__minor\" \"$__patch\" \"$__prere\" \"$__build\")" + else + eval "$__result=" + fi +} + +# Compare two versions and returns -1, 0 or 1 +# $1 The first version to compare +# $2 The second version to compare +# $3 The variable where to store the result +function compare_versions { + local __first + local __second + explode_version $1 __first + explode_version $2 __second + local lv=$3 + + # Compares MAJOR, MINOR and PATCH + for i in 0 1 2; do + local __numberfirst=${__first[$i]} + local __numbersecond=${__second[$i]} + case $(($__numberfirst - $__numbersecond)) in + 0) + ;; + -[0-9]*) + eval "$lv=-1" + return 0 + ;; + [0-9]*) + eval "$lv=1" + return 0 + ;; + esac + done + + # Identifiers should compare with the ASCII order. + local __identifierfirst=${__first[3]} + local __identifiersecond=${__second[3]} + if [[ -n "$__identifierfirst" ]] && [[ -n "$__identifiersecond" ]]; then + if [[ "$__identifierfirst" > "$__identifiersecond" ]]; then + eval "$lv=1" + return 0 + elif [[ "$__identifierfirst" < "$__identifiersecond" ]]; then + eval "$lv=-1" + return 0 + fi + elif [[ -z "$__identifierfirst" ]] && [[ -n "$__identifiersecond" ]]; then + eval "$lv=1" + return 0 + elif [[ -n "$__identifierfirst" ]] && [[ -z "$__identifiersecond" ]]; then + eval "$lv=-1" + return 0 + fi + + eval "$lv=0" +} + +# Returns the last version of two +# $1 The first version to compare +# $2 The second version to compare +# $3 The variable where to store the last one +function get_latest_of_two { + local __first=$1 + local __second=$2 + local __result + local __latest=$3 + compare_versions $__first $__second __result + case $__result in + 0) + eval "$__latest=$__second" + ;; + -1) + eval "$__latest=$__second" + ;; + 1) + eval "$__latest=$__first" + ;; + esac +} + +# Assigns a 2 size array with the identifier, having the identifier at pos 0, and the number in pos 1 +# $1 The identifier in the format -id.# +# $2 The vferiable where to store the 2 size array +function explode_identifier { + local __identifier=$1 + local __result=$2 + if [[ $__identifier =~ $IDENTIFIER_REGEX ]] ; then + local __id=${BASH_REMATCH[1]} + local __number=${BASH_REMATCH[2]} + if [[ -z "$__number" ]]; then + __number=1 + fi + eval "$__result=(\"$__id\" \"$__number\")" + else + eval "$__result=" + fi +} + +# Gets a list of tags and assigns the base and latest versions +# Receives an array with the tags containing the versions +# Assigns to the global variables finalversion and lastversion the final version and the latest version +function get_latest { + local __taglist=("$@") + local __tagsnumber=${#__taglist[@]} + local __current + case $__tagsnumber in + 0) + finalversion=$FIRST_VERSION + lastversion=$FIRST_VERSION + ;; + 1) + __current=${__taglist[0]} + explode_version $__current ver + if [ -n "$ver" ]; then + if [ -n "${ver[3]}" ]; then + finalversion=$FIRST_VERSION + else + finalversion=$__current + fi + lastversion=$__current + else + finalversion=$FIRST_VERSION + lastversion=$FIRST_VERSION + fi + ;; + *) + local __lastpos=$(($__tagsnumber-1)) + for i in $(seq 0 $__lastpos) + do + __current=${__taglist[i]} + explode_version ${__taglist[i]} ver + if [ -n "$ver" ]; then + if [ -z "${ver[3]}" ]; then + get_latest_of_two $finalversion $__current finalversion + get_latest_of_two $lastversion $finalversion lastversion + else + get_latest_of_two $lastversion $__current lastversion + fi + fi + done + ;; + esac + + if git rev-parse -q --verify "refs/tags/$lastversion" >/dev/null; then + hasversiontag="true" + else + hasversiontag="false" + fi +} + +# Gets the next version given the provided scope +# $1 The version that is going to be bumped +# $2 The scope to bump +# $3 The variable where to stoer the result +function get_next_version { + local __exploded + local __fromversion=$1 + local __scope=$2 + local __result=$3 + explode_version $__fromversion __exploded + case $__scope in + major) + __exploded[0]=$((${__exploded[0]}+1)) + __exploded[1]=0 + __exploded[2]=0 + ;; + minor) + __exploded[1]=$((${__exploded[1]}+1)) + __exploded[2]=0 + ;; + patch) + __exploded[2]=$((${__exploded[2]}+1)) + ;; + esac + + eval "$__result=v${__exploded[0]}.${__exploded[1]}.${__exploded[2]}" +} + +function bump_version { + ## First we try to get the next version based on the existing last one + if [ "$scope" == "auto" ]; then + get_scope_auto scope + fi + + local __candidatefromlast=$FIRST_VERSION + local __explodedlast + explode_version $lastversion __explodedlast + if [[ -n "${__explodedlast[3]}" ]]; then + # Last version is not final + local __idlast + explode_identifier ${__explodedlast[3]} __idlast + + # We get the last, given the desired id based on the scope + __candidatefromlast="v${__explodedlast[0]}.${__explodedlast[1]}.${__explodedlast[2]}" + if [[ -n "$identifier" ]]; then + local __nextid="$identifier.1" + if [ "$identifier" == "${__idlast[0]}" ]; then + # We target the same identifier as the last so we increase one + __nextid="$identifier.$(( ${__idlast[1]}+1 ))" + __candidatefromlast="$__candidatefromlast-$__nextid" + else + # Different identifiers, we make sure we are assigning a higher identifier, if not, we increase the version + __candidatefromlast="$__candidatefromlast-$__nextid" + local __comparedwithlast + compare_versions $__candidatefromlast $lastversion __comparedwithlast + if [ "$__comparedwithlast" == -1 ]; then + get_next_version $__candidatefromlast $scope __candidatefromlast + __candidatefromlast="$__candidatefromlast-$__nextid" + fi + fi + fi + fi + + # Then we try to get the version based on the latest final one + local __candidatefromfinal=$FIRST_VERSION + get_next_version $finalversion $scope __candidatefromfinal + if [[ -n "$identifier" ]]; then + __candidatefromfinal="$__candidatefromfinal-$identifier.1" + fi + + # Finally we compare both candidates + local __resultversion + local __result + compare_versions $__candidatefromlast $__candidatefromfinal __result + case $__result in + 0) + __resultversion=$__candidatefromlast + ;; + -1) + __resultversion="$__candidatefromfinal" + ;; + 1) + __resultversion=$__candidatefromlast + ;; + esac + + eval "$1=$__resultversion" +} + +function increase_version { + local __version= + + if [ -z $forcedversion ]; then + bump_version __version + else + if [[ $forcedversion =~ $SEMVER_REGEX ]] ; then + compare_versions $forcedversion $lastversion __result + if [ $__result -le 0 ]; then + echo "Version can't be lower than last version: $lastversion" + exit 1 + fi + else + echo "Non valid version to bump" + exit 1 + fi + __version=$forcedversion + fi + + if [ "$displayonly" == "true" ]; then + echo "$__version" + else + if [ "$forcetag" == "false" ]; then + check_git_dirty_status + fi + local __commitlist + if [ "$finalversion" == "$FIRST_VERSION" ] || [ "$hasversiontag" != "true" ]; then + __commitlist="$(git log --pretty=oneline | cat)" + else + __commitlist="$(git log --pretty=oneline $finalversion... | cat)" + fi + + # If we are forcing a bump, we add bump to the commit list + if [[ -z $__commitlist && "$forcetag" == "true" ]]; then + __commitlist="bump" + fi + + if [[ -z $__commitlist ]]; then + echo "No commits since the last final version, not bumping version" + else + if [[ -z $versionname ]]; then + versionname=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + fi + local __message="$versionname +$__commitlist" + + # We check we have info on the user + local __username=$(git config user.name) + if [ -z "$__username" ]; then + __username=$(id -u -n) + git config user.name $__username + fi + local __useremail=$(git config user.email) + if [ -z "$__useremail" ]; then + __useremail=$(hostname) + git config user.email "$__username@$__useremail" + fi + + git tag -a $__version -m "$__message" + + # If we have a remote, we push there + local __remotes=$(git remote) + if [[ -n $__remotes ]]; then + for __remote in $__remotes; do + git push $__remote $__version > /dev/null + if [ $? -eq 0 ]; then + echo "$__version pushed to $__remote" + else + echo "Error pushing the tag $__version to $__remote" + exit 1 + fi + done + else + echo "$__version" + fi + fi + fi +} + +function check_git_dirty_status { + local __repostatus= + get_work_tree_status __repostatus + + if [ "$__repostatus" == "uncommitted" ]; then + echo "ERROR: You have uncommitted changes" + git status --porcelain + exit 1 + fi + + if [ "$__repostatus" == "unstaged" ]; then + echo "ERROR: You have unstaged changes" + git status --porcelain + exit 1 + fi +} + +# Get the total amount of lines of code in the repo +function get_total_lines { + local __empty_id="$(git hash-object -t tree /dev/null)" + local __changes="$(git diff --numstat $__empty_id | cat)" + local __added_deleted=$1 + get_changed_lines "$__changes" $__added_deleted +} + +# Get the total amount of lines of code since the provided tag +function get_sincetag_lines { + local __sincetag=$1 + local __changes="$(git diff --numstat $__sincetag | cat)" + local __added_deleted=$2 + get_changed_lines "$__changes" $__added_deleted +} + +function get_changed_lines { + local __changes_numstat=$1 + local __result=$2 + IFS=$'\n' read -rd '' -a __changes_array <<<"$__changes_numstat" + local __diff_regex="^([0-9]+)[[:space:]]+([0-9]+)[[:space:]]+.+$" + + local __total_added=0 + local __total_deleted=0 + for i in "${__changes_array[@]}" + do + if [[ $i =~ $__diff_regex ]] ; then + local __added=${BASH_REMATCH[1]} + local __deleted=${BASH_REMATCH[2]} + __total_added=$(( $__total_added+$__added )) + __total_deleted=$(( $__total_deleted+$__deleted )) + fi + done + eval "$2=( $__total_added $__total_deleted )" +} + +function get_scope_auto { + local __verbose=$2 + local __total=0 + local __since=0 + local __scope= + + get_total_lines __total + get_sincetag_lines $finalversion __since + + local __percentage=0 + if [ "$__total" != "0" ]; then + local __percentage=$(( 100*$__since/$__total )) + if [ $__percentage -gt "10" ]; then + __scope="minor" + else + __scope="patch" + fi + fi + + eval "$1=$__scope" + if [[ -n "$__verbose" ]]; then + echo "[Auto Scope] Percentage of lines changed: $__percentage" + echo "[Auto Scope] : $__scope" + fi +} + +function get_work_tree_status { + # Update the index + git update-index -q --ignore-submodules --refresh > /dev/null + eval "$1=" + + if ! git diff-files --quiet --ignore-submodules -- > /dev/null + then + eval "$1=unstaged" + fi + + if ! git diff-index --cached --quiet HEAD --ignore-submodules -- > /dev/null + then + eval "$1=uncommitted" + fi +} + +function get_current { + if [ "$hasversiontag" == "true" ]; then + local __commitcount="$(git rev-list $lastversion.. --count)" + else + local __commitcount="$(git rev-list --count HEAD)" + fi + local __status= + get_work_tree_status __status + + if [ "$__commitcount" == "0" ] && [ -z "$__status" ]; then + eval "$1=$lastversion" + else + local __buildinfo="$(git rev-parse --short HEAD)" + local __currentbranch="$(git rev-parse --abbrev-ref HEAD)" + if [ "$__currentbranch" != "master" ]; then + __buildinfo="$__currentbranch.$__buildinfo" + fi + + local __suffix= + if [ "$__commitcount" != "0" ]; then + if [ -n "$__suffix" ]; then + __suffix="$__suffix." + fi + __suffix="$__suffix$__commitcount" + fi + if [ -n "$__status" ]; then + if [ -n "$__suffix" ]; then + __suffix="$__suffix." + fi + __suffix="$__suffix$__status" + fi + + __suffix="$__suffix+$__buildinfo" + if [ "$lastversion" == "$finalversion" ]; then + scope="patch" + identifier= + local __bumped= + bump_version __bumped + eval "$1=$__bumped-dev.$__suffix" + else + eval "$1=$lastversion.$__suffix" + fi + fi +} + +function init { + git fetch > /dev/null + TAGS="$(git tag)" + IFS=$'\n' read -rd '' -a TAG_ARRAY <<<"$TAGS" + + get_latest ${TAG_ARRAY[@]} + currentbranch="$(git rev-parse --abbrev-ref HEAD)" +} + +case $ACTION in + --help) + echo -e "$HELP" + ;; + --version) + echo -e "${PROG}: $PROG_VERSION" + ;; + final) + init + diff=$(git diff master | cat) + diff_dev=$(git diff develop | cat) + if [ "$forcetag" == "false" ]; then + if [ -n "$diff_dev" ] && [ -n "$diff" ]; then + echo "ERROR: Branch must be updated with develop, or master for final versions" + exit 1 + fi + fi + increase_version + ;; + alpha|beta) + init + identifier="$ACTION" + increase_version + ;; + candidate) + init + identifier="rc" + increase_version + ;; + getlast) + init + echo "$lastversion" + ;; + getfinal) + init + echo "$finalversion" + ;; + getcurrent) + init + get_current current + echo "$current" + ;; + get) + init + echo "Current final version: $finalversion" + echo "Last tagged version: $lastversion" + ;; + *) + echo "'$ACTION' is not a valid command, see --help for available commands." + ;; +esac From 7bbdf8535745d4684c7f1a2d3ffd931a7c673bc7 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Fri, 12 Apr 2024 12:33:47 +0200 Subject: [PATCH 6/7] DXE-3751 Release cli-terraform 1.14.0 --- cli/cli.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cli.go b/cli/cli.go index 025a0d5..b059f0f 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -33,7 +33,7 @@ import ( var ( // Version holds current version of cli-terraform - Version = "1.13.0" + Version = "1.14.0" ) // Run initializes the cli and runs it From 71ed27522aa06684e3144dab9f7ddc0e6242402e Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Mon, 22 Apr 2024 14:44:52 +0000 Subject: [PATCH 7/7] DXE-3751 Release cli-terraform 1.14.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5757433..f84c57c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes -## Version 1.14.0 (April 17, 2024) +## Version 1.14.0 (April 23, 2024) ### Features/Enhancements