Skip to content

Commit

Permalink
fix: keep default values for all primitive type
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiiiel committed Nov 8, 2024
1 parent 0d2b144 commit 01d333c
Show file tree
Hide file tree
Showing 53 changed files with 800 additions and 214 deletions.
4 changes: 2 additions & 2 deletions api/model/api/base/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ const (

type ResponseTemplate struct {
// +kubebuilder:validation:Optional
StatusCode int `json:"status,omitempty"`
StatusCode *int `json:"status,omitempty"`
// +kubebuilder:validation:Optional
Headers map[string]string `json:"headers,omitempty"`
// +kubebuilder:validation:Optional
Body string `json:"body,omitempty"`
Body *string `json:"body,omitempty"`
}

func (api *ApiBase) GetName() string {
Expand Down
8 changes: 4 additions & 4 deletions api/model/api/base/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ type FlowStep struct {
Enabled bool `json:"enabled"`
// FlowStep policy
// +kubebuilder:validation:Optional
Policy string `json:"policy,omitempty"`
Policy *string `json:"policy,omitempty"`
// FlowStep name
// +kubebuilder:validation:Optional
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// FlowStep description
// +kubebuilder:validation:Optional
Description string `json:"description,omitempty"`
Description *string `json:"description,omitempty"`
// FlowStep configuration is a map of arbitrary key-values
// +kubebuilder:validation:Optional
Configuration *utils.GenericStringMap `json:"configuration,omitempty"`
// FlowStep condition
// +kubebuilder:validation:Optional
Condition string `json:"condition,omitempty"`
Condition *string `json:"condition,omitempty"`
}
20 changes: 10 additions & 10 deletions api/model/api/base/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ type Cors struct {
type HttpClientOptions struct {
// Idle Timeout for the http connection
// +kubebuilder:validation:Optional
IdleTimeout uint64 `json:"idleTimeout,omitempty"`
IdleTimeout *uint64 `json:"idleTimeout,omitempty"`
// Connection timeout of the http connection
// +kubebuilder:validation:Optional
ConnectTimeout uint64 `json:"connectTimeout,omitempty"`
ConnectTimeout *uint64 `json:"connectTimeout,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default:=true
KeepAlive bool `json:"keepAlive"`
Expand All @@ -69,13 +69,13 @@ type HttpClientOptions struct {
KeepAliveTimeout uint64 `json:"keepAliveTimeout"`
// Read timeout
// +kubebuilder:validation:Optional
ReadTimeout uint64 `json:"readTimeout,omitempty"`
ReadTimeout *uint64 `json:"readTimeout,omitempty"`
// +kubebuilder:default:=false
// Should HTTP/1.1 pipelining be used for the connection or not ?
Pipelining bool `json:"pipelining"`
// HTTP max concurrent connections
// +kubebuilder:validation:Optional
MaxConcurrentConnections int `json:"maxConcurrentConnections,omitempty"`
MaxConcurrentConnections *int `json:"maxConcurrentConnections,omitempty"`
// +kubebuilder:default:=false
// Should compression be used or not ?
UseCompression bool `json:"useCompression"`
Expand Down Expand Up @@ -117,25 +117,25 @@ type HttpProxy struct {
UseSystemProxy bool `json:"useSystemProxy,omitempty"`
// Proxy host name
// +kubebuilder:validation:Optional
Host string `json:"host,omitempty"`
Host *string `json:"host,omitempty"`
// The HTTP proxy port
// +kubebuilder:validation:Optional
Port int `json:"port,omitempty"`
Port *int `json:"port,omitempty"`
// The HTTP proxy username (if the proxy requires authentication)
// +kubebuilder:validation:Optional
Username string `json:"username,omitempty"`
Username *string `json:"username,omitempty"`
// The HTTP proxy password (if the proxy requires authentication)
// +kubebuilder:validation:Optional
Password string `json:"password,omitempty"`
Password *string `json:"password,omitempty"`
// The HTTP proxy type (possible values Http, Socks4, Socks5)
HttpProxyType HttpProxyType `json:"type,omitempty"`
}

type HttpHeader struct {
// The HTTP header name
// +kubebuilder:validation:Optional
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// The HTTP header value
// +kubebuilder:validation:Optional
Value string `json:"value,omitempty"`
Value *string `json:"value,omitempty"`
}
36 changes: 18 additions & 18 deletions api/model/api/base/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,76 +36,76 @@ type PEMTrustStore struct {
Type KeyStoreType `json:"type,omitempty"`
// The path to the TrustStore
// +kubebuilder:validation:Optional
Path string `json:"path,omitempty"`
Path *string `json:"path,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
}

type PKCS12TrustStore struct {
// The trustStore type (should be set to PKCS12 in that case)
Type KeyStoreType `json:"type,omitempty"`
// The TrustStore path
// +kubebuilder:validation:Optional
Path string `json:"path,omitempty"`
Path *string `json:"path,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
// TrustStore password
// +kubebuilder:validation:Optional
Password string `json:"password,omitempty"`
Password *string `json:"password,omitempty"`
}
type JKSTrustStore struct {
// The TrustStore type (should be JKS in that case)
Type KeyStoreType `json:"type,omitempty"`
// TrustStore path
// +kubebuilder:validation:Optional
Path string `json:"path,omitempty"`
Path *string `json:"path,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
// TrustStore password
// +kubebuilder:validation:Optional
Password string `json:"password,omitempty"`
Password *string `json:"password,omitempty"`
}
type PEMKeyStore struct {
// KeyStore type (should be PEM in that case)
Type KeyStoreType `json:"type,omitempty"`
// KeyStore key path
// +kubebuilder:validation:Optional
KeyPath string `json:"keyPath,omitempty"`
KeyPath *string `json:"keyPath,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
KeyContent string `json:"keyContent,omitempty"`
KeyContent *string `json:"keyContent,omitempty"`
// KeyStore cert path
// +kubebuilder:validation:Optional
CertPath string `json:"certPath,omitempty"`
CertPath *string `json:"certPath,omitempty"`
// KeyStore cert content
// +kubebuilder:validation:Optional
CertContent string `json:"certContent,omitempty"`
CertContent *string `json:"certContent,omitempty"`
}

type PKCS12KeyStore struct {
// KeyStore type (should be PKCS12 in that case)
Type KeyStoreType `json:"type,omitempty"`
// KeyStore path
// +kubebuilder:validation:Optional
Path string `json:"path,omitempty"`
Path *string `json:"path,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
// +kubebuilder:validation:Optional
Password string `json:"password,omitempty"`
Password *string `json:"password,omitempty"`
}

type JKSKeyStore struct {
Type KeyStoreType `json:"type,omitempty"`
// +kubebuilder:validation:Optional
Path string `json:"path,omitempty"`
Path *string `json:"path,omitempty"`
// The base64 encoded trustStore content, if not relying on a path to a file
// +kubebuilder:validation:Optional
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
// KeyStore password
// +kubebuilder:validation:Optional
Password string `json:"password,omitempty"`
Password *string `json:"password,omitempty"`
}
4 changes: 2 additions & 2 deletions api/model/api/base/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Member struct {
SourceID string `json:"sourceId"`
// Member display name
// +kubebuilder:validation:Optional
DisplayName string `json:"displayName,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
// The API role associated with this Member
// +kubebuilder:default:=USER
Role string `json:"role,omitempty"`
Expand All @@ -36,7 +36,7 @@ type Member struct {
func (m *Member) String() string {
return fmt.Sprintf(
"{Source:%s,SourceID:%s,DisplayName:%s,Role:%s}",
m.Source, m.SourceID, m.DisplayName, m.Role,
m.Source, m.SourceID, *m.DisplayName, m.Role,
)
}

Expand Down
2 changes: 1 addition & 1 deletion api/model/api/base/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ type MetadataEntry struct {
Value string `json:"value,omitempty"`
// Metadata Default value
// +kubebuilder:validation:Optional
DefaultValue string `json:"defaultValue,omitempty"`
DefaultValue *string `json:"defaultValue,omitempty"`
}
10 changes: 5 additions & 5 deletions api/model/api/base/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ type Page struct {
Type string `json:"type"`
// +kubebuilder:validation:Optional
// The content of the page, if any.
Content string `json:"content,omitempty"`
Content *string `json:"content,omitempty"`
// +kubebuilder:validation:Optional
// The order used to display the page in APIM and on the portal.
Order uint64 `json:"order,omitempty"`
Order *uint64 `json:"order,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default:=false
// If true, the page will be accessible from the portal (default is false)
Expand All @@ -76,15 +76,15 @@ type Page struct {
// +kubebuilder:validation:Optional
// If your page contains a folder, setting this field to the map key associated to the
// folder entry will be reflected into APIM by making the page a child of this folder.
Parent string `json:"parent,omitempty"`
Parent *string `json:"parent,omitempty"`
// +kubebuilder:validation:Optional
// The parent ID of the page. This field is mostly required when you are applying
// an API exported from APIM to make the operator take control over it. Use `Parent`
// in any other case.
ParentID string `json:"parentId,omitempty"`
ParentID *string `json:"parentId,omitempty"`
// +kubebuilder:validation:Optional
// The API of the page. If empty, will be set automatically to the generated ID of the API.
API string `json:"api,omitempty"`
API *string `json:"api,omitempty"`
// +kubebuilder:validation:Optional
// Source allow you to fetch pages from various external sources, overriding page content
// each time the source is fetched.
Expand Down
4 changes: 2 additions & 2 deletions api/model/api/base/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type Plan struct {
Validation PlanValidation `json:"validation,omitempty"`
// Indicate of comment is required for this plan or not
// +kubebuilder:validation:Optional
CommentRequired bool `json:"comment_required,omitempty"`
CommentRequired *bool `json:"comment_required,omitempty"`
// Plan order
// +kubebuilder:validation:Optional
Order int `json:"order,omitempty"`
Order *int `json:"order,omitempty"`
// +kubebuilder:default:=API
// Plan type
Type PlanType `json:"type,omitempty"`
Expand Down
14 changes: 7 additions & 7 deletions api/model/api/base/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import "github.com/gravitee-io/gravitee-kubernetes-operator/api/model/utils"
type Plugin struct {
// Plugin Policy
// +kubebuilder:validation:Optional
Policy string `json:"policy,omitempty"`
Policy *string `json:"policy,omitempty"`
// Plugin Resource
// +kubebuilder:validation:Optional
Resource string `json:"resource,omitempty"`
Resource *string `json:"resource,omitempty"`
// Plugin Configuration, a map of arbitrary key-values
// +kubebuilder:validation:Optional
Configuration *utils.GenericStringMap `json:"configuration,omitempty"`
Expand All @@ -31,24 +31,24 @@ type Plugin struct {
type PluginReference struct {
// Plugin Reference Namespace
// +kubebuilder:validation:Optional
Namespace string `json:"namespace,omitempty"`
Namespace *string `json:"namespace,omitempty"`
// Plugin Reference Resource
// +kubebuilder:validation:Optional
Resource string `json:"resource,omitempty"`
Resource *string `json:"resource,omitempty"`
// Plugin Reference Name
// +kubebuilder:validation:Optional
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
}

type PluginRevision struct {
// Plugin reference
PluginReference *PluginReference `json:"pluginReference,omitempty"`
// Plugin Generation
// +kubebuilder:validation:Optional
Generation int64 `json:"generation,omitempty"`
Generation *int64 `json:"generation,omitempty"`
// Plugin
Plugin *Plugin `json:"plugin,omitempty"`
// Plugin Revision Hash code
// +kubebuilder:validation:Optional
HashCode string `json:"hashCode,omitempty"`
HashCode *string `json:"hashCode,omitempty"`
}
8 changes: 4 additions & 4 deletions api/model/api/base/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ package base
type Property struct {
// Property Key
// +kubebuilder:validation:Optional
Key string `json:"key,omitempty"`
Key *string `json:"key,omitempty"`
// Property Value
// +kubebuilder:validation:Optional
Value string `json:"value,omitempty"`
Value *string `json:"value,omitempty"`
// Property Encrypted or not?
// +kubebuilder:validation:Optional
Encrypted bool `json:"encrypted,omitempty"`
Encrypted *bool `json:"encrypted,omitempty"`
// Property is dynamic or not?
// +kubebuilder:validation:Optional
Dynamic bool `json:"dynamic,omitempty"`
Dynamic *bool `json:"dynamic,omitempty"`
}
16 changes: 12 additions & 4 deletions api/model/api/base/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,29 @@ type Resource struct {
Enabled bool `json:"enabled"`
// Resource Name
// +kubebuilder:validation:Optional
Name string `json:"name,omitempty"`
Name *string `json:"name,omitempty"`
// Resource Type
// +kubebuilder:validation:Optional
Type string `json:"type,omitempty"`
Type *string `json:"type,omitempty"`
// Resource Configuration, arbitrary map of key-values
// +kubebuilder:validation:Optional
Configuration *utils.GenericStringMap `json:"configuration,omitempty"`
}

func (r *Resource) GetType() string {
return r.Type
if r.Type != nil {
return *r.Type
}

return ""
}

func (r *Resource) GetResourceName() string {
return r.Name
if r.Name != nil {
return *r.Name
}

return ""
}

func (r *Resource) GetConfig() *utils.GenericStringMap {
Expand Down
Loading

0 comments on commit 01d333c

Please sign in to comment.