Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Rancher
Commits
c06fbe47
Commit
c06fbe47
authored
4 years ago
by
Darren Shepherd
Browse files
Options
Download
Email Patches
Plain Diff
Update all code to new types location
parent
323367a0
master
2.4-head
2.5-head
aecdb0589
ansilh-cs-status-logging
cfbd0d3
cloudnautique-patch-1
cwarren/automate_private_registry_1
dev
dnoland1-cores-metric-patch
dnoland1-patch-1
dnoland1-patch-2
dnoland1-patch-3
dnoland1-patch-4
kinarashah-patch-1
mrajashree-patch-1
not-release/v2.5.11
paynejacob-patch-1
paynejacob-patch-1-1
rc-19
release/v1.1
release/v2.5
release/v2.5.11
release/v2.5.11-alt
release/v2.5.11-patch1
release/v2.5.3
release/v2.5.5
release/v2.5.7
release/v2.5.7-patch1
release/v2.5.8
release/v2.5.8-patch1
release/v2.5.8-patch2
release/v2.5.8-patch3
release/v2.5.8-rc1
release/v2.5.9
release/v2.5.9-debug1
release/v2.6
release/v2.6.2
revert-29888-revert-ingress-version-fwd
revert-29936-fleet-gitjob-proxy-support
revert-30671-release/v2.5
revert-30698-revert-30671-release/v2.5
revert-31102-restrictedadminrancher
revert-31118-fwd_restrictedadmin
revert-35793-temporarily-disable-fossa
snyk-fix-0564176c790784e319dbf499a8a4b2b8
update-issue-templates
Tags unavailable
No related merge requests found
Changes
482
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
pkg/api/customization/cluster/actions_yaml.go
+10
-9
pkg/api/customization/cluster/actions_yaml.go
pkg/api/customization/cluster/formatter.go
+17
-15
pkg/api/customization/cluster/formatter.go
pkg/api/customization/cluster/utils.go
+1
-1
pkg/api/customization/cluster/utils.go
pkg/api/customization/cluster/validator.go
+12
-11
pkg/api/customization/cluster/validator.go
pkg/api/customization/cluster/validator_test.go
+1
-1
pkg/api/customization/cluster/validator_test.go
pkg/api/customization/clusterregistrationtokens/formatter.go
+1
-1
pkg/api/customization/clusterregistrationtokens/formatter.go
pkg/api/customization/clusterregistrationtokens/import.go
+1
-1
pkg/api/customization/clusterregistrationtokens/import.go
pkg/api/customization/clusterscan/clusterscan.go
+9
-7
pkg/api/customization/clusterscan/clusterscan.go
pkg/api/customization/clustertemplate/cluster_template.go
+10
-8
pkg/api/customization/clustertemplate/cluster_template.go
pkg/api/customization/cred/store.go
+2
-2
pkg/api/customization/cred/store.go
pkg/api/customization/feature/feature.go
+1
-1
pkg/api/customization/feature/feature.go
pkg/api/customization/globaldns/action_globaldns.go
+2
-2
pkg/api/customization/globaldns/action_globaldns.go
pkg/api/customization/globaldns/validator_globaldns.go
+2
-2
pkg/api/customization/globaldns/validator_globaldns.go
pkg/api/customization/globalnamespaceaccess/access_common.go
+7
-5
pkg/api/customization/globalnamespaceaccess/access_common.go
pkg/api/customization/globalrole/validator.go
+1
-1
pkg/api/customization/globalrole/validator.go
pkg/api/customization/kontainerdriver/actionhandler.go
+1
-1
pkg/api/customization/kontainerdriver/actionhandler.go
pkg/api/customization/kontainerdriver/formatter.go
+2
-2
pkg/api/customization/kontainerdriver/formatter.go
pkg/api/customization/kontainerdriver/store.go
+1
-1
pkg/api/customization/kontainerdriver/store.go
pkg/api/customization/kontainerdriver/validator.go
+5
-3
pkg/api/customization/kontainerdriver/validator.go
pkg/api/customization/logging/action.go
+12
-10
pkg/api/customization/logging/action.go
with
98 additions
and
84 deletions
+98
-84
pkg/api/customization/cluster/actions_yaml.go
+
10
-
9
View file @
c06fbe47
...
...
@@ -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
!=
v3
2
.
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
==
v3
2
.
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
:=
v3
2
.
ExportOutput
{
YAMLOutput
:
string
(
buf
),
}
jsonOutput
,
err
:=
json
.
Marshal
(
r
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/cluster/formatter.go
+
17
-
15
View file @
c06fbe47
...
...
@@ -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
,
v3
2
.
ClusterActionGenerateKubeconfig
)
resource
.
AddAction
(
request
,
v3
2
.
ClusterActionImportYaml
)
if
_
,
ok
:=
resource
.
Values
[
"rancherKubernetesEngineConfig"
];
ok
{
resource
.
AddAction
(
request
,
v3
.
ClusterActionExportYaml
)
resource
.
AddAction
(
request
,
v3
.
ClusterActionRotateCertificates
)
resource
.
AddAction
(
request
,
v3
2
.
ClusterActionExportYaml
)
resource
.
AddAction
(
request
,
v3
2
.
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
,
v3
2
.
ClusterActionBackupEtcd
)
resource
.
AddAction
(
request
,
v3
2
.
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
,
v3
2
.
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
,
v3
2
.
ClusterActionDisableMonitoring
)
resource
.
AddAction
(
request
,
v3
2
.
ClusterActionEditMonitoring
)
}
else
{
resource
.
AddAction
(
request
,
v3
.
ClusterActionEnableMonitoring
)
resource
.
AddAction
(
request
,
v3
2
.
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
,
v3
2
.
ClusterActionSaveAsTemplate
)
}
}
}
}
if
convert
.
ToBool
(
resource
.
Values
[
"enableClusterMonitoring"
])
{
resource
.
AddAction
(
request
,
v3
.
ClusterActionViewMonitoring
)
resource
.
AddAction
(
request
,
v3
2
.
ClusterActionViewMonitoring
)
}
if
gkeConfig
,
ok
:=
resource
.
Values
[
"googleKubernetesEngineConfig"
];
ok
{
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/cluster/utils.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/cluster/validator.go
+
12
-
11
View file @
c06fbe47
...
...
@@ -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
v3
2
.
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
(
v3
2
.
CisScanProfileTypePermissive
)
&&
profile
!=
string
(
v3
2
.
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
*
v3
2
.
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
==
v3
2
.
ClusterDriverRKE
||
cluster
.
Status
.
Driver
==
v3
2
.
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
*
v3
2
.
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
*
v3
2
.
ClusterSpec
)
error
{
if
request
.
Method
==
http
.
MethodPost
{
return
nil
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/cluster/validator_test.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/clusterregistrationtokens/formatter.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/clusterregistrationtokens/import.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/clusterscan/clusterscan.go
+
9
-
7
View file @
c06fbe47
...
...
@@ -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
(
mgmt
v3
.
ClusterScanConditionCompleted
)
&&
cond
[
"status"
]
==
"True"
{
if
cond
[
"type"
]
==
string
(
v3
2
.
ClusterScanConditionCompleted
)
&&
cond
[
"status"
]
==
"True"
{
completed
=
true
}
if
cond
[
"type"
]
==
string
(
mgmt
v3
.
ClusterScanConditionFailed
)
&&
cond
[
"status"
]
==
"True"
{
if
cond
[
"type"
]
==
string
(
v3
2
.
ClusterScanConditionFailed
)
&&
cond
[
"status"
]
==
"True"
{
failed
=
true
}
if
cond
[
"type"
]
==
string
(
mgmt
v3
.
ClusterScanConditionRunCompleted
)
&&
cond
[
"status"
]
==
"True"
{
if
cond
[
"type"
]
==
string
(
v3
2
.
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
(
mgmt
v3
.
DefaultNamespaceForCis
)
.
Get
(
clusterScanID
,
metav1
.
GetOptions
{})
cm
,
err
:=
clusterContext
.
Core
.
ConfigMaps
(
v3
2
.
DefaultNamespaceForCis
)
.
Get
(
clusterScanID
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
}
reportJSON
,
err
:=
report
.
GetJSONBytes
([]
byte
(
cm
.
Data
[
mgmt
v3
.
DefaultScanOutputFileName
]))
reportJSON
,
err
:=
report
.
GetJSONBytes
([]
byte
(
cm
.
Data
[
v3
2
.
DefaultScanOutputFileName
]))
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/clustertemplate/cluster_template.go
+
10
-
8
View file @
c06fbe47
...
...
@@ -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
[]
v3
2
.
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
:=
v3
2
.
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
)
[]
v3
2
.
Question
{
questions
:=
[]
v3
2
.
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
:=
v3
2
.
Question
{}
if
field
.
Type
==
"password"
{
newQuestion
.
Group
=
"password"
}
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/cred/store.go
+
2
-
2
View file @
c06fbe47
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/feature/feature.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/globaldns/action_globaldns.go
+
2
-
2
View file @
c06fbe47
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/globaldns/validator_globaldns.go
+
2
-
2
View file @
c06fbe47
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/globalnamespaceaccess/access_common.go
+
7
-
5
View file @
c06fbe47
...
...
@@ -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
[]
v3
2
.
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
[]
v3
2
.
Member
)
(
string
,
error
)
{
var
username
string
isAdmin
,
err
:=
ma
.
IsAdmin
(
callerID
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/globalrole/validator.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/kontainerdriver/actionhandler.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/kontainerdriver/formatter.go
+
2
-
2
View file @
c06fbe47
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/kontainerdriver/store.go
+
1
-
1
View file @
c06fbe47
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/kontainerdriver/validator.go
+
5
-
3
View file @
c06fbe47
...
...
@@ -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
v3
2
.
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
v3
2
.
KontainerDriverSpec
)
error
{
kontainerDrivers
,
err
:=
v
.
KontainerDriverLister
.
List
(
""
,
labels
.
NewSelector
())
if
err
!=
nil
{
return
httperror
.
WrapAPIError
(
err
,
httperror
.
ServerError
,
"Failed to list kontainer drivers"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/api/customization/logging/action.go
+
12
-
10
View file @
c06fbe47
...
...
@@ -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
mgmt
v3
.
LoggingTargets
var
target
v
3
3
.
LoggingTargets
var
clusterName
,
projectID
,
projectName
,
level
,
containerLogSourceTag
string
var
outputTags
map
[
string
]
string
switch
apiContext
.
Type
{
case
mgmtv3client
.
ClusterLoggingType
:
var
input
mgmt
v3
.
ClusterTestInput
var
input
v
3
3
.
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
mgmt
v3
.
ProjectTestInput
var
input
v
3
3
.
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
mgmt
v3
.
LoggingTargets
)
error
{
func
(
h
*
Handler
)
testLoggingTarget
(
ctx
context
.
Context
,
clusterName
string
,
target
v
3
3
.
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
mgmt
v3
.
LoggingTargets
)
error
{
func
(
h
*
Handler
)
dryRunLoggingTarget
(
apiContext
*
types
.
APIContext
,
level
,
clusterName
,
projectID
string
,
target
v
3
3
.
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
:
mgmt
v3
.
ClusterLoggingSpec
{
Spec
:
v
3
3
.
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
:
mgmt
v3
.
ProjectLoggingSpec
{
Spec
:
v
3
3
.
ProjectLoggingSpec
{
LoggingTargets
:
target
,
ProjectName
:
projectID
,
},
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
6
7
…
25
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help