-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Authentication and OAuth crds #948
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: apiextensions.k8s.io/v1beta1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: authentications.config.openshift.io | ||
| spec: | ||
| group: config.openshift.io | ||
| names: | ||
| kind: Authentication | ||
| listKind: AuthenticationList | ||
| plural: authentications | ||
| singular: authentication | ||
| scope: Cluster | ||
| subresources: | ||
| status: {} | ||
| versions: | ||
| - name: v1 | ||
| served: true | ||
| storage: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| apiVersion: apiextensions.k8s.io/v1beta1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: oauths.config.openshift.io | ||
| spec: | ||
| group: config.openshift.io | ||
| names: | ||
| kind: OAuth | ||
| listKind: OAuthList | ||
| plural: oauths | ||
| singular: oauth | ||
| scope: Cluster | ||
| subresources: | ||
| status: {} | ||
| versions: | ||
| - name: v1 | ||
| served: true | ||
| storage: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
|
|
||
| "github.com/ghodss/yaml" | ||
| "github.com/pkg/errors" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| "github.com/openshift/installer/pkg/asset/templates/content" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| var ( | ||
| authCrdFilename = "cluster-authentication-crd.yaml" | ||
| authCfgFilename = filepath.Join(manifestDir, "cluster-authentication-config.yml") | ||
| ) | ||
|
|
||
| // Authentication generates the authentication-*.yml files. | ||
| type Authentication struct { | ||
| config *configv1.Authentication | ||
|
||
| FileList []*asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*Authentication)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*Authentication) Name() string { | ||
| return "Authentication Config" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*Authentication) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the Authentication and its CRD. | ||
| func (a *Authentication) Generate(dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| dependencies.Get(installConfig) | ||
|
|
||
| a.config = &configv1.Authentication{ | ||
|
||
| TypeMeta: metav1.TypeMeta{ | ||
| Kind: "Authentication", | ||
| APIVersion: configv1.GroupVersion.String(), | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "cluster", | ||
| }, | ||
| } | ||
|
|
||
| configData, err := yaml.Marshal(a.config) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to generate data for asset: %s", a.Name()) | ||
| } | ||
|
|
||
| crdData, err := content.GetOpenshiftTemplate(authCrdFilename) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to get contentes of %s", authCrdFilename) | ||
| } | ||
|
|
||
| a.FileList = []*asset.File{ | ||
| { | ||
| Filename: filepath.Join(manifestDir, authCrdFilename), | ||
| Data: []byte(crdData), | ||
| }, | ||
| { | ||
| Filename: authCfgFilename, | ||
| Data: configData, | ||
| }, | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (a *Authentication) Files() []*asset.File { | ||
| return a.FileList | ||
| } | ||
|
|
||
| // Load returns false since this asset is not written to disk by the installer. | ||
| func (a *Authentication) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
|
|
||
| "github.com/ghodss/yaml" | ||
| "github.com/pkg/errors" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| "github.com/openshift/installer/pkg/asset/templates/content" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| var ( | ||
| oauthCrdFilename = "cluster-oauth-crd.yaml" | ||
| oauthCfgFilename = filepath.Join(manifestDir, "cluster-oauth-config.yml") | ||
| ) | ||
|
|
||
| // OAuth generates the authentication-*.yml files. | ||
| type OAuth struct { | ||
| config *configv1.OAuth | ||
| FileList []*asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*OAuth)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*OAuth) Name() string { | ||
| return "OAuth Config" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*OAuth) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the OAuth and its CRD. | ||
| func (o *OAuth) Generate(dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| dependencies.Get(installConfig) | ||
|
|
||
| o.config = &configv1.OAuth{ | ||
|
||
| TypeMeta: metav1.TypeMeta{ | ||
| Kind: "OAuth", | ||
| APIVersion: configv1.GroupVersion.String(), | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "cluster", | ||
| }, | ||
| Spec: configv1.OAuthSpec{ | ||
| TokenConfig: configv1.TokenConfig{ | ||
| AuthorizeTokenMaxAgeSeconds: 5 * 60, // 5 minutes | ||
| AccessTokenMaxAgeSeconds: 24 * 60 * 60, // 1 day | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| configData, err := yaml.Marshal(o.config) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to generate data for asset: %s", o.Name()) | ||
| } | ||
|
|
||
| crdData, err := content.GetOpenshiftTemplate(oauthCrdFilename) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to get contentes of %s", oauthCrdFilename) | ||
| } | ||
|
|
||
| o.FileList = []*asset.File{ | ||
| { | ||
| Filename: filepath.Join(manifestDir, oauthCrdFilename), | ||
| Data: []byte(crdData), | ||
| }, | ||
| { | ||
| Filename: oauthCfgFilename, | ||
| Data: configData, | ||
| }, | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (o *OAuth) Files() []*asset.File { | ||
| return o.FileList | ||
| } | ||
|
|
||
| // Load returns false since this asset is not written to disk by the installer. | ||
| func (o *OAuth) Load(f asset.FileFetcher) (bool, error) { | ||
| return false, nil | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set
spec.subresources.statusto the empty object for both resources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done