-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce v1beta1 version #526
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
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 v1beta1 | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// FeatureFlagConfigurationSpec defines the desired state of FeatureFlagConfiguration | ||
type FeatureFlagConfigurationSpec struct { | ||
// FeatureFlagSpec is the structured representation of the feature flag specification | ||
FeatureFlagSpec FeatureFlagSpec `json:"featureFlagSpec,omitempty"` | ||
} | ||
|
||
type FeatureFlagSpec struct { | ||
Flags map[string]FlagSpec `json:"flags"` | ||
// +optional | ||
// +kubebuilder:validation:Schemaless | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
Evaluators json.RawMessage `json:"$evaluators,omitempty"` | ||
} | ||
|
||
type FlagSpec struct { | ||
// +kubebuilder:validation:Enum=ENABLED;DISABLED | ||
State string `json:"state"` | ||
// +kubebuilder:validation:Schemaless | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
Variants json.RawMessage `json:"variants"` | ||
DefaultVariant string `json:"defaultVariant"` | ||
// +optional | ||
// +kubebuilder:validation:Schemaless | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Type=object | ||
// Targeting is the json targeting rule | ||
Targeting json.RawMessage `json:"targeting,omitempty"` | ||
} | ||
|
||
type FeatureFlagSyncProvider struct { | ||
Name string `json:"name"` | ||
// +optional | ||
// +nullable | ||
HttpSyncConfiguration *HttpSyncConfiguration `json:"httpSyncConfiguration"` | ||
} | ||
|
||
// HttpSyncConfiguration defines the desired configuration for a http sync | ||
type HttpSyncConfiguration struct { | ||
// Target is the target url for flagd to poll | ||
Target string `json:"target"` | ||
// +optional | ||
BearerToken string `json:"bearerToken,omitempty"` | ||
} | ||
|
||
type FeatureFlagServiceProvider struct { | ||
// +kubebuilder:validation:Enum=flagd | ||
Name string `json:"name"` | ||
// +optional | ||
// +nullable | ||
Credentials *corev1.ObjectReference `json:"credentials"` | ||
} | ||
|
||
// FeatureFlagConfigurationStatus defines the observed state of FeatureFlagConfiguration | ||
type FeatureFlagConfigurationStatus struct { | ||
} | ||
|
||
//+kubebuilder:resource:shortName="ff" | ||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// FeatureFlagConfiguration is the Schema for the featureflagconfigurations API | ||
type FeatureFlagConfiguration struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec FeatureFlagConfigurationSpec `json:"spec,omitempty"` | ||
Status FeatureFlagConfigurationStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// FeatureFlagConfigurationList contains a list of FeatureFlagConfiguration | ||
type FeatureFlagConfigurationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []FeatureFlagConfiguration `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&FeatureFlagConfiguration{}, &FeatureFlagConfigurationList{}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
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 v1beta1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
SyncProviderKubernetes SyncProviderType = "kubernetes" | ||
SyncProviderFilepath SyncProviderType = "filepath" | ||
SyncProviderHttp SyncProviderType = "http" | ||
SyncProviderGrpc SyncProviderType = "grpc" | ||
SyncProviderFlagdProxy SyncProviderType = "flagd-proxy" | ||
) | ||
|
||
type SyncProviderType string | ||
|
||
// FlagSourceConfigurationSpec defines the desired state of FlagSourceConfiguration | ||
type FlagSourceConfigurationSpec struct { | ||
// MetricsPort defines the port to serve metrics on, defaults to 8014 | ||
// +optional | ||
MetricsPort int32 `json:"metricsPort"` | ||
|
||
// Port defines the port to listen on, defaults to 8013 | ||
// +optional | ||
Port int32 `json:"port"` | ||
|
||
// SocketPath defines the unix socket path to listen on | ||
// +optional | ||
SocketPath string `json:"socketPath"` | ||
|
||
// Evaluator sets an evaluator, defaults to 'json' | ||
// +optional | ||
Evaluator string `json:"evaluator"` | ||
|
||
// Image allows for the sidecar image to be overridden, defaults to 'ghcr.io/open-feature/flagd' | ||
// +optional | ||
Image string `json:"image"` | ||
|
||
// Tag to be appended to the sidecar image, defaults to 'main' | ||
// +optional | ||
Tag string `json:"tag"` | ||
Comment on lines
+54
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is related to issue #517 This can be considered as a security concern and hence we can discuss on removing these cc - @toddbaert @thisthat appreciate your opinion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adapted the code to remove tag and image from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya I'm fine with removing them. I have only heard agreements on this. I think we should come up with a short list of changes that we can include in the extended commit message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With further implementation I came across some issues regarding this. Read comment here #517 (comment) I would suggest that covering this should be part of a separate PR, as it will bump the complexity of the PR, which will be adapting the code to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
// SyncProviders define the syncProviders and associated configuration to be applied to the sidecar | ||
// +kubebuilder:validation:MinItems=1 | ||
Sources []Source `json:"sources"` | ||
|
||
// EnvVars define the env vars to be applied to the sidecar, any env vars in FeatureFlagConfiguration CRs | ||
// are added at the lowest index, all values will have the EnvVarPrefix applied, default FLAGD | ||
// +optional | ||
EnvVars []corev1.EnvVar `json:"envVars"` | ||
|
||
// SyncProviderArgs are string arguments passed to all sync providers, defined as key values separated by = | ||
// +optional | ||
SyncProviderArgs []string `json:"syncProviderArgs"` | ||
|
||
// DefaultSyncProvider defines the default sync provider | ||
// +optional | ||
DefaultSyncProvider string `json:"defaultSyncProvider"` | ||
|
||
// LogFormat allows for the sidecar log format to be overridden, defaults to 'json' | ||
// +optional | ||
LogFormat string `json:"logFormat"` | ||
|
||
// EnvVarPrefix defines the prefix to be applied to all environment variables applied to the sidecar, default FLAGD | ||
// +optional | ||
EnvVarPrefix string `json:"envVarPrefix"` | ||
|
||
// RolloutOnChange dictates whether annotated deployments will be restarted when configuration changes are | ||
// detected in this CR, defaults to false | ||
// +optional | ||
RolloutOnChange *bool `json:"rolloutOnChange"` | ||
|
||
// ProbesEnabled defines whether to enable liveness and readiness probes of flagd sidecar. Default true (enabled). | ||
// +optional | ||
ProbesEnabled *bool `json:"probesEnabled"` | ||
|
||
// DebugLogging defines whether to enable --debug flag of flagd sidecar. Default false (disabled). | ||
// +optional | ||
DebugLogging *bool `json:"debugLogging"` | ||
|
||
// OtelCollectorUri defines whether to enable --otel-collector-uri flag of flagd sidecar. Default false (disabled). | ||
// +optional | ||
OtelCollectorUri string `json:"otelCollectorUri"` | ||
|
||
// Resources defines flagd sidecar resources. Default to operator sidecar-cpu-* and sidecar-ram-* flags. | ||
// +optional | ||
Resources corev1.ResourceRequirements `json:"resources"` | ||
} | ||
|
||
type Source struct { | ||
// Source is a URI of the flag sources | ||
Source string `json:"source"` | ||
|
||
// Provider type - kubernetes, http(s), grpc(s) or filepath | ||
// +optional | ||
Provider SyncProviderType `json:"provider"` | ||
|
||
// HttpSyncBearerToken is a bearer token. Used by http(s) sync provider only | ||
// +optional | ||
HttpSyncBearerToken string `json:"httpSyncBearerToken"` | ||
|
||
// TLS - Enable/Disable secure TLS connectivity. Currently used only by GRPC sync | ||
// +optional | ||
TLS bool `json:"tls"` | ||
|
||
// CertPath is a path of a certificate to be used by grpc TLS connection | ||
// +optional | ||
CertPath string `json:"certPath"` | ||
|
||
// ProviderID is an identifier to be used in grpc provider | ||
// +optional | ||
ProviderID string `json:"providerID"` | ||
|
||
// Selector is a flag configuration selector used by grpc provider | ||
// +optional | ||
Selector string `json:"selector,omitempty"` | ||
} | ||
|
||
// FlagSourceConfigurationStatus defines the observed state of FlagSourceConfiguration | ||
type FlagSourceConfigurationStatus struct { | ||
} | ||
|
||
//+kubebuilder:resource:shortName="fsc" | ||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// FlagSourceConfiguration is the Schema for the FlagSourceConfigurations API | ||
type FlagSourceConfiguration struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec FlagSourceConfigurationSpec `json:"spec,omitempty"` | ||
Status FlagSourceConfigurationStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// FlagSourceConfigurationList contains a list of FlagSourceConfiguration | ||
type FlagSourceConfigurationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []FlagSourceConfiguration `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&FlagSourceConfiguration{}, &FlagSourceConfigurationList{}) | ||
} | ||
|
||
func (s SyncProviderType) IsKubernetes() bool { | ||
return s == SyncProviderKubernetes | ||
} | ||
|
||
func (s SyncProviderType) IsHttp() bool { | ||
return s == SyncProviderHttp | ||
} | ||
|
||
func (s SyncProviderType) IsFilepath() bool { | ||
return s == SyncProviderFilepath | ||
} | ||
|
||
func (s SyncProviderType) IsGrpc() bool { | ||
return s == SyncProviderGrpc | ||
} | ||
|
||
func (s SyncProviderType) IsFlagdProxy() bool { | ||
return s == SyncProviderFlagdProxy | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2022. | ||
|
||
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 v1beta1 contains API Schema definitions for the core v1beta1 API group | ||
//+kubebuilder:object:generate=true | ||
//+groupName=core.openfeature.dev | ||
package v1beta1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "core.openfeature.dev", Version: "v1beta1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider the diff highlighted in this related issue - #433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we already have a unified solution? I see that the ticket does not clearly state which option to use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beeme1mr @Kavindu-Dodan @thisthat which is better here? Any opinions? I suppose since we're already doing breaking changes here, it makes sense to concentrate them all here... so perhaps we should conform here in OFO to the flagd style:
file
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapted to
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Kavindu-Dodan @beeme1mr