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

Surpport snippet for server section by the annotation of the ingess #1398

Merged
merged 3 commits into from
Sep 27, 2017
Merged

Surpport snippet for server section by the annotation of the ingess #1398

merged 3 commits into from
Sep 27, 2017

Conversation

decker502
Copy link
Contributor

eg:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/server-snippet: |
set $agentflag 0;

if ($http_user_agent ~* "(Mobile)" )
{
set $agentflag 1;
}

  if ( $agentflag = 1 ) {
    return 301 https://m.example.com;
  }

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 21, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 43.673% when pulling 15c6a11 on decker502:server-snippet into 37bd14d on kubernetes:master.

@@ -236,6 +236,9 @@ type Server struct {
// CertificateAuth indicates the this server requires mutual authentication
// +optional
CertificateAuth authtls.AuthSSLConfig `json:"certificateAuth"`

// ServerSnippet returns the snippet of server
Copy link

Choose a reason for hiding this comment

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

+optional

@@ -1065,6 +1065,28 @@ func (ic *GenericController) createServers(data []interface{},
servers[host].Alias = ""
}
}

// configure server snippet
for _, ingIf := range data {
Copy link

Choose a reason for hiding this comment

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

This loop is already being called in line 982, why not add this logic in there to avoid looping again?

host = defServerName
}

srvsnippet := ic.annotations.ServerSnippet(ing)
Copy link

Choose a reason for hiding this comment

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

You can add this before the loop to avoid calling each time.


if servers[host].ServerSnippet == "" && srvsnippet != "" {
servers[host].ServerSnippet = srvsnippet
}
Copy link

Choose a reason for hiding this comment

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

Add a Warning, notifying the user that it has already been configured.

type serverSnippet struct {
}

// NewParser creates a new CORS annotation parser
Copy link

Choose a reason for hiding this comment

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

Not CORS

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 43.752% when pulling 5dfee7b on decker502:server-snippet into 37bd14d on kubernetes:master.

@aledbf
Copy link
Member

aledbf commented Sep 27, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 27, 2017
@aledbf
Copy link
Member

aledbf commented Sep 27, 2017

@decker502 thanks!

@aledbf aledbf merged commit 75cccbb into kubernetes:master Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants