Skip to content
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

Sync data-types for webhook config with upstream #6626

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ type KubeAPIServerConfig struct {
// AuditWebhookBatchMaxSize is The maximum size of a batch. Only used in batch mode. (default 400)
AuditWebhookBatchMaxSize *int32 `json:"auditWebhookBatchMaxSize,omitempty" flag:"audit-webhook-batch-max-size"`
// AuditWebhookBatchMaxWait is The amount of time to wait before force writing the batch that hadn't reached the max size. Only used in batch mode. (default 30s)
AuditWebhookBatchMaxWait string `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
AuditWebhookBatchMaxWait *metav1.Duration `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
// AuditWebhookBatchThrottleBurst is Maximum number of requests sent at the same moment if ThrottleQPS was not utilized before. Only used in batch mode. (default 15)
AuditWebhookBatchThrottleBurst *int32 `json:"auditWebhookBatchThrottleBurst,omitempty" flag:"audit-webhook-batch-throttle-burst"`
// AuditWebhookBatchThrottleEnable is Whether batching throttling is enabled. Only used in batch mode. (default true)
AuditWebhookBatchThrottleEnable string `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
AuditWebhookBatchThrottleEnable *bool `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
// AuditWebhookBatchThrottleQps is Maximum average number of batches per second. Only used in batch mode. (default 10)
AuditWebhookBatchThrottleQps *float64 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
AuditWebhookBatchThrottleQps *float32 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
// AuditWebhookConfigFile is Path to a kubeconfig formatted file that defines the audit webhook configuration. Requires the 'AdvancedAuditing' feature gate.
AuditWebhookConfigFile string `json:"auditWebhookConfigFile,omitempty" flag:"audit-webhook-config-file"`
// AuditWebhookInitialBackoff is The amount of time to wait before retrying the first failed request. (default 10s)
AuditWebhookInitialBackoff string `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
AuditWebhookInitialBackoff *metav1.Duration `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
// AuditWebhookMode is Strategy for sending audit events. Blocking indicates sending events should block server responses. Batch causes the backend to buffer and write events asynchronously. Known modes are batch,blocking. (default "batch")
AuditWebhookMode string `json:"auditWebhookMode,omitempty" flag:"audit-webhook-mode"`
// File with webhook configuration for token authentication in kubeconfig format. The API server will query the remote service to determine authentication for bearer tokens.
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/kops/v1alpha1/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ type KubeAPIServerConfig struct {
// AuditWebhookBatchMaxSize is The maximum size of a batch. Only used in batch mode. (default 400)
AuditWebhookBatchMaxSize *int32 `json:"auditWebhookBatchMaxSize,omitempty" flag:"audit-webhook-batch-max-size"`
// AuditWebhookBatchMaxWait is The amount of time to wait before force writing the batch that hadn't reached the max size. Only used in batch mode. (default 30s)
AuditWebhookBatchMaxWait string `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
AuditWebhookBatchMaxWait *metav1.Duration `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
// AuditWebhookBatchThrottleBurst is Maximum number of requests sent at the same moment if ThrottleQPS was not utilized before. Only used in batch mode. (default 15)
AuditWebhookBatchThrottleBurst *int32 `json:"auditWebhookBatchThrottleBurst,omitempty" flag:"audit-webhook-batch-throttle-burst"`
// AuditWebhookBatchThrottleEnable is Whether batching throttling is enabled. Only used in batch mode. (default true)
AuditWebhookBatchThrottleEnable string `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
AuditWebhookBatchThrottleEnable *bool `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
// AuditWebhookBatchThrottleQps is Maximum average number of batches per second. Only used in batch mode. (default 10)
AuditWebhookBatchThrottleQps *float64 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
AuditWebhookBatchThrottleQps *float32 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
// AuditWebhookConfigFile is Path to a kubeconfig formatted file that defines the audit webhook configuration. Requires the 'AdvancedAuditing' feature gate.
AuditWebhookConfigFile string `json:"auditWebhookConfigFile,omitempty" flag:"audit-webhook-config-file"`
// AuditWebhookInitialBackoff is The amount of time to wait before retrying the first failed request. (default 10s)
AuditWebhookInitialBackoff string `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
AuditWebhookInitialBackoff *metav1.Duration `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
// AuditWebhookMode is Strategy for sending audit events. Blocking indicates sending events should block server responses. Batch causes the backend to buffer and write events asynchronously. Known modes are batch,blocking. (default "batch")
AuditWebhookMode string `json:"auditWebhookMode,omitempty" flag:"audit-webhook-mode"`
// File with webhook configuration for token authentication in kubeconfig format. The API server will query the remote service to determine authentication for bearer tokens.
Expand Down
17 changes: 16 additions & 1 deletion pkg/apis/kops/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ type KubeAPIServerConfig struct {
// AuditWebhookBatchMaxSize is The maximum size of a batch. Only used in batch mode. (default 400)
AuditWebhookBatchMaxSize *int32 `json:"auditWebhookBatchMaxSize,omitempty" flag:"audit-webhook-batch-max-size"`
// AuditWebhookBatchMaxWait is The amount of time to wait before force writing the batch that hadn't reached the max size. Only used in batch mode. (default 30s)
AuditWebhookBatchMaxWait string `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
AuditWebhookBatchMaxWait *metav1.Duration `json:"auditWebhookBatchMaxWait,omitempty" flag:"audit-webhook-batch-max-wait"`
// AuditWebhookBatchThrottleBurst is Maximum number of requests sent at the same moment if ThrottleQPS was not utilized before. Only used in batch mode. (default 15)
AuditWebhookBatchThrottleBurst *int32 `json:"auditWebhookBatchThrottleBurst,omitempty" flag:"audit-webhook-batch-throttle-burst"`
// AuditWebhookBatchThrottleEnable is Whether batching throttling is enabled. Only used in batch mode. (default true)
AuditWebhookBatchThrottleEnable string `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
AuditWebhookBatchThrottleEnable *bool `json:"auditWebhookBatchThrottleEnable,omitempty" flag:"audit-webhook-batch-throttle-enable"`
// AuditWebhookBatchThrottleQps is Maximum average number of batches per second. Only used in batch mode. (default 10)
AuditWebhookBatchThrottleQps *float64 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
AuditWebhookBatchThrottleQps *float32 `json:"auditWebhookBatchThrottleQps,omitempty" flag:"audit-webhook-batch-throttle-qps"`
// AuditWebhookConfigFile is Path to a kubeconfig formatted file that defines the audit webhook configuration. Requires the 'AdvancedAuditing' feature gate.
AuditWebhookConfigFile string `json:"auditWebhookConfigFile,omitempty" flag:"audit-webhook-config-file"`
// AuditWebhookInitialBackoff is The amount of time to wait before retrying the first failed request. (default 10s)
AuditWebhookInitialBackoff string `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
AuditWebhookInitialBackoff *metav1.Duration `json:"auditWebhookInitialBackoff,omitempty" flag:"audit-webhook-initial-backoff"`
// AuditWebhookMode is Strategy for sending audit events. Blocking indicates sending events should block server responses. Batch causes the backend to buffer and write events asynchronously. Known modes are batch,blocking. (default "batch")
AuditWebhookMode string `json:"auditWebhookMode,omitempty" flag:"audit-webhook-mode"`
// File with webhook configuration for token authentication in kubeconfig format. The API server will query the remote service to determine authentication for bearer tokens.
Expand Down
17 changes: 16 additions & 1 deletion pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 61 additions & 14 deletions pkg/flagbuilder/buildflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ import (
"k8s.io/kops/upup/pkg/fi"
)

func stringPointer(s string) *string {
return &s
}

func int32Pointer(i32 int32) *int32 {
return &i32
}

func TestBuildKCMFlags(t *testing.T) {
grid := []struct {
Config interface{}
Expand Down Expand Up @@ -89,27 +81,27 @@ func TestKubeletConfigSpec(t *testing.T) {
},
{
Config: &kops.KubeletConfigSpec{
LogLevel: new(int32),
LogLevel: fi.Int32(0),
},
Expected: "",
},
{
Config: &kops.KubeletConfigSpec{
LogLevel: int32Pointer(2),
LogLevel: fi.Int32(2),
},
Expected: "--v=2",
},

// Test string pointers without the "flag-include-empty" tag
{
Config: &kops.KubeletConfigSpec{
EvictionHard: stringPointer("memory.available<100Mi"),
EvictionHard: fi.String("memory.available<100Mi"),
},
Expected: "--eviction-hard=memory.available<100Mi",
},
{
Config: &kops.KubeletConfigSpec{
EvictionHard: stringPointer(""),
EvictionHard: fi.String(""),
},
Expected: "",
},
Expand All @@ -121,13 +113,13 @@ func TestKubeletConfigSpec(t *testing.T) {
},
{
Config: &kops.KubeletConfigSpec{
ResolverConfig: stringPointer("test"),
ResolverConfig: fi.String("test"),
},
Expected: "--resolv-conf=test",
},
{
Config: &kops.KubeletConfigSpec{
ResolverConfig: stringPointer(""),
ResolverConfig: fi.String(""),
},
Expected: "--resolv-conf=",
},
Expand All @@ -152,3 +144,58 @@ func TestKubeletConfigSpec(t *testing.T) {
}
}
}

func TestBuildAPIServerFlags(t *testing.T) {
grid := []struct {
Config interface{}
Expected string
}{
{
Config: &kops.KubeAPIServerConfig{},
Expected: "--insecure-port=0 --secure-port=0",
},
{
Config: &kops.KubeAPIServerConfig{
AuditWebhookBatchThrottleQps: fi.Float32(3.14),
},
Expected: "--audit-webhook-batch-throttle-qps=3.14 --insecure-port=0 --secure-port=0",
},
{
Config: &kops.KubeAPIServerConfig{
AuditWebhookBatchThrottleEnable: fi.Bool(true),
},
Expected: "--audit-webhook-batch-throttle-enable=true --insecure-port=0 --secure-port=0",
},
{
Config: &kops.KubeAPIServerConfig{
AuditWebhookBatchThrottleEnable: fi.Bool(false),
},
Expected: "--audit-webhook-batch-throttle-enable=false --insecure-port=0 --secure-port=0",
},
{
Config: &kops.KubeAPIServerConfig{
AuditWebhookInitialBackoff: &metav1.Duration{Duration: 120 * time.Second},
},
Expected: "--audit-webhook-initial-backoff=2m0s --insecure-port=0 --secure-port=0",
},
{
Config: &kops.KubeAPIServerConfig{
AuditWebhookBatchMaxSize: fi.Int32(1000),
},
Expected: "--audit-webhook-batch-max-size=1000 --insecure-port=0 --secure-port=0",
},
}

for _, test := range grid {
actual, err := BuildFlags(test.Config)
if err != nil {
t.Errorf("error from BuildFlags: %v", err)
continue
}

if actual != test.Expected {
t.Errorf("unexpected flags. actual=%q expected=%q", actual, test.Expected)
continue
}
}
}
16 changes: 15 additions & 1 deletion upup/pkg/fi/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,21 @@ func String(s string) *string {
return &s
}

// Float64 returns a point to a flot64
// Float32 returns a point to a float32
func Float32(v float32) *float32 {
return &v
}

// Float32Value returns the value of the float
func Float32Value(v *float32) float32 {
if v == nil {
return 0.0
}

return *v
}

// Float64 returns a point to a float64
func Float64(v float64) *float64 {
return &v
}
Expand Down