Comments (6)
This script will update network rules that will be applied to all namespaces of the "Runtime" type. It will prohibit these namespaces from outbound traffic to specific IP addresses.
The script will update the network rules, which will be applied to all namespaces with the "Runtime" type. These namespaces will be prohibited from flowing to specific IPs.
from go.
如果你想从已经配置的gcloud账户中获取账户信息,你可以使用以下方式来实现:
# 获取当前的gcloud账户
current_account=$(gcloud config get-value account)
# 撤销授权
gcloud auth revoke "$sa"
# 设置账户为之前获取的账户
gcloud config set account "$current_account"
这样,脚本首先使用 gcloud config get-value account
命令获取当前的gcloud账户,并将其存储在 current_account
变量中。然后,它执行撤销授权操作,最后再将账户设置为之前获取的账户。这样就能确保在操作之前获取并保存了当前的账户信息。
from go.
如果你想让以 "sit" 开头的 ${environment}
也执行 "prd" 逻辑,你可以将这两个条件合并在一起,像这样:
if [[ ${environment} == prd* || ${environment} == sit* ]]; then
echo "Setting proxy prd proxy"
else
echo "Setting proxy dev proxy"
fi
在这个修改后的脚本中,我使用 ||
运算符将两个条件组合在一起。现在,如果 ${environment}
以 "prd" 开头或者以 "sit" 开头,都会执行 "Setting proxy prd proxy" 的逻辑,否则将执行 "Setting proxy dev proxy" 的逻辑。这样就满足了你的要求。
from go.
if [[ ${environment} == prd* || ${environment} == dev* ]]; then
echo "Setting proxy prd proxy"
else
echo "Setting proxy otherproxy"
fi
from go.
if [[ ${environment} =~ ^(dev|prd).* ]]; then
echo "Setting proxy prd proxy"
else
echo "Setting proxy otherproxy"
fi
from go.
To add a condition to the existing script to check if the environment variable environment
matches either dev*
or prd*
, you can use the following syntax:
if [[ ${environment} =~ ^(dev|prd) ]]; then
echo "Setting proxy prd proxy"
else
echo "Setting proxy otherproxy"
fi
Here, the =~
operator is used to perform a regular expression match against the value of the environment
variable. The regular expression ^(dev|prd)
matches any string that starts with either dev
or prd
.
If the regular expression matches, the script will execute the echo
command to print the message "Setting proxy prd proxy". If the regular expression does not match, the script will execute the echo
command to print the message "Setting proxy otherproxy".
Note that the ^
anchor at the beginning of the regular expression ensures that the match occurs only at the beginning of the string. This is important because otherwise, the regular expression would also match strings like "devtest" or "prdtest", which may not be desirable.
from go.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.