Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
89e96910
Commit
89e96910
authored
Sep 17, 2015
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding scale up/down code to DeploymentController
parent
9e5ed1dc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+0
-0
util.go
pkg/util/util.go
+20
-0
No files found.
pkg/controller/deployment/deployment_controller.go
View file @
89e96910
This diff is collapsed.
Click to expand it.
pkg/util/util.go
View file @
89e96910
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io"
"io"
"math"
"net"
"net"
"net/http"
"net/http"
"os"
"os"
...
@@ -191,6 +192,25 @@ func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
...
@@ -191,6 +192,25 @@ func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
}
}
}
}
func
GetIntOrPercentValue
(
intStr
*
IntOrString
)
(
int
,
bool
,
error
)
{
switch
intStr
.
Kind
{
case
IntstrInt
:
return
intStr
.
IntVal
,
false
,
nil
case
IntstrString
:
s
:=
strings
.
Replace
(
intStr
.
StrVal
,
"%"
,
""
,
-
1
)
v
,
err
:=
strconv
.
Atoi
(
s
)
if
err
!=
nil
{
return
0
,
false
,
fmt
.
Errorf
(
"invalid value %q: %v"
,
intStr
.
StrVal
,
err
)
}
return
v
,
true
,
nil
}
return
0
,
false
,
fmt
.
Errorf
(
"invalid value: neither int nor percentage"
)
}
func
GetValueFromPercent
(
percent
int
,
value
int
)
int
{
return
int
(
math
.
Ceil
(
float64
(
percent
)
*
(
float64
(
value
))
/
100
))
}
// Takes a list of strings and compiles them into a list of regular expressions
// Takes a list of strings and compiles them into a list of regular expressions
func
CompileRegexps
(
regexpStrings
[]
string
)
([]
*
regexp
.
Regexp
,
error
)
{
func
CompileRegexps
(
regexpStrings
[]
string
)
([]
*
regexp
.
Regexp
,
error
)
{
regexps
:=
[]
*
regexp
.
Regexp
{}
regexps
:=
[]
*
regexp
.
Regexp
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment