Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Dec 18, 2024
1 parent aa973fe commit 9f0a905
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 5 deletions.
116 changes: 116 additions & 0 deletions api/types/settings/issuer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: Apache-2.0

package settings

import "fmt"

// OIDCIssuerSlice is an alias for a slice of OIDCIssuer types.
type OIDCIssuerSlice []*OIDCIssuer

// OIDCIssuer is the API representation of the OIDCIssuer setting.
type OIDCIssuer struct {
Issuer *string `json:"issuer,omitempty" yaml:"issuer,omitempty"`
UsernameMap *string `json:"username_map,omitempty" yaml:"username_map,omitempty"`
Redirect *string `json:"redirect,omitempty" yaml:"redirect,omitempty"`
}

// GetIssuer returns the Issuer field.
//
// When the provided OIDCIssuer type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (oi *OIDCIssuer) GetIssuer() string {
// return zero value if OIDCIssuer type or Issuer field is nil
if oi == nil || oi.Issuer == nil {
return ""
}

return *oi.Issuer
}

// GetUsernameMap returns the UsernameMap field.
//
// When the provided OIDCIssuer type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (oi *OIDCIssuer) GetUsernameMap() string {
// return zero value if OIDCIssuer type or UsernameMap field is nil
if oi == nil || oi.UsernameMap == nil {
return ""
}

return *oi.UsernameMap
}

// GetRedirect returns the Redirect field.
//
// When the provided OIDCIssuer type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (oi *OIDCIssuer) GetRedirect() string {
// return zero value if OIDCIssuer type or Redirect field is nil
if oi == nil || oi.Redirect == nil {
return ""
}

return *oi.Redirect
}

// SetIssuer sets the Issuer field.
//
// When the provided OIDCIssuer type is nil, it
// will set nothing and immediately return.
func (oi *OIDCIssuer) SetIssuer(v string) {
// return if OIDCIssuer type is nil
if oi == nil {
return
}

oi.Issuer = &v
}

// SetUsernameMap sets the UsernameMap field.
//
// When the provided OIDCIssuer type is nil, it
// will set nothing and immediately return.
func (oi *OIDCIssuer) SetUsernameMap(v string) {
// return if OIDCIssuer type is nil
if oi == nil {
return
}

oi.UsernameMap = &v
}

// SetRedirect sets the Redirect field.
//
// When the provided OIDCIssuer type is nil, it
// will set nothing and immediately return.
func (oi *OIDCIssuer) SetRedirect(v string) {
// return if OIDCIssuer type is nil
if oi == nil {
return
}

oi.Redirect = &v
}

// String implements the Stringer interface for the OIDCIssuer type.
func (oi *OIDCIssuer) String() string {
return fmt.Sprintf(`{
Issuer: %s,
UsernameMap: %s,
Redirect: %s,
}`,
oi.GetIssuer(),
oi.GetUsernameMap(),
oi.GetRedirect(),
)
}

// OIDCIssuerMockEmpty returns an empty OIDCIssuer type.
func OIDCIssuerMockEmpty() OIDCIssuer {
oi := OIDCIssuer{}
oi.SetIssuer("")
oi.SetUsernameMap("")
oi.SetRedirect("")

return oi
}
39 changes: 34 additions & 5 deletions api/types/settings/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ type Platform struct {
ID *int64 `json:"id"`
*Compiler `json:"compiler,omitempty" yaml:"compiler,omitempty"`
*Queue `json:"queue,omitempty" yaml:"queue,omitempty"`
RepoAllowlist *[]string `json:"repo_allowlist,omitempty" yaml:"repo_allowlist,omitempty"`
ScheduleAllowlist *[]string `json:"schedule_allowlist,omitempty" yaml:"schedule_allowlist,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty" yaml:"created_at,omitempty"`
UpdatedAt *int64 `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty" yaml:"updated_by,omitempty"`
RepoAllowlist *[]string `json:"repo_allowlist,omitempty" yaml:"repo_allowlist,omitempty"`
ScheduleAllowlist *[]string `json:"schedule_allowlist,omitempty" yaml:"schedule_allowlist,omitempty"`
OIDCIssuers OIDCIssuerSlice `json:"oidc_issuers,omitempty" yaml:"oidc_issuers,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty" yaml:"created_at,omitempty"`
UpdatedAt *int64 `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`
UpdatedBy *string `json:"updated_by,omitempty" yaml:"updated_by,omitempty"`
}

// FromCLIContext returns a new Platform record from a cli context.
Expand Down Expand Up @@ -100,6 +101,19 @@ func (ps *Platform) GetScheduleAllowlist() []string {
return *ps.ScheduleAllowlist
}

// GetOIDCIssuers returns the OIDCIssuers field.
//
// When the provided Platform type is nil, or the field within
// the type is nil, it returns the zero value for the field.
func (ps *Platform) GetOIDCIssuers() OIDCIssuerSlice {
// return zero value if Platform type or OIDCIssuers field is nil
if ps == nil || ps.OIDCIssuers == nil {
return OIDCIssuerSlice{}
}

return ps.OIDCIssuers
}

// GetCreatedAt returns the CreatedAt field.
//
// When the provided Platform type is nil, or the field within
Expand Down Expand Up @@ -204,6 +218,19 @@ func (ps *Platform) SetScheduleAllowlist(v []string) {
ps.ScheduleAllowlist = &v
}

// SetOIDCIssuers sets the OIDCIssuers field.
//
// When the provided Platform type is nil, it
// will set nothing and immediately return.
func (ps *Platform) SetOIDCIssuers(v OIDCIssuerSlice) {
// return if Platform type is nil
if ps == nil {
return
}

ps.OIDCIssuers = v
}

// SetCreatedAt sets the CreatedAt field.
//
// When the provided Platform type is nil, it
Expand Down Expand Up @@ -275,6 +302,7 @@ func (ps *Platform) String() string {
Queue: %v,
RepoAllowlist: %v,
ScheduleAllowlist: %v,
OIDCIssuers: %v,
CreatedAt: %d,
UpdatedAt: %d,
UpdatedBy: %s,
Expand All @@ -284,6 +312,7 @@ func (ps *Platform) String() string {
qs.String(),
ps.GetRepoAllowlist(),
ps.GetScheduleAllowlist(),
ps.GetOIDCIssuers(),
ps.GetCreatedAt(),
ps.GetUpdatedAt(),
ps.GetUpdatedBy(),
Expand Down

0 comments on commit 9f0a905

Please sign in to comment.