Skip to content

Commit 7b1af42

Browse files
authored
feat: release APIs and Operator independently (#541)
Signed-off-by: Giovanni Liva <[email protected]>
1 parent a97d336 commit 7b1af42

16 files changed

+824
-90
lines changed

.github/workflows/release-please.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ env:
1212
IMAGE_NAME: ${{ github.repository }}
1313
GITHUB_PAGES_BRANCH: gh-pages
1414

15+
defaults:
16+
run:
17+
shell: bash
18+
1519
permissions:
1620
contents: read
1721

@@ -30,6 +34,7 @@ jobs:
3034
command: manifest
3135
token: ${{secrets.GITHUB_TOKEN}}
3236
default-branch: main
37+
3338
outputs:
3439
release_created: ${{ steps.release.outputs.release_created }}
3540
release_tag_name: ${{ steps.release.outputs.tag_name }}

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
".": "0.2.36"
2+
".": "0.2.36",
3+
"apis": "0.2.36"
34
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package common
2+
3+
import "fmt"
4+
5+
func TrueVal() *bool {
6+
b := true
7+
return &b
8+
}
9+
10+
func FalseVal() *bool {
11+
b := false
12+
return &b
13+
}
14+
15+
// unique string used to create unique volume mount and file name
16+
func FeatureFlagConfigurationId(namespace, name string) string {
17+
return fmt.Sprintf("%s_%s", namespace, name)
18+
}
19+
20+
// unique key (and filename) for configMap data
21+
func FeatureFlagConfigurationConfigMapKey(namespace, name string) string {
22+
return fmt.Sprintf("%s.flagd.json", FeatureFlagConfigurationId(namespace, name))
23+
}

apis/core/v1alpha1/featureflagconfiguration_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20-
"github.com/open-feature/open-feature-operator/pkg/utils"
20+
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
2121
corev1 "k8s.io/api/core/v1"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
)
@@ -114,7 +114,7 @@ func (ff *FeatureFlagConfiguration) GetReference() metav1.OwnerReference {
114114
Kind: ff.Kind,
115115
Name: ff.Name,
116116
UID: ff.UID,
117-
Controller: utils.TrueVal(),
117+
Controller: common.TrueVal(),
118118
}
119119
}
120120

@@ -129,7 +129,7 @@ func (ff *FeatureFlagConfiguration) GenerateConfigMap(name string, namespace str
129129
OwnerReferences: references,
130130
},
131131
Data: map[string]string{
132-
utils.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
132+
common.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
133133
},
134134
}
135135
}

apis/core/v1alpha1/featureflagconfiguration_types_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package v1alpha1
22

33
import (
4+
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
45
"testing"
56

6-
"github.com/open-feature/open-feature-operator/pkg/utils"
77
"github.com/stretchr/testify/require"
88
corev1 "k8s.io/api/core/v1"
99
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -21,7 +21,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
2121
Kind: "kind",
2222
Name: "ffconf1",
2323
UID: types.UID("5"),
24-
Controller: utils.TrueVal(),
24+
Controller: common.TrueVal(),
2525
},
2626
},
2727
},
@@ -38,7 +38,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
3838
Kind: "kind",
3939
Name: "ffconf1",
4040
UID: types.UID("5"),
41-
Controller: utils.TrueVal(),
41+
Controller: common.TrueVal(),
4242
},
4343
}
4444

@@ -47,7 +47,7 @@ func Test_FeatureFlagConfiguration(t *testing.T) {
4747
Kind: ffConfig.Kind,
4848
Name: ffConfig.Name,
4949
UID: ffConfig.UID,
50-
Controller: utils.TrueVal(),
50+
Controller: common.TrueVal(),
5151
}, ffConfig.GetReference())
5252

5353
require.Equal(t, corev1.ConfigMap{

apis/core/v1alpha1/flagsourceconfiguration_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package v1alpha1
1818

1919
import (
2020
"fmt"
21+
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
2122
"os"
2223
"strconv"
2324
"strings"
2425

25-
"github.com/open-feature/open-feature-operator/pkg/utils"
2626
corev1 "k8s.io/api/core/v1"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
)
@@ -212,7 +212,7 @@ func NewFlagSourceConfigurationSpec() (*FlagSourceConfigurationSpec, error) {
212212
EnvVarPrefix: defaultSidecarEnvVarPrefix,
213213
LogFormat: defaultLogFormat,
214214
RolloutOnChange: nil,
215-
DebugLogging: utils.FalseVal(),
215+
DebugLogging: common.FalseVal(),
216216
OtelCollectorUri: "",
217217
}
218218

apis/core/v1alpha1/flagsourceconfiguration_types_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package v1alpha1
22

33
import (
4+
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
45
"testing"
56

6-
"github.com/open-feature/open-feature-operator/pkg/utils"
77
"github.com/stretchr/testify/require"
88
v1 "k8s.io/api/core/v1"
99
)
@@ -116,9 +116,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
116116
},
117117
SyncProviderArgs: []string{"arg1", "arg2"},
118118
DefaultSyncProvider: SyncProviderKubernetes,
119-
RolloutOnChange: utils.TrueVal(),
120-
ProbesEnabled: utils.TrueVal(),
121-
DebugLogging: utils.TrueVal(),
119+
RolloutOnChange: common.TrueVal(),
120+
ProbesEnabled: common.TrueVal(),
121+
DebugLogging: common.TrueVal(),
122122
OtelCollectorUri: "",
123123
},
124124
}
@@ -157,9 +157,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
157157
},
158158
SyncProviderArgs: []string{"arg1", "arg2"},
159159
DefaultSyncProvider: SyncProviderKubernetes,
160-
RolloutOnChange: utils.TrueVal(),
161-
ProbesEnabled: utils.TrueVal(),
162-
DebugLogging: utils.TrueVal(),
160+
RolloutOnChange: common.TrueVal(),
161+
ProbesEnabled: common.TrueVal(),
162+
DebugLogging: common.TrueVal(),
163163
OtelCollectorUri: "",
164164
},
165165
}, ff_old)
@@ -192,9 +192,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
192192
},
193193
SyncProviderArgs: []string{"arg3", "arg4"},
194194
DefaultSyncProvider: SyncProviderFilepath,
195-
RolloutOnChange: utils.FalseVal(),
196-
ProbesEnabled: utils.FalseVal(),
197-
DebugLogging: utils.FalseVal(),
195+
RolloutOnChange: common.FalseVal(),
196+
ProbesEnabled: common.FalseVal(),
197+
DebugLogging: common.FalseVal(),
198198
OtelCollectorUri: "",
199199
},
200200
}
@@ -245,9 +245,9 @@ func Test_FLagSourceConfiguration_Merge(t *testing.T) {
245245
},
246246
SyncProviderArgs: []string{"arg1", "arg2", "arg3", "arg4"},
247247
DefaultSyncProvider: SyncProviderFilepath,
248-
RolloutOnChange: utils.FalseVal(),
249-
ProbesEnabled: utils.FalseVal(),
250-
DebugLogging: utils.FalseVal(),
248+
RolloutOnChange: common.FalseVal(),
249+
ProbesEnabled: common.FalseVal(),
250+
DebugLogging: common.FalseVal(),
251251
OtelCollectorUri: "",
252252
},
253253
}, ff_old)
@@ -283,8 +283,8 @@ func Test_FLagSourceConfiguration_NewFlagSourceConfigurationSpec(t *testing.T) {
283283
DefaultSyncProvider: SyncProviderKubernetes,
284284
EnvVarPrefix: "val6",
285285
LogFormat: "val5",
286-
ProbesEnabled: utils.TrueVal(),
287-
DebugLogging: utils.FalseVal(),
286+
ProbesEnabled: common.TrueVal(),
287+
DebugLogging: common.FalseVal(),
288288
OtelCollectorUri: "",
289289
}, fs)
290290

apis/core/v1alpha2/common/common.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ import "errors"
44

55
var ErrCannotCastFlagSourceConfiguration = errors.New("cannot cast FlagSourceConfiguration to v1alpha2")
66
var ErrCannotCastFeatureFlagConfiguration = errors.New("cannot cast FeatureFlagConfiguration to v1alpha2")
7+
8+
func TrueVal() *bool {
9+
b := true
10+
return &b
11+
}
12+
13+
func FalseVal() *bool {
14+
b := false
15+
return &b
16+
}

apis/core/v1alpha2/flagsourceconfiguration_conversion.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
2323
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
24-
"github.com/open-feature/open-feature-operator/pkg/utils"
2524
"sigs.k8s.io/controller-runtime/pkg/conversion"
2625
)
2726

@@ -48,7 +47,7 @@ func (src *FlagSourceConfiguration) ConvertTo(dstRaw conversion.Hub) error {
4847
LogFormat: src.Spec.LogFormat,
4948
DefaultSyncProvider: v1alpha1.SyncProviderType(src.Spec.DefaultSyncProvider),
5049
ProbesEnabled: src.Spec.ProbesEnabled,
51-
DebugLogging: utils.FalseVal(),
50+
DebugLogging: common.FalseVal(),
5251
OtelCollectorUri: src.Spec.OtelCollectorUri,
5352
}
5453
return nil

apis/core/v1alpha2/flagsourceconfiguration_conversion_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
77
"github.com/open-feature/open-feature-operator/apis/core/v1alpha2/common"
8-
"github.com/open-feature/open-feature-operator/pkg/utils"
98
"github.com/stretchr/testify/require"
109
corev1 "k8s.io/api/core/v1"
1110
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -64,7 +63,7 @@ func TestFlagSourceConfiguration_ConvertFrom(t *testing.T) {
6463
EnvVarPrefix: "pre",
6564
RolloutOnChange: &tt,
6665
SyncProviderArgs: []string{"provider", "arg"},
67-
DebugLogging: utils.FalseVal(),
66+
DebugLogging: common.FalseVal(),
6867
OtelCollectorUri: "",
6968
},
7069
},
@@ -155,7 +154,7 @@ func TestFlagSourceConfiguration_ConvertTo(t *testing.T) {
155154
EnvVarPrefix: "",
156155
RolloutOnChange: nil,
157156
SyncProviderArgs: []string{"provider", "arg"},
158-
DebugLogging: utils.FalseVal(),
157+
DebugLogging: common.FalseVal(),
159158
OtelCollectorUri: "",
160159
},
161160
},

0 commit comments

Comments
 (0)