assignCreateGroupOptions assigns the flags' values to gitlab.CreateGroupOptions fields. If a flag's default value is not changed by the caller, it's value will not be assigned to the associated gitlab.CreateGroupOptions field.
(cmd *cobra.Command)
| 325 | // If a flag's default value is not changed by the caller, |
| 326 | // it's value will not be assigned to the associated gitlab.CreateGroupOptions field. |
| 327 | func assignCreateGroupOptions(cmd *cobra.Command) (*gitlab.CreateGroupOptions, error) { |
| 328 | var opts gitlab.CreateGroupOptions |
| 329 | |
| 330 | // name is only required when editing a group |
| 331 | if f := cmd.Flag("name"); f != nil { |
| 332 | if f.Changed { |
| 333 | opts.Name = gitlab.String(getFlagString(cmd, "name")) |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | // path is only required when editing a group |
| 338 | if f := cmd.Flag("path"); f != nil { |
| 339 | if f.Changed { |
| 340 | opts.Path = gitlab.String(getFlagString(cmd, "path")) |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | // namespace is only required when creating a new group |
| 345 | if f := cmd.Flag("namespace"); f != nil { |
| 346 | if f.Changed { |
| 347 | ns := getFlagString(cmd, "namespace") |
| 348 | id, err := strconv.Atoi(ns) |
| 349 | // if not nil take the given number |
| 350 | if err == nil { |
| 351 | opts.ParentID = &id |
| 352 | // find the group as string and get it's id |
| 353 | } else { |
| 354 | gid, err := getGroupID(getFlagString(cmd, "namespace")) |
| 355 | if err != nil { |
| 356 | return nil, err |
| 357 | } |
| 358 | opts.ParentID = gitlab.Int(gid) |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | if cmd.Flag("desc").Changed { |
| 364 | opts.Description = gitlab.String(getFlagString(cmd, "desc")) |
| 365 | } |
| 366 | |
| 367 | if cmd.Flag("visibility").Changed { |
| 368 | v := getFlagVisibility(cmd) |
| 369 | opts.Visibility = v |
| 370 | } |
| 371 | if cmd.Flag("lfs-enabled").Changed { |
| 372 | opts.LFSEnabled = gitlab.Bool(getFlagBool(cmd, "lfs-enabled")) |
| 373 | } |
| 374 | if cmd.Flag("request-access-enabled").Changed { |
| 375 | opts.RequestAccessEnabled = gitlab.Bool( |
| 376 | getFlagBool(cmd, "request-access-enabled")) |
| 377 | } |
| 378 | return &opts, nil |
| 379 | } |
| 380 | |
| 381 | // assignAddProjectMemberOptions assigns the flags' values to gitlab.AddProjectMemberOptions fields. |
| 382 | // If a flag's default value is not changed by the caller, |
no test coverage detected