Commit c06fbe47 authored by Darren Shepherd's avatar Darren Shepherd
Browse files

Update all code to new types location

Showing with 98 additions and 84 deletions
+98 -84
......@@ -8,20 +8,21 @@ import (
"net/http"
"time"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
"github.com/rancher/norman/api/access"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
clusterclient "github.com/rancher/rancher/pkg/client/generated/cluster/v3"
mgmtclient "github.com/rancher/rancher/pkg/client/generated/management/v3"
"github.com/rancher/rancher/pkg/controllers/user/nslabels"
"github.com/rancher/rancher/pkg/generated/compose"
corev1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
"github.com/rancher/rancher/pkg/kubectl"
"github.com/rancher/rancher/pkg/ref"
"github.com/rancher/rancher/pkg/types/apis/cluster.cattle.io/v3/schema"
corev1 "github.com/rancher/rancher/pkg/types/apis/core/v1"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
clusterclient "github.com/rancher/rancher/pkg/types/client/cluster/v3"
mgmtclient "github.com/rancher/rancher/pkg/types/client/management/v3"
"github.com/rancher/rancher/pkg/types/compose"
schema "github.com/rancher/rancher/pkg/schemas/cluster.cattle.io/v3"
kerrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
......@@ -87,7 +88,7 @@ func (a ActionHandler) ExportYamlHandler(actionName string, action *types.Action
return err
}
if cluster.Status.Driver != v3.ClusterDriverRKE {
if cluster.Status.Driver != v32.ClusterDriverRKE {
return fmt.Errorf("cluster %v does not support being exported", cluster.Name)
}
......@@ -101,7 +102,7 @@ func (a ActionHandler) ExportYamlHandler(actionName string, action *types.Action
topkey.Clusters[cluster.Spec.DisplayName] = c
// if driver is rancherKubernetesEngine, add any nodePool if found
if cluster.Status.Driver == v3.ClusterDriverRKE {
if cluster.Status.Driver == v32.ClusterDriverRKE {
nodepools, err := a.NodepoolGetter.NodePools(cluster.Name).List(v1.ListOptions{})
if err != nil {
return err
......@@ -148,7 +149,7 @@ func (a ActionHandler) ExportYamlHandler(actionName string, action *types.Action
http.ServeContent(apiContext.Response, apiContext.Request, "exportYaml", time.Now(), reader)
return nil
}
r := v3.ExportOutput{
r := v32.ExportOutput{
YAMLOutput: string(buf),
}
jsonOutput, err := json.Marshal(r)
......
......@@ -3,13 +3,15 @@ package cluster
import (
"strings"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
gaccess "github.com/rancher/rancher/pkg/api/customization/globalnamespaceaccess"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
managementschema "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
managementschema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/config"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/labels"
......@@ -57,14 +59,14 @@ func (f *Formatter) Formatter(request *types.APIContext, resource *types.RawReso
shellLink = strings.Replace(shellLink, "http", "ws", 1)
shellLink = strings.Replace(shellLink, "/shell", "?shell=true", 1)
resource.Links["shell"] = shellLink
resource.AddAction(request, v3.ClusterActionGenerateKubeconfig)
resource.AddAction(request, v3.ClusterActionImportYaml)
resource.AddAction(request, v32.ClusterActionGenerateKubeconfig)
resource.AddAction(request, v32.ClusterActionImportYaml)
if _, ok := resource.Values["rancherKubernetesEngineConfig"]; ok {
resource.AddAction(request, v3.ClusterActionExportYaml)
resource.AddAction(request, v3.ClusterActionRotateCertificates)
resource.AddAction(request, v32.ClusterActionExportYaml)
resource.AddAction(request, v32.ClusterActionRotateCertificates)
if _, ok := values.GetValue(resource.Values, "rancherKubernetesEngineConfig", "services", "etcd", "backupConfig"); ok {
resource.AddAction(request, v3.ClusterActionBackupEtcd)
resource.AddAction(request, v3.ClusterActionRestoreFromEtcdBackup)
resource.AddAction(request, v32.ClusterActionBackupEtcd)
resource.AddAction(request, v32.ClusterActionRestoreFromEtcdBackup)
}
isActiveCluster := false
if resource.Values["state"] == "active" {
......@@ -78,30 +80,30 @@ func (f *Formatter) Formatter(request *types.APIContext, resource *types.RawReso
canUpdateCluster := canUserUpdateCluster(request, resource)
logrus.Debugf("isActiveCluster: %v isWindowsCluster: %v user: %v, canUpdateCluster: %v", isActiveCluster, isWindowsCluster, request.Request.Header.Get("Impersonate-User"), canUpdateCluster)
if canUpdateCluster {
resource.AddAction(request, v3.ClusterActionRunSecurityScan)
resource.AddAction(request, v32.ClusterActionRunSecurityScan)
}
}
}
if err := request.AccessControl.CanDo(v3.ClusterGroupVersionKind.Group, v3.ClusterResource.Name, "update", request, resource.Values, request.Schema); err == nil {
if convert.ToBool(resource.Values["enableClusterMonitoring"]) {
resource.AddAction(request, v3.ClusterActionDisableMonitoring)
resource.AddAction(request, v3.ClusterActionEditMonitoring)
resource.AddAction(request, v32.ClusterActionDisableMonitoring)
resource.AddAction(request, v32.ClusterActionEditMonitoring)
} else {
resource.AddAction(request, v3.ClusterActionEnableMonitoring)
resource.AddAction(request, v32.ClusterActionEnableMonitoring)
}
if _, ok := resource.Values["rancherKubernetesEngineConfig"]; ok {
if val, ok := values.GetValue(resource.Values, "clusterTemplateRevisionId"); ok && val == nil {
callerID := request.Request.Header.Get(gaccess.ImpersonateUserHeader)
if canCreateTemplates, _ := CanCreateRKETemplate(callerID, f.SubjectAccessReviewClient); canCreateTemplates {
resource.AddAction(request, v3.ClusterActionSaveAsTemplate)
resource.AddAction(request, v32.ClusterActionSaveAsTemplate)
}
}
}
}
if convert.ToBool(resource.Values["enableClusterMonitoring"]) {
resource.AddAction(request, v3.ClusterActionViewMonitoring)
resource.AddAction(request, v32.ClusterActionViewMonitoring)
}
if gkeConfig, ok := resource.Values["googleKubernetesEngineConfig"]; ok {
......
......@@ -11,7 +11,7 @@ import (
yaml2 "github.com/ghodss/yaml"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
v1 "github.com/rancher/rancher/pkg/types/apis/core/v1"
v1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
"github.com/sirupsen/logrus"
authV1 "k8s.io/api/authorization/v1"
"k8s.io/apimachinery/pkg/api/meta"
......
......@@ -12,13 +12,14 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
gaccess "github.com/rancher/rancher/pkg/api/customization/globalnamespaceaccess"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
mgmtclient "github.com/rancher/rancher/pkg/client/generated/management/v3"
"github.com/rancher/rancher/pkg/controllers/management/k3supgrade"
"github.com/rancher/rancher/pkg/controllers/user/cis"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/kontainer-engine/service"
mgmtSchema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/settings"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
mgmtSchema "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
mgmtclient "github.com/rancher/rancher/pkg/types/client/management/v3"
"github.com/rancher/rancher/pkg/types/namespace"
"github.com/robfig/cron"
)
......@@ -37,7 +38,7 @@ type Validator struct {
}
func (v *Validator) Validator(request *types.APIContext, schema *types.Schema, data map[string]interface{}) error {
var clusterSpec v3.ClusterSpec
var clusterSpec v32.ClusterSpec
var clientClusterSpec mgmtclient.Cluster
if err := convert.ToObj(data, &clusterSpec); err != nil {
return httperror.WrapAPIError(err, httperror.InvalidBodyContent, "Cluster spec conversion error")
......@@ -104,8 +105,8 @@ func validateScheduledClusterScan(spec *mgmtclient.Cluster) error {
if spec.ScheduledClusterScan.ScanConfig != nil &&
spec.ScheduledClusterScan.ScanConfig.CisScanConfig != nil {
profile := spec.ScheduledClusterScan.ScanConfig.CisScanConfig.Profile
if profile != string(v3.CisScanProfileTypePermissive) &&
profile != string(v3.CisScanProfileTypeHardened) {
if profile != string(v32.CisScanProfileTypePermissive) &&
profile != string(v32.CisScanProfileTypeHardened) {
return httperror.NewFieldAPIError(httperror.InvalidOption, "ScheduledClusterScan.ScanConfig.CisScanConfig.Profile", "profile can be either permissive or hardened")
}
}
......@@ -134,7 +135,7 @@ func validateScheduledClusterScan(spec *mgmtclient.Cluster) error {
return nil
}
func (v *Validator) validateLocalClusterAuthEndpoint(request *types.APIContext, spec *v3.ClusterSpec) error {
func (v *Validator) validateLocalClusterAuthEndpoint(request *types.APIContext, spec *v32.ClusterSpec) error {
if !spec.LocalClusterAuthEndpoint.Enabled {
return nil
}
......@@ -148,8 +149,8 @@ func (v *Validator) validateLocalClusterAuthEndpoint(request *types.APIContext,
return err
}
isValidCluster = cluster.Status.Driver == "" ||
cluster.Status.Driver == v3.ClusterDriverRKE ||
cluster.Status.Driver == v3.ClusterDriverImported
cluster.Status.Driver == v32.ClusterDriverRKE ||
cluster.Status.Driver == v32.ClusterDriverImported
}
if !isValidCluster {
return httperror.NewFieldAPIError(httperror.InvalidState, "LocalClusterAuthEndpoint.Enabled", "Can only enable LocalClusterAuthEndpoint with RKE")
......@@ -212,7 +213,7 @@ func (v *Validator) validateEnforcement(request *types.APIContext, data map[stri
// TODO: test validator
// prevents downgrades, no-ops, and upgrading before versions have been set
func (v *Validator) validateK3sVersionUpgrade(request *types.APIContext, spec *v3.ClusterSpec) error {
func (v *Validator) validateK3sVersionUpgrade(request *types.APIContext, spec *v32.ClusterSpec) error {
upgradeNotReadyErr := httperror.NewAPIError(httperror.Conflict, "k3s version upgrade is not ready, try again later")
if request.Method == http.MethodPost {
......@@ -293,7 +294,7 @@ func (v *Validator) accessTemplate(request *types.APIContext, spec *mgmtclient.C
}
// validateGenericEngineConfig allows for additional validation of clusters that depend on Kontainer Engine or Rancher Machine driver
func (v *Validator) validateGenericEngineConfig(request *types.APIContext, spec *v3.ClusterSpec) error {
func (v *Validator) validateGenericEngineConfig(request *types.APIContext, spec *v32.ClusterSpec) error {
if request.Method == http.MethodPost {
return nil
......
......@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"
mgmtclient "github.com/rancher/rancher/pkg/types/client/management/v3"
mgmtclient "github.com/rancher/rancher/pkg/client/generated/management/v3"
"github.com/sirupsen/logrus"
)
......
......@@ -6,10 +6,10 @@ import (
"github.com/rancher/norman/types"
util "github.com/rancher/rancher/pkg/cluster"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/image"
"github.com/rancher/rancher/pkg/settings"
"github.com/rancher/rancher/pkg/systemtemplate"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
......
......@@ -7,9 +7,9 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/urlbuilder"
"github.com/rancher/rancher/pkg/image"
schema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/settings"
"github.com/rancher/rancher/pkg/systemtemplate"
"github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
)
func ClusterImportHandler(resp http.ResponseWriter, req *http.Request) {
......
......@@ -4,13 +4,15 @@ import (
"net/http"
"strconv"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/norman/api/access"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rancher/pkg/clustermanager"
corev1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
mgmtv3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/ref"
corev1 "github.com/rancher/rancher/pkg/types/apis/core/v1"
mgmtv3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
"github.com/rancher/security-scan/pkg/kb-summarizer/report"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
......@@ -33,13 +35,13 @@ func Formatter(apiContext *types.APIContext, resource *types.RawResource) {
completed := false
runCompleted := false
for _, cond := range convert.ToMapSlice(status["conditions"]) {
if cond["type"] == string(mgmtv3.ClusterScanConditionCompleted) && cond["status"] == "True" {
if cond["type"] == string(v32.ClusterScanConditionCompleted) && cond["status"] == "True" {
completed = true
}
if cond["type"] == string(mgmtv3.ClusterScanConditionFailed) && cond["status"] == "True" {
if cond["type"] == string(v32.ClusterScanConditionFailed) && cond["status"] == "True" {
failed = true
}
if cond["type"] == string(mgmtv3.ClusterScanConditionRunCompleted) && cond["status"] == "True" {
if cond["type"] == string(v32.ClusterScanConditionRunCompleted) && cond["status"] == "True" {
runCompleted = true
}
}
......@@ -93,12 +95,12 @@ func (h Handler) LinkHandler(apiContext *types.APIContext, next types.RequestHan
return err
}
cm, err := clusterContext.Core.ConfigMaps(mgmtv3.DefaultNamespaceForCis).Get(clusterScanID, metav1.GetOptions{})
cm, err := clusterContext.Core.ConfigMaps(v32.DefaultNamespaceForCis).Get(clusterScanID, metav1.GetOptions{})
if err != nil {
return err
}
reportJSON, err := report.GetJSONBytes([]byte(cm.Data[mgmtv3.DefaultScanOutputFileName]))
reportJSON, err := report.GetJSONBytes([]byte(cm.Data[v32.DefaultScanOutputFileName]))
if err != nil {
return err
}
......
......@@ -5,6 +5,8 @@ import (
"sort"
"time"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"encoding/json"
"fmt"
......@@ -15,9 +17,9 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
managementschema "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
managementschema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/namespace"
"github.com/sirupsen/logrus"
apierrors "k8s.io/apimachinery/pkg/api/errors"
......@@ -34,7 +36,7 @@ type Wrapper struct {
ClusterTemplateLister v3.ClusterTemplateLister
ClusterTemplateRevisionLister v3.ClusterTemplateRevisionLister
ClusterTemplateRevisions v3.ClusterTemplateRevisionInterface
ClusterTemplateQuestions []v3.Question
ClusterTemplateQuestions []v32.Question
}
func (w Wrapper) Formatter(apiContext *types.APIContext, resource *types.RawResource) {
......@@ -172,7 +174,7 @@ func (w Wrapper) loadRevision(apiContext *types.APIContext) (*v3.ClusterTemplate
}
func (w Wrapper) listRevisionQuestions(actionName string, action *types.Action, apiContext *types.APIContext) error {
questionsOutput := v3.ClusterTemplateQuestionsOutput{}
questionsOutput := v32.ClusterTemplateQuestionsOutput{}
if len(w.ClusterTemplateQuestions) == 0 {
w.ClusterTemplateQuestions = w.BuildQuestionsFromSchema(apiContext.Schemas.Schema(&managementschema.Version, client.ClusterSpecBaseType), apiContext.Schemas, "")
......@@ -187,8 +189,8 @@ func (w Wrapper) listRevisionQuestions(actionName string, action *types.Action,
return nil
}
func (w Wrapper) BuildQuestionsFromSchema(schema *types.Schema, schemas *types.Schemas, pathTofield string) []v3.Question {
questions := []v3.Question{}
func (w Wrapper) BuildQuestionsFromSchema(schema *types.Schema, schemas *types.Schemas, pathTofield string) []v32.Question {
questions := []v32.Question{}
for name, field := range schema.ResourceFields {
fieldType := field.Type
if strings.HasPrefix(fieldType, "array") {
......@@ -207,7 +209,7 @@ func (w Wrapper) BuildQuestionsFromSchema(schema *types.Schema, schemas *types.S
}
} else {
//add a Question
newQuestion := v3.Question{}
newQuestion := v32.Question{}
if field.Type == "password" {
newQuestion.Group = "password"
}
......
......@@ -10,8 +10,8 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/rancher/pkg/api/customization/namespacedresource"
v1 "github.com/rancher/rancher/pkg/types/apis/core/v1"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
v1 "github.com/rancher/rancher/pkg/generated/norman/core/v1"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/namespace"
"k8s.io/apimachinery/pkg/labels"
)
......
......@@ -6,7 +6,7 @@ import (
"github.com/rancher/norman/api/access"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
v3client "github.com/rancher/rancher/pkg/types/client/management/v3"
v3client "github.com/rancher/rancher/pkg/client/generated/management/v3"
)
func Validator(request *types.APIContext, schema *types.Schema, data map[string]interface{}) error {
......
......@@ -12,8 +12,8 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
gaccess "github.com/rancher/rancher/pkg/api/customization/globalnamespaceaccess"
managementschema "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
managementschema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
......
......@@ -8,8 +8,8 @@ import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
gaccess "github.com/rancher/rancher/pkg/api/customization/globalnamespaceaccess"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"k8s.io/apimachinery/pkg/api/meta"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
......
......@@ -5,16 +5,18 @@ import (
"fmt"
"strings"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/norman/api/access"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/set"
"github.com/rancher/norman/types/slice"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/ref"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
managementschema "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3/schema"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
managementschema "github.com/rancher/rancher/pkg/schemas/management.cattle.io/v3"
apierrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
......@@ -316,7 +318,7 @@ func (ma *MemberAccess) EnsureRoleInTargets(targetProjects, roleTemplates []stri
}
// CheckAccessToUpdateMembers checks if the request is updating members list, and if the caller has permission to do so
func CheckAccessToUpdateMembers(members []v3.Member, data map[string]interface{}, ownerAccess bool) error {
func CheckAccessToUpdateMembers(members []v32.Member, data map[string]interface{}, ownerAccess bool) error {
var requestUpdatesMembers bool
// Check if members are being updated, if yes, make sure only member with owner permission is making this update request
newMembers := convert.ToMapSlice(data[client.GlobalDnsFieldMembers])
......@@ -377,7 +379,7 @@ func CheckAccessToUpdateMembers(members []v3.Member, data map[string]interface{}
return nil
}
func (ma *MemberAccess) GetAccessTypeOfCaller(callerID, creatorID, name string, members []v3.Member) (string, error) {
func (ma *MemberAccess) GetAccessTypeOfCaller(callerID, creatorID, name string, members []v32.Member) (string, error) {
var username string
isAdmin, err := ma.IsAdmin(callerID)
if err != nil {
......
......@@ -5,7 +5,7 @@ import (
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"k8s.io/apimachinery/pkg/api/errors"
)
......
......@@ -15,9 +15,9 @@ import (
helmlib "github.com/rancher/rancher/pkg/catalog/helm"
"github.com/rancher/rancher/pkg/catalog/utils"
kd "github.com/rancher/rancher/pkg/controllers/management/kontainerdrivermetadata"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/image"
"github.com/rancher/rancher/pkg/settings"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
rketypes "github.com/rancher/rke/types"
img "github.com/rancher/rke/types/image"
"github.com/rancher/rke/util"
......
......@@ -5,8 +5,8 @@ import (
"strings"
"github.com/rancher/norman/types"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
client "github.com/rancher/rancher/pkg/types/client/management/v3"
client "github.com/rancher/rancher/pkg/client/generated/management/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/config"
"github.com/sirupsen/logrus"
"k8s.io/client-go/tools/cache"
......
......@@ -6,7 +6,7 @@ import (
errorsutil "github.com/pkg/errors"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/types/config"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/cache"
......
......@@ -3,10 +3,12 @@ package kontainerdriver
import (
"fmt"
v32 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
v3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"k8s.io/apimachinery/pkg/labels"
)
......@@ -15,7 +17,7 @@ type Validator struct {
}
func (v *Validator) Validator(request *types.APIContext, schema *types.Schema, data map[string]interface{}) error {
var spec v3.KontainerDriverSpec
var spec v32.KontainerDriverSpec
if err := convert.ToObj(data, &spec); err != nil {
return httperror.WrapAPIError(err, httperror.InvalidBodyContent, "Kontainer driver spec conversion error")
......@@ -24,7 +26,7 @@ func (v *Validator) Validator(request *types.APIContext, schema *types.Schema, d
return v.validateKontainerDriverURL(request, spec)
}
func (v *Validator) validateKontainerDriverURL(request *types.APIContext, spec v3.KontainerDriverSpec) error {
func (v *Validator) validateKontainerDriverURL(request *types.APIContext, spec v32.KontainerDriverSpec) error {
kontainerDrivers, err := v.KontainerDriverLister.List("", labels.NewSelector())
if err != nil {
return httperror.WrapAPIError(err, httperror.ServerError, "Failed to list kontainer drivers")
......
......@@ -8,21 +8,23 @@ import (
"path"
"strings"
v33 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/norman/condition"
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/parse"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
mgmtv3client "github.com/rancher/rancher/pkg/client/generated/management/v3"
"github.com/rancher/rancher/pkg/clustermanager"
loggingconfig "github.com/rancher/rancher/pkg/controllers/user/logging/config"
"github.com/rancher/rancher/pkg/controllers/user/logging/configsyncer"
"github.com/rancher/rancher/pkg/controllers/user/logging/deployer"
"github.com/rancher/rancher/pkg/controllers/user/logging/utils"
mgmtv3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
projectv3 "github.com/rancher/rancher/pkg/generated/norman/project.cattle.io/v3"
"github.com/rancher/rancher/pkg/rbac"
"github.com/rancher/rancher/pkg/ref"
mgmtv3 "github.com/rancher/rancher/pkg/types/apis/management.cattle.io/v3"
projectv3 "github.com/rancher/rancher/pkg/types/apis/project.cattle.io/v3"
mgmtv3client "github.com/rancher/rancher/pkg/types/client/management/v3"
"github.com/rancher/rancher/pkg/types/config"
"github.com/rancher/rancher/pkg/types/config/dialer"
......@@ -69,14 +71,14 @@ func CollectionFormatter(apiContext *types.APIContext, resource *types.GenericCo
}
func (h *Handler) ActionHandler(actionName string, action *types.Action, apiContext *types.APIContext) error {
var target mgmtv3.LoggingTargets
var target v33.LoggingTargets
var clusterName, projectID, projectName, level, containerLogSourceTag string
var outputTags map[string]string
switch apiContext.Type {
case mgmtv3client.ClusterLoggingType:
var input mgmtv3.ClusterTestInput
var input v33.ClusterTestInput
actionInput, err := parse.ReadBody(apiContext.Request)
if err != nil {
return err
......@@ -97,7 +99,7 @@ func (h *Handler) ActionHandler(actionName string, action *types.Action, apiCont
case mgmtv3client.ProjectLoggingType:
var input mgmtv3.ProjectTestInput
var input v33.ProjectTestInput
actionInput, err := parse.ReadBody(apiContext.Request)
if err != nil {
return err
......@@ -147,7 +149,7 @@ func (h *Handler) ActionHandler(actionName string, action *types.Action, apiCont
}
func (h *Handler) testLoggingTarget(ctx context.Context, clusterName string, target mgmtv3.LoggingTargets) error {
func (h *Handler) testLoggingTarget(ctx context.Context, clusterName string, target v33.LoggingTargets) error {
clusterDialer, err := h.dialerFactory.ClusterDialer(clusterName)
if err != nil {
return errors.Wrap(err, "get cluster dialer failed")
......@@ -161,7 +163,7 @@ func (h *Handler) testLoggingTarget(ctx context.Context, clusterName string, tar
return wp.TestReachable(ctx, clusterDialer, true)
}
func (h *Handler) dryRunLoggingTarget(apiContext *types.APIContext, level, clusterName, projectID string, target mgmtv3.LoggingTargets) error {
func (h *Handler) dryRunLoggingTarget(apiContext *types.APIContext, level, clusterName, projectID string, target v33.LoggingTargets) error {
context, err := h.clusterManager.UserContext(clusterName)
if err != nil {
return err
......@@ -178,7 +180,7 @@ func (h *Handler) dryRunLoggingTarget(apiContext *types.APIContext, level, clust
tmpCertDir := fmt.Sprintf("%s/%s", tmpCertDirPrefix, uuid.NewV4().String())
if level == loggingconfig.ClusterLevel {
clusterLogging := &mgmtv3.ClusterLogging{
Spec: mgmtv3.ClusterLoggingSpec{
Spec: v33.ClusterLoggingSpec{
LoggingTargets: target,
ClusterName: clusterName,
},
......@@ -192,7 +194,7 @@ func (h *Handler) dryRunLoggingTarget(apiContext *types.APIContext, level, clust
certScretKeyName = clusterName
} else {
new := &mgmtv3.ProjectLogging{
Spec: mgmtv3.ProjectLoggingSpec{
Spec: v33.ProjectLoggingSpec{
LoggingTargets: target,
ProjectName: projectID,
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment