Fix: fix can not create first app env plan bug (#2665)

* Fix: fix can not create first app env plan bug

* Fix: fix test bug

Co-authored-by: barnettZQG <yiyun.pro>
This commit is contained in:
barnettZQG
2021-11-09 09:47:41 +08:00
committed by GitHub
co-authored by lnx01
parent 39e8bc0b98
commit 738b416ec2
5 changed files with 594 additions and 408 deletions
+230 -84
View File
@@ -1605,9 +1605,9 @@
"parameters": [
{
"enum": [
"component",
"trait",
"workflowstep"
"workflowstep",
"component"
],
"type": "string",
"description": "query the definition type",
@@ -2275,10 +2275,10 @@
"common.AppRolloutStatus": {
"required": [
"rollingState",
"batchRollingState",
"currentBatch",
"upgradedReadyReplicas",
"upgradedReplicas",
"upgradedReadyReplicas",
"batchRollingState",
"lastTargetAppRevision"
],
"properties": {
@@ -2745,8 +2745,8 @@
},
"model.ApplicationComponentPlan": {
"required": [
"createTime",
"updateTime",
"createTime",
"appPrimaryKey",
"creator",
"name",
@@ -3445,10 +3445,6 @@
"v1.ClusterBase": {
"required": [
"name",
"alias",
"description",
"icon",
"labels",
"providerInfo",
"apiServerURL",
"dashboardURL",
@@ -3658,7 +3654,6 @@
"accessKeySecret",
"clusterID",
"name",
"alias",
"icon"
],
"properties": {
@@ -3707,9 +3702,7 @@
"v1.CreateApplicationEnvPlanRequest": {
"required": [
"name",
"alias",
"clusterSelector",
"componentSelector"
"clusterSelector"
],
"properties": {
"alias": {
@@ -3732,9 +3725,7 @@
"v1.CreateApplicationPlanRequest": {
"required": [
"name",
"alias",
"namespace",
"description",
"icon"
],
"properties": {
@@ -3845,7 +3836,6 @@
"v1.CreateClusterRequest": {
"required": [
"name",
"alias",
"icon"
],
"properties": {
@@ -3881,11 +3871,7 @@
"v1.CreateComponentPlanRequest": {
"required": [
"name",
"alias",
"description",
"icon",
"componentType",
"dependsOn"
"componentType"
],
"properties": {
"alias": {
@@ -3966,8 +3952,6 @@
"required": [
"appName",
"name",
"alias",
"description",
"enable",
"default"
],
@@ -3998,24 +3982,6 @@
}
}
},
"v1.Definition": {
"required": [
"kind",
"name",
"description"
],
"properties": {
"description": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"v1.DefinitionBase": {
"required": [
"name",
@@ -4036,15 +4002,19 @@
},
"v1.DetailAddonResponse": {
"required": [
"icon",
"name",
"version",
"description",
"icon",
"definitions",
"parameters",
"cue_templates"
"cue_templates",
"app_template"
],
"properties": {
"app_template": {
"$ref": "#/definitions/v1beta1.Application"
},
"cue_templates": {
"type": "array",
"items": {
@@ -4054,7 +4024,7 @@
"definitions": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.Definition"
"$ref": "#/definitions/v1.AddonElementFile"
}
},
"dependencies": {
@@ -4103,15 +4073,15 @@
},
"v1.DetailApplicationPlanResponse": {
"required": [
"alias",
"namespace",
"gatewayRule",
"name",
"description",
"createTime",
"updateTime",
"icon",
"status",
"name",
"alias",
"description",
"createTime",
"namespace",
"gatewayRule",
"policies",
"status",
"resourceInfo",
@@ -4181,20 +4151,20 @@
},
"v1.DetailClusterResponse": {
"required": [
"alias",
"kubeConfigSecret",
"createTime",
"description",
"icon",
"labels",
"reason",
"description",
"status",
"dashboardURL",
"name",
"apiServerURL",
"kubeConfigSecret",
"updateTime",
"alias",
"provider",
"kubeConfig",
"updateTime",
"name",
"status",
"reason",
"apiServerURL",
"dashboardURL",
"resourceInfo"
],
"properties": {
@@ -4252,11 +4222,11 @@
},
"v1.DetailComponentPlanResponse": {
"required": [
"appPrimaryKey",
"updateTime",
"name",
"creator",
"type",
"appPrimaryKey",
"creator",
"updateTime",
"createTime",
"alias"
],
@@ -4353,13 +4323,13 @@
},
"v1.DetailPolicyResponse": {
"required": [
"updateTime",
"name",
"type",
"description",
"creator",
"properties",
"createTime",
"updateTime"
"createTime"
],
"properties": {
"createTime": {
@@ -4389,13 +4359,13 @@
},
"v1.DetailWorkflowPlanResponse": {
"required": [
"updateTime",
"name",
"alias",
"description",
"enable",
"default",
"createTime",
"updateTime",
"name",
"alias",
"workflowRecord"
],
"properties": {
@@ -4435,10 +4405,10 @@
},
"v1.DetailWorkflowRecordResponse": {
"required": [
"name",
"namespace",
"suspend",
"terminated",
"name",
"deployTime",
"deployUser",
"commit",
@@ -4512,9 +4482,7 @@
"v1.EnvBind": {
"required": [
"name",
"alias",
"clusterSelector",
"componentSelector"
"clusterSelector"
],
"properties": {
"alias": {
@@ -4727,6 +4695,39 @@
}
}
},
"v1.ManagedFieldsEntry": {
"description": "ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.",
"properties": {
"apiVersion": {
"description": "APIVersion defines the version of this resource that this field set applies to. The format is \"group/version\" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.",
"type": "string"
},
"fieldsType": {
"description": "FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: \"FieldsV1\"",
"type": "string"
},
"fieldsV1": {
"description": "FieldsV1 holds the first JSON version format as described in the \"FieldsV1\" type.",
"type": "string"
},
"manager": {
"description": "Manager is an identifier of the workflow managing these fields.",
"type": "string"
},
"operation": {
"description": "Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.",
"type": "string"
},
"subresource": {
"description": "Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.",
"type": "string"
},
"time": {
"description": "Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply'",
"type": "string"
}
}
},
"v1.NamespaceBase": {
"required": [
"name",
@@ -4753,10 +4754,10 @@
},
"v1.NamespaceDetailResponse": {
"required": [
"updateTime",
"name",
"description",
"createTime"
"createTime",
"updateTime"
],
"properties": {
"createTime": {
@@ -4775,6 +4776,92 @@
}
}
},
"v1.ObjectMeta": {
"description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.",
"properties": {
"annotations": {
"description": "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"clusterName": {
"description": "The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request.",
"type": "string"
},
"creationTimestamp": {
"description": "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
"type": "string"
},
"deletionGracePeriodSeconds": {
"description": "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.",
"type": "integer",
"format": "int64"
},
"deletionTimestamp": {
"description": "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
"type": "string"
},
"finalizers": {
"description": "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.",
"type": "array",
"items": {
"type": "string"
}
},
"generateName": {
"description": "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.\n\nIf this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header).\n\nApplied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency",
"type": "string"
},
"generation": {
"description": "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.",
"type": "integer",
"format": "int64"
},
"labels": {
"description": "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"managedFields": {
"description": "ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like \"ci-cd\". The set of fields is always in the version that the workflow used when modifying the object.",
"type": "array",
"items": {
"$ref": "#/definitions/v1.ManagedFieldsEntry"
}
},
"name": {
"description": "Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
"type": "string"
},
"namespace": {
"description": "Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.\n\nMust be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces",
"type": "string"
},
"ownerReferences": {
"description": "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.",
"type": "array",
"items": {
"$ref": "#/definitions/v1.OwnerReference"
}
},
"resourceVersion": {
"description": "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency",
"type": "string"
},
"selfLink": {
"description": "SelfLink is a URL representing this object. Populated by the system. Read-only.\n\nDEPRECATED Kubernetes will stop propagating this field in 1.20 release and the field is planned to be removed in 1.21 release.",
"type": "string"
},
"uid": {
"description": "UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.\n\nPopulated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids",
"type": "string"
}
}
},
"v1.ObjectReference": {
"description": "ObjectReference contains enough information to let you inspect or modify the referred object.",
"properties": {
@@ -4808,6 +4895,41 @@
}
}
},
"v1.OwnerReference": {
"description": "OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field.",
"required": [
"apiVersion",
"kind",
"name",
"uid"
],
"properties": {
"apiVersion": {
"description": "API version of the referent.",
"type": "string"
},
"blockOwnerDeletion": {
"description": "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs \"delete\" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.",
"type": "boolean"
},
"controller": {
"description": "If true, this reference points to the managing controller.",
"type": "boolean"
},
"kind": {
"description": "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string"
},
"name": {
"description": "Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
"type": "string"
},
"uid": {
"description": "UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids",
"type": "string"
}
}
},
"v1.PolicyBase": {
"required": [
"name",
@@ -4881,12 +5003,20 @@
}
}
},
"v1.TypeMeta": {
"description": "TypeMeta describes an individual object in an API response or request with strings representing the type of the object and its API schema version. Structures that are versioned or persisted should inline TypeMeta.",
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
"type": "string"
},
"kind": {
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string"
}
}
},
"v1.UpdateApplicationPlanRequest": {
"required": [
"alias",
"description",
"icon"
],
"properties": {
"alias": {
"type": "string"
@@ -4925,8 +5055,6 @@
},
"v1.UpdateWorkflowPlanRequest": {
"required": [
"alias",
"description",
"enable",
"default"
],
@@ -5025,10 +5153,7 @@
"v1.WorkflowStep": {
"required": [
"name",
"alias",
"type",
"description",
"dependsOn"
"type"
],
"properties": {
"alias": {
@@ -5288,6 +5413,27 @@
}
}
},
"v1beta1.Application": {
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
"type": "string"
},
"kind": {
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string"
},
"metadata": {
"$ref": "#/definitions/v1.ObjectMeta"
},
"spec": {
"$ref": "#/definitions/v1beta1.ApplicationSpec"
},
"status": {
"$ref": "#/definitions/common.AppStatus"
}
}
},
"v1beta1.ApplicationSpec": {
"required": [
"components"
+31 -31
View File
@@ -149,7 +149,7 @@ type AccessKeyRequest struct {
// CreateClusterRequest request parameters to create a cluster
type CreateClusterRequest struct {
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description,omitempty"`
Icon string `json:"icon"`
KubeConfig string `json:"kubeConfig,omitempty" validate:"required_without=KubeConfigSecret"`
@@ -164,8 +164,8 @@ type ConnectCloudClusterRequest struct {
AccessKeySecret string `json:"accessKeySecret"`
ClusterID string `json:"clusterID"`
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description,omitempty"`
Alias string `json:"alias" optional:"true" validate:"checkalias"`
Description string `json:"description,omitempty" optional:"true"`
Icon string `json:"icon"`
Labels map[string]string `json:"labels,omitempty"`
}
@@ -227,10 +227,10 @@ type ListCloudClusterCreationResponse struct {
// ClusterBase cluster base model
type ClusterBase struct {
Name string `json:"name"`
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description"`
Icon string `json:"icon"`
Labels map[string]string `json:"labels"`
Alias string `json:"alias" optional:"true" validate:"checkalias"`
Description string `json:"description" optional:"true"`
Icon string `json:"icon" optional:"true"`
Labels map[string]string `json:"labels" optional:"true"`
Provider model.ProviderInfo `json:"providerInfo"`
APIServerURL string `json:"apiServerURL"`
@@ -302,9 +302,9 @@ type GatewayRule struct {
// CreateApplicationPlanRequest create application plan request body
type CreateApplicationPlanRequest struct {
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Namespace string `json:"namespace" validate:"checkname"`
Description string `json:"description"`
Description string `json:"description" optional:"true"`
Icon string `json:"icon"`
Labels map[string]string `json:"labels,omitempty"`
EnvBind []*EnvBind `json:"envBind,omitempty"`
@@ -315,19 +315,19 @@ type CreateApplicationPlanRequest struct {
// UpdateApplicationPlanRequest update application plan base config
type UpdateApplicationPlanRequest struct {
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description"`
Icon string `json:"icon"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description" optional:"true"`
Icon string `json:"icon" optional:"true"`
Labels map[string]string `json:"labels,omitempty"`
}
// EnvBind application env bind
type EnvBind struct {
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description,omitempty"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description,omitempty" optional:"true"`
ClusterSelector ClusterSelector `json:"clusterSelector"`
ComponentSelector *ComponentSelector `json:"componentSelector"`
ComponentSelector *ComponentSelector `json:"componentSelector" optional:"true"`
}
// ClusterSelector cluster selector
@@ -388,14 +388,14 @@ type ComponentPlanListResponse struct {
// CreateComponentPlanRequest create component plan request model
type CreateComponentPlanRequest struct {
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description"`
Icon string `json:"icon"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description" optional:"true"`
Icon string `json:"icon" optional:"true"`
Labels map[string]string `json:"labels,omitempty"`
ComponentType string `json:"componentType" validate:"checkname"`
EnvNames []string `json:"envNames,omitempty"`
EnvNames []string `json:"envNames,omitempty" optional:"true"`
Properties string `json:"properties,omitempty"`
DependsOn []string `json:"dependsOn"`
DependsOn []string `json:"dependsOn" optional:"true"`
}
// DetailComponentPlanResponse detail component plan model
@@ -535,8 +535,8 @@ type PolicyDefinition struct {
type CreateWorkflowPlanRequest struct {
AppName string `json:"appName" validate:"checkname"`
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description" optional:"true"`
Steps []WorkflowStep `json:"steps,omitempty"`
Enable bool `json:"enable"`
Default bool `json:"default"`
@@ -544,8 +544,8 @@ type CreateWorkflowPlanRequest struct {
// UpdateWorkflowPlanRequest update or create application workflow
type UpdateWorkflowPlanRequest struct {
Alias string `json:"alias" validate:"checkalias"`
Description string `json:"description"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Description string `json:"description" optional:"true"`
Steps []WorkflowStep `json:"steps,omitempty"`
Enable bool `json:"enable"`
Default bool `json:"default"`
@@ -555,13 +555,13 @@ type UpdateWorkflowPlanRequest struct {
type WorkflowStep struct {
// Name is the unique name of the workflow step.
Name string `json:"name" validate:"checkname"`
Alias string `json:"alias" validate:"checkalias"`
Alias string `json:"alias" validate:"checkalias" optional:"true"`
Type string `json:"type" validate:"checkname"`
Description string `json:"description"`
DependsOn []string `json:"dependsOn"`
Description string `json:"description" optional:"true"`
DependsOn []string `json:"dependsOn" optional:"true"`
Properties string `json:"properties,omitempty"`
Inputs common.StepInputs `json:"inputs,omitempty"`
Outputs common.StepOutputs `json:"outputs,omitempty"`
Inputs common.StepInputs `json:"inputs,omitempty" optional:"true"`
Outputs common.StepOutputs `json:"outputs,omitempty" optional:"true"`
}
// DetailWorkflowPlanResponse detail workflow response
@@ -641,8 +641,8 @@ type VelaQLViewResponse map[string]interface{}
// PutApplicationPlanEnvRequest set diff request
type PutApplicationPlanEnvRequest struct {
ComponentSelector *ComponentSelector `json:"componentSelector,omitempty"`
Alias *string `json:"alias,omitempty" validate:"checkalias"`
Description *string `json:"description,omitempty"`
Alias *string `json:"alias,omitempty" validate:"checkalias" optional:"true"`
Description *string `json:"description,omitempty" optional:"true"`
ClusterSelector *ClusterSelector `json:"clusterSelector,omitempty"`
}
+27 -18
View File
@@ -1013,27 +1013,36 @@ func (c *applicationUsecaseImpl) CreateApplicationEnvBindingPlan(ctx context.Con
return nil, bcode.ErrApplicationEnvExist
}
}
app.EnvBinds = append(app.EnvBinds, createModelEnvBind(envReq.EnvBind))
envBinding, err := c.GetApplicationPlanEnvBindingPolicy(ctx, app)
if err != nil {
return nil, err
if !errors.Is(err, bcode.ErrApplicationNotEnv) {
return nil, err
}
}
envBinding.Envs = append(envBinding.Envs, createEnvBind(envReq.EnvBind))
properties, err := model.NewJSONStructByStruct(envBinding)
if err != nil {
log.Logger.Errorf("new env binding properties failure,%s", err.Error())
return nil, bcode.ErrInvalidProperties
}
policy := &model.ApplicationPolicyPlan{
AppPrimaryKey: app.PrimaryKey(),
Name: EnvBindPolicyDefaultName,
}
if err := c.ds.Get(ctx, policy); err != nil {
return nil, err
}
policy.Properties = properties
if err := c.ds.Put(ctx, policy); err != nil {
return nil, err
if envBinding == nil {
_, err := c.createApplictionPlanEnvBindingPolicy(ctx, app, []*apisv1.EnvBind{&envReq.EnvBind})
if err != nil {
return nil, err
}
} else {
app.EnvBinds = append(app.EnvBinds, createModelEnvBind(envReq.EnvBind))
envBinding.Envs = append(envBinding.Envs, createEnvBind(envReq.EnvBind))
properties, err := model.NewJSONStructByStruct(envBinding)
if err != nil {
log.Logger.Errorf("new env binding properties failure,%s", err.Error())
return nil, bcode.ErrInvalidProperties
}
policy := &model.ApplicationPolicyPlan{
AppPrimaryKey: app.PrimaryKey(),
Name: EnvBindPolicyDefaultName,
}
if err := c.ds.Get(ctx, policy); err != nil {
return nil, err
}
policy.Properties = properties
if err := c.ds.Put(ctx, policy); err != nil {
return nil, err
}
}
if err := c.ds.Put(ctx, app); err != nil {
return nil, err
@@ -346,6 +346,36 @@ var _ = Describe("Test application usecase function", func() {
})
It("Test CreateApplicationEnvBindingPlan function", func() {
req := v1.CreateApplicationPlanRequest{
Name: "not-have-env-bind",
Namespace: "test-app-namespace",
Description: "this is a test app",
Icon: "",
Labels: map[string]string{"test": "true"},
}
_, err := appUsecase.CreateApplicationPlan(context.TODO(), req)
Expect(err).Should(BeNil())
appModel4, err := appUsecase.GetApplicationPlan(context.TODO(), "not-have-env-bind")
Expect(err).Should(BeNil())
By("test create first env")
env4, err := appUsecase.CreateApplicationEnvBindingPlan(context.TODO(), appModel4, v1.CreateApplicationEnvPlanRequest{
EnvBind: v1.EnvBind{
Name: "prod2",
Alias: "生产环境",
Description: "这是一个用户某客户的生产环境",
ClusterSelector: v1.ClusterSelector{
Name: "prob",
},
},
})
Expect(err).Should(BeNil())
Expect(env4).ShouldNot(BeNil())
appModelNew, err := appUsecase.GetApplicationPlan(context.TODO(), "not-have-env-bind")
Expect(err).Should(BeNil())
Expect(cmp.Diff(len(appModelNew.EnvBinds), 1)).Should(BeEmpty())
By("test create not first env")
appModel, err := appUsecase.GetApplicationPlan(context.TODO(), "test-app-sadasd")
Expect(err).Should(BeNil())
Expect(cmp.Diff(appModel.Namespace, "test-app-namespace")).Should(BeEmpty())
@@ -362,7 +392,7 @@ var _ = Describe("Test application usecase function", func() {
Expect(err).Should(BeNil())
Expect(env).ShouldNot(BeNil())
appModelNew, err := appUsecase.GetApplicationPlan(context.TODO(), "test-app-sadasd")
appModelNew, err = appUsecase.GetApplicationPlan(context.TODO(), "test-app-sadasd")
Expect(err).Should(BeNil())
Expect(cmp.Diff(len(appModelNew.EnvBinds), 4)).Should(BeEmpty())
+275 -274
View File
@@ -1,145 +1,9 @@
- description: Instructions for assessing whether the container is in a suitable state
to serve traffic.
jsonKey: readinessProbe
label: ReadinessProbe检测
sort: 1
subParameters:
- description: Number of seconds after the container is started before the first
probe is initiated.
jsonKey: readinessProbe.initialDelaySeconds
label: InitialDelaySeconds
sort: 100
uiType: Number
validete:
defaultValue: 0
required: true
- description: How often, in seconds, to execute the probe.
jsonKey: readinessProbe.periodSeconds
label: PeriodSeconds
sort: 100
uiType: Number
validete:
defaultValue: 10
required: true
- description: Minimum consecutive successes for the probe to be considered successful
after having failed.
jsonKey: readinessProbe.successThreshold
label: SuccessThreshold
sort: 100
uiType: Number
validete:
defaultValue: 1
required: true
- description: Instructions for assessing container health by probing a TCP socket.
Either this attribute or the exec attribute or the httpGet attribute MUST be
specified. This attribute is mutually exclusive with both the exec attribute
and the httpGet attribute.
jsonKey: readinessProbe.tcpSocket
label: TcpSocket
sort: 100
subParameters:
- description: The TCP socket within the container that should be probed to assess
container health.
jsonKey: readinessProbe.tcpSocket.port
label: Port
sort: 100
uiType: Number
validete:
required: true
uiType: KV
validete: {}
- description: Number of seconds after which the probe times out.
jsonKey: readinessProbe.timeoutSeconds
label: TimeoutSeconds
sort: 100
uiType: Number
validete:
defaultValue: 1
required: true
- description: Instructions for assessing container health by executing a command.
Either this attribute or the httpGet attribute or the tcpSocket attribute MUST
be specified. This attribute is mutually exclusive with both the httpGet attribute
and the tcpSocket attribute.
jsonKey: readinessProbe.exec
label: Exec
sort: 100
subParameters:
- description: A command to be executed inside the container to assess its health.
Each space delimited token of the command is a separate array element. Commands
exiting 0 are considered to be successful probes, whilst all other exit codes
are considered failures.
jsonKey: readinessProbe.exec.command
label: Command
sort: 100
uiType: Strings
validete:
required: true
uiType: KV
validete: {}
- description: Number of consecutive failures required to determine the container
is not alive (liveness probe) or not ready (readiness probe).
jsonKey: readinessProbe.failureThreshold
label: FailureThreshold
sort: 100
uiType: Number
validete:
defaultValue: 3
required: true
- description: Instructions for assessing container health by executing an HTTP
GET request. Either this attribute or the exec attribute or the tcpSocket attribute
MUST be specified. This attribute is mutually exclusive with both the exec attribute
and the tcpSocket attribute.
jsonKey: readinessProbe.httpGet
label: HttpGet
sort: 100
subParameters:
- description: ""
jsonKey: readinessProbe.httpGet.httpHeaders
label: HttpHeaders
sort: 100
subParameters:
- description: ""
jsonKey: readinessProbe.httpGet.httpHeaders.[].name
label: Name
sort: 100
uiType: Input
validete:
required: true
- description: ""
jsonKey: readinessProbe.httpGet.httpHeaders.[].value
label: Value
sort: 100
uiType: Input
validete:
required: true
uiType: Structs
validete: {}
- description: The endpoint, relative to the port, to which the HTTP GET request
should be directed.
jsonKey: readinessProbe.httpGet.path
label: Path
sort: 100
uiType: Input
validete:
required: true
- description: The TCP socket within the container to which the HTTP GET request
should be directed.
jsonKey: readinessProbe.httpGet.port
label: Port
sort: 100
uiType: Number
validete:
required: true
uiType: KV
validete: {}
uiType: Group
validete: {}
- description: Which image would you like to use for your service
jsonKey: image
label: Image
sort: 2
sort: 1
uiType: ImageInput
validete:
validate:
required: true
- description: Specify image pull policy for your service
disable: false
@@ -147,7 +11,7 @@
label: 镜像更新策略
sort: 2
uiType: Select
validete:
validate:
options:
- label: 镜像不存在时更新
value: IfNotPresent
@@ -161,45 +25,26 @@
label: Memory
sort: 3
uiType: MemoryNumber
validete: {}
- description: Commands to run in the container
jsonKey: cmd
label: Cmd
sort: 100
uiType: Strings
validete: {}
- description: Which port do you want customer traffic sent to
jsonKey: port
label: Port
sort: 100
uiType: Number
validete:
defaultValue: 80
required: true
- description: Specify image pull secrets for your service
jsonKey: imagePullSecrets
label: ImagePullSecrets
sort: 100
uiType: Strings
validete: {}
- description: Instructions for assessing whether the container is alive.
jsonKey: livenessProbe
label: LivenessProbe
sort: 100
validate: {}
- description: Instructions for assessing whether the container is in a suitable state
to serve traffic.
jsonKey: readinessProbe
label: ReadinessProbe检测
sort: 4
subParameters:
- description: Number of seconds after which the probe times out.
jsonKey: livenessProbe.timeoutSeconds
jsonKey: timeoutSeconds
label: TimeoutSeconds
sort: 100
uiType: Number
validete:
validate:
defaultValue: 1
required: true
- description: Instructions for assessing container health by executing a command.
Either this attribute or the httpGet attribute or the tcpSocket attribute MUST
be specified. This attribute is mutually exclusive with both the httpGet attribute
and the tcpSocket attribute.
jsonKey: livenessProbe.exec
jsonKey: exec
label: Exec
sort: 100
subParameters:
@@ -207,141 +52,369 @@
Each space delimited token of the command is a separate array element. Commands
exiting 0 are considered to be successful probes, whilst all other exit codes
are considered failures.
jsonKey: livenessProbe.exec.command
jsonKey: command
label: Command
sort: 100
uiType: Strings
validete:
validate:
required: true
uiType: KV
validete: {}
validate: {}
- description: Number of consecutive failures required to determine the container
is not alive (liveness probe) or not ready (readiness probe).
jsonKey: livenessProbe.failureThreshold
jsonKey: failureThreshold
label: FailureThreshold
sort: 100
uiType: Number
validete:
validate:
defaultValue: 3
required: true
- description: Instructions for assessing container health by executing an HTTP
GET request. Either this attribute or the exec attribute or the tcpSocket attribute
MUST be specified. This attribute is mutually exclusive with both the exec attribute
and the tcpSocket attribute.
jsonKey: livenessProbe.httpGet
jsonKey: httpGet
label: HttpGet
sort: 100
subParameters:
- description: The TCP socket within the container to which the HTTP GET request
should be directed.
jsonKey: livenessProbe.httpGet.port
jsonKey: port
label: Port
sort: 100
uiType: Number
validete:
validate:
required: true
- description: ""
jsonKey: livenessProbe.httpGet.httpHeaders
jsonKey: httpHeaders
label: HttpHeaders
sort: 100
subParameters:
- description: ""
jsonKey: livenessProbe.httpGet.httpHeaders.[].name
jsonKey: name
label: Name
sort: 100
uiType: Input
validete:
validate:
required: true
- description: ""
jsonKey: livenessProbe.httpGet.httpHeaders.[].value
jsonKey: value
label: Value
sort: 100
uiType: Input
validete:
validate:
required: true
uiType: Structs
validete: {}
validate: {}
- description: The endpoint, relative to the port, to which the HTTP GET request
should be directed.
jsonKey: livenessProbe.httpGet.path
jsonKey: path
label: Path
sort: 100
uiType: Input
validete:
validate:
required: true
uiType: KV
validete: {}
validate: {}
- description: Number of seconds after the container is started before the first
probe is initiated.
jsonKey: livenessProbe.initialDelaySeconds
jsonKey: initialDelaySeconds
label: InitialDelaySeconds
sort: 100
uiType: Number
validete:
validate:
defaultValue: 0
required: true
- description: How often, in seconds, to execute the probe.
jsonKey: livenessProbe.periodSeconds
jsonKey: periodSeconds
label: PeriodSeconds
sort: 100
uiType: Number
validete:
validate:
defaultValue: 10
required: true
- description: Minimum consecutive successes for the probe to be considered successful
after having failed.
jsonKey: livenessProbe.successThreshold
jsonKey: successThreshold
label: SuccessThreshold
sort: 100
uiType: Number
validete:
validate:
defaultValue: 1
required: true
- description: Instructions for assessing container health by probing a TCP socket.
Either this attribute or the exec attribute or the httpGet attribute MUST be
specified. This attribute is mutually exclusive with both the exec attribute
and the httpGet attribute.
jsonKey: livenessProbe.tcpSocket
jsonKey: tcpSocket
label: TcpSocket
sort: 100
subParameters:
- description: The TCP socket within the container that should be probed to assess
container health.
jsonKey: livenessProbe.tcpSocket.port
jsonKey: port
label: Port
sort: 100
uiType: Number
validete:
validate:
required: true
uiType: KV
validete: {}
validate: {}
uiType: Group
validate: {}
- description: Number of CPU units for the service, like `0.5` (0.5 CPU core), `1`
(1 CPU core)
jsonKey: cpu
label: Cpu
sort: 100
uiType: CPUNumber
validate: {}
- description: Define arguments by using environment variables
disable: false
jsonKey: env
label: Env
sort: 100
subParameterGroupOption:
- - name
- value
- - name
- valueFrom
subParameters:
- description: Environment variable name
jsonKey: name
label: Name
sort: 100
uiType: Input
validate:
required: true
- description: The value of the environment variable
jsonKey: value
label: Value
sort: 100
uiType: Input
validate: {}
- description: Specifies a source the value of this var should come from
disable: false
jsonKey: valueFrom
label: Secret选择器
sort: 100
subParameters:
- description: Selects a key of a secret in the pod's namespace
jsonKey: secretKeyRef
label: SecretKeyRef
sort: 100
subParameters:
- description: The key of the secret to select from. Must be a valid secret
key
jsonKey: key
label: SecretKey选择
sort: 100
uiType: SecretKeySelect
validate:
required: true
- description: The name of the secret in the pod's namespace to select from
jsonKey: name
label: Secret选择
sort: 100
uiType: SecretSelect
validate:
required: true
uiType: Ignore
validate:
required: true
uiType: InnerGroup
validate: {}
uiType: Structs
validate: {}
- description: If addRevisionLabel is true, the appRevision label will be added to
the underlying pods
jsonKey: addRevisionLabel
label: AddRevisionLabel
sort: 100
uiType: Switch
validate:
defaultValue: false
required: true
- description: Commands to run in the container
jsonKey: cmd
label: Cmd
sort: 100
uiType: Strings
validate: {}
- description: Specify image pull secrets for your service
jsonKey: imagePullSecrets
label: ImagePullSecrets
sort: 100
uiType: Strings
validate: {}
- description: Instructions for assessing whether the container is alive.
jsonKey: livenessProbe
label: LivenessProbe
sort: 100
subParameters:
- description: Instructions for assessing container health by executing an HTTP
GET request. Either this attribute or the exec attribute or the tcpSocket attribute
MUST be specified. This attribute is mutually exclusive with both the exec attribute
and the tcpSocket attribute.
jsonKey: httpGet
label: HttpGet
sort: 100
subParameters:
- description: ""
jsonKey: httpHeaders
label: HttpHeaders
sort: 100
subParameters:
- description: ""
jsonKey: name
label: Name
sort: 100
uiType: Input
validate:
required: true
- description: ""
jsonKey: value
label: Value
sort: 100
uiType: Input
validate:
required: true
uiType: Structs
validate: {}
- description: The endpoint, relative to the port, to which the HTTP GET request
should be directed.
jsonKey: path
label: Path
sort: 100
uiType: Input
validate:
required: true
- description: The TCP socket within the container to which the HTTP GET request
should be directed.
jsonKey: port
label: Port
sort: 100
uiType: Number
validate:
required: true
uiType: KV
validate: {}
- description: Number of seconds after the container is started before the first
probe is initiated.
jsonKey: initialDelaySeconds
label: InitialDelaySeconds
sort: 100
uiType: Number
validate:
defaultValue: 0
required: true
- description: How often, in seconds, to execute the probe.
jsonKey: periodSeconds
label: PeriodSeconds
sort: 100
uiType: Number
validate:
defaultValue: 10
required: true
- description: Minimum consecutive successes for the probe to be considered successful
after having failed.
jsonKey: successThreshold
label: SuccessThreshold
sort: 100
uiType: Number
validate:
defaultValue: 1
required: true
- description: Instructions for assessing container health by probing a TCP socket.
Either this attribute or the exec attribute or the httpGet attribute MUST be
specified. This attribute is mutually exclusive with both the exec attribute
and the httpGet attribute.
jsonKey: tcpSocket
label: TcpSocket
sort: 100
subParameters:
- description: The TCP socket within the container that should be probed to assess
container health.
jsonKey: port
label: Port
sort: 100
uiType: Number
validate:
required: true
uiType: KV
validate: {}
- description: Number of seconds after which the probe times out.
jsonKey: timeoutSeconds
label: TimeoutSeconds
sort: 100
uiType: Number
validate:
defaultValue: 1
required: true
- description: Instructions for assessing container health by executing a command.
Either this attribute or the httpGet attribute or the tcpSocket attribute MUST
be specified. This attribute is mutually exclusive with both the httpGet attribute
and the tcpSocket attribute.
jsonKey: exec
label: Exec
sort: 100
subParameters:
- description: A command to be executed inside the container to assess its health.
Each space delimited token of the command is a separate array element. Commands
exiting 0 are considered to be successful probes, whilst all other exit codes
are considered failures.
jsonKey: command
label: Command
sort: 100
uiType: Strings
validate:
required: true
uiType: KV
validate: {}
- description: Number of consecutive failures required to determine the container
is not alive (liveness probe) or not ready (readiness probe).
jsonKey: failureThreshold
label: FailureThreshold
sort: 100
uiType: Number
validate:
defaultValue: 3
required: true
uiType: KV
validete: {}
validate: {}
- description: Which port do you want customer traffic sent to
jsonKey: port
label: Port
sort: 100
uiType: Number
validate:
defaultValue: 80
required: true
- description: Declare volumes and volumeMounts
jsonKey: volumes
label: Volumes
sort: 100
subParameters:
- description: ""
jsonKey: volumes.[].mountPath
jsonKey: mountPath
label: MountPath
sort: 100
uiType: Input
validete:
validate:
required: true
- description: ""
jsonKey: volumes.[].name
jsonKey: name
label: Name
sort: 100
uiType: Input
validete:
validate:
required: true
- description: 'Specify volume type, options: "pvc","configMap","secret","emptyDir"'
jsonKey: volumes.[].type
jsonKey: type
label: Type
sort: 100
uiType: Select
validete:
validate:
options:
- label: Pvc
value: pvc
@@ -353,76 +426,4 @@
value: emptyDir
required: true
uiType: Structs
validete: {}
- description: If addRevisionLabel is true, the appRevision label will be added to
the underlying pods
jsonKey: addRevisionLabel
label: AddRevisionLabel
sort: 100
uiType: Switch
validete:
defaultValue: false
required: true
- description: Number of CPU units for the service, like `0.5` (0.5 CPU core), `1`
(1 CPU core)
jsonKey: cpu
label: Cpu
sort: 100
uiType: CPUNumber
validete: {}
- description: Define arguments by using environment variables
disable: false
jsonKey: env
label: Env
sort: 100
subParameterGroupOption:
- - env.name
- env.value
- - env.name
- env.valueFrom
subParameters:
- description: The value of the environment variable
jsonKey: env.[].value
label: Value
sort: 100
uiType: Input
validete: {}
- description: Specifies a source the value of this var should come from
jsonKey: env.[].valueFrom
label: ValueFrom
sort: 100
subParameters:
- description: Selects a key of a secret in the pod's namespace
jsonKey: env.[].valueFrom.secretKeyRef
label: SecretKeyRef
sort: 100
subParameters:
- description: The key of the secret to select from. Must be a valid secret
key
jsonKey: env.[].valueFrom.secretKeyRef.key
label: Key
sort: 100
uiType: Input
validete:
required: true
- description: The name of the secret in the pod's namespace to select from
jsonKey: env.[].valueFrom.secretKeyRef.name
label: Name
sort: 100
uiType: Input
validete:
required: true
uiType: KV
validete:
required: true
uiType: KV
validete: {}
- description: Environment variable name
jsonKey: env.[].name
label: Name
sort: 100
uiType: Input
validete:
required: true
uiType: Structs
validete: {}
validate: {}