()
| 24 | ) |
| 25 | |
| 26 | func newOrganizationUpdateCmd() *cobra.Command { |
| 27 | var ( |
| 28 | orgName string |
| 29 | blockOnPolicyViolation bool |
| 30 | policiesAllowedHostnames []string |
| 31 | preventImplicitWorkflowCreation bool |
| 32 | restrictContractCreation bool |
| 33 | apiTokenMaxDaysInactive string |
| 34 | enableAIAgentCollector bool |
| 35 | blockAttestationsOnReleasedVersions bool |
| 36 | skipRunnerEnvVars bool |
| 37 | ) |
| 38 | |
| 39 | cmd := &cobra.Command{ |
| 40 | Use: "update", |
| 41 | Short: "Update an existing organization", |
| 42 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 43 | opts := &action.NewOrgUpdateOpts{} |
| 44 | if cmd.Flags().Changed("block") { |
| 45 | opts.BlockOnPolicyViolation = &blockOnPolicyViolation |
| 46 | } |
| 47 | |
| 48 | if cmd.Flags().Changed("policies-allowed-hostnames") { |
| 49 | opts.PoliciesAllowedHostnames = &policiesAllowedHostnames |
| 50 | } |
| 51 | |
| 52 | if cmd.Flags().Changed("prevent-implicit-workflow-creation") { |
| 53 | opts.PreventImplicitWorkflowCreation = &preventImplicitWorkflowCreation |
| 54 | } |
| 55 | |
| 56 | if cmd.Flags().Changed("restrict-contract-creation") { |
| 57 | opts.RestrictContractCreation = &restrictContractCreation |
| 58 | } |
| 59 | |
| 60 | if cmd.Flags().Changed("enable-ai-agent-collector") { |
| 61 | opts.EnableAIAgentCollector = &enableAIAgentCollector |
| 62 | } |
| 63 | |
| 64 | if cmd.Flags().Changed("block-attestations-on-released-versions") { |
| 65 | opts.BlockAttestationsOnReleasedVersions = &blockAttestationsOnReleasedVersions |
| 66 | } |
| 67 | |
| 68 | if cmd.Flags().Changed("skip-runner-env-vars") { |
| 69 | opts.SkipRunnerEnvVars = &skipRunnerEnvVars |
| 70 | } |
| 71 | |
| 72 | if cmd.Flags().Changed("api-token-max-days-inactive") { |
| 73 | days, err := strconv.Atoi(apiTokenMaxDaysInactive) |
| 74 | if err != nil { |
| 75 | return fmt.Errorf("invalid value %q: must be a number of days (0 to disable)", apiTokenMaxDaysInactive) |
| 76 | } |
| 77 | if days < 0 || days > 365 { |
| 78 | return fmt.Errorf("api-token-max-days-inactive must be between 0 (disabled) and 365") |
| 79 | } |
| 80 | opts.APITokenMaxDaysInactive = &days |
| 81 | } |
| 82 | |
| 83 | _, err := action.NewOrgUpdate(ActionOpts).Run(cmd.Context(), orgName, opts) |
no test coverage detected