MCPcopy Index your code
hub / github.com/cli/cli / setRun

Function setRun

pkg/cmd/variable/set/set.go:142–226  ·  view source on GitHub ↗
(opts *SetOptions)

Source from the content-addressed store, hash-verified

140}
141
142func setRun(opts *SetOptions) error {
143 variables, err := getVariablesFromOptions(opts)
144 if err != nil {
145 return err
146 }
147
148 c, err := opts.HttpClient()
149 if err != nil {
150 return fmt.Errorf("could not set http client: %w", err)
151 }
152 client := api.NewClientFromHTTP(c)
153
154 orgName := opts.OrgName
155 envName := opts.EnvName
156
157 var host string
158 var baseRepo ghrepo.Interface
159 if orgName == "" {
160 baseRepo, err = opts.BaseRepo()
161 if err != nil {
162 return err
163 }
164 host = baseRepo.RepoHost()
165 } else {
166 cfg, err := opts.Config()
167 if err != nil {
168 return err
169 }
170 host, _ = cfg.Authentication().DefaultHost()
171 }
172
173 entity, err := shared.GetVariableEntity(orgName, envName)
174 if err != nil {
175 return err
176 }
177
178 opts.IO.StartProgressIndicator()
179 repositoryIDs, err := getRepoIds(client, host, opts.OrgName, opts.RepositoryNames)
180 opts.IO.StopProgressIndicator()
181 if err != nil {
182 return err
183 }
184
185 setc := make(chan setResult)
186 for key, value := range variables {
187 k := key
188 v := value
189 go func() {
190 setOpts := setOptions{
191 Entity: entity,
192 Environment: envName,
193 Key: k,
194 Organization: orgName,
195 Repository: baseRepo,
196 RepositoryIDs: repositoryIDs,
197 Value: v,
198 Visibility: opts.Visibility,
199 }

Callers 4

NewCmdSetFunction · 0.70
Test_setRun_repoFunction · 0.70
Test_setRun_envFunction · 0.70
Test_setRun_orgFunction · 0.70

Calls 15

RepoHostMethod · 0.95
NewClientFromHTTPFunction · 0.92
GetVariableEntityFunction · 0.92
FullNameFunction · 0.92
getVariablesFromOptionsFunction · 0.85
getRepoIdsFunction · 0.85
setVariableFunction · 0.85
ColorSchemeMethod · 0.80
IsStdoutTTYMethod · 0.80
SuccessIconMethod · 0.80
JoinMethod · 0.80
ErrorfMethod · 0.65

Tested by 3

Test_setRun_repoFunction · 0.56
Test_setRun_envFunction · 0.56
Test_setRun_orgFunction · 0.56