// MetadataFromConfigUpdate extracts consensus metadata from config update
778252
func MetadataFromConfigUpdate(update *common.ConfigUpdate) (*etcdraft.ConfigMetadata, error) {
	var baseVersion uint64
	if update.ReadSet != nil && update.ReadSet.Groups != nil {
		if ordererConfigGroup, ok := update.ReadSet.Groups["Orderer"]; ok {
			if val, ok := ordererConfigGroup.Values["ConsensusType"]; ok {
				baseVersion = val.Version
			}
		}
	}

	if update.WriteSet != nil && update.WriteSet.Groups != nil {
		if ordererConfigGroup, ok := update.WriteSet.Groups["Orderer"]; ok {
			if val, ok := ordererConfigGroup.Values["ConsensusType"]; ok {
				if baseVersion == val.Version {
					// Only if the version in the write set differs from the read-set
					// should we consider this to be an update to the consensus type
					return nil, nil
				}
				return MetadataFromConfigValue(val)
			}
		}
	}
	return nil, nil
}
187642
func UnmarshalConfigUpdateOrPanic(data []byte) *cb.ConfigUpdate {
	result, err := UnmarshalConfigUpdate(data)
	if err != nil {
		panic(err)
	}
	return result
}
78417
func UpdateEtcdRaftMetadata(network *Network, peer *Peer, orderer *Orderer, channel string, f func(md *ectdraft_protos.ConfigMetadata)) {
	UpdateConsensusMetadata(network, peer, orderer, channel, func(originalMetadata []byte) []byte {
		metadata := &ectdraft_protos.ConfigMetadata{}
		err := proto.Unmarshal(originalMetadata, metadata)
		Expect(err).NotTo(HaveOccurred())

		f(metadata)

		newMetadata, err := proto.Marshal(metadata)
		Expect(err).NotTo(HaveOccurred())
		return newMetadata
	})
}
392484
func (s *GetPipelineOutput) SetMetadata(v *PipelineMetadata) *GetPipelineOutput {
	s.Metadata = v
	return s
}
185114
func NewMetadata(Name string) *Metadata {
	s := new(Metadata)
	s.Name = Name
	return s
}
152377
func (idp *IdentityProvider) Metadata() *Metadata {
	cert, _ := pem.Decode([]byte(idp.Certificate))
	if cert == nil {
		panic("invalid IDP certificate")
	}
	certStr := base64.StdEncoding.EncodeToString(cert.Bytes)

	return &Metadata{
		EntityID:      idp.MetadataURL,
		ValidUntil:    TimeNow().Add(DefaultValidDuration),
		CacheDuration: DefaultValidDuration,
		IDPSSODescriptor: &IDPSSODescriptor{
			ProtocolSupportEnumeration: "urn:oasis:names:tc:SAML:2.0:protocol",
			KeyDescriptor: []KeyDescriptor{
				{
					Use: "signing",
					KeyInfo: KeyInfo{
						Certificate: certStr,
					},
				},
				{
					Use: "encryption",
					KeyInfo: KeyInfo{
						Certificate: certStr,
					},
					EncryptionMethods: []EncryptionMethod{
						{Algorithm: "http://www.w3.org/2001/04/xmlenc#aes128-cbc"},
						{Algorithm: "http://www.w3.org/2001/04/xmlenc#aes192-cbc"},
						{Algorithm: "http://www.w3.org/2001/04/xmlenc#aes256-cbc"},
						{Algorithm: "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"},
					},
				},
			},
			NameIDFormat: []string{
				"urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
			},
			SingleSignOnService: []Endpoint{
				{
					Binding:  HTTPRedirectBinding,
					Location: idp.SSOURL,
				},
				{
					Binding:  HTTPPostBinding,
					Location: idp.SSOURL,
				},
			},
		},
	}
}
1010464
func (vi *ValidatorImpl) ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error) {
	return vi.proposeConfigUpdate(configtx)
}
616693
func (s *VirtualNodeData) SetMetadata(v *ResourceMetadata) *VirtualNodeData {
	s.Metadata = v
	return s
}
1230112
func metadataFromField(ctx context.Context, param interface{}, fieldName string) string {
	var ov reflect.Value

	ov = reflect.ValueOf(param)
	for ov.Kind() == reflect.Ptr || ov.Kind() == reflect.Interface {
		ov = ov.Elem()
	}

	// We check if the field was set to a value as this will overide the value in the tag
	// At the same time, we check if the field exists and early exit with the empty string if it doesn't
	field := reflect.Value(ov.FieldByName(fieldName))
	if !field.IsValid() {
		return ""
	}

	userVal := field.Interface()
	if userVal != "" {
		return userVal.(string)
	}

	ot := ov.Type()
	if field, ok := ot.FieldByName(fieldName); ok {
		// The val tag defines the «default» value the metadata field should have
		// If the val tag has a value of "-", then a user value was expected and this will panic
		val := field.Tag.Get("val")
		if val != "-" {
			return val
		} else {
			panic(fmt.Sprintf("No default value defined for %s on %s. User specified value is required.", fieldName, ot.String()))
		}
	} else {
		panic(fmt.Sprintf("Missing %s for %s", fieldName, ot.String()))
	}
}
209236
func (s *InitiateDocumentVersionUploadOutput) SetMetadata(v *DocumentMetadata) *InitiateDocumentVersionUploadOutput {
	s.Metadata = v
	return s
}
1100960
func Metadata(md map[string]string) Option {
	return func(o *Options) {
		o.Metadata = md
	}
}
1309678
func (s *Service) AddOnConfigUpdate(ctx context.Context, addOnIdentity string, o AddOnConfigUpdateOpts) (AddOnConfigUpdateResult, error) {
	var addOnConfig AddOnConfigUpdateResult
	return addOnConfig, s.Patch(ctx, &addOnConfig, fmt.Sprintf("/addons/%v/config", addOnIdentity), o)
}
458803
func Metadata(md map[string]string) Option {
	return func(o *Options) {
		o.Server.Init(server.Metadata(md))
	}
}
1265500
func (s *CopyObjectInput) SetMetadata(v map[string]*string) *CopyObjectInput {
	s.Metadata = v
	return s
}
784517
func (s *Service) UserPreferencesUpdate(ctx context.Context, userPreferencesIdentity string, o UserPreferencesUpdateOpts) (*UserPreferences, error) {
	var userPreferences UserPreferences
	return &userPreferences, s.Patch(ctx, &userPreferences, fmt.Sprintf("/users/%v/preferences", userPreferencesIdentity), o)
}
1252019
func (v *vserver) handleConfigUpdate(config *config.Vserver) {
	if config == nil {
		return
	}
	switch {
	case v.config == nil:
		v.configInit(config)
		return

	case v.enabled && !vserverEnabled(config, v.vserverOverride.State()):
		log.Infof("%v: disabling vserver", v)
		v.downAll()
		v.unconfigureVIPs()
		v.configInit(config)
		return

	case !v.enabled && !vserverEnabled(config, v.vserverOverride.State()):
		v.configInit(config)
		return

	case !v.enabled && vserverEnabled(config, v.vserverOverride.State()):
		log.Infof("%v: enabling vserver", v)
		v.configInit(config)
		return

	default:
		// Some updates require changes to the iptables rules. Since we currently
		// can't make fine-grained changes to the iptables rules, we must
		// re-initialise the entire vserver. This is necessary in the following
		// scenarios:
		// - A port or protocol is added, removed or changed
		// - A vserver is changed from FWM to non-FWM or vice versa
		// - A vserverEntry is changed from DSR to NAT or vice versa
		//
		// (Changing a VIP address also requires updating iptables, but
		//  v.configUpdate() handles this case)
		//
		// TODO(angusc): Add support for finer-grained updates to ncc so we can
		// avoid re-initialising the vserver in these cases.
		reInit := false
		switch {
		case config.UseFWM != v.config.UseFWM:
			reInit = true
		case len(config.Entries) != len(v.config.Entries):
			reInit = true
		default:
			for k, entry := range config.Entries {
				if v.config.Entries[k] == nil {
					reInit = true
					break
				}
				if v.config.Entries[k].Mode != entry.Mode {
					reInit = true
					break
				}
			}
		}
		if reInit {
			log.Infof("%v: re-initialising vserver", v)
			v.downAll()
			v.unconfigureVIPs()
			v.configInit(config)
			return
		}

		v.config = config
		v.configUpdate()
	}
}
731134
func (b *Broker) Metadata() (*proto.MetadataResp, error) {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.fetchMetadata()
}