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

docs: secret demo #804

Merged
merged 3 commits into from
Oct 8, 2022
Merged
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
35 changes: 35 additions & 0 deletions docs/en/start/secret/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Once finished, the layotto file will be generated in the directory, run it:
```

### Step 2: Run the client program and call Layotto to get the secret
<!-- tabs:start -->
### **Go**

```shell
cd ${project_path}/demo/secret/common/
Expand All @@ -50,6 +52,39 @@ data:{key:"db-user-pass:password" value:"S!S*d$zDsb="}
data:{key:"db-user-pass:password" value:{secrets:{key:"db-user-pass:password" value:"S!S*d$zDsb="}}} data:{key:"db-user-pass:username" value:{secrets:{key:"db-user-pass:username" value:"devuser"}}}
```

### **Java**

Download java sdk and examples:

```shell @if.not.exist java-sdk
git clone https://github.com/layotto/java-sdk
```

Change directory:

```shell
cd java-sdk
```

Build:

```shell @if.not.exist examples-secret/target/examples-secret-jar-with-dependencies.jar
# build example jar
mvn -f examples-secret/pom.xml clean package
```

Run the examples:

```shell
java -jar examples-secret/target/examples-secret-jar-with-dependencies.jar
```

And you will see:

```bash
{db-user-pass:password=S!S*d$zDsb=}
{redisPassword={redisPassword=redis123}, db-user-pass:password={db-user-pass:password=S!S*d$zDsb=}, db-user-pass:username={db-user-pass:username=devuser}}
```
<!-- tabs:end -->
## Want to learn more about Secret API?
Layotto reuse Dapr Secret API,learn more:https://docs.dapr.io/operations/components/setup-secret-store/
34 changes: 34 additions & 0 deletions docs/zh/start/secret/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ go build -o layotto
```

### 第二步:运行客户端程序,调用 Layotto 获取 secret
<!-- tabs:start -->
### **Go**

```shell
cd ${project_path}/demo/secret/common/
Expand All @@ -49,6 +51,38 @@ data:{key:"db-user-pass:password" value:"S!S*d$zDsb="}
data:{key:"db-user-pass:password" value:{secrets:{key:"db-user-pass:password" value:"S!S*d$zDsb="}}} data:{key:"db-user-pass:username" value:{secrets:{key:"db-user-pass:username" value:"devuser"}}}
```

### **Java**
下载 java sdk 和示例代码:

```shell @if.not.exist java-sdk
git clone https://github.com/layotto/java-sdk
```

切换目录:

```shell
cd java-sdk
```

构建:

```shell @if.not.exist examples-secret/target/examples-secret-jar-with-dependencies.jar
# build example jar
mvn -f examples-secret/pom.xml clean package
```

运行:

```shell
java -jar examples-secret/target/examples-secret-jar-with-dependencies.jar
```

打印出以下信息说明运行成功:

```bash
{db-user-pass:password=S!S*d$zDsb=}
{redisPassword={redisPassword=redis123}, db-user-pass:password={db-user-pass:password=S!S*d$zDsb=}, db-user-pass:username={db-user-pass:username=devuser}}
```
<!-- tabs:end -->
## 想要详细了解Secret API?
Layotto复用了Dapr的Secret API,了解更多:https://docs.dapr.io/operations/components/setup-secret-store/