I tried the script and it was not working, after some initial research I found that the v2beta1 should be replaced by v2beta2 because I was upgrading slightly newer version so I had to run all commands one by one and finally figured it out by outputting the metadata and searching the output.