From 375a297111d4d93edd6ede3e2f837f114e9f9f64 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Thu, 24 Nov 2022 17:48:31 +0000 Subject: [PATCH 1/4] DXE-1762 Documentation changes (for V1) Merge in DEVEXP/akamaiopen-edgegrid-golang from feature/DXE-1762-plan-steps-for-moving-edgegird-golang-v2-into-master-for-v1 to v1 --- .github/workflows/checks.yml | 2 +- README.md | 25 ++++++++++++------------- scripts/semtag | 8 ++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 43b6363b..183cbf76 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -5,7 +5,7 @@ on: - "*" pull_request: branches: - - master + - v1 jobs: test: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 21b44fd7..3258bd08 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,24 @@ # Akamai OPEN EdgeGrid for GoLang v1 -[![Build Status](https://travis-ci.org/akamai/AkamaiOPEN-edgegrid-golang.svg?branch=master)](https://travis-ci.org/akamai/AkamaiOPEN-edgegrid-golang) +[![Build Status](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/actions/workflows/checks.yml/badge.svg?branch=v1)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/actions/workflows/checks.yml?query=branch%3Av1) [![GoDoc](https://godoc.org/github.com/akamai/AkamaiOPEN-edgegrid-golang?status.svg)](https://godoc.org/github.com/akamai/AkamaiOPEN-edgegrid-golang) [![Go Report Card](https://goreportcard.com/badge/github.com/akamai/AkamaiOPEN-edgegrid-golang)](https://goreportcard.com/report/github.com/akamai/AkamaiOPEN-edgegrid-golang) -[![License](http://img.shields.io/:license-apache-blue.svg)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/master/LICENSE) +[![License](http://img.shields.io/:license-apache-blue.svg)](https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/v1/LICENSE) This library implements an Authentication handler for [net/http](https://golang.org/pkg/net/http/) -that provides the [Akamai OPEN Edgegrid Authentication](https://developer.akamai.com/introduction/Client_Auth.html) -scheme. For more information visit the [Akamai OPEN Developer Community](https://developer.akamai.com). This library -has been released as a v1 library though future development will be on the v2 branch +that provides the [Akamai OPEN Edgegrid Authentication](https://developer.akamai.com/introduction/Client_Auth.html) scheme. +For more information visit the [Akamai OPEN Developer Community](https://developer.akamai.com). +This library has been released as a v1 library though future development will be on the **develop** branch for version v3. -## Announcing Akamai OPEN EdgeGrid for GoLang v2 (release v2.0.0) +## Announcing Akamai OPEN EdgeGrid for GoLang v3 (release v3.0.0) -The v2 branch of this module is under active development and provides a subset of Akamai APIs for use in the -Akamai Terraform Provider. The v2 branch **does not yet** implement the full set of Akamai endpoints supported by the -0.x and 1.x releases. +The v3 version of this module is under active development and provides a subset of Akamai APIs for use in the +Akamai Terraform Provider. -New users are encouraged to adopt v2 branch it is a simpler API wrapper with little to no business logic. +New users are encouraged to adopt v3 version it is a simpler API wrapper with little to no business logic. -Current direct users of this v0.9 library are recommended to continue to use the the v1 version as initialization -and package structure has significantly changed in v2 and will require substantial work to migrate existing +Current direct users of this v1.x.x library are recommended to continue to use the v1 version as initialization +and package structure has significantly changed in v3 and will require substantial work to migrate existing applications. Non-backwards compatible changes were made to improve the code quality and make the project more maintainable. @@ -180,7 +179,7 @@ Alternatively, your program can read it from config struct. ## Contribute -1. Fork [the repository](https://github.com/akamai/AkamaiOPEN-edgegrid-golang) to start making your changes to the **master** branch +1. Fork [the repository](https://github.com/akamai/AkamaiOPEN-edgegrid-golang) to start making your changes to the **v1** branch 2. Send a pull request. ## Author diff --git a/scripts/semtag b/scripts/semtag index bb2d25d0..6fb97776 100755 --- a/scripts/semtag +++ b/scripts/semtag @@ -584,11 +584,11 @@ case $ACTION in final) init diff=$(git diff master | cat) - diff_dev=$(git diff develop | cat) - diff_v2=$(git diff v2 | cat) + diff_dev=$(git diff develop-v1 | cat) + diff_v1=$(git diff v1 | cat) if [ "$forcetag" == "false" ]; then - if [ -n "$diff_dev" ] && [ -n "$diff" ] && [ -n "$diff_v2" ]; then - echo "ERROR: Branch must be updated with develop, master, or v2 for final versions" + if [ -n "$diff_dev" ] && [ -n "$diff" ] && [ -n "$diff_v1" ]; then + echo "ERROR: Branch must be updated with develop, master, or v1 for final versions" fi if [ -n "$diff" ]; then echo "ERROR: Branch must be updated with master for final versions" From de2faa53db7d8e78f4f7a9c9891f0dc6338d65ae Mon Sep 17 00:00:00 2001 From: "Zagrajczuk, Wojciech" Date: Tue, 6 Dec 2022 14:20:04 +0100 Subject: [PATCH 2/4] DXE-1895 Update changelog for release 1.2.2 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f81bce..03b049c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # EDGEGRID GOLANG RELEASE NOTES +## 1.2.2 (Dec 07, 2022) + +#### FEATURES/ENHANCEMENTS: +* Updated dependencies + ## 1.2.1 (Jul 14, 2022) #### BUG FIXES: From 4468d4229c2ea37542554253a8c688e97ee16396 Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Wed, 7 Dec 2022 11:35:21 +0100 Subject: [PATCH 3/4] DXE-1893 Release AkamaiOpen Edgegrid Golang 1.2.2 DXE-1920 update script to v0.1.2 --- scripts/semtag | 181 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 143 insertions(+), 38 deletions(-) diff --git a/scripts/semtag b/scripts/semtag index 6fb97776..a8d0134d 100755 --- a/scripts/semtag +++ b/scripts/semtag @@ -1,11 +1,14 @@ #!/usr/bin/env bash -# this file has semantic versioning script from https://github.com/pnikosis/semtag PROG=semtag -PROG_VERSION="v0.1.0" +PROG_VERSION="v0.1.2" 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-]+)*$" +IDENTIFIER_REGEX="^\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*$" +NUMERIC_REGEX='^[0-9]+$' + +# Length limit for the branch name in build metadata. +MAX_BRANCH_LENGTH=50 # Global variables FIRST_VERSION="v0.0.0" @@ -15,6 +18,7 @@ hasversiontag="false" scope="patch" displayonly="false" forcetag="false" +prefix="v" forcedversion= versionname= identifier= @@ -42,6 +46,7 @@ Options: 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. + -p Use a plain version, ie. do not prefix with 'v'. Commands: --help Print this help message. --version Prints the program's version. @@ -51,7 +56,7 @@ Commands: 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. + final Tags the current build as a final version, this only can be done on the default 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 @@ -65,7 +70,7 @@ ACTION="$1" shift # We get the parameters -while getopts "v:s:of" opt; do +while getopts "v:s:ofp" opt; do case $opt in v) forcedversion="$OPTARG" @@ -79,6 +84,9 @@ while getopts "v:s:of" opt; do f) forcetag="true" ;; + p) + prefix="" + ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -90,6 +98,25 @@ while getopts "v:s:of" opt; do esac done +# Try to programmatically fetch the default branch. Go by the first remote HEAD found, otherwise default to `master`. +# $1 The variable to store the result +function get_default_branch { + local __result=$1 + + local __remotes=$(git remote) + if [[ -n $__remotes ]]; then + for __remote in $__remotes; do + local __default_branch_ref=$(git symbolic-ref --quiet refs/remotes/${__remote}/HEAD || true) + local __default_branch=${__default_branch_ref#refs/remotes/${__remote}/} + if [[ -n ${__default_branch} ]]; then + break + fi + done + fi + + eval "${__result}=${__default_branch:-master}" +} + # 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: @@ -145,23 +172,45 @@ function compare_versions { # 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 + compare_identifiers "${__first[3]}" "${__second[3]}" compareresult + eval "$lv=$compareresult" +} + + +# Returns the number comparison +# $1 The first number to compare +# $2 The second number to compare +# $3 The variable where to store the result +function compare_numeric { + local __first=$1 + local __second=$2 + local __result=$3 + + if (( "$__first" < "$__second" )) ; then + eval "$__result=-1" + elif (( "$__first" > "$__second" )) ; then + eval "$__result=1" + else + eval "$__result=0" fi +} + +# Returns the alpanumeric comparison +# $1 The first alpanumeric to compare +# $2 The second alpanumeric to compare +# $3 The variable where to store the result +function compare_alphanumeric { + local __first=$1 + local __second=$2 + local __result=$3 - eval "$lv=0" + if [[ "$__first" < "$__second" ]] ; then + eval "$__result=-1" + elif [[ "$__first" > "$__second" ]] ; then + eval "$__result=1" + else + eval "$__result=0" + fi } # Returns the last version of two @@ -173,6 +222,7 @@ function get_latest_of_two { local __second=$2 local __result local __latest=$3 + compare_versions $__first $__second __result case $__result in 0) @@ -187,6 +237,69 @@ function get_latest_of_two { esac } +# Returns comparison of two identifier parts +# $1 The first part to compare +# $2 The second part to compare +# $3 The variable where to store the compare result +function compare_identifier_part { + local __first=$1 + local __second=$2 + local __result=$3 + local compareresult + + if [[ "$__first" =~ $NUMERIC_REGEX ]] && [[ "$__second" =~ $NUMERIC_REGEX ]] ; then + compare_numeric "$__first" "$__second" compareresult + eval "$__result=$compareresult" + return 0 + fi + + + compare_alphanumeric "$__first" "$__second" compareresult + eval "$__result=$compareresult" +} + +# Returns comparison of two identifiers +# $1 The first identifier to compare +# $2 The second identifier to compare +# $3 The variable where to store the compare result +function compare_identifiers { + local __first=$1 + local __second=$2 + local __result=$3 + local partresult + local arraylengths + if [[ -n "$__first" ]] && [[ -n "$__second" ]]; then + explode_identifier "${__first}" explodedidentifierfirst + explode_identifier "${__second}" explodedidentifiersecond + + firstsize=${#explodedidentifierfirst[@]} + secondsize=${#explodedidentifiersecond[@]} + minlength=$(( $firstsize<$secondsize ? $firstsize : $secondsize )) + for (( i = 0 ; i < $minlength ; i++ )); do + compare_identifier_part "${explodedidentifierfirst[$i]}" "${explodedidentifiersecond[$i]}" partresult + case $partresult in + 0) + ;; + *) + eval "$__result=$partresult" + return 0 + ;; + esac + done + compare_numeric $firstsize $secondsize arraylengths + eval "$__result=$arraylengths" + return 0 + elif [[ -z "$__first" ]] && [[ -n "$__second" ]]; then + eval "$__result=1" + return 0 + elif [[ -n "$__first" ]] && [[ -z "$__second" ]]; then + eval "$__result=-1" + return 0 + fi + + eval "$__result=0" +} + # 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 @@ -194,12 +307,8 @@ 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\")" + IFS='-.' read -ra identifierparts <<< $__identifier + eval "$__result=( ${identifierparts[@]} )" else eval "$__result=" fi @@ -282,7 +391,7 @@ function get_next_version { ;; esac - eval "$__result=v${__exploded[0]}.${__exploded[1]}.${__exploded[2]}" + eval "$__result=${prefix}${__exploded[0]}.${__exploded[1]}.${__exploded[2]}" } function bump_version { @@ -300,7 +409,7 @@ function bump_version { 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]}" + __candidatefromlast="${prefix}${__explodedlast[0]}.${__explodedlast[1]}.${__explodedlast[2]}" if [[ -n "$identifier" ]]; then local __nextid="$identifier.1" if [ "$identifier" == "${__idlast[0]}" ]; then @@ -533,7 +642,8 @@ function get_current { eval "$1=$lastversion" else local __buildinfo="$(git rev-parse --short HEAD)" - local __currentbranch="$(git rev-parse --abbrev-ref HEAD)" + local __currentbranch="$(git rev-parse --abbrev-ref HEAD | cut -c1-$MAX_BRANCH_LENGTH)" + get_default_branch default_branch if [ "$__currentbranch" != "master" ]; then __buildinfo="$__currentbranch.$__buildinfo" fi @@ -566,8 +676,7 @@ function get_current { } function init { - git fetch > /dev/null - TAGS="$(git tag)" + TAGS="$(git tag --merged)" IFS=$'\n' read -rd '' -a TAG_ARRAY <<<"$TAGS" get_latest ${TAG_ARRAY[@]} @@ -583,15 +692,11 @@ case $ACTION in ;; final) init - diff=$(git diff master | cat) - diff_dev=$(git diff develop-v1 | cat) - diff_v1=$(git diff v1 | cat) + get_default_branch default_branch + diff=$(git diff $default_branch | cat) if [ "$forcetag" == "false" ]; then - if [ -n "$diff_dev" ] && [ -n "$diff" ] && [ -n "$diff_v1" ]; then - echo "ERROR: Branch must be updated with develop, master, or v1 for final versions" - fi if [ -n "$diff" ]; then - echo "ERROR: Branch must be updated with master for final versions" + echo "ERROR: Branch must be updated with $default_branch for final versions" exit 1 fi fi From bf58746e5917740fb9ddb3f978438738b54824cf Mon Sep 17 00:00:00 2001 From: Michal Wojcik Date: Wed, 7 Dec 2022 11:36:32 +0100 Subject: [PATCH 4/4] DXE-1893 Release AkamaiOpen Edgegrid Golang 1.2.2 DXE-1920 Fix semtag script in v1 after v2-v3 transformaiton --- scripts/semtag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/semtag b/scripts/semtag index a8d0134d..3f70028c 100755 --- a/scripts/semtag +++ b/scripts/semtag @@ -106,8 +106,8 @@ function get_default_branch { local __remotes=$(git remote) if [[ -n $__remotes ]]; then for __remote in $__remotes; do - local __default_branch_ref=$(git symbolic-ref --quiet refs/remotes/${__remote}/HEAD || true) - local __default_branch=${__default_branch_ref#refs/remotes/${__remote}/} + local __default_branch_ref=$(git symbolic-ref --quiet --short HEAD || true) + local __default_branch=${__default_branch_ref#refs/heads/} if [[ -n ${__default_branch} ]]; then break fi