(ctx *cli.Context)
| 81 | } |
| 82 | |
| 83 | func updateAction(ctx *cli.Context) (err error) { |
| 84 | if err := errs.NumberOfArguments(ctx, 2); err != nil { |
| 85 | return err |
| 86 | } |
| 87 | |
| 88 | args := ctx.Args() |
| 89 | |
| 90 | provisionerName := args.Get(0) |
| 91 | |
| 92 | client, err := newCRUDClient(ctx, ctx.String("ca-config")) |
| 93 | if err != nil { |
| 94 | return err |
| 95 | } |
| 96 | |
| 97 | prov, err := client.GetProvisioner(ca.WithProvisionerName(provisionerName)) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | var wh *linkedca.Webhook |
| 102 | for _, pwh := range prov.Webhooks { |
| 103 | if pwh.Name == args.Get(1) { |
| 104 | wh = pwh |
| 105 | break |
| 106 | } |
| 107 | } |
| 108 | if wh == nil { |
| 109 | return fmt.Errorf("provisioner %q does not have a webhook with the name %q", provisionerName, args.Get(1)) |
| 110 | } |
| 111 | |
| 112 | if ctx.IsSet("kind") { |
| 113 | kind := linkedca.Webhook_Kind(linkedca.Webhook_Kind_value[ctx.String("kind")]) |
| 114 | if kind == linkedca.Webhook_NO_KIND { |
| 115 | return errors.New("invalid webhook kind") |
| 116 | } |
| 117 | wh.Kind = kind |
| 118 | } |
| 119 | |
| 120 | if ctx.IsSet("url") { |
| 121 | wh.Url = ctx.String("url") |
| 122 | } |
| 123 | |
| 124 | if ctx.IsSet("bearer-token-file") { |
| 125 | bearerTkn, err := utils.ReadStringPasswordFromFile(ctx.String("bearer-token-file")) |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | wh.Auth = &linkedca.Webhook_BearerToken{ |
| 130 | BearerToken: &linkedca.BearerToken{ |
| 131 | BearerToken: bearerTkn, |
| 132 | }, |
| 133 | } |
| 134 | } else if ctx.IsSet("basic-auth-username") || ctx.IsSet("basic-auth-password-file") { |
| 135 | wba, _ := wh.GetAuth().(*linkedca.Webhook_BasicAuth) |
| 136 | if wba == nil { |
| 137 | wba = &linkedca.Webhook_BasicAuth{ |
| 138 | BasicAuth: &linkedca.BasicAuth{}, |
| 139 | } |
| 140 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…