Comments (5)
Hey @kennethito
Yes I do agree, this should be configurable.
I can't answer why strategic merge is not the default as patch
was still implemented by @coryodaniel. I have implemented apply
, hence that case statement. That being said, changing the default would be a breaking change, I'd like to avoid. But yes to making it configurable.
from k8s.
Thanks for the PR #228, @kennethito. While the approach in #228 solves this issue, I'd rather keep the abstraction and not expose more HTTP communication details to run
. I see the following approaches:
- make
Operation
a protocol so that different operations can have their own data structure but offer the same API to create requests. This is a big refactoring, though. - add headers to the
Operation
struct.
I prefer the first approach but it's all but a quick win! Could go for variant 2. now and implement 1. later... Open for discussion.
from k8s.
For number 2 are you thinking that many of the functions on K8s.Client
now take an additional optional parameter that's passed into Operation.build
? Something like the below, where Operation.build
would look for a :headers
options?
def patch(%{} = resource, opts \\ []), do: Operation.build(:patch, resource, opts)
Or something more along the lines of
operation |> K8s.Operation.put_header_param(:"Custom", "Header")
similar to #229 ?
from k8s.
I was thinking about an API like this.
# Defined in operation.ex
@spec patch_type :: :strategic_merge | :merge | :json_merge | :apply
# Defined in client.ex
@spec patch(resource :: map(), type :: Operation.patch_type()) :: Operation.t()
def patch(resource, type \\ :merge) do
Operation.build(:patch, resource, patch_type: type)
end
Once the patch types are implemented, K8s.Client.apply/2
could be implemented like this:
@spec apply(resource :: map(), mgmt_params :: keyword()) :: Operation.t()
def apply(resource, mgmt_params \\ []) do
field_manager = Keyword.get(mgmt_params, :field_manager, @mgmt_param_defaults[:field_manager])
force = Keyword.get(mgmt_params, :force, @mgmt_param_defaults[:force])
Operation.build(:patch, resource, patch_type: :apply, field_manager: field_manager, force: force)
end
from k8s.
Just back from some work travel and getting started again.
There exists
K8s.Client.patch/1
K8s.Client.patch/2
K8s.Client.patch/4
So adding an optional patch_type
to them all conflicts. The conflict is between /1 and /2, so I could do something like not add patch_type
to K8s.Client.patch/1
. How do you want to proceed?
I pushed a commit into #229 with my understanding of what you want (might be flawed), can you take a quick peek? If the approach looks good, I'll fix all the tests and get it ready for review.
from k8s.
Related Issues (20)
- Source links in the documentation are incorrect HOT 3
- Read kube config from string
- 2.0.0-rc.1 doesn't work with kind clusters HOT 6
- Configuration of http_provider and discovery_driver is ignored HOT 13
- Large resources unusable with 2.0.0 HOT 6
- Does the watch steam handle disconnects in V2? HOT 13
- hostname issues HOT 7
- Streams resetting resource version HOT 4
- K8s.Conn.Config does not exist HOT 4
- Improve documentation on in-cluster connection HOT 5
- what is different between k8s lib and swarm ? HOT 2
- Support pods/logs subresource streaming HOT 5
- Exception raised when running too many get requests HOT 6
- Mint HTTPAdapter failure cycle spams errors HOT 1
- Hex.pm Usage Guide doc is unavailable HOT 2
- Http2 Adapter causing 500 requests HOT 10
- Long-lasting shell connection example is broken HOT 4
- Connections being closed -- K8s.Client.Mint.HTTPAdapter Connection closed for reading and writing - stopping this process. HOT 2
- ArgumentError in K8s.Client.Mint.ConnectionRegistry on TCP Connection HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k8s.