From 6ba1912b80ea2de724f8d75f5800a43aa7b42447 Mon Sep 17 00:00:00 2001 From: Sergey Smolnikov Date: Fri, 19 Apr 2024 11:15:43 +0200 Subject: [PATCH] add-pipeline-job-apply-config (#93) * Added apply-config pipeline-job type * Updated radix-operator version --- cmd/createApplyConfigPipelineJob.go | 93 +++++++ .../client/application/application_client.go | 41 ++++ ...rigger_pipeline_apply_config_parameters.go | 225 +++++++++++++++++ ...trigger_pipeline_apply_config_responses.go | 227 ++++++++++++++++++ .../client/job/job_log_parameters.go | 34 +++ generated-client/models/application.go | 62 +++++ generated-client/models/component.go | 62 ++++- generated-client/models/component_summary.go | 71 +++++- generated-client/models/dns_external_alias.go | 108 +++++++++ generated-client/models/job.go | 4 - .../pipeline_parameters_apply_config.go | 51 ++++ generated-client/models/replica_status.go | 14 +- generated-client/models/replica_summary.go | 87 +++++++ .../models/scheduled_job_summary.go | 7 +- generated-client/models/tls.go | 51 ++++ generated-client/models/tls_automation.go | 117 +++++++++ go.mod | 2 +- go.sum | 4 +- 18 files changed, 1246 insertions(+), 14 deletions(-) create mode 100644 cmd/createApplyConfigPipelineJob.go create mode 100644 generated-client/client/application/trigger_pipeline_apply_config_parameters.go create mode 100644 generated-client/client/application/trigger_pipeline_apply_config_responses.go create mode 100644 generated-client/models/dns_external_alias.go create mode 100644 generated-client/models/pipeline_parameters_apply_config.go create mode 100644 generated-client/models/tls_automation.go diff --git a/cmd/createApplyConfigPipelineJob.go b/cmd/createApplyConfigPipelineJob.go new file mode 100644 index 0000000..b0dc914 --- /dev/null +++ b/cmd/createApplyConfigPipelineJob.go @@ -0,0 +1,93 @@ +// Copyright © 2023 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "errors" + + "github.com/equinor/radix-cli/generated-client/client/application" + "github.com/equinor/radix-cli/generated-client/models" + "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +var createApplyConfigPipelineJobCmd = &cobra.Command{ + Use: "apply-config", + Short: "Will trigger apply-config of a Radix application", + Long: "Triggers applyConfig of a Radix application according to the radix config in its repository's master branch.", + Example: ` # Create a Radix pipeline apply-config job to apply the radixconfig properties without re-building or re-deploying components. +Currently applied changes in properties DNS alias, build secrets, create new or soft-delete existing environments. + rx create job apply-config --application radix-test + + # Create a Radix pipeline applyConfig-only job, short option versions + rx create job apply-config -a radix-test`, + RunE: func(cmd *cobra.Command, args []string) error { + var errs []error + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) + if err != nil { + errs = append(errs, err) + } + triggeredByUser, err := cmd.Flags().GetString(flagnames.User) + if err != nil { + errs = append(errs, err) + } + follow, err := cmd.Flags().GetBool(flagnames.Follow) + if err != nil { + errs = append(errs, err) + } + if len(errs) > 0 { + return errors.Join(errs...) + } + if appName == nil || *appName == "" { + return errors.New("application name is required") + } + + cmd.SilenceUsage = true + + apiClient, err := client.GetForCommand(cmd) + if err != nil { + return err + } + + triggerPipelineParams := application.NewTriggerPipelineApplyConfigParams() + triggerPipelineParams.SetAppName(*appName) + parametersApplyConfig := models.PipelineParametersApplyConfig{ + TriggeredBy: triggeredByUser, + } + triggerPipelineParams.SetPipelineParametersApplyConfig(¶metersApplyConfig) + + newJob, err := apiClient.Application.TriggerPipelineApplyConfig(triggerPipelineParams, nil) + if err != nil { + return err + } + + jobName := newJob.GetPayload().Name + log.Infof("Apply-config pipeline job triggered with the name %s\n", jobName) + if !follow { + return nil + } + return getLogsJob(cmd, apiClient, *appName, jobName) + }, +} + +func init() { + createJobCmd.AddCommand(createApplyConfigPipelineJobCmd) + createApplyConfigPipelineJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to apply-config") + createApplyConfigPipelineJobCmd.Flags().StringP(flagnames.User, "u", "", "The user who triggered the apply-config") + createApplyConfigPipelineJobCmd.Flags().BoolP(flagnames.Follow, "f", false, "Follow applyConfig") + setContextSpecificPersistentFlags(createApplyConfigPipelineJobCmd) +} diff --git a/generated-client/client/application/application_client.go b/generated-client/client/application/application_client.go index 4474959..6ac7f93 100644 --- a/generated-client/client/application/application_client.go +++ b/generated-client/client/application/application_client.go @@ -64,6 +64,8 @@ type ClientService interface { StopApplication(params *StopApplicationParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*StopApplicationOK, error) + TriggerPipelineApplyConfig(params *TriggerPipelineApplyConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TriggerPipelineApplyConfigOK, error) + TriggerPipelineBuild(params *TriggerPipelineBuildParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TriggerPipelineBuildOK, error) TriggerPipelineBuildDeploy(params *TriggerPipelineBuildDeployParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TriggerPipelineBuildDeployOK, error) @@ -744,6 +746,45 @@ func (a *Client) StopApplication(params *StopApplicationParams, authInfo runtime panic(msg) } +/* +TriggerPipelineApplyConfig runs a apply config pipeline for a given application +*/ +func (a *Client) TriggerPipelineApplyConfig(params *TriggerPipelineApplyConfigParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*TriggerPipelineApplyConfigOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewTriggerPipelineApplyConfigParams() + } + op := &runtime.ClientOperation{ + ID: "triggerPipelineApplyConfig", + Method: "POST", + PathPattern: "/applications/{appName}/pipelines/apply-config", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &TriggerPipelineApplyConfigReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*TriggerPipelineApplyConfigOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for triggerPipelineApplyConfig: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* TriggerPipelineBuild runs a build pipeline for a given application and branch */ diff --git a/generated-client/client/application/trigger_pipeline_apply_config_parameters.go b/generated-client/client/application/trigger_pipeline_apply_config_parameters.go new file mode 100644 index 0000000..ec1e9c4 --- /dev/null +++ b/generated-client/client/application/trigger_pipeline_apply_config_parameters.go @@ -0,0 +1,225 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package application + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/equinor/radix-cli/generated-client/models" +) + +// NewTriggerPipelineApplyConfigParams creates a new TriggerPipelineApplyConfigParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewTriggerPipelineApplyConfigParams() *TriggerPipelineApplyConfigParams { + return &TriggerPipelineApplyConfigParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewTriggerPipelineApplyConfigParamsWithTimeout creates a new TriggerPipelineApplyConfigParams object +// with the ability to set a timeout on a request. +func NewTriggerPipelineApplyConfigParamsWithTimeout(timeout time.Duration) *TriggerPipelineApplyConfigParams { + return &TriggerPipelineApplyConfigParams{ + timeout: timeout, + } +} + +// NewTriggerPipelineApplyConfigParamsWithContext creates a new TriggerPipelineApplyConfigParams object +// with the ability to set a context for a request. +func NewTriggerPipelineApplyConfigParamsWithContext(ctx context.Context) *TriggerPipelineApplyConfigParams { + return &TriggerPipelineApplyConfigParams{ + Context: ctx, + } +} + +// NewTriggerPipelineApplyConfigParamsWithHTTPClient creates a new TriggerPipelineApplyConfigParams object +// with the ability to set a custom HTTPClient for a request. +func NewTriggerPipelineApplyConfigParamsWithHTTPClient(client *http.Client) *TriggerPipelineApplyConfigParams { + return &TriggerPipelineApplyConfigParams{ + HTTPClient: client, + } +} + +/* +TriggerPipelineApplyConfigParams contains all the parameters to send to the API endpoint + + for the trigger pipeline apply config operation. + + Typically these are written to a http.Request. +*/ +type TriggerPipelineApplyConfigParams struct { + + /* ImpersonateGroup. + + Works only with custom setup of cluster. Allow impersonation of a comma-seperated list of test groups (Required if Impersonate-User is set) + */ + ImpersonateGroup *string + + /* ImpersonateUser. + + Works only with custom setup of cluster. Allow impersonation of test users (Required if Impersonate-Group is set) + */ + ImpersonateUser *string + + /* PipelineParametersApplyConfig. + + Pipeline parameters + */ + PipelineParametersApplyConfig *models.PipelineParametersApplyConfig + + /* AppName. + + Name of application + */ + AppName string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the trigger pipeline apply config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *TriggerPipelineApplyConfigParams) WithDefaults() *TriggerPipelineApplyConfigParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the trigger pipeline apply config params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *TriggerPipelineApplyConfigParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithTimeout(timeout time.Duration) *TriggerPipelineApplyConfigParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithContext(ctx context.Context) *TriggerPipelineApplyConfigParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithHTTPClient(client *http.Client) *TriggerPipelineApplyConfigParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithImpersonateGroup adds the impersonateGroup to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithImpersonateGroup(impersonateGroup *string) *TriggerPipelineApplyConfigParams { + o.SetImpersonateGroup(impersonateGroup) + return o +} + +// SetImpersonateGroup adds the impersonateGroup to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetImpersonateGroup(impersonateGroup *string) { + o.ImpersonateGroup = impersonateGroup +} + +// WithImpersonateUser adds the impersonateUser to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithImpersonateUser(impersonateUser *string) *TriggerPipelineApplyConfigParams { + o.SetImpersonateUser(impersonateUser) + return o +} + +// SetImpersonateUser adds the impersonateUser to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetImpersonateUser(impersonateUser *string) { + o.ImpersonateUser = impersonateUser +} + +// WithPipelineParametersApplyConfig adds the pipelineParametersApplyConfig to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithPipelineParametersApplyConfig(pipelineParametersApplyConfig *models.PipelineParametersApplyConfig) *TriggerPipelineApplyConfigParams { + o.SetPipelineParametersApplyConfig(pipelineParametersApplyConfig) + return o +} + +// SetPipelineParametersApplyConfig adds the pipelineParametersApplyConfig to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetPipelineParametersApplyConfig(pipelineParametersApplyConfig *models.PipelineParametersApplyConfig) { + o.PipelineParametersApplyConfig = pipelineParametersApplyConfig +} + +// WithAppName adds the appName to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) WithAppName(appName string) *TriggerPipelineApplyConfigParams { + o.SetAppName(appName) + return o +} + +// SetAppName adds the appName to the trigger pipeline apply config params +func (o *TriggerPipelineApplyConfigParams) SetAppName(appName string) { + o.AppName = appName +} + +// WriteToRequest writes these params to a swagger request +func (o *TriggerPipelineApplyConfigParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.ImpersonateGroup != nil { + + // header param Impersonate-Group + if err := r.SetHeaderParam("Impersonate-Group", *o.ImpersonateGroup); err != nil { + return err + } + } + + if o.ImpersonateUser != nil { + + // header param Impersonate-User + if err := r.SetHeaderParam("Impersonate-User", *o.ImpersonateUser); err != nil { + return err + } + } + if o.PipelineParametersApplyConfig != nil { + if err := r.SetBodyParam(o.PipelineParametersApplyConfig); err != nil { + return err + } + } + + // path param appName + if err := r.SetPathParam("appName", o.AppName); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/generated-client/client/application/trigger_pipeline_apply_config_responses.go b/generated-client/client/application/trigger_pipeline_apply_config_responses.go new file mode 100644 index 0000000..7587344 --- /dev/null +++ b/generated-client/client/application/trigger_pipeline_apply_config_responses.go @@ -0,0 +1,227 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package application + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/equinor/radix-cli/generated-client/models" +) + +// TriggerPipelineApplyConfigReader is a Reader for the TriggerPipelineApplyConfig structure. +type TriggerPipelineApplyConfigReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *TriggerPipelineApplyConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewTriggerPipelineApplyConfigOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 403: + result := NewTriggerPipelineApplyConfigForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewTriggerPipelineApplyConfigNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /applications/{appName}/pipelines/apply-config] triggerPipelineApplyConfig", response, response.Code()) + } +} + +// NewTriggerPipelineApplyConfigOK creates a TriggerPipelineApplyConfigOK with default headers values +func NewTriggerPipelineApplyConfigOK() *TriggerPipelineApplyConfigOK { + return &TriggerPipelineApplyConfigOK{} +} + +/* +TriggerPipelineApplyConfigOK describes a response with status code 200, with default header values. + +Successful trigger pipeline +*/ +type TriggerPipelineApplyConfigOK struct { + Payload *models.JobSummary +} + +// IsSuccess returns true when this trigger pipeline apply config o k response has a 2xx status code +func (o *TriggerPipelineApplyConfigOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this trigger pipeline apply config o k response has a 3xx status code +func (o *TriggerPipelineApplyConfigOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this trigger pipeline apply config o k response has a 4xx status code +func (o *TriggerPipelineApplyConfigOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this trigger pipeline apply config o k response has a 5xx status code +func (o *TriggerPipelineApplyConfigOK) IsServerError() bool { + return false +} + +// IsCode returns true when this trigger pipeline apply config o k response a status code equal to that given +func (o *TriggerPipelineApplyConfigOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the trigger pipeline apply config o k response +func (o *TriggerPipelineApplyConfigOK) Code() int { + return 200 +} + +func (o *TriggerPipelineApplyConfigOK) Error() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigOK %+v", 200, o.Payload) +} + +func (o *TriggerPipelineApplyConfigOK) String() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigOK %+v", 200, o.Payload) +} + +func (o *TriggerPipelineApplyConfigOK) GetPayload() *models.JobSummary { + return o.Payload +} + +func (o *TriggerPipelineApplyConfigOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.JobSummary) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewTriggerPipelineApplyConfigForbidden creates a TriggerPipelineApplyConfigForbidden with default headers values +func NewTriggerPipelineApplyConfigForbidden() *TriggerPipelineApplyConfigForbidden { + return &TriggerPipelineApplyConfigForbidden{} +} + +/* +TriggerPipelineApplyConfigForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type TriggerPipelineApplyConfigForbidden struct { +} + +// IsSuccess returns true when this trigger pipeline apply config forbidden response has a 2xx status code +func (o *TriggerPipelineApplyConfigForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this trigger pipeline apply config forbidden response has a 3xx status code +func (o *TriggerPipelineApplyConfigForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this trigger pipeline apply config forbidden response has a 4xx status code +func (o *TriggerPipelineApplyConfigForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this trigger pipeline apply config forbidden response has a 5xx status code +func (o *TriggerPipelineApplyConfigForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this trigger pipeline apply config forbidden response a status code equal to that given +func (o *TriggerPipelineApplyConfigForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the trigger pipeline apply config forbidden response +func (o *TriggerPipelineApplyConfigForbidden) Code() int { + return 403 +} + +func (o *TriggerPipelineApplyConfigForbidden) Error() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigForbidden ", 403) +} + +func (o *TriggerPipelineApplyConfigForbidden) String() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigForbidden ", 403) +} + +func (o *TriggerPipelineApplyConfigForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewTriggerPipelineApplyConfigNotFound creates a TriggerPipelineApplyConfigNotFound with default headers values +func NewTriggerPipelineApplyConfigNotFound() *TriggerPipelineApplyConfigNotFound { + return &TriggerPipelineApplyConfigNotFound{} +} + +/* +TriggerPipelineApplyConfigNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type TriggerPipelineApplyConfigNotFound struct { +} + +// IsSuccess returns true when this trigger pipeline apply config not found response has a 2xx status code +func (o *TriggerPipelineApplyConfigNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this trigger pipeline apply config not found response has a 3xx status code +func (o *TriggerPipelineApplyConfigNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this trigger pipeline apply config not found response has a 4xx status code +func (o *TriggerPipelineApplyConfigNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this trigger pipeline apply config not found response has a 5xx status code +func (o *TriggerPipelineApplyConfigNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this trigger pipeline apply config not found response a status code equal to that given +func (o *TriggerPipelineApplyConfigNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the trigger pipeline apply config not found response +func (o *TriggerPipelineApplyConfigNotFound) Code() int { + return 404 +} + +func (o *TriggerPipelineApplyConfigNotFound) Error() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigNotFound ", 404) +} + +func (o *TriggerPipelineApplyConfigNotFound) String() string { + return fmt.Sprintf("[POST /applications/{appName}/pipelines/apply-config][%d] triggerPipelineApplyConfigNotFound ", 404) +} + +func (o *TriggerPipelineApplyConfigNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/generated-client/client/job/job_log_parameters.go b/generated-client/client/job/job_log_parameters.go index d7228db..2ae7c0f 100644 --- a/generated-client/client/job/job_log_parameters.go +++ b/generated-client/client/job/job_log_parameters.go @@ -107,6 +107,12 @@ type JobLogParams struct { */ Lines *string + /* ReplicaName. + + Name of the job replica + */ + ReplicaName *string + /* ScheduledJobName. Name of scheduled job @@ -251,6 +257,17 @@ func (o *JobLogParams) SetLines(lines *string) { o.Lines = lines } +// WithReplicaName adds the replicaName to the job log params +func (o *JobLogParams) WithReplicaName(replicaName *string) *JobLogParams { + o.SetReplicaName(replicaName) + return o +} + +// SetReplicaName adds the replicaName to the job log params +func (o *JobLogParams) SetReplicaName(replicaName *string) { + o.ReplicaName = replicaName +} + // WithScheduledJobName adds the scheduledJobName to the job log params func (o *JobLogParams) WithScheduledJobName(scheduledJobName string) *JobLogParams { o.SetScheduledJobName(scheduledJobName) @@ -346,6 +363,23 @@ func (o *JobLogParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist } } + if o.ReplicaName != nil { + + // query param replicaName + var qrReplicaName string + + if o.ReplicaName != nil { + qrReplicaName = *o.ReplicaName + } + qReplicaName := qrReplicaName + if qReplicaName != "" { + + if err := r.SetQueryParam("replicaName", qReplicaName); err != nil { + return err + } + } + } + // path param scheduledJobName if err := r.SetPathParam("scheduledJobName", o.ScheduledJobName); err != nil { return err diff --git a/generated-client/models/application.go b/generated-client/models/application.go index e9caeba..c58ec48 100644 --- a/generated-client/models/application.go +++ b/generated-client/models/application.go @@ -23,6 +23,9 @@ type Application struct { // DNS aliases showing nicer endpoint for application, without "app." subdomain domain DNSAliases []*DNSAlias `json:"dnsAliases"` + // List of external DNS names and which component and environment incoming requests shall be routed to. + DNSExternalAliases []*DNSExternalAlias `json:"dnsExternalAliases"` + // Environments List of environments for this application Environments []*EnvironmentSummary `json:"environments"` @@ -52,6 +55,10 @@ func (m *Application) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateDNSExternalAliases(formats); err != nil { + res = append(res, err) + } + if err := m.validateEnvironments(formats); err != nil { res = append(res, err) } @@ -104,6 +111,32 @@ func (m *Application) validateDNSAliases(formats strfmt.Registry) error { return nil } +func (m *Application) validateDNSExternalAliases(formats strfmt.Registry) error { + if swag.IsZero(m.DNSExternalAliases) { // not required + return nil + } + + for i := 0; i < len(m.DNSExternalAliases); i++ { + if swag.IsZero(m.DNSExternalAliases[i]) { // not required + continue + } + + if m.DNSExternalAliases[i] != nil { + if err := m.DNSExternalAliases[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dnsExternalAliases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dnsExternalAliases" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Application) validateEnvironments(formats strfmt.Registry) error { if swag.IsZero(m.Environments) { // not required return nil @@ -211,6 +244,10 @@ func (m *Application) ContextValidate(ctx context.Context, formats strfmt.Regist res = append(res, err) } + if err := m.contextValidateDNSExternalAliases(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateEnvironments(ctx, formats); err != nil { res = append(res, err) } @@ -258,6 +295,31 @@ func (m *Application) contextValidateDNSAliases(ctx context.Context, formats str return nil } +func (m *Application) contextValidateDNSExternalAliases(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.DNSExternalAliases); i++ { + + if m.DNSExternalAliases[i] != nil { + + if swag.IsZero(m.DNSExternalAliases[i]) { // not required + return nil + } + + if err := m.DNSExternalAliases[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("dnsExternalAliases" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("dnsExternalAliases" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Application) contextValidateEnvironments(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Environments); i++ { diff --git a/generated-client/models/component.go b/generated-client/models/component.go index d6ea085..f9d3f95 100644 --- a/generated-client/models/component.go +++ b/generated-client/models/component.go @@ -22,11 +22,16 @@ import ( type Component struct { // Commit ID for the component. It can be different from the Commit ID, specified in deployment label - CommitID string `json:"CommitID,omitempty"` + // Example: 4faca8595c5283a9d0f17a623b9255a0d9866a2e + CommitID string `json:"commitID,omitempty"` // Array of external DNS configurations ExternalDNS []*ExternalDNS `json:"externalDNS"` + // GitTags the git tags that the git commit hash points to + // Example: \"v1.22.1 v1.22.3\ + GitTags string `json:"gitTags,omitempty"` + // Image name // Example: radixdev.azurecr.io/app-server:cdgkg // Required: true @@ -59,6 +64,10 @@ type Component struct { // Example: ["DB_CON","A_SECRET"] Secrets []string `json:"secrets"` + // SkipDeployment The component should not be deployed, but used existing + // Example: true + SkipDeployment bool `json:"skipDeployment,omitempty"` + // Status of the component // Example: Consistent // Enum: [Stopped Consistent Reconciling Restarting Outdated] @@ -84,6 +93,9 @@ type Component struct { // oauth2 Oauth2 *OAuth2AuxiliaryResource `json:"oauth2,omitempty"` + + // resources + Resources *ResourceRequirements `json:"resources,omitempty"` } // Validate validates this component @@ -134,6 +146,10 @@ func (m *Component) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateResources(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -406,6 +422,25 @@ func (m *Component) validateOauth2(formats strfmt.Registry) error { return nil } +func (m *Component) validateResources(formats strfmt.Registry) error { + if swag.IsZero(m.Resources) { // not required + return nil + } + + if m.Resources != nil { + if err := m.Resources.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources") + } + return err + } + } + + return nil +} + // ContextValidate validate this component based on the context it is used func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error @@ -438,6 +473,10 @@ func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry res = append(res, err) } + if err := m.contextValidateResources(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -603,6 +642,27 @@ func (m *Component) contextValidateOauth2(ctx context.Context, formats strfmt.Re return nil } +func (m *Component) contextValidateResources(ctx context.Context, formats strfmt.Registry) error { + + if m.Resources != nil { + + if swag.IsZero(m.Resources) { // not required + return nil + } + + if err := m.Resources.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Component) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/generated-client/models/component_summary.go b/generated-client/models/component_summary.go index 7900a4c..09986cd 100644 --- a/generated-client/models/component_summary.go +++ b/generated-client/models/component_summary.go @@ -20,6 +20,15 @@ import ( // swagger:model ComponentSummary type ComponentSummary struct { + // CommitID the commit ID of the branch to build + // REQUIRED for "build" and "build-deploy" pipelines + // Example: 4faca8595c5283a9d0f17a623b9255a0d9866a2e + CommitID string `json:"commitID,omitempty"` + + // GitTags the git tags that the git commit hash points to + // Example: \"v1.22.1 v1.22.3\ + GitTags string `json:"gitTags,omitempty"` + // Image name // Example: radixdev.azurecr.io/app-server:cdgkg // Required: true @@ -30,11 +39,18 @@ type ComponentSummary struct { // Required: true Name *string `json:"name"` + // SkipDeployment The component should not be deployed, but used existing + // Example: true + SkipDeployment bool `json:"skipDeployment,omitempty"` + // Type of component // Example: component // Required: true // Enum: [component job] Type *string `json:"type"` + + // resources + Resources *ResourceRequirements `json:"resources,omitempty"` } // Validate validates this component summary @@ -53,6 +69,10 @@ func (m *ComponentSummary) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateResources(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -120,8 +140,57 @@ func (m *ComponentSummary) validateType(formats strfmt.Registry) error { return nil } -// ContextValidate validates this component summary based on context it is used +func (m *ComponentSummary) validateResources(formats strfmt.Registry) error { + if swag.IsZero(m.Resources) { // not required + return nil + } + + if m.Resources != nil { + if err := m.Resources.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources") + } + return err + } + } + + return nil +} + +// ContextValidate validate this component summary based on the context it is used func (m *ComponentSummary) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComponentSummary) contextValidateResources(ctx context.Context, formats strfmt.Registry) error { + + if m.Resources != nil { + + if swag.IsZero(m.Resources) { // not required + return nil + } + + if err := m.Resources.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("resources") + } + return err + } + } + return nil } diff --git a/generated-client/models/dns_external_alias.go b/generated-client/models/dns_external_alias.go new file mode 100644 index 0000000..2d5ba59 --- /dev/null +++ b/generated-client/models/dns_external_alias.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// DNSExternalAlias DNSExternalAlias holds public external DNS alias information +// +// swagger:model DNSExternalAlias +type DNSExternalAlias struct { + + // ComponentName the component exposing the endpoint + // Example: frontend + // Required: true + ComponentName *string `json:"componentName"` + + // EnvironmentName the environment hosting the endpoint + // Example: prod + // Required: true + EnvironmentName *string `json:"environmentName"` + + // URL the public endpoint + // Example: https://my-app.equinor.com + // Required: true + URL *string `json:"url"` +} + +// Validate validates this DNS external alias +func (m *DNSExternalAlias) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateComponentName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEnvironmentName(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DNSExternalAlias) validateComponentName(formats strfmt.Registry) error { + + if err := validate.Required("componentName", "body", m.ComponentName); err != nil { + return err + } + + return nil +} + +func (m *DNSExternalAlias) validateEnvironmentName(formats strfmt.Registry) error { + + if err := validate.Required("environmentName", "body", m.EnvironmentName); err != nil { + return err + } + + return nil +} + +func (m *DNSExternalAlias) validateURL(formats strfmt.Registry) error { + + if err := validate.Required("url", "body", m.URL); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this DNS external alias based on context it is used +func (m *DNSExternalAlias) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *DNSExternalAlias) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DNSExternalAlias) UnmarshalBinary(b []byte) error { + var res DNSExternalAlias + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/job.go b/generated-client/models/job.go index 9f1884a..489e8c6 100644 --- a/generated-client/models/job.go +++ b/generated-client/models/job.go @@ -34,10 +34,6 @@ type Job struct { // Deprecated: Inspect each deployment to get list of components created by the job Components []*ComponentSummary `json:"components"` - // ComponentsToDeploy List of components to deploy - // OPTIONAL If specified, only these components are deployed - ComponentsToDeploy []string `json:"componentsToDeploy"` - // Created timestamp // Example: 2006-01-02T15:04:05Z Created string `json:"created,omitempty"` diff --git a/generated-client/models/pipeline_parameters_apply_config.go b/generated-client/models/pipeline_parameters_apply_config.go new file mode 100644 index 0000000..a8cc72d --- /dev/null +++ b/generated-client/models/pipeline_parameters_apply_config.go @@ -0,0 +1,51 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PipelineParametersApplyConfig PipelineParametersApplyConfig describes base info +// +// swagger:model PipelineParametersApplyConfig +type PipelineParametersApplyConfig struct { + + // TriggeredBy of the job - if empty will use user token upn (user principle name) + // Example: a_user@equinor.com + TriggeredBy string `json:"triggeredBy,omitempty"` +} + +// Validate validates this pipeline parameters apply config +func (m *PipelineParametersApplyConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this pipeline parameters apply config based on context it is used +func (m *PipelineParametersApplyConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PipelineParametersApplyConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PipelineParametersApplyConfig) UnmarshalBinary(b []byte) error { + var res PipelineParametersApplyConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/replica_status.go b/generated-client/models/replica_status.go index f241f5f..bac6fef 100644 --- a/generated-client/models/replica_status.go +++ b/generated-client/models/replica_status.go @@ -22,12 +22,14 @@ type ReplicaStatus struct { // Status of the container // Pending = Container in Waiting state and the reason is ContainerCreating - // Failing = Container in Waiting state and the reason is anything else but ContainerCreating + // Failed = Container is failed + // Failing = Container is failed // Running = Container in Running state + // Succeeded = Container in Succeeded state // Terminated = Container in Terminated state // Example: Running // Required: true - // Enum: [Pending Failing Running Terminated Starting] + // Enum: [Pending Succeeded Failing Failed Running Terminated Starting] Status *string `json:"status"` } @@ -49,7 +51,7 @@ var replicaStatusTypeStatusPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Pending","Failing","Running","Terminated","Starting"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Pending","Succeeded","Failing","Failed","Running","Terminated","Starting"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -62,9 +64,15 @@ const ( // ReplicaStatusStatusPending captures enum value "Pending" ReplicaStatusStatusPending string = "Pending" + // ReplicaStatusStatusSucceeded captures enum value "Succeeded" + ReplicaStatusStatusSucceeded string = "Succeeded" + // ReplicaStatusStatusFailing captures enum value "Failing" ReplicaStatusStatusFailing string = "Failing" + // ReplicaStatusStatusFailed captures enum value "Failed" + ReplicaStatusStatusFailed string = "Failed" + // ReplicaStatusStatusRunning captures enum value "Running" ReplicaStatusStatusRunning string = "Running" diff --git a/generated-client/models/replica_summary.go b/generated-client/models/replica_summary.go index 43eef4c..69015e3 100644 --- a/generated-client/models/replica_summary.go +++ b/generated-client/models/replica_summary.go @@ -7,6 +7,7 @@ package models import ( "context" + "encoding/json" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -27,6 +28,13 @@ type ReplicaSummary struct { // Example: 2006-01-02T15:04:05Z Created string `json:"created,omitempty"` + // The time at which the batch job's pod finishedAt. + // Example: 2006-01-02T15:04:05Z + EndTime string `json:"endTime,omitempty"` + + // Exit status from the last termination of the container + ExitCode int32 `json:"exitCode,omitempty"` + // The image the container is running. // Example: radixdev.azurecr.io/app-server:cdgkg Image string `json:"image,omitempty"` @@ -40,12 +48,33 @@ type ReplicaSummary struct { // Required: true Name *string `json:"name"` + // The index of the pod in the re-starts + PodIndex int64 `json:"podIndex,omitempty"` + + // A brief CamelCase message indicating details about why the job is in this phase + Reason string `json:"reason,omitempty"` + // RestartCount count of restarts of a component container inside a pod RestartCount int32 `json:"restartCount,omitempty"` + // The time at which the batch job's pod startedAt + // Example: 2006-01-02T15:04:05Z + StartTime string `json:"startTime,omitempty"` + // StatusMessage provides message describing the status of a component container inside a pod StatusMessage string `json:"statusMessage,omitempty"` + // Pod type + // ComponentReplica = Replica of a Radix component + // ScheduledJobReplica = Replica of a Radix job-component + // JobManager = Replica of a Radix job-component scheduler + // JobManagerAux = Replica of a Radix job-component scheduler auxiliary + // OAuth2 = Replica of a Radix OAuth2 component + // Undefined = Replica without defined type - to be extended + // Example: ComponentReplica + // Enum: [ComponentReplica ScheduledJobReplica JobManager JobManagerAux OAuth2 Undefined] + Type string `json:"type,omitempty"` + // replica status ReplicaStatus *ReplicaStatus `json:"replicaStatus,omitempty"` @@ -61,6 +90,10 @@ func (m *ReplicaSummary) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + if err := m.validateReplicaStatus(formats); err != nil { res = append(res, err) } @@ -84,6 +117,60 @@ func (m *ReplicaSummary) validateName(formats strfmt.Registry) error { return nil } +var replicaSummaryTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["ComponentReplica","ScheduledJobReplica","JobManager","JobManagerAux","OAuth2","Undefined"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + replicaSummaryTypeTypePropEnum = append(replicaSummaryTypeTypePropEnum, v) + } +} + +const ( + + // ReplicaSummaryTypeComponentReplica captures enum value "ComponentReplica" + ReplicaSummaryTypeComponentReplica string = "ComponentReplica" + + // ReplicaSummaryTypeScheduledJobReplica captures enum value "ScheduledJobReplica" + ReplicaSummaryTypeScheduledJobReplica string = "ScheduledJobReplica" + + // ReplicaSummaryTypeJobManager captures enum value "JobManager" + ReplicaSummaryTypeJobManager string = "JobManager" + + // ReplicaSummaryTypeJobManagerAux captures enum value "JobManagerAux" + ReplicaSummaryTypeJobManagerAux string = "JobManagerAux" + + // ReplicaSummaryTypeOAuth2 captures enum value "OAuth2" + ReplicaSummaryTypeOAuth2 string = "OAuth2" + + // ReplicaSummaryTypeUndefined captures enum value "Undefined" + ReplicaSummaryTypeUndefined string = "Undefined" +) + +// prop value enum +func (m *ReplicaSummary) validateTypeEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, replicaSummaryTypeTypePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ReplicaSummary) validateType(formats strfmt.Registry) error { + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + func (m *ReplicaSummary) validateReplicaStatus(formats strfmt.Registry) error { if swag.IsZero(m.ReplicaStatus) { // not required return nil diff --git a/generated-client/models/scheduled_job_summary.go b/generated-client/models/scheduled_job_summary.go index 1210de5..c39dd08 100644 --- a/generated-client/models/scheduled_job_summary.go +++ b/generated-client/models/scheduled_job_summary.go @@ -72,7 +72,7 @@ type ScheduledJobSummary struct { // Status of the job // Example: Waiting // Required: true - // Enum: [Running Succeeded Failed Waiting Stopping Stopped] + // Enum: [Running Active Succeeded Failed Waiting Stopping Stopped] Status *string `json:"status"` // TimeLimitSeconds How long the job supposed to run at maximum @@ -168,7 +168,7 @@ var scheduledJobSummaryTypeStatusPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Running","Succeeded","Failed","Waiting","Stopping","Stopped"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Running","Active","Succeeded","Failed","Waiting","Stopping","Stopped"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -181,6 +181,9 @@ const ( // ScheduledJobSummaryStatusRunning captures enum value "Running" ScheduledJobSummaryStatusRunning string = "Running" + // ScheduledJobSummaryStatusActive captures enum value "Active" + ScheduledJobSummaryStatusActive string = "Active" + // ScheduledJobSummaryStatusSucceeded captures enum value "Succeeded" ScheduledJobSummaryStatusSucceeded string = "Succeeded" diff --git a/generated-client/models/tls.go b/generated-client/models/tls.go index 31d3421..8156c9d 100644 --- a/generated-client/models/tls.go +++ b/generated-client/models/tls.go @@ -40,6 +40,9 @@ type TLS struct { // UseAutomation describes if TLS certificate is automatically issued using automation (ACME) // Required: true UseAutomation *bool `json:"useAutomation"` + + // automation + Automation *TLSAutomation `json:"automation,omitempty"` } // Validate validates this TLS @@ -58,6 +61,10 @@ func (m *TLS) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAutomation(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -145,6 +152,25 @@ func (m *TLS) validateUseAutomation(formats strfmt.Registry) error { return nil } +func (m *TLS) validateAutomation(formats strfmt.Registry) error { + if swag.IsZero(m.Automation) { // not required + return nil + } + + if m.Automation != nil { + if err := m.Automation.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("automation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("automation") + } + return err + } + } + + return nil +} + // ContextValidate validate this TLS based on the context it is used func (m *TLS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error @@ -153,6 +179,10 @@ func (m *TLS) ContextValidate(ctx context.Context, formats strfmt.Registry) erro res = append(res, err) } + if err := m.contextValidateAutomation(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -184,6 +214,27 @@ func (m *TLS) contextValidateCertificates(ctx context.Context, formats strfmt.Re return nil } +func (m *TLS) contextValidateAutomation(ctx context.Context, formats strfmt.Registry) error { + + if m.Automation != nil { + + if swag.IsZero(m.Automation) { // not required + return nil + } + + if err := m.Automation.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("automation") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("automation") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *TLS) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/generated-client/models/tls_automation.go b/generated-client/models/tls_automation.go new file mode 100644 index 0000000..0429996 --- /dev/null +++ b/generated-client/models/tls_automation.go @@ -0,0 +1,117 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TLSAutomation TLSAutomation describes the current condition of TLS automation +// +// swagger:model TLSAutomation +type TLSAutomation struct { + + // Message is a human readable description of the reason for the status + Message string `json:"message,omitempty"` + + // Status of certificate automation request + // Pending TLSAutomationPending Certificate automation request pending + // Success TLSAutomationSuccess Certificate automation request succeeded + // Failed TLSAutomationFailed Certificate automation request failed + // Example: Pending + // Required: true + // Enum: [Pending Success Failed] + Status *string `json:"status"` +} + +// Validate validates this TLS automation +func (m *TLSAutomation) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var tlsAutomationTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Pending","Success","Failed"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + tlsAutomationTypeStatusPropEnum = append(tlsAutomationTypeStatusPropEnum, v) + } +} + +const ( + + // TLSAutomationStatusPending captures enum value "Pending" + TLSAutomationStatusPending string = "Pending" + + // TLSAutomationStatusSuccess captures enum value "Success" + TLSAutomationStatusSuccess string = "Success" + + // TLSAutomationStatusFailed captures enum value "Failed" + TLSAutomationStatusFailed string = "Failed" +) + +// prop value enum +func (m *TLSAutomation) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, tlsAutomationTypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *TLSAutomation) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + // value enum + if err := m.validateStatusEnum("status", "body", *m.Status); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this TLS automation based on context it is used +func (m *TLSAutomation) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *TLSAutomation) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TLSAutomation) UnmarshalBinary(b []byte) error { + var res TLSAutomation + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go.mod b/go.mod index 7bfd609..addc548 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.21.0 require ( github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 - github.com/equinor/radix-operator v1.50.8 + github.com/equinor/radix-operator v1.51.2 github.com/fatih/color v1.15.0 github.com/go-openapi/errors v0.20.4 github.com/go-openapi/runtime v0.26.2 diff --git a/go.sum b/go.sum index 7862014..a9f2e0e 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/equinor/radix-common v1.7.1 h1:kl7Tuo2VEo2WHGm/vkvktrZ9t9S3Nht7Mob3CSIzcJI= github.com/equinor/radix-common v1.7.1/go.mod h1:M6mhgHtFQ3rnjJnyOuECXiZOh7XQ5xVeHMyCAU+YPzQ= -github.com/equinor/radix-operator v1.50.8 h1:PC9WxMOHxDzRH/2zboCn1Rq1nSuSpYA2/ylgvTgaTsA= -github.com/equinor/radix-operator v1.50.8/go.mod h1:bLL8hVfdEUuucNRGUit33uBjUhuunpNWO5youmZz8e8= +github.com/equinor/radix-operator v1.51.2 h1:O/FvXfCCPrzdlXpRVXH2rGf4v0sn1uHQxvMn//T5Al0= +github.com/equinor/radix-operator v1.51.2/go.mod h1:bLL8hVfdEUuucNRGUit33uBjUhuunpNWO5youmZz8e8= github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=