MCPcopy Create free account
hub / github.com/nhost/nhost / pullSecrets

Function pullSecrets

cli/cmd/config/pull.go:136–168  ·  view source on GitHub ↗
(
	ctx context.Context,
	ce *clienv.CliEnv,
	proj *graphql.AppSummaryFragment,
)

Source from the content-addressed store, hash-verified

134}
135
136func pullSecrets(
137 ctx context.Context,
138 ce *clienv.CliEnv,
139 proj *graphql.AppSummaryFragment,
140) error {
141 ce.Infoln("Getting secrets list from Nhost...")
142
143 cl, err := ce.GetNhostClient(ctx)
144 if err != nil {
145 return fmt.Errorf("failed to get nhost client: %w", err)
146 }
147
148 resp, err := cl.GetSecrets(
149 ctx,
150 proj.ID,
151 )
152 if err != nil {
153 return fmt.Errorf("failed to get secrets: %w", err)
154 }
155
156 secrets := respToSecrets(resp.GetAppSecrets(), true)
157 if err := clienv.MarshalFile(&secrets, ce.Path.Secrets(), env.Marshal); err != nil {
158 return fmt.Errorf("failed to save nhost.toml: %w", err)
159 }
160
161 ce.Infoln("Adding .secrets to .gitignore...")
162
163 if err := system.AddToGitignore("\n.secrets\n"); err != nil {
164 return fmt.Errorf("failed to add .secrets to .gitignore: %w", err)
165 }
166
167 return nil
168}
169
170func Pull(
171 ctx context.Context,

Callers 1

PullFunction · 0.85

Calls 9

MarshalFileFunction · 0.92
AddToGitignoreFunction · 0.92
InfolnMethod · 0.80
GetNhostClientMethod · 0.80
ErrorfMethod · 0.80
GetSecretsMethod · 0.80
GetAppSecretsMethod · 0.80
SecretsMethod · 0.80
respToSecretsFunction · 0.70

Tested by

no test coverage detected