From 00bcb54b6712b0a96dd637699f3edd07dcb8bc81 Mon Sep 17 00:00:00 2001 From: adfost Date: Mon, 2 May 2022 18:35:36 -0700 Subject: [PATCH] Describe pod API (#1861) --- models/condition.go | 70 ++ models/config_map.go | 70 ++ models/container.go | 309 ++++++++ models/describe_pod_wrapper.go | 517 +++++++++++++ models/environment_variable.go | 70 ++ models/mount.go | 76 ++ models/projected_volume.go | 133 ++++ models/projected_volume_source.go | 216 ++++++ models/pvc.go | 70 ++ models/secret.go | 70 ++ models/service_account_token.go | 67 ++ models/state.go | 85 +++ models/toleration.go | 79 ++ models/volume.go | 170 +++++ operator-integration/tenant_test.go | 45 ++ operatorapi/embedded_spec.go | 718 ++++++++++++++++++ operatorapi/operations/operator_api.go | 12 + .../operations/operator_api/describe_pod.go | 88 +++ .../operator_api/describe_pod_parameters.go | 136 ++++ .../operator_api/describe_pod_responses.go | 133 ++++ .../operator_api/describe_pod_urlbuilder.go | 132 ++++ operatorapi/tenants.go | 297 +++++++- swagger-operator.yml | 250 ++++++ 23 files changed, 3811 insertions(+), 2 deletions(-) create mode 100644 models/condition.go create mode 100644 models/config_map.go create mode 100644 models/container.go create mode 100644 models/describe_pod_wrapper.go create mode 100644 models/environment_variable.go create mode 100644 models/mount.go create mode 100644 models/projected_volume.go create mode 100644 models/projected_volume_source.go create mode 100644 models/pvc.go create mode 100644 models/secret.go create mode 100644 models/service_account_token.go create mode 100644 models/state.go create mode 100644 models/toleration.go create mode 100644 models/volume.go create mode 100644 operatorapi/operations/operator_api/describe_pod.go create mode 100644 operatorapi/operations/operator_api/describe_pod_parameters.go create mode 100644 operatorapi/operations/operator_api/describe_pod_responses.go create mode 100644 operatorapi/operations/operator_api/describe_pod_urlbuilder.go diff --git a/models/condition.go b/models/condition.go new file mode 100644 index 000000000..a57ca5c2d --- /dev/null +++ b/models/condition.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Condition condition +// +// swagger:model condition +type Condition struct { + + // status + Status string `json:"status,omitempty"` + + // type + Type string `json:"type,omitempty"` +} + +// Validate validates this condition +func (m *Condition) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this condition based on context it is used +func (m *Condition) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Condition) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Condition) UnmarshalBinary(b []byte) error { + var res Condition + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/config_map.go b/models/config_map.go new file mode 100644 index 000000000..a696b5b2a --- /dev/null +++ b/models/config_map.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ConfigMap config map +// +// swagger:model configMap +type ConfigMap struct { + + // name + Name string `json:"name,omitempty"` + + // optional + Optional bool `json:"optional,omitempty"` +} + +// Validate validates this config map +func (m *ConfigMap) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this config map based on context it is used +func (m *ConfigMap) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ConfigMap) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ConfigMap) UnmarshalBinary(b []byte) error { + var res ConfigMap + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/container.go b/models/container.go new file mode 100644 index 000000000..0edcb1c17 --- /dev/null +++ b/models/container.go @@ -0,0 +1,309 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Container container +// +// swagger:model container +type Container struct { + + // args + Args []string `json:"args"` + + // container ID + ContainerID string `json:"containerID,omitempty"` + + // environment variables + EnvironmentVariables []*EnvironmentVariable `json:"environmentVariables"` + + // host ports + HostPorts []string `json:"hostPorts"` + + // image + Image string `json:"image,omitempty"` + + // image ID + ImageID string `json:"imageID,omitempty"` + + // last state + LastState *State `json:"lastState,omitempty"` + + // mounts + Mounts []*Mount `json:"mounts"` + + // name + Name string `json:"name,omitempty"` + + // ports + Ports []string `json:"ports"` + + // ready + Ready bool `json:"ready,omitempty"` + + // restart count + RestartCount int64 `json:"restartCount,omitempty"` + + // state + State *State `json:"state,omitempty"` +} + +// Validate validates this container +func (m *Container) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEnvironmentVariables(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMounts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Container) validateEnvironmentVariables(formats strfmt.Registry) error { + if swag.IsZero(m.EnvironmentVariables) { // not required + return nil + } + + for i := 0; i < len(m.EnvironmentVariables); i++ { + if swag.IsZero(m.EnvironmentVariables[i]) { // not required + continue + } + + if m.EnvironmentVariables[i] != nil { + if err := m.EnvironmentVariables[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environmentVariables" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environmentVariables" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Container) validateLastState(formats strfmt.Registry) error { + if swag.IsZero(m.LastState) { // not required + return nil + } + + if m.LastState != nil { + if err := m.LastState.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("lastState") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("lastState") + } + return err + } + } + + return nil +} + +func (m *Container) validateMounts(formats strfmt.Registry) error { + if swag.IsZero(m.Mounts) { // not required + return nil + } + + for i := 0; i < len(m.Mounts); i++ { + if swag.IsZero(m.Mounts[i]) { // not required + continue + } + + if m.Mounts[i] != nil { + if err := m.Mounts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Container) validateState(formats strfmt.Registry) error { + if swag.IsZero(m.State) { // not required + return nil + } + + if m.State != nil { + if err := m.State.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("state") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("state") + } + return err + } + } + + return nil +} + +// ContextValidate validate this container based on the context it is used +func (m *Container) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateEnvironmentVariables(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLastState(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMounts(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateState(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Container) contextValidateEnvironmentVariables(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.EnvironmentVariables); i++ { + + if m.EnvironmentVariables[i] != nil { + if err := m.EnvironmentVariables[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("environmentVariables" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("environmentVariables" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Container) contextValidateLastState(ctx context.Context, formats strfmt.Registry) error { + + if m.LastState != nil { + if err := m.LastState.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("lastState") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("lastState") + } + return err + } + } + + return nil +} + +func (m *Container) contextValidateMounts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Mounts); i++ { + + if m.Mounts[i] != nil { + if err := m.Mounts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("mounts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("mounts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Container) contextValidateState(ctx context.Context, formats strfmt.Registry) error { + + if m.State != nil { + if err := m.State.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("state") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("state") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Container) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Container) UnmarshalBinary(b []byte) error { + var res Container + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/describe_pod_wrapper.go b/models/describe_pod_wrapper.go new file mode 100644 index 000000000..bf7fece83 --- /dev/null +++ b/models/describe_pod_wrapper.go @@ -0,0 +1,517 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DescribePodWrapper describe pod wrapper +// +// swagger:model describePodWrapper +type DescribePodWrapper struct { + + // annotations + Annotations []*Annotation `json:"annotations"` + + // conditions + Conditions []*Condition `json:"conditions"` + + // containers + Containers []*Container `json:"containers"` + + // controller ref + ControllerRef string `json:"controllerRef,omitempty"` + + // deletion grace period seconds + DeletionGracePeriodSeconds int64 `json:"deletionGracePeriodSeconds,omitempty"` + + // deletion timestamp + DeletionTimestamp string `json:"deletionTimestamp,omitempty"` + + // labels + Labels []*Label `json:"labels"` + + // message + Message string `json:"message,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // namespace + Namespace string `json:"namespace,omitempty"` + + // node name + NodeName string `json:"nodeName,omitempty"` + + // node selector + NodeSelector []*NodeSelector `json:"nodeSelector"` + + // phase + Phase string `json:"phase,omitempty"` + + // pod IP + PodIP string `json:"podIP,omitempty"` + + // priority + Priority int64 `json:"priority,omitempty"` + + // priority class name + PriorityClassName string `json:"priorityClassName,omitempty"` + + // qos class + QosClass string `json:"qosClass,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // start time + StartTime string `json:"startTime,omitempty"` + + // tolerations + Tolerations []*Toleration `json:"tolerations"` + + // volumes + Volumes []*Volume `json:"volumes"` +} + +// Validate validates this describe pod wrapper +func (m *DescribePodWrapper) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAnnotations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateConditions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateContainers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNodeSelector(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTolerations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVolumes(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DescribePodWrapper) validateAnnotations(formats strfmt.Registry) error { + if swag.IsZero(m.Annotations) { // not required + return nil + } + + for i := 0; i < len(m.Annotations); i++ { + if swag.IsZero(m.Annotations[i]) { // not required + continue + } + + if m.Annotations[i] != nil { + if err := m.Annotations[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("annotations" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("annotations" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateConditions(formats strfmt.Registry) error { + if swag.IsZero(m.Conditions) { // not required + return nil + } + + for i := 0; i < len(m.Conditions); i++ { + if swag.IsZero(m.Conditions[i]) { // not required + continue + } + + if m.Conditions[i] != nil { + if err := m.Conditions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateContainers(formats strfmt.Registry) error { + if swag.IsZero(m.Containers) { // not required + return nil + } + + for i := 0; i < len(m.Containers); i++ { + if swag.IsZero(m.Containers[i]) { // not required + continue + } + + if m.Containers[i] != nil { + if err := m.Containers[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("containers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("containers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateLabels(formats strfmt.Registry) error { + if swag.IsZero(m.Labels) { // not required + return nil + } + + for i := 0; i < len(m.Labels); i++ { + if swag.IsZero(m.Labels[i]) { // not required + continue + } + + if m.Labels[i] != nil { + if err := m.Labels[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateNodeSelector(formats strfmt.Registry) error { + if swag.IsZero(m.NodeSelector) { // not required + return nil + } + + for i := 0; i < len(m.NodeSelector); i++ { + if swag.IsZero(m.NodeSelector[i]) { // not required + continue + } + + if m.NodeSelector[i] != nil { + if err := m.NodeSelector[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("nodeSelector" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodeSelector" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateTolerations(formats strfmt.Registry) error { + if swag.IsZero(m.Tolerations) { // not required + return nil + } + + for i := 0; i < len(m.Tolerations); i++ { + if swag.IsZero(m.Tolerations[i]) { // not required + continue + } + + if m.Tolerations[i] != nil { + if err := m.Tolerations[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tolerations" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tolerations" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) validateVolumes(formats strfmt.Registry) error { + if swag.IsZero(m.Volumes) { // not required + return nil + } + + for i := 0; i < len(m.Volumes); i++ { + if swag.IsZero(m.Volumes[i]) { // not required + continue + } + + if m.Volumes[i] != nil { + if err := m.Volumes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this describe pod wrapper based on the context it is used +func (m *DescribePodWrapper) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAnnotations(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateConditions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateContainers(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLabels(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateNodeSelector(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTolerations(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateVolumes(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DescribePodWrapper) contextValidateAnnotations(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Annotations); i++ { + + if m.Annotations[i] != nil { + if err := m.Annotations[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("annotations" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("annotations" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateConditions(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Conditions); i++ { + + if m.Conditions[i] != nil { + if err := m.Conditions[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("conditions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("conditions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateContainers(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Containers); i++ { + + if m.Containers[i] != nil { + if err := m.Containers[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("containers" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("containers" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Labels); i++ { + + if m.Labels[i] != nil { + if err := m.Labels[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateNodeSelector(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.NodeSelector); i++ { + + if m.NodeSelector[i] != nil { + if err := m.NodeSelector[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("nodeSelector" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("nodeSelector" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateTolerations(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Tolerations); i++ { + + if m.Tolerations[i] != nil { + if err := m.Tolerations[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tolerations" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tolerations" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *DescribePodWrapper) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Volumes); i++ { + + if m.Volumes[i] != nil { + if err := m.Volumes[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("volumes" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("volumes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DescribePodWrapper) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DescribePodWrapper) UnmarshalBinary(b []byte) error { + var res DescribePodWrapper + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/environment_variable.go b/models/environment_variable.go new file mode 100644 index 000000000..10de80ba1 --- /dev/null +++ b/models/environment_variable.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// EnvironmentVariable environment variable +// +// swagger:model environmentVariable +type EnvironmentVariable struct { + + // key + Key string `json:"key,omitempty"` + + // value + Value string `json:"value,omitempty"` +} + +// Validate validates this environment variable +func (m *EnvironmentVariable) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this environment variable based on context it is used +func (m *EnvironmentVariable) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *EnvironmentVariable) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EnvironmentVariable) UnmarshalBinary(b []byte) error { + var res EnvironmentVariable + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/mount.go b/models/mount.go new file mode 100644 index 000000000..d414a18fb --- /dev/null +++ b/models/mount.go @@ -0,0 +1,76 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Mount mount +// +// swagger:model mount +type Mount struct { + + // mount path + MountPath string `json:"mountPath,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // read only + ReadOnly bool `json:"readOnly,omitempty"` + + // sub path + SubPath string `json:"subPath,omitempty"` +} + +// Validate validates this mount +func (m *Mount) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this mount based on context it is used +func (m *Mount) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Mount) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Mount) UnmarshalBinary(b []byte) error { + var res Mount + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/projected_volume.go b/models/projected_volume.go new file mode 100644 index 000000000..8a94c3c24 --- /dev/null +++ b/models/projected_volume.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectedVolume projected volume +// +// swagger:model projectedVolume +type ProjectedVolume struct { + + // sources + Sources []*ProjectedVolumeSource `json:"sources"` +} + +// Validate validates this projected volume +func (m *ProjectedVolume) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateSources(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectedVolume) validateSources(formats strfmt.Registry) error { + if swag.IsZero(m.Sources) { // not required + return nil + } + + for i := 0; i < len(m.Sources); i++ { + if swag.IsZero(m.Sources[i]) { // not required + continue + } + + if m.Sources[i] != nil { + if err := m.Sources[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this projected volume based on the context it is used +func (m *ProjectedVolume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateSources(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectedVolume) contextValidateSources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Sources); i++ { + + if m.Sources[i] != nil { + if err := m.Sources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectedVolume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectedVolume) UnmarshalBinary(b []byte) error { + var res ProjectedVolume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/projected_volume_source.go b/models/projected_volume_source.go new file mode 100644 index 000000000..ae09e9cff --- /dev/null +++ b/models/projected_volume_source.go @@ -0,0 +1,216 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ProjectedVolumeSource projected volume source +// +// swagger:model projectedVolumeSource +type ProjectedVolumeSource struct { + + // config map + ConfigMap *ConfigMap `json:"configMap,omitempty"` + + // downward Api + DownwardAPI bool `json:"downwardApi,omitempty"` + + // secret + Secret *Secret `json:"secret,omitempty"` + + // service account token + ServiceAccountToken *ServiceAccountToken `json:"serviceAccountToken,omitempty"` +} + +// Validate validates this projected volume source +func (m *ProjectedVolumeSource) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConfigMap(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceAccountToken(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectedVolumeSource) validateConfigMap(formats strfmt.Registry) error { + if swag.IsZero(m.ConfigMap) { // not required + return nil + } + + if m.ConfigMap != nil { + if err := m.ConfigMap.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configMap") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configMap") + } + return err + } + } + + return nil +} + +func (m *ProjectedVolumeSource) validateSecret(formats strfmt.Registry) error { + if swag.IsZero(m.Secret) { // not required + return nil + } + + if m.Secret != nil { + if err := m.Secret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("secret") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("secret") + } + return err + } + } + + return nil +} + +func (m *ProjectedVolumeSource) validateServiceAccountToken(formats strfmt.Registry) error { + if swag.IsZero(m.ServiceAccountToken) { // not required + return nil + } + + if m.ServiceAccountToken != nil { + if err := m.ServiceAccountToken.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("serviceAccountToken") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("serviceAccountToken") + } + return err + } + } + + return nil +} + +// ContextValidate validate this projected volume source based on the context it is used +func (m *ProjectedVolumeSource) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateConfigMap(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSecret(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateServiceAccountToken(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProjectedVolumeSource) contextValidateConfigMap(ctx context.Context, formats strfmt.Registry) error { + + if m.ConfigMap != nil { + if err := m.ConfigMap.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("configMap") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("configMap") + } + return err + } + } + + return nil +} + +func (m *ProjectedVolumeSource) contextValidateSecret(ctx context.Context, formats strfmt.Registry) error { + + if m.Secret != nil { + if err := m.Secret.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("secret") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("secret") + } + return err + } + } + + return nil +} + +func (m *ProjectedVolumeSource) contextValidateServiceAccountToken(ctx context.Context, formats strfmt.Registry) error { + + if m.ServiceAccountToken != nil { + if err := m.ServiceAccountToken.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("serviceAccountToken") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("serviceAccountToken") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProjectedVolumeSource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProjectedVolumeSource) UnmarshalBinary(b []byte) error { + var res ProjectedVolumeSource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/pvc.go b/models/pvc.go new file mode 100644 index 000000000..f1f8e8f07 --- /dev/null +++ b/models/pvc.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Pvc pvc +// +// swagger:model pvc +type Pvc struct { + + // claim name + ClaimName string `json:"claimName,omitempty"` + + // read only + ReadOnly bool `json:"readOnly,omitempty"` +} + +// Validate validates this pvc +func (m *Pvc) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this pvc based on context it is used +func (m *Pvc) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Pvc) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Pvc) UnmarshalBinary(b []byte) error { + var res Pvc + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/secret.go b/models/secret.go new file mode 100644 index 000000000..c151601a2 --- /dev/null +++ b/models/secret.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Secret secret +// +// swagger:model secret +type Secret struct { + + // name + Name string `json:"name,omitempty"` + + // optional + Optional bool `json:"optional,omitempty"` +} + +// Validate validates this secret +func (m *Secret) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this secret based on context it is used +func (m *Secret) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Secret) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Secret) UnmarshalBinary(b []byte) error { + var res Secret + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/service_account_token.go b/models/service_account_token.go new file mode 100644 index 000000000..9141b13b8 --- /dev/null +++ b/models/service_account_token.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ServiceAccountToken service account token +// +// swagger:model serviceAccountToken +type ServiceAccountToken struct { + + // expiration seconds + ExpirationSeconds int64 `json:"expirationSeconds,omitempty"` +} + +// Validate validates this service account token +func (m *ServiceAccountToken) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this service account token based on context it is used +func (m *ServiceAccountToken) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ServiceAccountToken) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ServiceAccountToken) UnmarshalBinary(b []byte) error { + var res ServiceAccountToken + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/state.go b/models/state.go new file mode 100644 index 000000000..afcff2ba7 --- /dev/null +++ b/models/state.go @@ -0,0 +1,85 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// State state +// +// swagger:model state +type State struct { + + // exit code + ExitCode int64 `json:"exitCode,omitempty"` + + // finished + Finished string `json:"finished,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // reason + Reason string `json:"reason,omitempty"` + + // signal + Signal int64 `json:"signal,omitempty"` + + // started + Started string `json:"started,omitempty"` + + // state + State string `json:"state,omitempty"` +} + +// Validate validates this state +func (m *State) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this state based on context it is used +func (m *State) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *State) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *State) UnmarshalBinary(b []byte) error { + var res State + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/toleration.go b/models/toleration.go new file mode 100644 index 000000000..f9e66d9dc --- /dev/null +++ b/models/toleration.go @@ -0,0 +1,79 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Toleration toleration +// +// swagger:model toleration +type Toleration struct { + + // effect + Effect string `json:"effect,omitempty"` + + // key + Key string `json:"key,omitempty"` + + // operator + Operator string `json:"operator,omitempty"` + + // toleration seconds + TolerationSeconds int64 `json:"tolerationSeconds,omitempty"` + + // value + Value string `json:"value,omitempty"` +} + +// Validate validates this toleration +func (m *Toleration) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this toleration based on context it is used +func (m *Toleration) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Toleration) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Toleration) UnmarshalBinary(b []byte) error { + var res Toleration + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/volume.go b/models/volume.go new file mode 100644 index 000000000..70b62c562 --- /dev/null +++ b/models/volume.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Volume volume +// +// swagger:model volume +type Volume struct { + + // name + Name string `json:"name,omitempty"` + + // projected + Projected *ProjectedVolume `json:"projected,omitempty"` + + // pvc + Pvc *Pvc `json:"pvc,omitempty"` +} + +// Validate validates this volume +func (m *Volume) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProjected(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePvc(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Volume) validateProjected(formats strfmt.Registry) error { + if swag.IsZero(m.Projected) { // not required + return nil + } + + if m.Projected != nil { + if err := m.Projected.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("projected") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projected") + } + return err + } + } + + return nil +} + +func (m *Volume) validatePvc(formats strfmt.Registry) error { + if swag.IsZero(m.Pvc) { // not required + return nil + } + + if m.Pvc != nil { + if err := m.Pvc.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvc") + } + return err + } + } + + return nil +} + +// ContextValidate validate this volume based on the context it is used +func (m *Volume) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateProjected(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidatePvc(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Volume) contextValidateProjected(ctx context.Context, formats strfmt.Registry) error { + + if m.Projected != nil { + if err := m.Projected.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("projected") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("projected") + } + return err + } + } + + return nil +} + +func (m *Volume) contextValidatePvc(ctx context.Context, formats strfmt.Registry) error { + + if m.Pvc != nil { + if err := m.Pvc.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pvc") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("pvc") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Volume) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Volume) UnmarshalBinary(b []byte) error { + var res Volume + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/operator-integration/tenant_test.go b/operator-integration/tenant_test.go index 3f43428da..230bea0da 100644 --- a/operator-integration/tenant_test.go +++ b/operator-integration/tenant_test.go @@ -564,3 +564,48 @@ func TestGetPodEvents(t *testing.T) { 200, resp.StatusCode, "Status Code is incorrect") } } + +func GetPodDescribe(nameSpace string, tenant string, podName string) (*http.Response, error) { + /* + Helper function to get events for pod + URL: /namespaces/{namespace}/tenants/{tenant}/pods/{podName}/events + HTTP Verb: GET + */ + fmt.Println(nameSpace) + fmt.Println(tenant) + fmt.Println(podName) + request, err := http.NewRequest( + "GET", "http://localhost:9090/api/v1/namespaces/"+nameSpace+"/tenants/"+tenant+"/pods/"+podName+"/describe", nil) + if err != nil { + log.Println(err) + } + request.Header.Add("Cookie", fmt.Sprintf("token=%s", token)) + request.Header.Add("Content-Type", "application/json") + client := &http.Client{ + Timeout: 2 * time.Second, + } + response, err := client.Do(request) + return response, err +} + +func TestGetPodDescribe(t *testing.T) { + assert := assert.New(t) + namespace := "tenant-lite" + tenant := "storage-lite" + podName := "storage-lite-pool-0-0" + resp, err := GetPodDescribe(namespace, tenant, podName) + assert.Nil(err) + if err != nil { + log.Println(err) + return + } + finalResponse := inspectHTTPResponse(resp) + if resp != nil { + assert.Equal( + 200, resp.StatusCode, finalResponse) + } + /*if resp != nil { + assert.Equal( + 200, resp.StatusCode, "Status Code is incorrect") + }*/ +} diff --git a/operatorapi/embedded_spec.go b/operatorapi/embedded_spec.go index e0a1b0846..cffcf936e 100644 --- a/operatorapi/embedded_spec.go +++ b/operatorapi/embedded_spec.go @@ -1200,6 +1200,49 @@ func init() { } } }, + "/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe": { + "get": { + "tags": [ + "OperatorAPI" + ], + "summary": "Describe Pod", + "operationId": "DescribePod", + "parameters": [ + { + "type": "string", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "tenant", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "podName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/describePodWrapper" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/events": { "get": { "tags": [ @@ -2017,6 +2060,28 @@ func init() { } } }, + "condition": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "configMap": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "optional": { + "type": "boolean" + } + } + }, "configureTenantRequest": { "type": "object", "properties": { @@ -2025,6 +2090,65 @@ func init() { } } }, + "container": { + "type": "object", + "properties": { + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "containerID": { + "type": "string" + }, + "environmentVariables": { + "type": "array", + "items": { + "$ref": "#/definitions/environmentVariable" + } + }, + "hostPorts": { + "type": "array", + "items": { + "type": "string" + } + }, + "image": { + "type": "string" + }, + "imageID": { + "type": "string" + }, + "lastState": { + "$ref": "#/definitions/state" + }, + "mounts": { + "type": "array", + "items": { + "$ref": "#/definitions/mount" + } + }, + "name": { + "type": "string" + }, + "ports": { + "type": "array", + "items": { + "type": "string" + } + }, + "ready": { + "type": "boolean" + }, + "restartCount": { + "type": "integer" + }, + "state": { + "$ref": "#/definitions/state" + } + } + }, "createTenantRequest": { "type": "object", "required": [ @@ -2157,6 +2281,95 @@ func init() { } } }, + "describePodWrapper": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "$ref": "#/definitions/annotation" + } + }, + "conditions": { + "type": "array", + "items": { + "$ref": "#/definitions/condition" + } + }, + "containers": { + "type": "array", + "items": { + "$ref": "#/definitions/container" + } + }, + "controllerRef": { + "type": "string" + }, + "deletionGracePeriodSeconds": { + "type": "integer" + }, + "deletionTimestamp": { + "type": "string" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/label" + } + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "nodeName": { + "type": "string" + }, + "nodeSelector": { + "type": "array", + "items": { + "$ref": "#/definitions/nodeSelector" + } + }, + "phase": { + "type": "string" + }, + "podIP": { + "type": "string" + }, + "priority": { + "type": "integer" + }, + "priorityClassName": { + "type": "string" + }, + "qosClass": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "startTime": { + "type": "string" + }, + "tolerations": { + "type": "array", + "items": { + "$ref": "#/definitions/toleration" + } + }, + "volumes": { + "type": "array", + "items": { + "$ref": "#/definitions/volume" + } + } + } + }, "directCSIDriveInfo": { "type": "object", "properties": { @@ -2324,6 +2537,17 @@ func init() { } ] }, + "environmentVariable": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "error": { "type": "object", "required": [ @@ -2886,6 +3110,23 @@ func init() { } } }, + "mount": { + "type": "object", + "properties": { + "mountPath": { + "type": "string" + }, + "name": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + }, + "subPath": { + "type": "string" + } + } + }, "namespace": { "type": "object", "required": [ @@ -3357,6 +3598,34 @@ func init() { } } }, + "projectedVolume": { + "type": "object", + "properties": { + "sources": { + "type": "array", + "items": { + "$ref": "#/definitions/projectedVolumeSource" + } + } + } + }, + "projectedVolumeSource": { + "type": "object", + "properties": { + "configMap": { + "$ref": "#/definitions/configMap" + }, + "downwardApi": { + "type": "boolean" + }, + "secret": { + "$ref": "#/definitions/secret" + }, + "serviceAccountToken": { + "$ref": "#/definitions/serviceAccountToken" + } + } + }, "prometheusConfiguration": { "type": "object", "properties": { @@ -3383,6 +3652,17 @@ func init() { } } }, + "pvc": { + "type": "object", + "properties": { + "claimName": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, "pvcsListResponse": { "type": "object", "properties": { @@ -3442,6 +3722,17 @@ func init() { } } }, + "secret": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "optional": { + "type": "boolean" + } + } + }, "securityContext": { "type": "object", "required": [ @@ -3465,6 +3756,40 @@ func init() { } } }, + "serviceAccountToken": { + "type": "object", + "properties": { + "expirationSeconds": { + "type": "integer" + } + } + }, + "state": { + "type": "object", + "properties": { + "exitCode": { + "type": "integer" + }, + "finished": { + "type": "string" + }, + "message": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "signal": { + "type": "integer" + }, + "started": { + "type": "string" + }, + "state": { + "type": "string" + } + } + }, "subscriptionValidateRequest": { "type": "object", "properties": { @@ -3901,6 +4226,26 @@ func init() { } } }, + "toleration": { + "type": "object", + "properties": { + "effect": { + "type": "string" + }, + "key": { + "type": "string" + }, + "operator": { + "type": "string" + }, + "tolerationSeconds": { + "type": "integer" + }, + "value": { + "type": "string" + } + } + }, "updateDomainsRequest": { "type": "object", "properties": { @@ -4088,6 +4433,20 @@ func init() { } } } + }, + "volume": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "projected": { + "$ref": "#/definitions/projectedVolume" + }, + "pvc": { + "$ref": "#/definitions/pvc" + } + } } }, "securityDefinitions": { @@ -5270,6 +5629,49 @@ func init() { } } }, + "/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe": { + "get": { + "tags": [ + "OperatorAPI" + ], + "summary": "Describe Pod", + "operationId": "DescribePod", + "parameters": [ + { + "type": "string", + "name": "namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "tenant", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "podName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/describePodWrapper" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/events": { "get": { "tags": [ @@ -6930,6 +7332,28 @@ func init() { } } }, + "condition": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "configMap": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "optional": { + "type": "boolean" + } + } + }, "configureTenantRequest": { "type": "object", "properties": { @@ -6938,6 +7362,65 @@ func init() { } } }, + "container": { + "type": "object", + "properties": { + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "containerID": { + "type": "string" + }, + "environmentVariables": { + "type": "array", + "items": { + "$ref": "#/definitions/environmentVariable" + } + }, + "hostPorts": { + "type": "array", + "items": { + "type": "string" + } + }, + "image": { + "type": "string" + }, + "imageID": { + "type": "string" + }, + "lastState": { + "$ref": "#/definitions/state" + }, + "mounts": { + "type": "array", + "items": { + "$ref": "#/definitions/mount" + } + }, + "name": { + "type": "string" + }, + "ports": { + "type": "array", + "items": { + "type": "string" + } + }, + "ready": { + "type": "boolean" + }, + "restartCount": { + "type": "integer" + }, + "state": { + "$ref": "#/definitions/state" + } + } + }, "createTenantRequest": { "type": "object", "required": [ @@ -7070,6 +7553,95 @@ func init() { } } }, + "describePodWrapper": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "$ref": "#/definitions/annotation" + } + }, + "conditions": { + "type": "array", + "items": { + "$ref": "#/definitions/condition" + } + }, + "containers": { + "type": "array", + "items": { + "$ref": "#/definitions/container" + } + }, + "controllerRef": { + "type": "string" + }, + "deletionGracePeriodSeconds": { + "type": "integer" + }, + "deletionTimestamp": { + "type": "string" + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/label" + } + }, + "message": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "nodeName": { + "type": "string" + }, + "nodeSelector": { + "type": "array", + "items": { + "$ref": "#/definitions/nodeSelector" + } + }, + "phase": { + "type": "string" + }, + "podIP": { + "type": "string" + }, + "priority": { + "type": "integer" + }, + "priorityClassName": { + "type": "string" + }, + "qosClass": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "startTime": { + "type": "string" + }, + "tolerations": { + "type": "array", + "items": { + "$ref": "#/definitions/toleration" + } + }, + "volumes": { + "type": "array", + "items": { + "$ref": "#/definitions/volume" + } + } + } + }, "directCSIDriveInfo": { "type": "object", "properties": { @@ -7237,6 +7809,17 @@ func init() { } ] }, + "environmentVariable": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, "error": { "type": "object", "required": [ @@ -7787,6 +8370,23 @@ func init() { } } }, + "mount": { + "type": "object", + "properties": { + "mountPath": { + "type": "string" + }, + "name": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + }, + "subPath": { + "type": "string" + } + } + }, "namespace": { "type": "object", "required": [ @@ -8123,6 +8723,34 @@ func init() { } } }, + "projectedVolume": { + "type": "object", + "properties": { + "sources": { + "type": "array", + "items": { + "$ref": "#/definitions/projectedVolumeSource" + } + } + } + }, + "projectedVolumeSource": { + "type": "object", + "properties": { + "configMap": { + "$ref": "#/definitions/configMap" + }, + "downwardApi": { + "type": "boolean" + }, + "secret": { + "$ref": "#/definitions/secret" + }, + "serviceAccountToken": { + "$ref": "#/definitions/serviceAccountToken" + } + } + }, "prometheusConfiguration": { "type": "object", "properties": { @@ -8149,6 +8777,17 @@ func init() { } } }, + "pvc": { + "type": "object", + "properties": { + "claimName": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, "pvcsListResponse": { "type": "object", "properties": { @@ -8208,6 +8847,17 @@ func init() { } } }, + "secret": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "optional": { + "type": "boolean" + } + } + }, "securityContext": { "type": "object", "required": [ @@ -8231,6 +8881,40 @@ func init() { } } }, + "serviceAccountToken": { + "type": "object", + "properties": { + "expirationSeconds": { + "type": "integer" + } + } + }, + "state": { + "type": "object", + "properties": { + "exitCode": { + "type": "integer" + }, + "finished": { + "type": "string" + }, + "message": { + "type": "string" + }, + "reason": { + "type": "string" + }, + "signal": { + "type": "integer" + }, + "started": { + "type": "string" + }, + "state": { + "type": "string" + } + } + }, "subscriptionValidateRequest": { "type": "object", "properties": { @@ -8667,6 +9351,26 @@ func init() { } } }, + "toleration": { + "type": "object", + "properties": { + "effect": { + "type": "string" + }, + "key": { + "type": "string" + }, + "operator": { + "type": "string" + }, + "tolerationSeconds": { + "type": "integer" + }, + "value": { + "type": "string" + } + } + }, "updateDomainsRequest": { "type": "object", "properties": { @@ -8854,6 +9558,20 @@ func init() { } } } + }, + "volume": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "projected": { + "$ref": "#/definitions/projectedVolume" + }, + "pvc": { + "$ref": "#/definitions/pvc" + } + } } }, "securityDefinitions": { diff --git a/operatorapi/operations/operator_api.go b/operatorapi/operations/operator_api.go index d44a36a04..ecaf229a8 100644 --- a/operatorapi/operations/operator_api.go +++ b/operatorapi/operations/operator_api.go @@ -82,6 +82,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI { OperatorAPIDeleteTenantHandler: operator_api.DeleteTenantHandlerFunc(func(params operator_api.DeleteTenantParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation operator_api.DeleteTenant has not yet been implemented") }), + OperatorAPIDescribePodHandler: operator_api.DescribePodHandlerFunc(func(params operator_api.DescribePodParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation operator_api.DescribePod has not yet been implemented") + }), OperatorAPIDisableTenantLoggingHandler: operator_api.DisableTenantLoggingHandlerFunc(func(params operator_api.DisableTenantLoggingParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation operator_api.DisableTenantLogging has not yet been implemented") }), @@ -278,6 +281,8 @@ type OperatorAPI struct { OperatorAPIDeletePodHandler operator_api.DeletePodHandler // OperatorAPIDeleteTenantHandler sets the operation handler for the delete tenant operation OperatorAPIDeleteTenantHandler operator_api.DeleteTenantHandler + // OperatorAPIDescribePodHandler sets the operation handler for the describe pod operation + OperatorAPIDescribePodHandler operator_api.DescribePodHandler // OperatorAPIDisableTenantLoggingHandler sets the operation handler for the disable tenant logging operation OperatorAPIDisableTenantLoggingHandler operator_api.DisableTenantLoggingHandler // OperatorAPIEnableTenantLoggingHandler sets the operation handler for the enable tenant logging operation @@ -467,6 +472,9 @@ func (o *OperatorAPI) Validate() error { if o.OperatorAPIDeleteTenantHandler == nil { unregistered = append(unregistered, "operator_api.DeleteTenantHandler") } + if o.OperatorAPIDescribePodHandler == nil { + unregistered = append(unregistered, "operator_api.DescribePodHandler") + } if o.OperatorAPIDisableTenantLoggingHandler == nil { unregistered = append(unregistered, "operator_api.DisableTenantLoggingHandler") } @@ -724,6 +732,10 @@ func (o *OperatorAPI) initHandlerCache() { o.handlers["DELETE"] = make(map[string]http.Handler) } o.handlers["DELETE"]["/namespaces/{namespace}/tenants/{tenant}"] = operator_api.NewDeleteTenant(o.context, o.OperatorAPIDeleteTenantHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe"] = operator_api.NewDescribePod(o.context, o.OperatorAPIDescribePodHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/operatorapi/operations/operator_api/describe_pod.go b/operatorapi/operations/operator_api/describe_pod.go new file mode 100644 index 000000000..27659fea6 --- /dev/null +++ b/operatorapi/operations/operator_api/describe_pod.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package operator_api + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" + + "github.com/minio/console/models" +) + +// DescribePodHandlerFunc turns a function with the right signature into a describe pod handler +type DescribePodHandlerFunc func(DescribePodParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn DescribePodHandlerFunc) Handle(params DescribePodParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// DescribePodHandler interface for that can handle valid describe pod params +type DescribePodHandler interface { + Handle(DescribePodParams, *models.Principal) middleware.Responder +} + +// NewDescribePod creates a new http.Handler for the describe pod operation +func NewDescribePod(ctx *middleware.Context, handler DescribePodHandler) *DescribePod { + return &DescribePod{Context: ctx, Handler: handler} +} + +/* DescribePod swagger:route GET /namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe OperatorAPI describePod + +Describe Pod + +*/ +type DescribePod struct { + Context *middleware.Context + Handler DescribePodHandler +} + +func (o *DescribePod) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDescribePodParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *models.Principal + if uprinc != nil { + principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/operatorapi/operations/operator_api/describe_pod_parameters.go b/operatorapi/operations/operator_api/describe_pod_parameters.go new file mode 100644 index 000000000..fb8bf753b --- /dev/null +++ b/operatorapi/operations/operator_api/describe_pod_parameters.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package operator_api + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewDescribePodParams creates a new DescribePodParams object +// +// There are no default values defined in the spec. +func NewDescribePodParams() DescribePodParams { + + return DescribePodParams{} +} + +// DescribePodParams contains all the bound params for the describe pod operation +// typically these are obtained from a http.Request +// +// swagger:parameters DescribePod +type DescribePodParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + Namespace string + /* + Required: true + In: path + */ + PodName string + /* + Required: true + In: path + */ + Tenant string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDescribePodParams() beforehand. +func (o *DescribePodParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rNamespace, rhkNamespace, _ := route.Params.GetOK("namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + rPodName, rhkPodName, _ := route.Params.GetOK("podName") + if err := o.bindPodName(rPodName, rhkPodName, route.Formats); err != nil { + res = append(res, err) + } + + rTenant, rhkTenant, _ := route.Params.GetOK("tenant") + if err := o.bindTenant(rTenant, rhkTenant, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *DescribePodParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Namespace = raw + + return nil +} + +// bindPodName binds and validates parameter PodName from path. +func (o *DescribePodParams) bindPodName(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.PodName = raw + + return nil +} + +// bindTenant binds and validates parameter Tenant from path. +func (o *DescribePodParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.Tenant = raw + + return nil +} diff --git a/operatorapi/operations/operator_api/describe_pod_responses.go b/operatorapi/operations/operator_api/describe_pod_responses.go new file mode 100644 index 000000000..ac27b116e --- /dev/null +++ b/operatorapi/operations/operator_api/describe_pod_responses.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package operator_api + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/minio/console/models" +) + +// DescribePodOKCode is the HTTP code returned for type DescribePodOK +const DescribePodOKCode int = 200 + +/*DescribePodOK A successful response. + +swagger:response describePodOK +*/ +type DescribePodOK struct { + + /* + In: Body + */ + Payload *models.DescribePodWrapper `json:"body,omitempty"` +} + +// NewDescribePodOK creates DescribePodOK with default headers values +func NewDescribePodOK() *DescribePodOK { + + return &DescribePodOK{} +} + +// WithPayload adds the payload to the describe pod o k response +func (o *DescribePodOK) WithPayload(payload *models.DescribePodWrapper) *DescribePodOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the describe pod o k response +func (o *DescribePodOK) SetPayload(payload *models.DescribePodWrapper) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DescribePodOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*DescribePodDefault Generic error response. + +swagger:response describePodDefault +*/ +type DescribePodDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDescribePodDefault creates DescribePodDefault with default headers values +func NewDescribePodDefault(code int) *DescribePodDefault { + if code <= 0 { + code = 500 + } + + return &DescribePodDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the describe pod default response +func (o *DescribePodDefault) WithStatusCode(code int) *DescribePodDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the describe pod default response +func (o *DescribePodDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the describe pod default response +func (o *DescribePodDefault) WithPayload(payload *models.Error) *DescribePodDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the describe pod default response +func (o *DescribePodDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DescribePodDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/operatorapi/operations/operator_api/describe_pod_urlbuilder.go b/operatorapi/operations/operator_api/describe_pod_urlbuilder.go new file mode 100644 index 000000000..f721381bd --- /dev/null +++ b/operatorapi/operations/operator_api/describe_pod_urlbuilder.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package operator_api + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// DescribePodURL generates an URL for the describe pod operation +type DescribePodURL struct { + Namespace string + PodName string + Tenant string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DescribePodURL) WithBasePath(bp string) *DescribePodURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DescribePodURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DescribePodURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe" + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on DescribePodURL") + } + + podName := o.PodName + if podName != "" { + _path = strings.Replace(_path, "{podName}", podName, -1) + } else { + return nil, errors.New("podName is required on DescribePodURL") + } + + tenant := o.Tenant + if tenant != "" { + _path = strings.Replace(_path, "{tenant}", tenant, -1) + } else { + return nil, errors.New("tenant is required on DescribePodURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DescribePodURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *DescribePodURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DescribePodURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DescribePodURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DescribePodURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *DescribePodURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operatorapi/tenants.go b/operatorapi/tenants.go index 61aa37ef5..2fdb18cc2 100644 --- a/operatorapi/tenants.go +++ b/operatorapi/tenants.go @@ -44,11 +44,13 @@ import ( "github.com/minio/console/pkg/auth/utils" + "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" - - "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/duration" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/utils/strings/slices" corev1 "k8s.io/api/core/v1" @@ -256,6 +258,14 @@ func registerTenantHandlers(api *operations.OperatorAPI) { return operator_api.NewGetPodEventsOK().WithPayload(payload) }) + api.OperatorAPIDescribePodHandler = operator_api.DescribePodHandlerFunc(func(params operator_api.DescribePodParams, session *models.Principal) middleware.Responder { + payload, err := getDescribePodResponse(session, params) + if err != nil { + return operator_api.NewDescribePodDefault(int(err.Code)).WithPayload(err) + } + return operator_api.NewDescribePodOK().WithPayload(payload) + }) + //Get tenant monitoring info api.OperatorAPIGetTenantMonitoringHandler = operator_api.GetTenantMonitoringHandlerFunc(func(params operator_api.GetTenantMonitoringParams, session *models.Principal) middleware.Responder { payload, err := getTenantMonitoringResponse(session, params) @@ -1800,6 +1810,289 @@ func getPodEventsResponse(session *models.Principal, params operator_api.GetPodE return retval, nil } +func getDescribePodResponse(session *models.Principal, params operator_api.DescribePodParams) (*models.DescribePodWrapper, *models.Error) { + ctx := context.Background() + clientset, err := cluster.K8sClient(session.STSSessionToken) + if err != nil { + return nil, restapi.ErrorWithContext(ctx, err) + } + pod, err := clientset.CoreV1().Pods(params.Namespace).Get(ctx, params.PodName, metav1.GetOptions{}) + if err != nil { + return nil, restapi.ErrorWithContext(ctx, err) + } + retval := &models.DescribePodWrapper{ + Name: pod.Name, + Namespace: pod.Namespace, + PriorityClassName: pod.Spec.PriorityClassName, + NodeName: pod.Spec.NodeName, + } + if pod.Spec.Priority != nil { + retval.Priority = int64(*pod.Spec.Priority) + } + if pod.Status.StartTime != nil { + retval.StartTime = pod.Status.StartTime.Time.String() + } + labelArray := make([]*models.Label, len(pod.Labels)) + i := 0 + for key := range pod.Labels { + labelArray[i] = &models.Label{Key: key, Value: pod.Labels[key]} + i++ + } + retval.Labels = labelArray + annotationArray := make([]*models.Annotation, len(pod.Annotations)) + i = 0 + for key := range pod.Annotations { + annotationArray[i] = &models.Annotation{Key: key, Value: pod.Annotations[key]} + i++ + } + retval.Annotations = annotationArray + if pod.DeletionTimestamp != nil { + retval.DeletionTimestamp = translateTimestampSince(*pod.DeletionTimestamp) + retval.DeletionGracePeriodSeconds = *pod.DeletionGracePeriodSeconds + } + retval.Phase = string(pod.Status.Phase) + retval.Reason = pod.Status.Reason + retval.Message = pod.Status.Message + retval.PodIP = pod.Status.PodIP + retval.ControllerRef = metav1.GetControllerOf(pod).String() + retval.Containers = make([]*models.Container, len(pod.Spec.Containers)) + statusMap := map[string]corev1.ContainerStatus{} + statusKeys := make([]string, len(pod.Status.ContainerStatuses)) + for i, status := range pod.Status.ContainerStatuses { + statusMap[status.Name] = status + statusKeys[i] = status.Name + + } + for i := range pod.Spec.Containers { + retval.Containers[i] = &models.Container{ + Name: pod.Spec.Containers[i].Name, + Image: pod.Spec.Containers[i].Image, + Ports: describeContainerPorts(pod.Spec.Containers[i].Ports), + HostPorts: describeContainerHostPorts(pod.Spec.Containers[i].Ports), + Args: pod.Spec.Containers[i].Args, + } + if slices.Contains(statusKeys, pod.Spec.Containers[i].Name) { + retval.Containers[i].ContainerID = statusMap[pod.Spec.Containers[i].Name].ContainerID + retval.Containers[i].ImageID = statusMap[pod.Spec.Containers[i].Name].ImageID + retval.Containers[i].Ready = statusMap[pod.Spec.Containers[i].Name].Ready + retval.Containers[i].RestartCount = int64(statusMap[pod.Spec.Containers[i].Name].RestartCount) + retval.Containers[i].State, retval.Containers[i].LastState = describeStatus(statusMap[pod.Spec.Containers[i].Name]) + } + retval.Containers[i].EnvironmentVariables = make([]*models.EnvironmentVariable, len(pod.Spec.Containers[0].Env)) + for j := range pod.Spec.Containers[i].Env { + retval.Containers[i].EnvironmentVariables[j] = &models.EnvironmentVariable{ + Key: pod.Spec.Containers[i].Env[j].Name, + Value: pod.Spec.Containers[i].Env[j].Value, + } + } + retval.Containers[i].Mounts = make([]*models.Mount, len(pod.Spec.Containers[i].VolumeMounts)) + for j := range pod.Spec.Containers[i].VolumeMounts { + retval.Containers[i].Mounts[j] = &models.Mount{ + Name: pod.Spec.Containers[i].VolumeMounts[j].Name, + MountPath: pod.Spec.Containers[i].VolumeMounts[j].MountPath, + SubPath: pod.Spec.Containers[i].VolumeMounts[j].SubPath, + ReadOnly: pod.Spec.Containers[i].VolumeMounts[j].ReadOnly, + } + } + } + retval.Conditions = make([]*models.Condition, len(pod.Status.Conditions)) + for i := range pod.Status.Conditions { + retval.Conditions[i] = &models.Condition{ + Type: string(pod.Status.Conditions[i].Type), + Status: string(pod.Status.Conditions[i].Status), + } + } + retval.Volumes = make([]*models.Volume, len(pod.Spec.Volumes)) + for i := range pod.Spec.Volumes { + retval.Volumes[i] = &models.Volume{ + Name: pod.Spec.Volumes[i].Name, + } + if pod.Spec.Volumes[i].PersistentVolumeClaim != nil { + retval.Volumes[i].Pvc = &models.Pvc{ + ReadOnly: pod.Spec.Volumes[i].PersistentVolumeClaim.ReadOnly, + ClaimName: pod.Spec.Volumes[i].PersistentVolumeClaim.ClaimName, + } + } else if pod.Spec.Volumes[i].Projected != nil { + retval.Volumes[i].Projected = &models.ProjectedVolume{} + retval.Volumes[i].Projected.Sources = make([]*models.ProjectedVolumeSource, len(pod.Spec.Volumes[i].Projected.Sources)) + for j := range pod.Spec.Volumes[i].Projected.Sources { + retval.Volumes[i].Projected.Sources[j] = &models.ProjectedVolumeSource{} + if pod.Spec.Volumes[i].Projected.Sources[j].Secret != nil { + retval.Volumes[i].Projected.Sources[j].Secret = &models.Secret{Name: pod.Spec.Volumes[i].Projected.Sources[j].Secret.Name, + Optional: pod.Spec.Volumes[i].Projected.Sources[j].Secret.Optional != nil} + } + if pod.Spec.Volumes[i].Projected.Sources[j].DownwardAPI != nil { + retval.Volumes[i].Projected.Sources[j].DownwardAPI = true + } + if pod.Spec.Volumes[i].Projected.Sources[j].ConfigMap != nil { + retval.Volumes[i].Projected.Sources[j].ConfigMap = &models.ConfigMap{Name: pod.Spec.Volumes[i].Projected.Sources[j].ConfigMap.Name, + Optional: pod.Spec.Volumes[i].Projected.Sources[j].ConfigMap.Optional != nil} + } + if pod.Spec.Volumes[i].Projected.Sources[j].ServiceAccountToken != nil { + retval.Volumes[i].Projected.Sources[j].ServiceAccountToken = + &models.ServiceAccountToken{ExpirationSeconds: *pod.Spec.Volumes[i].Projected.Sources[j].ServiceAccountToken.ExpirationSeconds} + } + } + } + } + retval.QosClass = string(getPodQOS(pod)) + nodeSelectorArray := make([]*models.NodeSelector, len(pod.Spec.NodeSelector)) + i = 0 + for key := range pod.Spec.NodeSelector { + nodeSelectorArray[i] = &models.NodeSelector{Key: key, Value: pod.Spec.NodeSelector[key]} + i++ + } + retval.NodeSelector = nodeSelectorArray + retval.Tolerations = make([]*models.Toleration, len(pod.Spec.Tolerations)) + for i := range pod.Spec.Tolerations { + retval.Tolerations[i] = &models.Toleration{ + Effect: string(pod.Spec.Tolerations[i].Effect), + Key: pod.Spec.Tolerations[i].Key, + Value: pod.Spec.Tolerations[i].Value, + Operator: string(pod.Spec.Tolerations[i].Operator), + TolerationSeconds: *pod.Spec.Tolerations[i].TolerationSeconds, + } + } + return retval, nil +} + +func describeStatus(status corev1.ContainerStatus) (*models.State, *models.State) { + retval := &models.State{} + last := &models.State{} + state := status.State + lastState := status.LastTerminationState + switch { + case state.Running != nil: + retval.State = "Running" + retval.Started = state.Running.StartedAt.Time.Format(time.RFC1123Z) + case state.Waiting != nil: + retval.State = "Waiting" + retval.Reason = state.Waiting.Reason + case state.Terminated != nil: + retval.State = "Terminated" + retval.Message = state.Terminated.Message + retval.ExitCode = int64(state.Terminated.ExitCode) + retval.Signal = int64(state.Terminated.Signal) + retval.Started = state.Terminated.StartedAt.Time.Format(time.RFC1123Z) + retval.Finished = state.Terminated.FinishedAt.Time.Format(time.RFC1123Z) + switch { + case lastState.Running != nil: + last.State = "Running" + last.Started = lastState.Running.StartedAt.Time.Format(time.RFC1123Z) + case lastState.Waiting != nil: + last.State = "Waiting" + last.Reason = lastState.Waiting.Reason + case lastState.Terminated != nil: + last.State = "Terminated" + last.Message = lastState.Terminated.Message + last.ExitCode = int64(lastState.Terminated.ExitCode) + last.Signal = int64(lastState.Terminated.Signal) + last.Started = lastState.Terminated.StartedAt.Time.Format(time.RFC1123Z) + last.Finished = lastState.Terminated.FinishedAt.Time.Format(time.RFC1123Z) + default: + last.State = "Waiting" + } + default: + retval.State = "Waiting" + } + return retval, last +} + +func describeContainerPorts(cPorts []corev1.ContainerPort) []string { + ports := make([]string, 0, len(cPorts)) + for _, cPort := range cPorts { + ports = append(ports, fmt.Sprintf("%d/%s", cPort.ContainerPort, cPort.Protocol)) + } + return ports +} + +func describeContainerHostPorts(cPorts []corev1.ContainerPort) []string { + ports := make([]string, 0, len(cPorts)) + for _, cPort := range cPorts { + ports = append(ports, fmt.Sprintf("%d/%s", cPort.HostPort, cPort.Protocol)) + } + return ports +} + +func getPodQOS(pod *corev1.Pod) corev1.PodQOSClass { + requests := corev1.ResourceList{} + limits := corev1.ResourceList{} + zeroQuantity := resource.MustParse("0") + isGuaranteed := true + allContainers := []corev1.Container{} + allContainers = append(allContainers, pod.Spec.Containers...) + allContainers = append(allContainers, pod.Spec.InitContainers...) + for _, container := range allContainers { + // process requests + for name, quantity := range container.Resources.Requests { + if !isSupportedQoSComputeResource(name) { + continue + } + if quantity.Cmp(zeroQuantity) == 1 { + delta := quantity.DeepCopy() + if _, exists := requests[name]; !exists { + requests[name] = delta + } else { + delta.Add(requests[name]) + requests[name] = delta + } + } + } + // process limits + qosLimitsFound := sets.NewString() + for name, quantity := range container.Resources.Limits { + if !isSupportedQoSComputeResource(name) { + continue + } + if quantity.Cmp(zeroQuantity) == 1 { + qosLimitsFound.Insert(string(name)) + delta := quantity.DeepCopy() + if _, exists := limits[name]; !exists { + limits[name] = delta + } else { + delta.Add(limits[name]) + limits[name] = delta + } + } + } + + if !qosLimitsFound.HasAll(string(corev1.ResourceMemory), string(corev1.ResourceCPU)) { + isGuaranteed = false + } + } + if len(requests) == 0 && len(limits) == 0 { + return corev1.PodQOSBestEffort + } + // Check is requests match limits for all resources. + if isGuaranteed { + for name, req := range requests { + if lim, exists := limits[name]; !exists || lim.Cmp(req) != 0 { + isGuaranteed = false + break + } + } + } + if isGuaranteed && + len(requests) == len(limits) { + return corev1.PodQOSGuaranteed + } + return corev1.PodQOSBurstable +} + +var supportedQoSComputeResources = sets.NewString(string(corev1.ResourceCPU), string(corev1.ResourceMemory)) + +func isSupportedQoSComputeResource(name corev1.ResourceName) bool { + return supportedQoSComputeResources.Has(string(name)) +} + +func translateTimestampSince(timestamp metav1.Time) string { + if timestamp.IsZero() { + return "" + } + + return duration.HumanDuration(time.Since(timestamp.Time)) +} + //get values for prometheus metrics func getTenantMonitoringResponse(session *models.Principal, params operator_api.GetTenantMonitoringParams) (*models.TenantMonitoringInfo, *models.Error) { ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) diff --git a/swagger-operator.yml b/swagger-operator.yml index 32c58d6d2..91b2f7f83 100644 --- a/swagger-operator.yml +++ b/swagger-operator.yml @@ -832,6 +832,36 @@ paths: $ref: "#/definitions/error" tags: - OperatorAPI + + /namespaces/{namespace}/tenants/{tenant}/pods/{podName}/describe: + get: + summary: Describe Pod + operationId: DescribePod + parameters: + - name: namespace + in: path + required: true + type: string + - name: tenant + in: path + required: true + type: string + - name: podName + in: path + required: true + type: string + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/describePodWrapper" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - OperatorAPI + /namespaces/{namespace}/tenants/{tenant}/monitoring: get: summary: Get Prometheus Monitoring config info For The Tenant @@ -2823,6 +2853,226 @@ definitions: message: type: string + describePodWrapper: + type: object + properties: + name: + type: string + namespace: + type: string + priority: + type: integer + priorityClassName: + type: string + nodeName: + type: string + startTime: + type: string + labels: + type: array + items: + $ref: "#/definitions/label" + annotations: + type: array + items: + $ref: "#/definitions/annotation" + deletionTimestamp: + type: string + deletionGracePeriodSeconds: + type: integer + phase: + type: string + reason: + type: string + message: + type: string + podIP: + type: string + controllerRef: + type: string + containers: + type: array + items: + $ref: "#/definitions/container" + conditions: + type: array + items: + $ref: "#/definitions/condition" + volumes: + type: array + items: + $ref: "#/definitions/volume" + qosClass: + type: string + nodeSelector: + type: array + items: + $ref: "#/definitions/nodeSelector" + tolerations: + type: array + items: + $ref: "#/definitions/toleration" + + container: + type: object + properties: + name: + type: string + containerID: + type: string + image: + type: string + imageID: + type: string + ports: + type: array + items: + type: string + hostPorts: + type: array + items: + type: string + args: + type: array + items: + type: string + state: + $ref: "#/definitions/state" + lastState: + $ref: "#/definitions/state" + ready: + type: boolean + restartCount: + type: integer + environmentVariables: + type: array + items: + $ref: "#/definitions/environmentVariable" + mounts: + type: array + items: + $ref: "#/definitions/mount" + + state: + type: object + properties: + state: + type: string + reason: + type: string + message: + type: string + exitCode: + type: integer + started: + type: string + finished: + type: string + signal: + type: integer + + environmentVariable: + type: object + properties: + key: + type: string + value: + type: string + + mount: + type: object + properties: + mountPath: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + + condition: + type: object + properties: + type: + type: string + status: + type: string + + volume: + type: object + properties: + name: + type: string + pvc: + $ref: "#/definitions/pvc" + projected: + $ref: "#/definitions/projectedVolume" + + pvc: + type: object + properties: + claimName: + type: string + readOnly: + type: boolean + + projectedVolume: + type: object + properties: + sources: + type: array + items: + $ref: "#/definitions/projectedVolumeSource" + + projectedVolumeSource: + type: object + properties: + secret: + $ref: "#/definitions/secret" + downwardApi: + type: boolean + configMap: + $ref: "#/definitions/configMap" + serviceAccountToken: + $ref: "#/definitions/serviceAccountToken" + + secret: + type: object + properties: + name: + type: string + optional: + type: boolean + + configMap: + type: object + properties: + name: + type: string + optional: + type: boolean + + serviceAccountToken: + type: object + properties: + expirationSeconds: + type: integer + + toleration: + type: object + properties: + tolerationSeconds: + type: integer + key: + type: string + value: + type: string + effect: + type: string + operator: + type: string + tenantMonitoringInfo: type: object properties: