MCPcopy Create free account
hub / github.com/cli/cli / setRun

Function setRun

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

Source from the content-addressed store, hash-verified

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

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