-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b848aba
commit 8ba04e7
Showing
15 changed files
with
691 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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 duck contains a partial schema of the Keda APIs | ||
// +kubebuilder:object:generate=true | ||
// +groupName=keda.sh | ||
package v1alpha1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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 v1alpha1 | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +genclient:onlyVerbs=get,list,watch | ||
// +genclient:noStatus | ||
// +kubebuilder:object:root=true | ||
|
||
// ScaledObject is a specification for a ScaledObject resource | ||
type ScaledObject struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ScaledObjectSpec `json:"spec"` | ||
} | ||
|
||
// ScaledObjectSpec is the spec for a ScaledObject resource | ||
type ScaledObjectSpec struct { | ||
ScaleTargetRef *v1.ObjectReference `json:"scaleTargetRef"` | ||
|
||
Triggers []ScaleTriggers `json:"triggers"` | ||
} | ||
|
||
// ScaleTriggers reference the scaler that will be used | ||
type ScaleTriggers struct { | ||
Type string `json:"type"` | ||
// +optional | ||
Name string `json:"name,omitempty"` | ||
Metadata map[string]string `json:"metadata"` | ||
// +optional | ||
AuthenticationRef *ScaledObjectAuthRef `json:"authenticationRef,omitempty"` | ||
// +optional | ||
FallbackReplicas *int32 `json:"fallback,omitempty"` | ||
} | ||
|
||
// ScaledObjectAuthRef points to the TriggerAuthentication or ClusterTriggerAuthentication object that | ||
// is used to authenticate the scaler with the environment | ||
type ScaledObjectAuthRef struct { | ||
Name string `json:"name"` | ||
// Kind of the resource being referred to. Defaults to TriggerAuthentication. | ||
// +optional | ||
Kind string `json:"kind,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// ScaledObjectList contains a list of ScaledObject. | ||
type ScaledObjectList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []ScaledObject `json:"items"` | ||
} | ||
|
||
// +genclient | ||
// +genclient:onlyVerbs=get,list,watch | ||
// +genclient:noStatus | ||
// +kubebuilder:object:root=true | ||
|
||
// TriggerAuthentication defines how a trigger can authenticate | ||
type TriggerAuthentication struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec TriggerAuthenticationSpec `json:"spec"` | ||
} | ||
|
||
// TriggerAuthenticationSpec defines the various ways to authenticate | ||
type TriggerAuthenticationSpec struct { | ||
// +optional | ||
SecretTargetRef []AuthSecretTargetRef `json:"secretTargetRef,omitempty"` | ||
} | ||
|
||
// AuthSecretTargetRef is used to authenticate using a reference to a secret | ||
type AuthSecretTargetRef struct { | ||
Parameter string `json:"parameter"` | ||
Name string `json:"name"` | ||
Key string `json:"key"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// TriggerAuthenticationList contains a list of TriggerAuthentication | ||
type TriggerAuthenticationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
Items []TriggerAuthentication `json:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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 v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
ScaledObjectKind = "ScaledObject" | ||
) | ||
|
||
func NewScaledObject(namespace string, name string) ScaledObject { | ||
return ScaledObject{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: SchemeGroupVersion.String(), | ||
Kind: ScaledObjectKind, | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: namespace, | ||
Name: name, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You 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 v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const ( | ||
KedaGroup = "keda.sh" | ||
KedaVersion = "v1alpha1" | ||
) | ||
|
||
var ( | ||
// SchemeGroupVersion is group version used to register these objects. | ||
SchemeGroupVersion = schema.GroupVersion{Group: KedaGroup, Version: KedaVersion} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
|
||
// AddToScheme is a shortcut to SchemeBuilder.AddToScheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource. | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
// Adds the list of known types to Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&ScaledObject{}, | ||
&ScaledObjectList{}, | ||
&TriggerAuthentication{}, | ||
&TriggerAuthenticationList{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
Oops, something went wrong.