Skip to content

Commit

Permalink
feat: release APIs and Operator independently (#541)
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Liva <giovanni.liva@dynatrace.com>
  • Loading branch information
thisthat authored Nov 15, 2023
1 parent a97d336 commit 7b1af42
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 90 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ env:
IMAGE_NAME: ${{ github.repository }}
GITHUB_PAGES_BRANCH: gh-pages

defaults:
run:
shell: bash

permissions:
contents: read

Expand All @@ -30,6 +34,7 @@ jobs:
command: manifest
token: ${{secrets.GITHUB_TOKEN}}
default-branch: main

outputs:
release_created: ${{ steps.release.outputs.release_created }}
release_tag_name: ${{ steps.release.outputs.tag_name }}
Expand Down
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
".": "0.2.36"
".": "0.2.36",
"apis": "0.2.36"
}
23 changes: 23 additions & 0 deletions apis/core/v1alpha1/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package common

import "fmt"

func TrueVal() *bool {
b := true
return &b
}

func FalseVal() *bool {
b := false
return &b
}

// unique string used to create unique volume mount and file name
func FeatureFlagConfigurationId(namespace, name string) string {
return fmt.Sprintf("%s_%s", namespace, name)
}

// unique key (and filename) for configMap data
func FeatureFlagConfigurationConfigMapKey(namespace, name string) string {
return fmt.Sprintf("%s.flagd.json", FeatureFlagConfigurationId(namespace, name))
}
6 changes: 3 additions & 3 deletions apis/core/v1alpha1/featureflagconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package v1alpha1

import (
"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -114,7 +114,7 @@ func (ff *FeatureFlagConfiguration) GetReference() metav1.OwnerReference {
Kind: ff.Kind,
Name: ff.Name,
UID: ff.UID,
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
}
}

Expand All @@ -129,7 +129,7 @@ func (ff *FeatureFlagConfiguration) GenerateConfigMap(name string, namespace str
OwnerReferences: references,
},
Data: map[string]string{
utils.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
common.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions apis/core/v1alpha1/featureflagconfiguration_types_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package v1alpha1

import (
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"testing"

"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -21,7 +21,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
Kind: "kind",
Name: "ffconf1",
UID: types.UID("5"),
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
},
},
},
Expand All @@ -38,7 +38,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
Kind: "kind",
Name: "ffconf1",
UID: types.UID("5"),
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
},
}

Expand All @@ -47,7 +47,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
Kind: ffConfig.Kind,
Name: ffConfig.Name,
UID: ffConfig.UID,
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
}, ffConfig.GetReference())

require.Equal(t, corev1.ConfigMap{
Expand Down
4 changes: 2 additions & 2 deletions apis/core/v1alpha1/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package v1alpha1

import (
"fmt"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"os"
"strconv"
"strings"

"github.com/open-feature/open-feature-operator/pkg/utils"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -212,7 +212,7 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
EnvVarPrefix: defaultSidecarEnvVarPrefix,
LogFormat: defaultLogFormat,
RolloutOnChange: nil,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
}

Expand Down
30 changes: 15 additions & 15 deletions apis/core/v1alpha1/flagsourceconfiguration_types_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package v1alpha1

import (
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"testing"

"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -116,9 +116,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
},
SyncProviderArgs: []string{"arg1", "arg2"},
DefaultSyncProvider: SyncProviderKubernetes,
RolloutOnChange: utils.TrueVal(),
ProbesEnabled: utils.TrueVal(),
DebugLogging: utils.TrueVal(),
RolloutOnChange: common.TrueVal(),
ProbesEnabled: common.TrueVal(),
DebugLogging: common.TrueVal(),
OtelCollectorUri: "",
},
}
Expand Down Expand Up @@ -157,9 +157,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
},
SyncProviderArgs: []string{"arg1", "arg2"},
DefaultSyncProvider: SyncProviderKubernetes,
RolloutOnChange: utils.TrueVal(),
ProbesEnabled: utils.TrueVal(),
DebugLogging: utils.TrueVal(),
RolloutOnChange: common.TrueVal(),
ProbesEnabled: common.TrueVal(),
DebugLogging: common.TrueVal(),
OtelCollectorUri: "",
},
}, ff_old)
Expand Down Expand Up @@ -192,9 +192,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
},
SyncProviderArgs: []string{"arg3", "arg4"},
DefaultSyncProvider: SyncProviderFilepath,
RolloutOnChange: utils.FalseVal(),
ProbesEnabled: utils.FalseVal(),
DebugLogging: utils.FalseVal(),
RolloutOnChange: common.FalseVal(),
ProbesEnabled: common.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
}
Expand Down Expand Up @@ -245,9 +245,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
},
SyncProviderArgs: []string{"arg1", "arg2", "arg3", "arg4"},
DefaultSyncProvider: SyncProviderFilepath,
RolloutOnChange: utils.FalseVal(),
ProbesEnabled: utils.FalseVal(),
DebugLogging: utils.FalseVal(),
RolloutOnChange: common.FalseVal(),
ProbesEnabled: common.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
}, ff_old)
Expand Down Expand Up @@ -283,8 +283,8 @@ func Test_FLagSourceConfiguration_NewFlagSourceConfigurationSpec(t *testing.T) {
DefaultSyncProvider: SyncProviderKubernetes,
EnvVarPrefix: "val6",
LogFormat: "val5",
ProbesEnabled: utils.TrueVal(),
DebugLogging: utils.FalseVal(),
ProbesEnabled: common.TrueVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
}, fs)

Expand Down
10 changes: 10 additions & 0 deletions apis/core/v1alpha2/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ import "errors"

var ErrCannotCastFlagSourceConfiguration = errors.New("cannot cast FlagSourceConfiguration to v1alpha2")
var ErrCannotCastFeatureFlagConfiguration = errors.New("cannot cast FeatureFlagConfiguration to v1alpha2")

func TrueVal() *bool {
b := true
return &b
}

func FalseVal() *bool {
b := false
return &b
}
3 changes: 1 addition & 2 deletions apis/core/v1alpha2/flagsourceconfiguration_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
"github.com/open-feature/open-feature-operator/pkg/utils"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

Expand All @@ -48,7 +47,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
LogFormat: src.Spec.LogFormat,
DefaultSyncProvider: v1alpha1.SyncProviderType(src.Spec.DefaultSyncProvider),
ProbesEnabled: src.Spec.ProbesEnabled,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: src.Spec.OtelCollectorUri,
}
return nil
Expand Down
5 changes: 2 additions & 3 deletions apis/core/v1alpha2/flagsourceconfiguration_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -64,7 +63,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
EnvVarPrefix: "pre",
RolloutOnChange: &tt,
SyncProviderArgs: []string{"provider", "arg"},
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
},
Expand Down Expand Up @@ -155,7 +154,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
EnvVarPrefix: "",
RolloutOnChange: nil,
SyncProviderArgs: []string{"provider", "arg"},
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
},
Expand Down
10 changes: 10 additions & 0 deletions apis/core/v1alpha3/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@ package common
import "errors"

var ErrCannotCastFlagSourceConfiguration = errors.New("cannot cast FlagSourceConfiguration to v1alpha3")

func TrueVal() *bool {
b := true
return &b
}

func FalseVal() *bool {
b := false
return &b
}
9 changes: 4 additions & 5 deletions apis/core/v1alpha3/flagsourceconfiguration_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha3/common"
"github.com/open-feature/open-feature-operator/pkg/utils"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -63,7 +62,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
LogFormat: "log",
EnvVarPrefix: "pre",
RolloutOnChange: &tt,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
},
Expand Down Expand Up @@ -105,7 +104,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
LogFormat: "log",
EnvVarPrefix: "pre",
RolloutOnChange: &tt,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
},
},
},
Expand Down Expand Up @@ -179,7 +178,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
LogFormat: "log",
EnvVarPrefix: "pre",
RolloutOnChange: &tt,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
},
},
wantErr: false,
Expand Down Expand Up @@ -220,7 +219,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
LogFormat: "log",
EnvVarPrefix: "pre",
RolloutOnChange: &tt,
DebugLogging: utils.FalseVal(),
DebugLogging: common.FalseVal(),
OtelCollectorUri: "",
},
},
Expand Down
66 changes: 66 additions & 0 deletions apis/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module github.com/open-feature/open-feature-operator/apis

go 1.19

require (
github.com/stretchr/testify v1.8.4
k8s.io/api v0.26.4
k8s.io/apimachinery v0.26.4
sigs.k8s.io/controller-runtime v0.14.6
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/client-go v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit 7b1af42

Please sign in to comment.