kontena / k8s-client

Ruby Kubernetes API client
Apache License 2.0
76 stars 26 forks source link

Get without exception #109

Open kke opened 5 years ago

kke commented 5 years ago

It would be nice to have exceptionless version of get(and maybe for put/patch etc?):

def cluster_id 
  client.api('v1')
    .resource('configmaps', namespace: 'kube-public')
    .get('cluster-info')
    .metadata
    .uid
rescue K8s::Error::NotFound
  nil
end

vs:

def cluster_id
  client.api('v1')
     .resource('configmaps', namespace: 'kube-public')
     .get!('cluster-info')&.metadata&.uid
end