Skip to content

Commit 39b0e41

Browse files
feat: add params for auto-injection
1 parent 91b16de commit 39b0e41

23 files changed

+1468
-948
lines changed

agent/proto/agent.pb.go

Lines changed: 1034 additions & 931 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/proto/agent.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ message Manifest {
9898
repeated WorkspaceApp apps = 11;
9999
repeated WorkspaceAgentMetadata.Description metadata = 12;
100100
repeated WorkspaceAgentDevcontainer devcontainers = 17;
101+
102+
map<string,Secret> user_secrets = 19;
103+
}
104+
105+
message Secret {
106+
string name = 1;
107+
string env_name = 2;
108+
string file_path = 3;
101109
}
102110

103111
message WorkspaceAgentDevcontainer {

cli/user_secrets.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func (r *RootCmd) secretCreate() *serpent.Command {
2626
client := new(codersdk.Client)
2727
var value string
2828
var description string
29+
var envName string
30+
var filePath string
2931
cmd := &serpent.Command{
3032
Use: "create <name>",
3133
Short: "Create a new user secret",
@@ -42,6 +44,8 @@ func (r *RootCmd) secretCreate() *serpent.Command {
4244
Name: name,
4345
Value: value,
4446
Description: description,
47+
EnvName: envName,
48+
FilePath: filePath,
4549
})
4650
if err != nil {
4751
return err
@@ -61,6 +65,16 @@ func (r *RootCmd) secretCreate() *serpent.Command {
6165
Description: "Description of the secret.",
6266
Value: serpent.StringOf(&description),
6367
},
68+
{
69+
Flag: "env_name",
70+
Description: "Environment variable name of the secret.",
71+
Value: serpent.StringOf(&envName),
72+
},
73+
{
74+
Flag: "file_path",
75+
Description: "File path of the secret.",
76+
Value: serpent.StringOf(&filePath),
77+
},
6478
}
6579
return cmd
6680
}
@@ -79,9 +93,10 @@ func (r *RootCmd) secretList() *serpent.Command {
7993
if err != nil {
8094
return err
8195
}
82-
fmt.Fprintf(inv.Stdout, "ID | Name | Description\n")
96+
fmt.Fprintf(inv.Stdout, "ID | Name | Description | EnvName | FilePath\n")
8397
for _, secret := range secretList.Secrets {
84-
fmt.Fprintf(inv.Stdout, "%v - %v - %v\n", secret.ID, secret.Name, secret.Description)
98+
fmt.Fprintf(inv.Stdout, "%v - %v - %v - %v - %v\n",
99+
secret.ID, secret.Name, secret.Description, secret.EnvName, secret.FilePath)
85100
}
86101
return nil
87102
},
@@ -118,8 +133,9 @@ func (r *RootCmd) secretGet() *serpent.Command {
118133
}
119134
value := userSecretValue.Value
120135

121-
fmt.Fprintf(inv.Stdout, "ID | Name | Description | Value\n")
122-
fmt.Fprintf(inv.Stdout, "%v - %v - %v - %v\n", secret.ID, secret.Name, secret.Description, value)
136+
fmt.Fprintf(inv.Stdout, "ID | Name | Description | Value | EnvName | FilePath\n")
137+
fmt.Fprintf(inv.Stdout, "%v - %v - %v - %v - %v - %v\n",
138+
secret.ID, secret.Name, secret.Description, value, secret.EnvName, secret.FilePath)
123139
return nil
124140
},
125141
}

coderd/apidoc/docs.go

Lines changed: 80 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 72 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/db2sdk/db2sdk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ func UserSecret(secret database.UserSecret) codersdk.UserSecret {
896896
UserID: secret.UserID,
897897
Name: secret.Name,
898898
Description: secret.Description,
899+
EnvName: secret.EnvName,
900+
FilePath: secret.FilePath,
899901
CreatedAt: secret.CreatedAt,
900902
UpdatedAt: secret.UpdatedAt,
901903
}

coderd/database/dump.sql

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/migrations/000350_add_user_secrets.up.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ CREATE TABLE user_secrets (
1212
-- If this is NULL, the secret value is not encrypted.
1313
value_key_id TEXT REFERENCES dbcrypt_keys(active_key_digest),
1414

15+
-- Auto-injection settings
16+
-- Environment variable name (e.g., "DATABASE_PASSWORD", "API_KEY")
17+
-- Empty string means don't inject as env var
18+
env_name TEXT NOT NULL DEFAULT '',
19+
20+
-- File path where secret should be written (e.g., "/home/coder/.ssh/id_rsa")
21+
-- Empty string means don't inject as file
22+
file_path TEXT NOT NULL DEFAULT '',
23+
1524
-- Timestamps
1625
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
1726
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL

coderd/database/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)