Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oc adm migrate scc: implement a command for converting SCCs to PSPs #18885

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions contrib/completions/bash/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions contrib/completions/zsh/oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions hack/import-restrictions.json
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
"vendor/github.com/fsouza/go-dockerclient",
"vendor/github.com/golang/glog",
"vendor/github.com/gonum/graph",
"vendor/github.com/google/gofuzz",
"vendor/github.com/joho/godotenv",
"vendor/github.com/MakeNowJust/heredoc",
"vendor/github.com/opencontainers/go-digest",
Expand All @@ -516,6 +517,7 @@
"vendor/k8s.io/kubernetes/pkg/client",
"vendor/k8s.io/kubernetes/pkg/kubectl",
"vendor/k8s.io/kubernetes/pkg/printers",
"vendor/k8s.io/kubernetes/pkg/security",
"vendor/k8s.io/kubernetes/pkg/util",
"vendor/github.com/davecgh/go-spew/spew",

Expand Down
2 changes: 2 additions & 0 deletions pkg/oc/cli/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
migrateetcd "github.com/openshift/origin/pkg/oc/cli/admin/migrate/etcd"
migrateimages "github.com/openshift/origin/pkg/oc/cli/admin/migrate/images"
migratehpa "github.com/openshift/origin/pkg/oc/cli/admin/migrate/legacyhpa"
migratescc "github.com/openshift/origin/pkg/oc/cli/admin/migrate/scc"
migratestorage "github.com/openshift/origin/pkg/oc/cli/admin/migrate/storage"
migratetemplateinstances "github.com/openshift/origin/pkg/oc/cli/admin/migrate/templateinstances"
"github.com/openshift/origin/pkg/oc/cli/admin/network"
Expand Down Expand Up @@ -101,6 +102,7 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc
migratestorage.NewCmdMigrateAPIStorage("storage", fullName+" "+migrate.MigrateRecommendedName+" storage", f, streams),
migrateetcd.NewCmdMigrateTTLs("etcd-ttl", fullName+" "+migrate.MigrateRecommendedName+" etcd-ttl", f, streams),
migratehpa.NewCmdMigrateLegacyHPA("legacy-hpa", fullName+" "+migrate.MigrateRecommendedName+" legacy-hpa", f, streams),
migratescc.NewCmdMigrateSCC("scc", fullName+" "+migrate.MigrateRecommendedName+" scc", f, streams),
migratetemplateinstances.NewCmdMigrateTemplateInstances("template-instances", fullName+" "+migrate.MigrateRecommendedName+" template-instances", f, streams),
),
top.NewCommandTop(top.TopRecommendedName, fullName+" "+top.TopRecommendedName, f, streams),
Expand Down
45 changes: 45 additions & 0 deletions pkg/oc/cli/admin/migrate/scc/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package scc

import (
"fmt"

"k8s.io/api/core/v1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use explicit alias in these imports, iow. corev1, policyv1beta, etc. This makes the code more obvious without reading imports.

policy "k8s.io/api/policy/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"
)

func convertCapabilities(inputCapabilities []v1.Capability) []v1.Capability {
caps := make([]v1.Capability, 0, len(inputCapabilities))
for _, capability := range inputCapabilities {
v1Cap := v1.Capability(string(capability))
caps = append(caps, v1Cap)
}
return caps
}

func int64val(value *int64) string {
if value == nil {
return "nil"
}

return fmt.Sprintf("%d", *value)
}

func createSingleIDRange(min, max int64) []policy.IDRange {
ranges := make([]policy.IDRange, 1)
ranges[0] = policy.IDRange{
Min: min,
Max: max,
}
return ranges
}

func collectSubjectNames(subjects []rbacv1.Subject, accept func(rbacv1.Subject) bool) []string {
result := []string{}
for _, subject := range subjects {
if accept(subject) {
result = append(result, subject.Name)
}
}
return result
}
Loading