Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local build + set platform to linux/amd64 #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Usage: $0
[--version]

required arguments:
--version Specify the version for image
--version Specify the version for image
EOF
exit 1
}
Expand All @@ -19,15 +19,15 @@ function handle_parameters() {
--version )
version="$2"
shift
;;
;;
esac
shift
done

if [ "$version" == "" ]; then
echo "version is missing"
usage
fi
fi
}


Expand All @@ -49,13 +49,14 @@ GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build \
.

echo "Building $image:latest docker image"
docker build --build-arg PRODUCT_VERSION="$version" --no-cache -t $image:latest .
docker build --platform linux/amd64 --build-arg PRODUCT_VERSION="$version" --no-cache -t $image:latest .
tuvia-akeyless marked this conversation as resolved.
Show resolved Hide resolved
docker tag "$image":latest "$docker_repo/$image":"$version"

docker login
echo "Docker login Succeeded"

#Push image
docker push "$docker_repo/$image"
docker push "$docker_repo/$image:$version"

rm -rf dist/
56 changes: 56 additions & 0 deletions build_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -e
function usage() {
cat <<EOF
Usage: $0
[--version]

required arguments:
--version Specify the version for image
EOF
exit 1
}


function handle_parameters() {
version=""
until [ -z $1 ]; do
case $1 in
--version )
version="$2"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can lead to UB in case that there is flag --version but there is no value for it.
consider adding this validation:

if [ -n "$2" ]; then
    version="$2"
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no value you will get usage text:
version is missing
Usage: ./build_local.sh
[--version]

required arguments:
--version Specify the version for image

shift
;;
esac
shift
done

if [ "$version" == "" ]; then
echo "version is missing"
usage
fi
}


# ========== Start main script ============

handle_parameters $*

image="akeyless/akeyless-csi-provider"
docker_repo="docker.io"
arc='amd64'
os='linux'
versionVar="akeyless.io/akeyless-csi-provider/internal/version.Version=$version"
buildDateVar="akeyless.io/akeyless-csi-provider/go/src/internal/version.BuildDate=$(date -u +%Y%m%d.%H%M%S)"
goVer="github.com/akeylesslabs/akeyless-csi-provider/internal/version.GoVersion=$(go version)"

GOOS=$os GOARCH=$arc CGO_ENABLED=0 go build \
-ldflags "-w -s -X $versionVar -X $buildDateVar" \
-o dist/ \
.

echo "Building $image:latest docker image"
eval $(minikube docker-env)
docker build --build-arg PRODUCT_VERSION="$version" --load -t $image:latest .

docker tag "$image":latest "$docker_repo/$image":"$version"
rm -rf dist/
6 changes: 3 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (p *Provider) HandleMountRequest(ctx context.Context, cfg config.Config) (*
}

func (p *Provider) GetRotatedSecret(ctx context.Context, itemName string, cfg config.Config) (string, error) {
body := akeyless.GetRotatedSecretValue{
Names: itemName,
body := akeyless.RotatedSecretGetValue{
Name: itemName,
}
body.SetJson(true)
if cfg.UsingUID() {
Expand All @@ -207,7 +207,7 @@ func (p *Provider) GetRotatedSecret(ctx context.Context, itemName string, cfg co
body.SetToken(config.GetAuthToken())
}

gsvOut, res, err := config.AklClient.GetRotatedSecretValue(ctx).Body(body).Execute()
gsvOut, res, err := config.AklClient.RotatedSecretGetValue(ctx).Body(body).Execute()
if err != nil {
if errors.As(err, &apiErr) {
return "", fmt.Errorf("can't get secret value: %v", string(apiErr.Body()))
Expand Down