diff --git a/cmd/setComponentTLSSecret.go b/cmd/setComponentTLSSecret.go new file mode 100644 index 0000000..543096e --- /dev/null +++ b/cmd/setComponentTLSSecret.go @@ -0,0 +1,143 @@ +// 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" + "fmt" + "os" + + apiclient "github.com/equinor/radix-cli/generated-client/client" + "github.com/equinor/radix-cli/generated-client/client/component" + "github.com/equinor/radix-cli/generated-client/client/environment" + "github.com/equinor/radix-cli/generated-client/models" + "github.com/equinor/radix-cli/pkg/client" + "github.com/spf13/cobra" +) + +// setComponentTLSSecretCmd represents the setComponentTLSSecretCmd command +var setComponentTLSSecretCmd = &cobra.Command{ + Use: "tls", + Short: "Set TLS certificate and private key for DNS external alias", + Long: `Set TLS certificate and private key for DNS external alias`, + RunE: func(cmd *cobra.Command, args []string) error { + appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + if err != nil { + return err + } + if appName == nil || *appName == "" { + return errors.New("application name is required") + } + + environmentName, _ := cmd.Flags().GetString("environment") + if environmentName == "" { + return errors.New("`environment` is required") + } + + componentName, _ := cmd.Flags().GetString("component") + if componentName == "" { + return errors.New("`component` is required") + } + + fqdn, _ := cmd.Flags().GetString("alias") + if fqdn == "" { + return errors.New("`alias` is required") + } + + certificate, _ := cmd.Flags().GetString("certificate") + if certificate == "" { + return errors.New("`certificate` is required") + } + + privateKey, _ := cmd.Flags().GetString("private-key") + if privateKey == "" { + return errors.New("`private-key` is required") + } + + skipValidation, _ := cmd.Flags().GetBool("skip-validation") + awaitReconcile, _ := cmd.Flags().GetBool("await-reconcile") + cmd.SilenceUsage = true + + apiClient, err := client.GetForCommand(cmd) + if err != nil { + return err + } + + if awaitReconcile { + reconciledOk := awaitReconciliation(func() bool { + return isComponentExternalDNSReconciled(apiClient, *appName, environmentName, componentName, fqdn) + }) + + if !reconciledOk { + return fmt.Errorf("component was not reconciled within time: either component %s does not exist in the environment %s or external DNS alias %s is not defined", + componentName, environmentName, fqdn) + } + } + updateExternalDNSTLS := component.NewUpdateComponentExternalDNSTLSParams(). + WithAppName(*appName). + WithEnvName(environmentName). + WithComponentName(componentName). + WithFqdn(fqdn). + WithTLSData(&models.UpdateExternalDNSTLSRequest{ + Certificate: &certificate, + PrivateKey: &privateKey, + SkipValidation: skipValidation, + }) + + _, err = apiClient.Component.UpdateComponentExternalDNSTLS(updateExternalDNSTLS, nil) + return err + }, +} + +func isComponentExternalDNSReconciled(apiClient *apiclient.Radixapi, appName, environmentName, componentName, fqdn string) bool { + getEnvironmentParameters := environment.NewGetEnvironmentParams(). + WithAppName(appName). + WithEnvName(environmentName) + + env, err := apiClient.Environment.GetEnvironment(getEnvironmentParameters, nil) + if err != nil { + fmt.Fprintln(os.Stderr, err) + return false + } + + if env.Payload != nil && + env.Payload.ActiveDeployment != nil && + env.Payload.ActiveDeployment.Components != nil { + for _, component := range env.Payload.ActiveDeployment.Components { + if *component.Name == componentName { + for _, externalDns := range component.ExternalDNS { + if *externalDns.FQDN == fqdn { + return true + } + } + } + } + } + + return false +} + +func init() { + setCmd.AddCommand(setComponentTLSSecretCmd) + setComponentTLSSecretCmd.Flags().StringP("application", "a", "", "Name of the application") + setComponentTLSSecretCmd.Flags().StringP("environment", "e", "", "Name of the environment") + setComponentTLSSecretCmd.Flags().String("component", "", "Name of the component") + setComponentTLSSecretCmd.Flags().String("alias", "", "External DNS alias to update TLS for") + setComponentTLSSecretCmd.Flags().String("certificate", "", "Certificate in PEM format") + setComponentTLSSecretCmd.Flags().String("private-key", "", "Private key in PEM format") + setComponentTLSSecretCmd.Flags().Bool("skip-validation", false, "Skip validation of certificate and private key") + setComponentTLSSecretCmd.Flags().Bool("await-reconcile", true, "Await reconciliation in Radix. Default is true") + setContextSpecificPersistentFlags(setComponentTLSSecretCmd) +} diff --git a/generated-client/client/component/component_client.go b/generated-client/client/component/component_client.go index d98fa2f..1587575 100644 --- a/generated-client/client/component/component_client.go +++ b/generated-client/client/component/component_client.go @@ -52,6 +52,8 @@ type ClientService interface { StopComponent(params *StopComponentParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*StopComponentOK, error) + UpdateComponentExternalDNSTLS(params *UpdateComponentExternalDNSTLSParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateComponentExternalDNSTLSOK, error) + SetTransport(transport runtime.ClientTransport) } @@ -484,6 +486,45 @@ func (a *Client) StopComponent(params *StopComponentParams, authInfo runtime.Cli panic(msg) } +/* +UpdateComponentExternalDNSTLS sets external DNS TLS private key certificate for a component +*/ +func (a *Client) UpdateComponentExternalDNSTLS(params *UpdateComponentExternalDNSTLSParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateComponentExternalDNSTLSOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateComponentExternalDNSTLSParams() + } + op := &runtime.ClientOperation{ + ID: "updateComponentExternalDnsTls", + Method: "PUT", + PathPattern: "/applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &UpdateComponentExternalDNSTLSReader{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.(*UpdateComponentExternalDNSTLSOK) + 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 updateComponentExternalDnsTls: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/generated-client/client/component/update_component_external_dns_tls_parameters.go b/generated-client/client/component/update_component_external_dns_tls_parameters.go new file mode 100644 index 0000000..7413cba --- /dev/null +++ b/generated-client/client/component/update_component_external_dns_tls_parameters.go @@ -0,0 +1,291 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package component + +// 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" +) + +// NewUpdateComponentExternalDNSTLSParams creates a new UpdateComponentExternalDNSTLSParams 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 NewUpdateComponentExternalDNSTLSParams() *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithTimeout creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a timeout on a request. +func NewUpdateComponentExternalDNSTLSParamsWithTimeout(timeout time.Duration) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + timeout: timeout, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithContext creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a context for a request. +func NewUpdateComponentExternalDNSTLSParamsWithContext(ctx context.Context) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + Context: ctx, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithHTTPClient creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateComponentExternalDNSTLSParamsWithHTTPClient(client *http.Client) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + HTTPClient: client, + } +} + +/* +UpdateComponentExternalDNSTLSParams contains all the parameters to send to the API endpoint + + for the update component external Dns Tls operation. + + Typically these are written to a http.Request. +*/ +type UpdateComponentExternalDNSTLSParams 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 + + /* AppName. + + Name of application + */ + AppName string + + /* ComponentName. + + secret component of Radix application + */ + ComponentName string + + /* EnvName. + + secret of Radix application + */ + EnvName string + + /* Fqdn. + + FQDN to be updated + */ + Fqdn string + + /* TLSData. + + New TLS private key and certificate + */ + TLSData *models.UpdateExternalDNSTLSRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update component external Dns Tls params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateComponentExternalDNSTLSParams) WithDefaults() *UpdateComponentExternalDNSTLSParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update component external Dns Tls params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateComponentExternalDNSTLSParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithTimeout(timeout time.Duration) *UpdateComponentExternalDNSTLSParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithContext(ctx context.Context) *UpdateComponentExternalDNSTLSParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithHTTPClient(client *http.Client) *UpdateComponentExternalDNSTLSParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithImpersonateGroup adds the impersonateGroup to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithImpersonateGroup(impersonateGroup *string) *UpdateComponentExternalDNSTLSParams { + o.SetImpersonateGroup(impersonateGroup) + return o +} + +// SetImpersonateGroup adds the impersonateGroup to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetImpersonateGroup(impersonateGroup *string) { + o.ImpersonateGroup = impersonateGroup +} + +// WithImpersonateUser adds the impersonateUser to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithImpersonateUser(impersonateUser *string) *UpdateComponentExternalDNSTLSParams { + o.SetImpersonateUser(impersonateUser) + return o +} + +// SetImpersonateUser adds the impersonateUser to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetImpersonateUser(impersonateUser *string) { + o.ImpersonateUser = impersonateUser +} + +// WithAppName adds the appName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithAppName(appName string) *UpdateComponentExternalDNSTLSParams { + o.SetAppName(appName) + return o +} + +// SetAppName adds the appName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetAppName(appName string) { + o.AppName = appName +} + +// WithComponentName adds the componentName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithComponentName(componentName string) *UpdateComponentExternalDNSTLSParams { + o.SetComponentName(componentName) + return o +} + +// SetComponentName adds the componentName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetComponentName(componentName string) { + o.ComponentName = componentName +} + +// WithEnvName adds the envName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithEnvName(envName string) *UpdateComponentExternalDNSTLSParams { + o.SetEnvName(envName) + return o +} + +// SetEnvName adds the envName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetEnvName(envName string) { + o.EnvName = envName +} + +// WithFqdn adds the fqdn to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithFqdn(fqdn string) *UpdateComponentExternalDNSTLSParams { + o.SetFqdn(fqdn) + return o +} + +// SetFqdn adds the fqdn to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetFqdn(fqdn string) { + o.Fqdn = fqdn +} + +// WithTLSData adds the tLSData to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithTLSData(tLSData *models.UpdateExternalDNSTLSRequest) *UpdateComponentExternalDNSTLSParams { + o.SetTLSData(tLSData) + return o +} + +// SetTLSData adds the tlsData to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetTLSData(tLSData *models.UpdateExternalDNSTLSRequest) { + o.TLSData = tLSData +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateComponentExternalDNSTLSParams) 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 + } + } + + // path param appName + if err := r.SetPathParam("appName", o.AppName); err != nil { + return err + } + + // path param componentName + if err := r.SetPathParam("componentName", o.ComponentName); err != nil { + return err + } + + // path param envName + if err := r.SetPathParam("envName", o.EnvName); err != nil { + return err + } + + // path param fqdn + if err := r.SetPathParam("fqdn", o.Fqdn); err != nil { + return err + } + if o.TLSData != nil { + if err := r.SetBodyParam(o.TLSData); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/generated-client/client/component/update_component_external_dns_tls_responses.go b/generated-client/client/component/update_component_external_dns_tls_responses.go new file mode 100644 index 0000000..8b4ed00 --- /dev/null +++ b/generated-client/client/component/update_component_external_dns_tls_responses.go @@ -0,0 +1,460 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package component + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// UpdateComponentExternalDNSTLSReader is a Reader for the UpdateComponentExternalDNSTLS structure. +type UpdateComponentExternalDNSTLSReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateComponentExternalDNSTLSReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateComponentExternalDNSTLSOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewUpdateComponentExternalDNSTLSBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewUpdateComponentExternalDNSTLSUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewUpdateComponentExternalDNSTLSForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewUpdateComponentExternalDNSTLSNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewUpdateComponentExternalDNSTLSConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewUpdateComponentExternalDNSTLSInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls] updateComponentExternalDnsTls", response, response.Code()) + } +} + +// NewUpdateComponentExternalDNSTLSOK creates a UpdateComponentExternalDNSTLSOK with default headers values +func NewUpdateComponentExternalDNSTLSOK() *UpdateComponentExternalDNSTLSOK { + return &UpdateComponentExternalDNSTLSOK{} +} + +/* +UpdateComponentExternalDNSTLSOK describes a response with status code 200, with default header values. + +success +*/ +type UpdateComponentExternalDNSTLSOK struct { +} + +// IsSuccess returns true when this update component external Dns Tls o k response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update component external Dns Tls o k response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls o k response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update component external Dns Tls o k response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls o k response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update component external Dns Tls o k response +func (o *UpdateComponentExternalDNSTLSOK) Code() int { + return 200 +} + +func (o *UpdateComponentExternalDNSTLSOK) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsOK ", 200) +} + +func (o *UpdateComponentExternalDNSTLSOK) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsOK ", 200) +} + +func (o *UpdateComponentExternalDNSTLSOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSBadRequest creates a UpdateComponentExternalDNSTLSBadRequest with default headers values +func NewUpdateComponentExternalDNSTLSBadRequest() *UpdateComponentExternalDNSTLSBadRequest { + return &UpdateComponentExternalDNSTLSBadRequest{} +} + +/* +UpdateComponentExternalDNSTLSBadRequest describes a response with status code 400, with default header values. + +Invalid application +*/ +type UpdateComponentExternalDNSTLSBadRequest struct { +} + +// IsSuccess returns true when this update component external Dns Tls bad request response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls bad request response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls bad request response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls bad request response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls bad request response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the update component external Dns Tls bad request response +func (o *UpdateComponentExternalDNSTLSBadRequest) Code() int { + return 400 +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsBadRequest ", 400) +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsBadRequest ", 400) +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSUnauthorized creates a UpdateComponentExternalDNSTLSUnauthorized with default headers values +func NewUpdateComponentExternalDNSTLSUnauthorized() *UpdateComponentExternalDNSTLSUnauthorized { + return &UpdateComponentExternalDNSTLSUnauthorized{} +} + +/* +UpdateComponentExternalDNSTLSUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type UpdateComponentExternalDNSTLSUnauthorized struct { +} + +// IsSuccess returns true when this update component external Dns Tls unauthorized response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls unauthorized response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls unauthorized response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls unauthorized response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls unauthorized response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the update component external Dns Tls unauthorized response +func (o *UpdateComponentExternalDNSTLSUnauthorized) Code() int { + return 401 +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsUnauthorized ", 401) +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsUnauthorized ", 401) +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSForbidden creates a UpdateComponentExternalDNSTLSForbidden with default headers values +func NewUpdateComponentExternalDNSTLSForbidden() *UpdateComponentExternalDNSTLSForbidden { + return &UpdateComponentExternalDNSTLSForbidden{} +} + +/* +UpdateComponentExternalDNSTLSForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type UpdateComponentExternalDNSTLSForbidden struct { +} + +// IsSuccess returns true when this update component external Dns Tls forbidden response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls forbidden response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls forbidden response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls forbidden response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls forbidden response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update component external Dns Tls forbidden response +func (o *UpdateComponentExternalDNSTLSForbidden) Code() int { + return 403 +} + +func (o *UpdateComponentExternalDNSTLSForbidden) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsForbidden ", 403) +} + +func (o *UpdateComponentExternalDNSTLSForbidden) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsForbidden ", 403) +} + +func (o *UpdateComponentExternalDNSTLSForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSNotFound creates a UpdateComponentExternalDNSTLSNotFound with default headers values +func NewUpdateComponentExternalDNSTLSNotFound() *UpdateComponentExternalDNSTLSNotFound { + return &UpdateComponentExternalDNSTLSNotFound{} +} + +/* +UpdateComponentExternalDNSTLSNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type UpdateComponentExternalDNSTLSNotFound struct { +} + +// IsSuccess returns true when this update component external Dns Tls not found response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls not found response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls not found response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls not found response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls not found response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update component external Dns Tls not found response +func (o *UpdateComponentExternalDNSTLSNotFound) Code() int { + return 404 +} + +func (o *UpdateComponentExternalDNSTLSNotFound) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsNotFound ", 404) +} + +func (o *UpdateComponentExternalDNSTLSNotFound) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsNotFound ", 404) +} + +func (o *UpdateComponentExternalDNSTLSNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSConflict creates a UpdateComponentExternalDNSTLSConflict with default headers values +func NewUpdateComponentExternalDNSTLSConflict() *UpdateComponentExternalDNSTLSConflict { + return &UpdateComponentExternalDNSTLSConflict{} +} + +/* +UpdateComponentExternalDNSTLSConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type UpdateComponentExternalDNSTLSConflict struct { +} + +// IsSuccess returns true when this update component external Dns Tls conflict response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls conflict response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls conflict response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls conflict response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls conflict response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the update component external Dns Tls conflict response +func (o *UpdateComponentExternalDNSTLSConflict) Code() int { + return 409 +} + +func (o *UpdateComponentExternalDNSTLSConflict) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsConflict ", 409) +} + +func (o *UpdateComponentExternalDNSTLSConflict) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsConflict ", 409) +} + +func (o *UpdateComponentExternalDNSTLSConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSInternalServerError creates a UpdateComponentExternalDNSTLSInternalServerError with default headers values +func NewUpdateComponentExternalDNSTLSInternalServerError() *UpdateComponentExternalDNSTLSInternalServerError { + return &UpdateComponentExternalDNSTLSInternalServerError{} +} + +/* +UpdateComponentExternalDNSTLSInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type UpdateComponentExternalDNSTLSInternalServerError struct { +} + +// IsSuccess returns true when this update component external Dns Tls internal server error response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls internal server error response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls internal server error response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this update component external Dns Tls internal server error response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this update component external Dns Tls internal server error response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the update component external Dns Tls internal server error response +func (o *UpdateComponentExternalDNSTLSInternalServerError) Code() int { + return 500 +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsInternalServerError ", 500) +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsInternalServerError ", 500) +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/generated-client/models/component.go b/generated-client/models/component.go index df70340..d1d70e4 100644 --- a/generated-client/models/component.go +++ b/generated-client/models/component.go @@ -21,6 +21,9 @@ import ( // swagger:model Component type Component struct { + // Array of external DNS configurations + ExternalDNS []*ExternalDNS `json:"externalDNS"` + // Image name // Example: radixdev.azurecr.io/app-server:cdgkg // Required: true @@ -84,6 +87,10 @@ type Component struct { func (m *Component) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateExternalDNS(formats); err != nil { + res = append(res, err) + } + if err := m.validateImage(formats); err != nil { res = append(res, err) } @@ -130,6 +137,32 @@ func (m *Component) Validate(formats strfmt.Registry) error { return nil } +func (m *Component) validateExternalDNS(formats strfmt.Registry) error { + if swag.IsZero(m.ExternalDNS) { // not required + return nil + } + + for i := 0; i < len(m.ExternalDNS); i++ { + if swag.IsZero(m.ExternalDNS[i]) { // not required + continue + } + + if m.ExternalDNS[i] != nil { + if err := m.ExternalDNS[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Component) validateImage(formats strfmt.Registry) error { if err := validate.Required("image", "body", m.Image); err != nil { @@ -374,6 +407,10 @@ func (m *Component) validateOauth2(formats strfmt.Registry) error { func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateExternalDNS(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidatePorts(ctx, formats); err != nil { res = append(res, err) } @@ -404,6 +441,31 @@ func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry return nil } +func (m *Component) contextValidateExternalDNS(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ExternalDNS); i++ { + + if m.ExternalDNS[i] != nil { + + if swag.IsZero(m.ExternalDNS[i]) { // not required + return nil + } + + if err := m.ExternalDNS[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Component) contextValidatePorts(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Ports); i++ { diff --git a/generated-client/models/external_dns.go b/generated-client/models/external_dns.go new file mode 100644 index 0000000..d5239d8 --- /dev/null +++ b/generated-client/models/external_dns.go @@ -0,0 +1,126 @@ +// 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" +) + +// ExternalDNS ExternalDNS describes an external DNS entry for a component +// +// swagger:model ExternalDNS +type ExternalDNS struct { + + // Fully Qualified Domain Name + // Example: site.example.com + // Required: true + FQDN *string `json:"fqdn"` + + // tls + // Required: true + TLS *TLS `json:"tls"` +} + +// Validate validates this external DNS +func (m *ExternalDNS) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFQDN(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTLS(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExternalDNS) validateFQDN(formats strfmt.Registry) error { + + if err := validate.Required("fqdn", "body", m.FQDN); err != nil { + return err + } + + return nil +} + +func (m *ExternalDNS) validateTLS(formats strfmt.Registry) error { + + if err := validate.Required("tls", "body", m.TLS); err != nil { + return err + } + + if m.TLS != nil { + if err := m.TLS.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tls") + } + return err + } + } + + return nil +} + +// ContextValidate validate this external DNS based on the context it is used +func (m *ExternalDNS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTLS(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExternalDNS) contextValidateTLS(ctx context.Context, formats strfmt.Registry) error { + + if m.TLS != nil { + + if err := m.TLS.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tls") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExternalDNS) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExternalDNS) UnmarshalBinary(b []byte) error { + var res ExternalDNS + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/secret.go b/generated-client/models/secret.go index a6016e9..e332d9d 100644 --- a/generated-client/models/secret.go +++ b/generated-client/models/secret.go @@ -8,7 +8,6 @@ package models import ( "context" "encoding/json" - "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -47,19 +46,11 @@ type Secret struct { // Consistent = Secret exists in Radix config and in cluster // NotAvailable = Secret is available in external secret configuration but not in cluster // Example: Consistent - // Enum: [Pending Consistent NotAvailable Invalid] + // Enum: [Pending Consistent NotAvailable] Status string `json:"status,omitempty"` - // StatusMessages contains a list of messages related to the Status - StatusMessages []string `json:"statusMessages"` - - // TLSCertificates holds the TLS certificate and certificate authorities (CA) - // The first certificate in the list should be the TLS certificate and the rest should be CA certificates - TLSCertificates []*TLSCertificate `json:"tlsCertificates"` - // Type of the secret // generic SecretTypeGeneric - // client-cert SecretTypeClientCert // azure-blob-fuse-volume SecretTypeAzureBlobFuseVolume // csi-azure-blob-volume SecretTypeCsiAzureBlobVolume // csi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds @@ -67,7 +58,7 @@ type Secret struct { // client-cert-auth SecretTypeClientCertificateAuth // oauth2-proxy SecretTypeOAuth2Proxy // Example: client-cert - // Enum: [generic client-cert azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] + // Enum: [generic azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] Type string `json:"type,omitempty"` } @@ -83,10 +74,6 @@ func (m *Secret) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateTLSCertificates(formats); err != nil { - res = append(res, err) - } - if err := m.validateType(formats); err != nil { res = append(res, err) } @@ -110,7 +97,7 @@ var secretTypeStatusPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Pending","Consistent","NotAvailable","Invalid"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Pending","Consistent","NotAvailable"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -128,9 +115,6 @@ const ( // SecretStatusNotAvailable captures enum value "NotAvailable" SecretStatusNotAvailable string = "NotAvailable" - - // SecretStatusInvalid captures enum value "Invalid" - SecretStatusInvalid string = "Invalid" ) // prop value enum @@ -154,37 +138,11 @@ func (m *Secret) validateStatus(formats strfmt.Registry) error { return nil } -func (m *Secret) validateTLSCertificates(formats strfmt.Registry) error { - if swag.IsZero(m.TLSCertificates) { // not required - return nil - } - - for i := 0; i < len(m.TLSCertificates); i++ { - if swag.IsZero(m.TLSCertificates[i]) { // not required - continue - } - - if m.TLSCertificates[i] != nil { - if err := m.TLSCertificates[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - var secretTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["generic","client-cert","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["generic","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -197,9 +155,6 @@ const ( // SecretTypeGeneric captures enum value "generic" SecretTypeGeneric string = "generic" - // SecretTypeClientDashCert captures enum value "client-cert" - SecretTypeClientDashCert string = "client-cert" - // SecretTypeAzureDashBlobDashFuseDashVolume captures enum value "azure-blob-fuse-volume" SecretTypeAzureDashBlobDashFuseDashVolume string = "azure-blob-fuse-volume" @@ -240,42 +195,8 @@ func (m *Secret) validateType(formats strfmt.Registry) error { return nil } -// ContextValidate validate this secret based on the context it is used +// ContextValidate validates this secret based on context it is used func (m *Secret) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateTLSCertificates(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Secret) contextValidateTLSCertificates(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.TLSCertificates); i++ { - - if m.TLSCertificates[i] != nil { - - if swag.IsZero(m.TLSCertificates[i]) { // not required - return nil - } - - if err := m.TLSCertificates[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - return nil } diff --git a/generated-client/models/secret_parameters.go b/generated-client/models/secret_parameters.go index b48776c..643f646 100644 --- a/generated-client/models/secret_parameters.go +++ b/generated-client/models/secret_parameters.go @@ -27,7 +27,6 @@ type SecretParameters struct { // Type of the secret // generic SecretTypeGeneric - // client-cert SecretTypeClientCert // azure-blob-fuse-volume SecretTypeAzureBlobFuseVolume // csi-azure-blob-volume SecretTypeCsiAzureBlobVolume // csi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds @@ -35,7 +34,7 @@ type SecretParameters struct { // client-cert-auth SecretTypeClientCertificateAuth // oauth2-proxy SecretTypeOAuth2Proxy // Example: azure-blob-fuse-volume - // Enum: [generic client-cert azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] + // Enum: [generic azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] Type string `json:"type,omitempty"` } @@ -70,7 +69,7 @@ var secretParametersTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["generic","client-cert","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["generic","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -83,9 +82,6 @@ const ( // SecretParametersTypeGeneric captures enum value "generic" SecretParametersTypeGeneric string = "generic" - // SecretParametersTypeClientDashCert captures enum value "client-cert" - SecretParametersTypeClientDashCert string = "client-cert" - // SecretParametersTypeAzureDashBlobDashFuseDashVolume captures enum value "azure-blob-fuse-volume" SecretParametersTypeAzureDashBlobDashFuseDashVolume string = "azure-blob-fuse-volume" diff --git a/generated-client/models/step.go b/generated-client/models/step.go index f433f9c..b47e10f 100644 --- a/generated-client/models/step.go +++ b/generated-client/models/step.go @@ -24,16 +24,16 @@ type Step struct { Components []string `json:"components"` // Ended timestamp - // Example: 2006-01-02T15:04:05Z - Ended string `json:"ended,omitempty"` + // Format: date-time + Ended strfmt.DateTime `json:"ended,omitempty"` // Name of the step // Example: build Name string `json:"name,omitempty"` // Started timestamp - // Example: 2006-01-02T15:04:05Z - Started string `json:"started,omitempty"` + // Format: date-time + Started strfmt.DateTime `json:"started,omitempty"` // Status of the step // Example: Waiting @@ -45,6 +45,14 @@ type Step struct { func (m *Step) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateEnded(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStarted(formats); err != nil { + res = append(res, err) + } + if err := m.validateStatus(formats); err != nil { res = append(res, err) } @@ -55,6 +63,30 @@ func (m *Step) Validate(formats strfmt.Registry) error { return nil } +func (m *Step) validateEnded(formats strfmt.Registry) error { + if swag.IsZero(m.Ended) { // not required + return nil + } + + if err := validate.FormatOf("ended", "body", "date-time", m.Ended.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Step) validateStarted(formats strfmt.Registry) error { + if swag.IsZero(m.Started) { // not required + return nil + } + + if err := validate.FormatOf("started", "body", "date-time", m.Started.String(), formats); err != nil { + return err + } + + return nil +} + var stepTypeStatusPropEnum []interface{} func init() { diff --git a/generated-client/models/tls.go b/generated-client/models/tls.go new file mode 100644 index 0000000..31d3421 --- /dev/null +++ b/generated-client/models/tls.go @@ -0,0 +1,203 @@ +// 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" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TLS TLS configuration and status for external DNS +// +// swagger:model TLS +type TLS struct { + + // Certificates holds the X509 certificate chain + // The first certificate in the list should be the host certificate and the rest should be intermediate certificates + Certificates []*X509Certificate `json:"certificates"` + + // Status of TLS certificate and private key + // Pending TLSStatusPending TLS certificate and private key not set + // Consistent TLSStatusConsistent TLS certificate and private key is valid + // Invalid TLSStatusInvalid TLS certificate and private key is invalid + // Example: Consistent + // Required: true + // Enum: [Pending Consistent Invalid] + Status *string `json:"status"` + + // StatusMessages contains a list of messages related to Status + StatusMessages []string `json:"statusMessages"` + + // UseAutomation describes if TLS certificate is automatically issued using automation (ACME) + // Required: true + UseAutomation *bool `json:"useAutomation"` +} + +// Validate validates this TLS +func (m *TLS) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCertificates(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUseAutomation(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TLS) validateCertificates(formats strfmt.Registry) error { + if swag.IsZero(m.Certificates) { // not required + return nil + } + + for i := 0; i < len(m.Certificates); i++ { + if swag.IsZero(m.Certificates[i]) { // not required + continue + } + + if m.Certificates[i] != nil { + if err := m.Certificates[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("certificates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("certificates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var tlsTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Pending","Consistent","Invalid"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + tlsTypeStatusPropEnum = append(tlsTypeStatusPropEnum, v) + } +} + +const ( + + // TLSStatusPending captures enum value "Pending" + TLSStatusPending string = "Pending" + + // TLSStatusConsistent captures enum value "Consistent" + TLSStatusConsistent string = "Consistent" + + // TLSStatusInvalid captures enum value "Invalid" + TLSStatusInvalid string = "Invalid" +) + +// prop value enum +func (m *TLS) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, tlsTypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *TLS) 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 +} + +func (m *TLS) validateUseAutomation(formats strfmt.Registry) error { + + if err := validate.Required("useAutomation", "body", m.UseAutomation); err != nil { + 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 + + if err := m.contextValidateCertificates(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TLS) contextValidateCertificates(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Certificates); i++ { + + if m.Certificates[i] != nil { + + if swag.IsZero(m.Certificates[i]) { // not required + return nil + } + + if err := m.Certificates[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("certificates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("certificates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TLS) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TLS) UnmarshalBinary(b []byte) error { + var res TLS + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/update_external_dns_tls_request.go b/generated-client/models/update_external_dns_tls_request.go new file mode 100644 index 0000000..29120a3 --- /dev/null +++ b/generated-client/models/update_external_dns_tls_request.go @@ -0,0 +1,91 @@ +// 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" +) + +// UpdateExternalDNSTLSRequest UpdateExternalDNSTLSRequest describes request body for setting private key and certificate for external DNS TLS +// +// swagger:model UpdateExternalDNSTLSRequest +type UpdateExternalDNSTLSRequest struct { + + // X509 certificate in PEM format + // Required: true + Certificate *string `json:"certificate"` + + // Private key in PEM format + // Required: true + PrivateKey *string `json:"privateKey"` + + // Skip validation of certificate and private key + SkipValidation bool `json:"skipValidation,omitempty"` +} + +// Validate validates this update external DNS TLS request +func (m *UpdateExternalDNSTLSRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCertificate(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrivateKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateExternalDNSTLSRequest) validateCertificate(formats strfmt.Registry) error { + + if err := validate.Required("certificate", "body", m.Certificate); err != nil { + return err + } + + return nil +} + +func (m *UpdateExternalDNSTLSRequest) validatePrivateKey(formats strfmt.Registry) error { + + if err := validate.Required("privateKey", "body", m.PrivateKey); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this update external DNS TLS request based on context it is used +func (m *UpdateExternalDNSTLSRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateExternalDNSTLSRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateExternalDNSTLSRequest) UnmarshalBinary(b []byte) error { + var res UpdateExternalDNSTLSRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/x509_certificate.go b/generated-client/models/x509_certificate.go new file mode 100644 index 0000000..f47f4d2 --- /dev/null +++ b/generated-client/models/x509_certificate.go @@ -0,0 +1,137 @@ +// 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" +) + +// X509Certificate X509Certificate holds information about a X509 certificate +// +// swagger:model X509Certificate +type X509Certificate struct { + + // DNSNames defines list of Subject Alternate Names in the certificate + DNSNames []string `json:"dnsNames"` + + // Issuer contains the distinguished name for the certificate's issuer + // Example: CN=DigiCert TLS RSA SHA256 2020 CA1,O=DigiCert Inc,C=US + // Required: true + Issuer *string `json:"issuer"` + + // NotAfter defines the uppdater date/time validity boundary + // Required: true + // Format: date-time + NotAfter *strfmt.DateTime `json:"notAfter"` + + // NotBefore defines the lower date/time validity boundary + // Required: true + // Format: date-time + NotBefore *strfmt.DateTime `json:"notBefore"` + + // Subject contains the distinguished name for the certificate + // Example: CN=mysite.example.com,O=MyOrg,L=MyLocation,C=NO + // Required: true + Subject *string `json:"subject"` +} + +// Validate validates this x509 certificate +func (m *X509Certificate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIssuer(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotAfter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotBefore(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubject(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *X509Certificate) validateIssuer(formats strfmt.Registry) error { + + if err := validate.Required("issuer", "body", m.Issuer); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateNotAfter(formats strfmt.Registry) error { + + if err := validate.Required("notAfter", "body", m.NotAfter); err != nil { + return err + } + + if err := validate.FormatOf("notAfter", "body", "date-time", m.NotAfter.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateNotBefore(formats strfmt.Registry) error { + + if err := validate.Required("notBefore", "body", m.NotBefore); err != nil { + return err + } + + if err := validate.FormatOf("notBefore", "body", "date-time", m.NotBefore.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateSubject(formats strfmt.Registry) error { + + if err := validate.Required("subject", "body", m.Subject); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this x509 certificate based on context it is used +func (m *X509Certificate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *X509Certificate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *X509Certificate) UnmarshalBinary(b []byte) error { + var res X509Certificate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}