utils

package
v2.2.5+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResourceOfType

func GetResourceOfType(url string, cred *RegistryAuth, bearerToken string, target interface{}) error

GetResourceOfType takes in the specified URL with credentials and tries to decode returning json to specified interface

func MapMerge

func MapMerge(base map[string]string, new map[string]string) map[string]string

MapMerge merges two maps together and returns the results. If both maps contain the same key, then the value of the existing key will be overwritten with the value from the new map

Types

type ArtDockerRepo

type ArtDockerRepo []struct {
	Key         string `json:"key"`
	Type        string `json:"type"`
	URL         string `json:"url"`
	PackageType string `json:"packageType"`
}

ArtDockerRepo contains list of docker repos in artifactory

type ArtHookStruct

type ArtHookStruct struct {
	Artifacts []struct {
		Type      string `json:"type"`
		Name      string `json:"name"`
		Version   string `json:"version"`
		Reference string `json:"reference"`
	} `json:"artifacts"`
}

ArtHookStruct is the structure returned by Artifactory webhook

type ArtImageSHAs

type ArtImageSHAs struct {
	Properties struct {
		Sha256 []string `json:"sha256"`
	} `json:"properties"`
	URI string `json:"uri"`
}

ArtImageSHAs gets all the sha256 of an image

type ArtImageTags

type ArtImageTags struct {
	Name string   `json:"name"`
	Tags []string `json:"tags"`
}

ArtImageTags lists out all the tags for the image

type ArtImages

type ArtImages struct {
	Repositories []string `json:"repositories"`
}

ArtImages contain list of images inside the docker repo

type ArtReposBySha

type ArtReposBySha struct {
	Results []struct {
		URI string `json:"uri"`
	} `json:"results"`
}

ArtReposBySha collects URIs for given SHA256

type FakeHandler

type FakeHandler struct {
	RequestReceived *http.Request
	RequestBody     string
	StatusCode      int
	RespondBody     string
	T               LogInterface
}

FakeHandler is to assist in testing HTTP requests

func (*FakeHandler) ServeHTTP

func (f *FakeHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*FakeHandler) Validate

func (f *FakeHandler) Validate(expectedPath string, expectedMethod string, expectedBody *string) error

Validate verifies that FakeHandler received a request with expected path, method, and body.

type LogInterface

type LogInterface interface {
	Errorf(format string, args ...interface{})
	Logf(format string, args ...interface{})
}

LogInterface is a simple interface providing Errorf an Logf

type RegistryAuth

type RegistryAuth struct {
	URL      string
	User     string
	Password string
	Token    string
}

RegistryAuth stores the credentials for a private docker repo and is same as common.RegistryAuth in perceptor-scanner repo

func PingArtifactoryServer

func PingArtifactoryServer(url string, username string, password string) (*RegistryAuth, error)

PingArtifactoryServer takes in the specified URL with username & password and checks weather it's a valid login for artifactory by pinging the server with various options and returns the correct URL

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL