Skip to content

Commit

Permalink
Spec redirects (#237)
Browse files Browse the repository at this point in the history
* Add redirects datatype

THERES A TODO FOR THE DOCS LINK IN THIS COMMIT

Co-Authored-By: sindrerh2 <[email protected]>
Co-Authored-By: Youssef Bel Mekki <[email protected]>

* Add source impls

Co-Authored-By: Youssef Bel Mekki <[email protected]>
Co-Authored-By: sindrerh2 <[email protected]>

* Add application doc example values

* fix REAL SCARY error message IN ALL CLUSTERS

Co-Authored-By: Youssef Bel Mekki <[email protected]>
Co-Authored-By: sindrerh2 <[email protected]>

* Fix broken link 🔪

Co-Authored-By: sindrerh2 <[email protected]>
Co-Authored-By: Youssef Bel Mekki <[email protected]>

* Explain the implementation-specific validation nonsense

Without the validation, you can supply data that would be correct
that we would need to reject becuase of what we want to do

Co-Authored-By: Youssef Bel Mekki <[email protected]>
Co-Authored-By: sindrerh2 <[email protected]>

---------

Co-authored-by: sindrerh2 <[email protected]>
Co-authored-by: Youssef Bel Mekki <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent cc4bc46 commit fa8f04f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/nais.io/v1/get_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func (in *Naisjob) GetIngress() []Ingress {
return nil
}

// As Jobs don't have ingresses, they also do not have redirects
func (in *Naisjob) GetRedirects() []Redirect {
return nil
}

func (in *Naisjob) GetImage() string {
return in.Spec.Image
}
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/nais.io/v1/naiserator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ type Influx struct {
// +kubebuilder:validation:Pattern=`^https:\/\/.+$`
type Ingress string

// +kubebuilder:validation:Pattern=`^https:\/\/.+$`
type fromRedirect string

/* - ^ These start with https because we are not using redirects to do redirects,
Instead we are using the rewrite-target annotation and that annotation
does redirects with a 302 iff the parameters are full urls, scheme and all. */

// +kubebuilder:validation:Pattern=`^https:\/\/.+$`
type toRedirect string

/* -^ These start with https because we are not using redirects to do redirects,
Instead we are using the rewrite-target annotation and that annotation
does redirects with a 302 iff the parameters are full urls, scheme and all. */

type Redirect struct {
From fromRedirect `json:"from"`
To toRedirect `json:"to"`
}

type IDPorten struct {
// Enable ID-porten authentication. Requires `.spec.idporten.sidecar.enabled=true`.
// +nais:doc:Availability="GCP"
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/nais.io/v1alpha1/application_doc_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ func ExampleApplicationForDocumentation() *Application {
Port: 8080,
Timeout: 1,
},
Redirects: []nais_io_v1.Redirect{
{
To: "https://myapplication.nav.no",
From: "https://myapplication-old.nav.no",
},
},
Redis: []nais_io_v1.Redis{
{
Instance: "cache",
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/nais.io/v1alpha1/application_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ type ApplicationSpec struct {
// Read more about this over at the [Kubernetes readiness documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/).
Readiness *nais_io_v1.Probe `json:"readiness,omitempty"`

// List of ingress redirects
Redirects []nais_io_v1.Redirect `json:"redirects,omitempty"`
// List of redis instances this job needs credentials for.
// Must be owned by same team.
// +nais:doc:Link="https://doc.nais.io/persistence/redis/"
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/nais.io/v1alpha1/get_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (in *Application) GetIngress() []nais_io_v1.Ingress {
return in.Spec.Ingresses
}

func (in *Application) GetRedirects() []nais_io_v1.Redirect {
return in.Spec.Redirects
}

func (in *Application) GetLeaderElection() bool {
return in.Spec.LeaderElection
}
Expand Down

0 comments on commit fa8f04f

Please sign in to comment.