...

Source file src/github.com/sigstore/timestamp-authority/pkg/client/timestamp_client.go

Documentation: github.com/sigstore/timestamp-authority/pkg/client

     1  // Copyright 2022 The Sigstore Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package client
    16  
    17  import (
    18  	"net/url"
    19  
    20  	"github.com/go-openapi/runtime"
    21  	httptransport "github.com/go-openapi/runtime/client"
    22  	"github.com/go-openapi/strfmt"
    23  	"github.com/sigstore/timestamp-authority/pkg/generated/client"
    24  )
    25  
    26  func GetTimestampClient(timestampServerURL string, opts ...Option) (*client.TimestampAuthority, error) {
    27  	url, err := url.Parse(timestampServerURL)
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  	o := makeOptions(opts...)
    32  
    33  	rt := httptransport.New(url.Host, client.DefaultBasePath, []string{url.Scheme})
    34  	// Input to server
    35  	rt.Producers["application/timestamp-query"] = runtime.ByteStreamProducer()
    36  	rt.Producers["application/json"] = runtime.JSONProducer()
    37  	// Output from server
    38  	rt.Consumers["application/timestamp-reply"] = runtime.ByteStreamConsumer()
    39  	rt.Consumers["application/json"] = runtime.JSONConsumer()
    40  	rt.Consumers["application/pem-certificate-chain"] = runtime.TextConsumer()
    41  
    42  	rt.Transport = createRoundTripper(rt.Transport, o)
    43  
    44  	registry := strfmt.Default
    45  	return client.New(rt, registry), nil
    46  }
    47  

View as plain text